[llvm] r254046 - [InstCombine] Don't drop operand bundles
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 24 16:42:19 PST 2015
Author: sanjoy
Date: Tue Nov 24 18:42:19 2015
New Revision: 254046
URL: http://llvm.org/viewvc/llvm-project?rev=254046&view=rev
Log:
[InstCombine] Don't drop operand bundles
Reviewers: majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D14857
Added:
llvm/trunk/test/Transforms/InstCombine/cast-callee-deopt-bundles.ll
Modified:
llvm/trunk/include/llvm/IR/IRBuilder.h
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
Modified: llvm/trunk/include/llvm/IR/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRBuilder.h?rev=254046&r1=254045&r2=254046&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/IRBuilder.h Tue Nov 24 18:42:19 2015
@@ -691,6 +691,13 @@ public:
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args),
Name);
}
+ InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
+ BasicBlock *UnwindDest, ArrayRef<Value *> Args,
+ ArrayRef<OperandBundleDef> OpBundles,
+ const Twine &Name = "") {
+ return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
+ OpBundles), Name);
+ }
ResumeInst *CreateResume(Value *Exn) {
return Insert(ResumeInst::Create(Exn));
@@ -1528,7 +1535,12 @@ public:
}
CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args = None,
+ ArrayRef<OperandBundleDef> OpBundles = None,
const Twine &Name = "") {
+ return Insert(CallInst::Create(Callee, Args, OpBundles), Name);
+ }
+ CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args,
+ const Twine &Name) {
return Insert(CallInst::Create(Callee, Args), Name);
}
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=254046&r1=254045&r2=254046&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Tue Nov 24 18:42:19 2015
@@ -2267,16 +2267,23 @@ bool InstCombiner::transformConstExprCas
const AttributeSet &NewCallerPAL = AttributeSet::get(Callee->getContext(),
attrVec);
+ SmallVector<OperandBundleDef, 1> OpBundles;
+
+ // Convert the operand bundle uses to operand bundle defs. See InstrTypes.h
+ // for details on how these differ.
+ for (unsigned i = 0, e = CS.getNumOperandBundles(); i != e; ++i)
+ OpBundles.emplace_back(CS.getOperandBundleAt(i));
+
Instruction *NC;
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
- NC = Builder->CreateInvoke(Callee, II->getNormalDest(),
- II->getUnwindDest(), Args);
+ NC = Builder->CreateInvoke(Callee, II->getNormalDest(), II->getUnwindDest(),
+ Args, OpBundles);
NC->takeName(II);
cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
cast<InvokeInst>(NC)->setAttributes(NewCallerPAL);
} else {
CallInst *CI = cast<CallInst>(Caller);
- NC = Builder->CreateCall(Callee, Args);
+ NC = Builder->CreateCall(Callee, Args, OpBundles);
NC->takeName(CI);
if (CI->isTailCall())
cast<CallInst>(NC)->setTailCall();
Added: llvm/trunk/test/Transforms/InstCombine/cast-callee-deopt-bundles.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-callee-deopt-bundles.ll?rev=254046&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cast-callee-deopt-bundles.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/cast-callee-deopt-bundles.ll Tue Nov 24 18:42:19 2015
@@ -0,0 +1,11 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+declare void @foo(i32)
+
+define void @g() {
+; CHECK-LABEL: @g(
+ entry:
+; CHECK: call void @foo(i32 0) [ "deopt"() ]
+ call void bitcast (void (i32)* @foo to void ()*) () [ "deopt"() ]
+ ret void
+}
More information about the llvm-commits
mailing list