summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2015-12-09 20:33:52 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2015-12-09 20:33:52 +0000
commit9abfb0b4291e47bea6e8dd267d155003a323b070 (patch)
tree11ecea8588a6cd4074813b2cd4e0c2242fd94207
parent1f8fd888735ed94f796d3f16e192471813207371 (diff)
downloadbcm5719-llvm-9abfb0b4291e47bea6e8dd267d155003a323b070.tar.gz
bcm5719-llvm-9abfb0b4291e47bea6e8dd267d155003a323b070.zip
Use WeakVH to keep track of calls with operand bundles in CloneCodeInfo
`CloneAndPruneIntoFromInst` can DCE instructions after cloning them into the new function, and so an AssertingVH is too strong. This change switches CloneCodeInfo to use a std::vector<WeakVH>. llvm-svn: 255148
-rw-r--r--llvm/include/llvm/Transforms/Utils/Cloning.h5
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp4
-rw-r--r--llvm/test/Transforms/Inline/deopt-bundles.ll31
3 files changed, 37 insertions, 3 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/Cloning.h b/llvm/include/llvm/Transforms/Utils/Cloning.h
index 5d5689c2c1a..d1a5fdeaddc 100644
--- a/llvm/include/llvm/Transforms/Utils/Cloning.h
+++ b/llvm/include/llvm/Transforms/Utils/Cloning.h
@@ -75,8 +75,9 @@ struct ClonedCodeInfo {
bool ContainsDynamicAllocas;
/// All cloned call sites that have operand bundles attached are appended to
- /// this vector.
- std::vector<AssertingVH<Instruction>> OperandBundleCallSites;
+ /// this vector. This vector may contain nulls if some of the originally
+ /// inserted callsites were DCE'ed after they were cloned.
+ std::vector<WeakVH> OperandBundleCallSites;
ClonedCodeInfo() : ContainsCalls(false), ContainsDynamicAllocas(false) {}
};
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 52bde6797db..9a0aabc38a5 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1162,7 +1162,9 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
SmallVector<OperandBundleDef, 2> OpDefs;
for (auto &VH : InlinedFunctionInfo.OperandBundleCallSites) {
- Instruction *I = VH;
+ if (!VH) continue; // instruction was DCE'd after being cloned
+
+ Instruction *I = cast<Instruction>(VH);
OpDefs.clear();
diff --git a/llvm/test/Transforms/Inline/deopt-bundles.ll b/llvm/test/Transforms/Inline/deopt-bundles.ll
index b4176089075..75e8d55acdb 100644
--- a/llvm/test/Transforms/Inline/deopt-bundles.ll
+++ b/llvm/test/Transforms/Inline/deopt-bundles.ll
@@ -131,6 +131,37 @@ define i32 @caller_6() {
ret i32 %x
}
+define i32 @callee_7(i1 %val) alwaysinline personality i8 3 {
+; We want something that PruningFunctionCloner is not smart enough to
+; recognize, but can be recognized by recursivelySimplifyInstruction.
+
+ entry:
+ br i1 %val, label %check, label %precheck
+
+ precheck:
+ br label %check
+
+ check:
+ %p = phi i1 [ %val, %entry ], [ true, %precheck ]
+ br i1 %p, label %do.not, label %do
+
+ do.not:
+ ret i32 0
+
+ do:
+ %v = call fastcc i32 @g.fastcc() [ "deopt"(i32 0, i32 1), "foo"(double 0.0) ]
+ ret i32 %v
+}
+
+define i32 @caller_7() {
+; CHECK-LABEL: @caller_7(
+ entry:
+; CHECK-NOT: call fastcc i32 @g.fastcc() #[[FOO_BAR_ATTR_IDX]] [ "deopt"(i32 7, i32 0, i32 1), "foo"(double 0.000000e+00) ]
+; CHECK: ret i32 0
+ %x = call i32 @callee_7(i1 true) [ "deopt"(i32 7) ]
+ ret i32 %x
+}
+
attributes #0 = { "foo"="bar" }
; CHECK: attributes #[[FOO_BAR_ATTR_IDX]] = { "foo"="bar" }
OpenPOWER on IntegriCloud