llvm.org GIT mirror llvm / 2306579
[PlaceSafepoints] Assertion on that gc_result can not have preceding phis should only apply to invoke statepoint Summary: When PlaceSafepoints pass replaces old return result with gc_result from statepoint, it asserts that gc_result can not have preceding phis in its parent block. This is only true on invoke statepoint, which terminates the block and puts its result at the beginning of the normal successor block. Call statepoint does not terminate the block and thus its result is in the same block with it. There should be no restriction on whether there are phis or not. Reviewers: reames, igor-laevsky Reviewed By: igor-laevsky Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9803 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237597 91177308-0d34-0410-b5e6-96231b3b80d8 Chen Li 4 years ago
2 changed file(s) with 40 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
715715 CallSite &CS = ParsePointNeeded[i];
716716 Value *GCResult = Results[i];
717717 if (GCResult) {
718 // Can not RAUW for the gc result in case of phi nodes preset.
719 assert(!isa(cast(GCResult)->getParent()->begin()));
718 // Can not RAUW for the invoke gc result in case of phi nodes preset.
719 assert(CS.isCall() || !isa(cast(GCResult)->getParent()->begin()));
720720
721721 // Replace all uses with the new call
722722 CS.getInstruction()->replaceAllUsesWith(GCResult);
0 ;; RUN: opt %s -place-safepoints -S | FileCheck %s
1
2 ;; This test is to verify that gc_result from a call statepoint
3 ;; can have preceding phis in its parent basic block. Unlike
4 ;; invoke statepoint, call statepoint does not terminate the
5 ;; block, and thus its gc_result is in the same block with the
6 ;; call statepoint.
7
8 declare i32 @foo()
9
10 define i32 @test1(i1 %cond, i32 %a) gc "statepoint-example" {
11 entry:
12 br i1 %cond, label %branch1, label %branch2
13
14 branch1:
15 %b = add i32 %a, 1
16 br label %merge
17
18 branch2:
19 br label %merge
20
21 merge:
22 ;; CHECK: %phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ]
23 ;; CHECK-NEXT: %safepoint_token.1 = call i32 (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* @foo, i32 0, i32 0, i32 0, i32 0)
24 ;; CHECK-NEXT: %ret.2 = call i32 @llvm.experimental.gc.result.i32(i32 %safepoint_token.1)
25 %phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ]
26 %ret = call i32 @foo()
27 ret i32 %ret
28 }
29
30 ; This function is inlined when inserting a poll.
31 declare void @do_safepoint()
32 define void @gc.safepoint_poll() {
33 ; CHECK-LABEL: gc.safepoint_poll
34 entry:
35 call void @do_safepoint()
36 ret void
37 }