[llvm] r255148 - Use WeakVH to keep track of calls with operand bundles in CloneCodeInfo
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 9 12:33:52 PST 2015
Author: sanjoy
Date: Wed Dec 9 14:33:52 2015
New Revision: 255148
URL: http://llvm.org/viewvc/llvm-project?rev=255148&view=rev
Log:
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>.
Modified:
llvm/trunk/include/llvm/Transforms/Utils/Cloning.h
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
llvm/trunk/test/Transforms/Inline/deopt-bundles.ll
Modified: llvm/trunk/include/llvm/Transforms/Utils/Cloning.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Cloning.h?rev=255148&r1=255147&r2=255148&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/Cloning.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/Cloning.h Wed Dec 9 14:33:52 2015
@@ -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) {}
};
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=255148&r1=255147&r2=255148&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Wed Dec 9 14:33:52 2015
@@ -1162,7 +1162,9 @@ bool llvm::InlineFunction(CallSite CS, I
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();
Modified: llvm/trunk/test/Transforms/Inline/deopt-bundles.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/deopt-bundles.ll?rev=255148&r1=255147&r2=255148&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/deopt-bundles.ll (original)
+++ llvm/trunk/test/Transforms/Inline/deopt-bundles.ll Wed Dec 9 14:33:52 2015
@@ -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" }
More information about the llvm-commits
mailing list