llvm.org GIT mirror llvm / fc240a1
[RewriteStatepoints] Fix incorrect assertion `RewriteStatepointsForGC` iterates over function blocks and their predecessors in order of declaration. One of outcomes of this is that callsites are placed in arbitrary order which has nothing to do with travelsar order. On the other hand, function `recomputeLiveInValues` asserts that bases are added to `Info.PointerToBase` before their deried pointers are updated. But if call sites are processed in order different from RPOT, this is not necessarily true. We cannot guarantee that the base was placed there before every pointer derived from it. All we can guarantee is that this base was marked as known base by this point. This patch replaces the fact that we assert from checking that the base was added to the map with assert that the base was marked as known base. Differential Revision: https://reviews.llvm.org/D41593 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321517 91177308-0d34-0410-b5e6-96231b3b80d8 Max Kazantsev 1 year, 8 months ago
2 changed file(s) with 40 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
27952795 StatepointLiveSetTy Updated;
27962796 findLiveSetAtInst(Inst, RevisedLivenessData, Updated);
27972797
2798 #ifndef NDEBUG
2799 DenseSet Bases;
2800 for (auto KVPair : Info.PointerToBase)
2801 Bases.insert(KVPair.second);
2802 #endif
2803
28042798 // We may have base pointers which are now live that weren't before. We need
28052799 // to update the PointerToBase structure to reflect this.
28062800 for (auto V : Updated)
28072801 if (Info.PointerToBase.insert({V, V}).second) {
2808 assert(Bases.count(V) && "Can't find base for unexpected live value!");
2802 assert(isKnownBaseResult(V) &&
2803 "Can't find base for unexpected live value!");
28092804 continue;
28102805 }
28112806
0 ; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
1
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
3 target triple = "x86_64-unknown-linux-gnu"
4
5 declare void @f()
6 declare void @g(i8 addrspace(1)*, i8 addrspace(1)*)
7 declare i32 @personality_function()
8
9 ; Make sure that we do not fail assertion because we process call of @g before
10 ; we process the call of @f.
11
12 define void @test_01(i8 addrspace(1)* %p, i1 %cond) gc "statepoint-example" personality i32 ()* @personality_function {
13
14 ; CHECK-LABEL: @test_01(
15
16 entry:
17 %tmp0 = insertelement <2 x i8 addrspace(1)*> undef, i8 addrspace(1)* %p, i32 0
18 %tmp1 = insertelement <2 x i8 addrspace(1)*> %tmp0, i8 addrspace(1)* %p, i32 1
19 %tmp2 = extractelement <2 x i8 addrspace(1)*> %tmp1, i32 1
20 %tmp3 = extractelement <2 x i8 addrspace(1)*> %tmp1, i32 0
21 br label %loop
22
23 loop:
24 br i1 %cond, label %cond_block, label %exit
25
26 cond_block:
27 br i1 %cond, label %backedge, label %exit
28
29 exit:
30 %tmp4 = phi i8 addrspace(1)* [ %tmp2, %loop ], [ %tmp2, %cond_block ]
31 call void @g(i8 addrspace(1)* %tmp3, i8 addrspace(1)* %tmp4)
32 ret void
33
34 backedge:
35 call void @f()
36 br label %loop
37 }