From b8dced5dfa3b5abba27898dfd0a8341995756584 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Wed, 9 Dec 2015 01:01:28 +0000 Subject: [PATCH] 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). llvm-svn: 255088 --- llvm/lib/IR/Instructions.cpp | 2 ++ llvm/test/Transforms/Inline/deopt-bundles.ll | 39 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index bba0ef2..6ec2e28 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/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/llvm/test/Transforms/Inline/deopt-bundles.ll b/llvm/test/Transforms/Inline/deopt-bundles.ll index 91d4690..b417608 100644 --- a/llvm/test/Transforms/Inline/deopt-bundles.ll +++ b/llvm/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" } -- 2.7.4