From: Sanjoy Das Date: Wed, 9 Dec 2015 01:01:28 +0000 (+0000) Subject: Don't drop attributes when inlining through "deopt" operand bundles X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f001e6b8dbc1bb1c5e52afab14d13a79b50267e4;p=oota-llvm.git Don't drop attributes when inlining through "deopt" operand bundles Test case attached (test case also checks that we don't drop the calling convention, but that functionality was correct before this patch). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255088 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index bba0ef2d7d3..6ec2e289970 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -307,6 +307,7 @@ CallInst *CallInst::Create(CallInst *CI, ArrayRef OpB, NewCI->setTailCallKind(CI->getTailCallKind()); NewCI->setCallingConv(CI->getCallingConv()); NewCI->SubclassOptionalData = CI->SubclassOptionalData; + NewCI->setAttributes(CI->getAttributes()); return NewCI; } @@ -594,6 +595,7 @@ InvokeInst *InvokeInst::Create(InvokeInst *II, ArrayRef OpB, II->getName(), InsertPt); NewII->setCallingConv(II->getCallingConv()); NewII->SubclassOptionalData = II->SubclassOptionalData; + NewII->setAttributes(II->getAttributes()); return NewII; } diff --git a/test/Transforms/Inline/deopt-bundles.ll b/test/Transforms/Inline/deopt-bundles.ll index 91d4690e0e6..b4176089075 100644 --- a/test/Transforms/Inline/deopt-bundles.ll +++ b/test/Transforms/Inline/deopt-bundles.ll @@ -2,6 +2,7 @@ declare void @f() declare i32 @g() +declare fastcc i32 @g.fastcc() define i32 @callee_0() alwaysinline { entry: @@ -95,3 +96,41 @@ define i32 @caller_4() { %x = call i32 @callee_4() [ "deopt"(i32 7) ] ret i32 %x } + +define i32 @callee_5() alwaysinline personality i8 3 { + entry: + %v = invoke fastcc i32 @g.fastcc() #0 [ "deopt"(i32 0, i32 1), "foo"(double 0.0) ] to label %normal unwind label %unwind + + normal: + ret i32 %v + + unwind: + %cleanup = landingpad i8 cleanup + ret i32 100 +} + +define i32 @caller_5() { +; CHECK-LABEL: @caller_5( + entry: +; CHECK: invoke fastcc i32 @g.fastcc() #[[FOO_BAR_ATTR_IDX:[0-9]+]] [ "deopt"(i32 7, i32 0, i32 1), "foo"(double 0.000000e+00) ] + %x = call i32 @callee_5() [ "deopt"(i32 7) ] + ret i32 %x +} + +define i32 @callee_6() alwaysinline personality i8 3 { + entry: + %v = call fastcc i32 @g.fastcc() #0 [ "deopt"(i32 0, i32 1), "foo"(double 0.0) ] + ret i32 %v +} + +define i32 @caller_6() { +; CHECK-LABEL: @caller_6( + entry: +; CHECK: call fastcc i32 @g.fastcc() #[[FOO_BAR_ATTR_IDX]] [ "deopt"(i32 7, i32 0, i32 1), "foo"(double 0.000000e+00) ] + %x = call i32 @callee_6() [ "deopt"(i32 7) ] + ret i32 %x +} + +attributes #0 = { "foo"="bar" } + +; CHECK: attributes #[[FOO_BAR_ATTR_IDX]] = { "foo"="bar" }