[OperandBundles] Fix a transform in simplifycfg
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 8 Dec 2015 22:26:08 +0000 (22:26 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 8 Dec 2015 22:26:08 +0000 (22:26 +0000)
Reviewers: pcc, majnemer, reames

Subscribers: reames, llvm-commits

Differential Revision: http://reviews.llvm.org/D15345

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

lib/Transforms/Utils/Local.cpp
test/Transforms/SimplifyCFG/invoke_unwind.ll

index ba79b32ac3d56af4e2ed685b09811345d1de5e47..19122dd21a71a4cec40084f993bc2a15d8d4ef6e 100644 (file)
@@ -1210,8 +1210,12 @@ static void changeToUnreachable(Instruction *I, bool UseLLVMTrap) {
 
 /// changeToCall - Convert the specified invoke into a normal call.
 static void changeToCall(InvokeInst *II) {
-  SmallVector<Value*, 8> Args(II->op_begin(), II->op_end() - 3);
-  CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args, "", II);
+  CallSite CS(II);
+  SmallVector<Value*, 8> Args(CS.arg_begin(), CS.arg_end());
+  SmallVector<OperandBundleDef, 1> OpBundles;
+  II->getOperandBundlesAsDefs(OpBundles);
+  CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args, OpBundles,
+                                       "", II);
   NewCall->takeName(II);
   NewCall->setCallingConv(II->getCallingConv());
   NewCall->setAttributes(II->getAttributes());
index 3b4c09d96f77cb3b907c145edc46929c1ebbdca9..100bfd4e9e3eaa1ab98079e71585703bb228b190 100644 (file)
@@ -17,4 +17,17 @@ Rethrow:
         resume { i8*, i32 } %exn
 }
 
+define i32 @test2() personality i32 (...)* @__gxx_personality_v0 {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: call void @bar() [ "foo"(i32 100) ]
+; CHECK-NEXT: ret i32 0
+        invoke void @bar( ) [ "foo"(i32 100) ]
+                        to label %1 unwind label %Rethrow
+        ret i32 0
+Rethrow:
+        %exn = landingpad {i8*, i32}
+                 catch i8* null
+        resume { i8*, i32 } %exn
+}
+
 declare i32 @__gxx_personality_v0(...)