llvm.org GIT mirror llvm / f8bc6b5
[RS4GC] Fix crash in the case that a live variable has a constant base. Summary: Previously, RS4GC crashed in CreateGCRelocates() because it assumed that every base is also in the array of live variables, which isn't true if a live variable has a constant base. This change fixes the crash by making sure CreateGCRelocates() won't try to relocate a live variable with a constant base. This would be unnecessary anyway because anything with a constant base won't move. Reviewers: reames Subscribers: llvm-commits, sanjoy Differential Revision: http://reviews.llvm.org/D15556 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256252 91177308-0d34-0410-b5e6-96231b3b80d8 Manuel Jacob 3 years ago
3 changed file(s) with 52 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
23862386 }
23872387 }
23882388
2389 // It is possible that non-constant live variables have a constant base. For
2390 // example, a GEP with a variable offset from a global. In this case we can
2391 // remove it from the liveset. We already don't add constants to the liveset
2392 // because we assume they won't move at runtime and the GC doesn't need to be
2393 // informed about them. The same reasoning applies if the base is constant.
2394 // Note that the relocation placement code relies on this filtering for
2395 // correctness as it expects the base to be in the liveset, which isn't true
2396 // if the base is constant.
2397 for (auto &Info : Records)
2398 for (auto &BasePair : Info.PointerToBase)
2399 if (isa(BasePair.second))
2400 Info.LiveSet.erase(BasePair.first);
2401
23892402 for (CallInst *CI : Holders)
23902403 CI->eraseFromParent();
23912404
0 ; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
1
2 ; CHECK: derived %select base %global
3
4 @global = external addrspace(1) global i8
5
6 define i8 @test(i1 %cond) gc "statepoint-example" {
7 %derived1 = getelementptr i8, i8 addrspace(1)* @global, i64 1
8 %derived2 = getelementptr i8, i8 addrspace(1)* @global, i64 2
9 %select = select i1 %cond, i8 addrspace(1)* %derived1, i8 addrspace(1)* %derived2
10 %safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @extern, i32 0, i32 0, i32 0, i32 0)
11 ; CHECK-NOT: relocate
12 ; CHECK: %load = load i8, i8 addrspace(1)* %select
13 %load = load i8, i8 addrspace(1)* %select
14 ret i8 %load
15 }
16
17 declare void @extern() gc "statepoint-example"
18
19 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
0 ; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
1
2 ; CHECK: derived %derived base %global
3
4 @global = external addrspace(1) global i8
5
6 define i8 @test(i64 %offset) gc "statepoint-example" {
7 %derived = getelementptr i8, i8 addrspace(1)* @global, i64 %offset
8 %safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @extern, i32 0, i32 0, i32 0, i32 0)
9 ; CHECK-NOT: relocate
10 ; CHECK-NOT: remat
11 ; CHECK: %load = load i8, i8 addrspace(1)* %derived
12 %load = load i8, i8 addrspace(1)* %derived
13 ret i8 %load
14 }
15
16 declare void @extern() gc "statepoint-example"
17
18 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)