[Inliner] Don't inline through callsites with operand bundles
authorSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 23 Oct 2015 20:09:55 +0000 (20:09 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 23 Oct 2015 20:09:55 +0000 (20:09 +0000)
Summary:
This change teaches the LLVM inliner to not inline through callsites
with unknown operand bundles.  Currently all operand bundles are
"unknown" operand bundles but in the near future we will add support for
inlining through some select kinds of operand bundles.

Reviewers: reames, chandlerc, majnemer

Subscribers: llvm-commits

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

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

lib/Transforms/Utils/InlineFunction.cpp
test/Feature/OperandBundles/inliner-conservative.ll [new file with mode: 0644]

index 5539a26b3f39e04b78dc5d8c2f4bb2c123a8a448..1507d313aa073cf7559fc6eac42d2e6c96ad8c66 100644 (file)
@@ -1029,6 +1029,10 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
       CalledFunc->isDeclaration() || // call, or call to a vararg function!
       CalledFunc->getFunctionType()->isVarArg()) return false;
 
+  // The inliner does not know how to inline through calls with operand bundles.
+  if (CS.hasOperandBundles())
+    return false;
+
   // If the call to the callee cannot throw, set the 'nounwind' flag on any
   // calls that we inline.
   bool MarkNoUnwind = CS.doesNotThrow();
diff --git a/test/Feature/OperandBundles/inliner-conservative.ll b/test/Feature/OperandBundles/inliner-conservative.ll
new file mode 100644 (file)
index 0000000..d9f09f7
--- /dev/null
@@ -0,0 +1,17 @@
+; RUN: opt -S -inline < %s | FileCheck %s
+
+; Check that the inliner does not inline through arbitrary unknown
+; operand bundles.
+
+define i32 @callee() {
+ entry:
+  ret i32 2
+}
+
+define i32 @caller() {
+; CHECK: @caller(
+ entry:
+; CHECK: call i32 @callee() [ "unknown"() ]
+  %x = call i32 @callee() [ "unknown"() ]
+  ret i32 %x
+}