Bugfix for 229954
authorPhilip Reames <listmail@philipreames.com>
Fri, 20 Feb 2015 18:56:14 +0000 (18:56 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 20 Feb 2015 18:56:14 +0000 (18:56 +0000)
Before calling Function::getGC to test for enablement, we need to make sure there's actually a GC at all via Function::hasGC.  Otherwise, we'd crash on functions without a GC.  Thankfully, this only mattered if you manually scheduled the pass, but still, oops. :(

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230040 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
test/Transforms/RewriteStatepointsForGC/basics.ll

index 052a149ae26a37f78c8dfd41b7450455cf593b53..e3859bcb67386b9c09408284fe4f798be6710eb2 100644 (file)
@@ -1911,8 +1911,11 @@ static bool insertParsePoints(Function &F, DominatorTree &DT, Pass *P,
 /// point of this function is as an extension point for custom logic.
 static bool shouldRewriteStatepointsIn(Function &F) {
   // TODO: This should check the GCStrategy
 /// point of this function is as an extension point for custom logic.
 static bool shouldRewriteStatepointsIn(Function &F) {
   // TODO: This should check the GCStrategy
-  const std::string StatepointExampleName("statepoint-example");
-  return StatepointExampleName == F.getGC();
+  if (F.hasGC()) {
+    const std::string StatepointExampleName("statepoint-example");
+    return StatepointExampleName == F.getGC();
+  } else
+    return false;
 }
 
 bool RewriteStatepointsForGC::runOnFunction(Function &F) {
 }
 
 bool RewriteStatepointsForGC::runOnFunction(Function &F) {
index 7454ea1d403fc28e4bfed8ae7b92536f0dec4e2d..ec522abd9125a4edb4aadebff0a7a2d5ce68138f 100644 (file)
@@ -74,4 +74,15 @@ merge:
   ret i8 addrspace(1)* %obj
 }
 
   ret i8 addrspace(1)* %obj
 }
 
+; When run over a function which doesn't opt in, should do nothing!
+define i8 addrspace(1)* @test5(i8 addrspace(1)* %obj) {
+; CHECK-LABEL: @test5
+; CHECK-LABEL: entry:
+; CHECK-NEXT: gc.statepoint
+; CHECK-NOT: %obj.relocated = call coldcc i8 addrspace(1)*
+entry:
+  call i32 (void ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @foo, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
+  ret i8 addrspace(1)* %obj
+}
+
 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...)
 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...)