[PATCH] D15556: [RS4GC] Fix crash in the case that a live variable has a constant base.
Manuel Jacob via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 17 15:28:37 PST 2015
mjacob updated this revision to Diff 43193.
mjacob added a comment.
Address review comments.
http://reviews.llvm.org/D15556
Files:
lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
test/Transforms/RewriteStatepointsForGC/base-pointers-12.ll
Index: test/Transforms/RewriteStatepointsForGC/base-pointers-12.ll
===================================================================
--- /dev/null
+++ test/Transforms/RewriteStatepointsForGC/base-pointers-12.ll
@@ -0,0 +1,20 @@
+; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
+
+; CHECK: derived %select base %global
+
+ at global = external addrspace(1) global i8
+
+define i8 @test(i1 %cond) gc "statepoint-example" {
+ %derived1 = getelementptr i8, i8 addrspace(1)* @global, i64 1
+ %derived2 = getelementptr i8, i8 addrspace(1)* @global, i64 2
+ %select = select i1 %cond, i8 addrspace(1)* %derived1, i8 addrspace(1)* %derived2
+ %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)
+; CHECK-NOT: relocate
+; CHECK: %load = load i8, i8 addrspace(1)* %select
+ %load = load i8, i8 addrspace(1)* %select
+ ret i8 %load
+}
+
+declare void @extern() gc "statepoint-example"
+
+declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
Index: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===================================================================
--- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2387,6 +2387,18 @@
}
}
+ // It is possible that non-constant live variables have a constant base. In
+ // this case we can remove it from the liveset. We already don't add
+ // constants to the liveset because we assume they won't move at runtime.
+ // Also, they won't move if the base is constant.
+ // Note that the relocation placement code relies on the following code
+ // because it expects the base to be in the liveset, which isn't true if the
+ // base is constant.
+ for (auto &Info : Records)
+ for (auto &BasePair : Info.PointerToBase)
+ if (isa<Constant>(BasePair.second))
+ Info.LiveSet.erase(BasePair.first);
+
for (CallInst *CI : Holders)
CI->eraseFromParent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15556.43193.patch
Type: text/x-patch
Size: 2103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151217/9edd422a/attachment.bin>
More information about the llvm-commits
mailing list