[llvm] r255088 - Don't drop attributes when inlining through "deopt" operand bundles

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 8 17:01:28 PST 2015


Author: sanjoy
Date: Tue Dec  8 19:01:28 2015
New Revision: 255088

URL: http://llvm.org/viewvc/llvm-project?rev=255088&view=rev
Log:
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).

Modified:
    llvm/trunk/lib/IR/Instructions.cpp
    llvm/trunk/test/Transforms/Inline/deopt-bundles.ll

Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=255088&r1=255087&r2=255088&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Tue Dec  8 19:01:28 2015
@@ -307,6 +307,7 @@ CallInst *CallInst::Create(CallInst *CI,
   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(InvokeIns
                                    II->getName(), InsertPt);
   NewII->setCallingConv(II->getCallingConv());
   NewII->SubclassOptionalData = II->SubclassOptionalData;
+  NewII->setAttributes(II->getAttributes());
   return NewII;
 }
 

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=255088&r1=255087&r2=255088&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/deopt-bundles.ll (original)
+++ llvm/trunk/test/Transforms/Inline/deopt-bundles.ll Tue Dec  8 19:01:28 2015
@@ -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" }




More information about the llvm-commits mailing list