Reverse 206485.
authorGerolf Hoflehner <ghoflehner@apple.com>
Thu, 17 Apr 2014 19:14:06 +0000 (19:14 +0000)
committerGerolf Hoflehner <ghoflehner@apple.com>
Thu, 17 Apr 2014 19:14:06 +0000 (19:14 +0000)
After some discussions the preferred semantics of
the always_inline attribute is
inline always when the compiler can determine
that it it safe to do so.

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

lib/Analysis/IPA/InlineCost.cpp
test/Transforms/Inline/always-inline-attribute.ll [deleted file]
test/Transforms/Inline/always-inline.ll

index 683637f5b7f737eb24c0539544b8b0474e9593df..a803f8c3bf970161b3420e4177a5380eb91c2e56 100644 (file)
@@ -1300,14 +1300,8 @@ bool InlineCostAnalysis::isInlineViable(Function &F) {
     F.getAttributes().hasAttribute(AttributeSet::FunctionIndex,
                                    Attribute::ReturnsTwice);
   for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; ++BI) {
     F.getAttributes().hasAttribute(AttributeSet::FunctionIndex,
                                    Attribute::ReturnsTwice);
   for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; ++BI) {
-    // Disallow inlining of functions which contain an indirect branch,
-    // unless the always_inline attribute is set.
-    // The attribute serves as a assertion that no local address
-    // like a block label can escpape the function.
-    // Revisit enabling inlining for functions with indirect branches
-    // when a more sophisticated espape/points-to analysis becomes available.
-    if (isa<IndirectBrInst>(BI->getTerminator()) &&
-        !F.hasFnAttribute(Attribute::AlwaysInline))
+    // Disallow inlining of functions which contain an indirect branch.
+    if (isa<IndirectBrInst>(BI->getTerminator()))
       return false;
 
     for (BasicBlock::iterator II = BI->begin(), IE = BI->end(); II != IE;
       return false;
 
     for (BasicBlock::iterator II = BI->begin(), IE = BI->end(); II != IE;
diff --git a/test/Transforms/Inline/always-inline-attribute.ll b/test/Transforms/Inline/always-inline-attribute.ll
deleted file mode 100644 (file)
index c146122..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-; RUN: opt < %s -O3 -S | FileCheck %s
-@gv = external global i32
-
-define i32 @main() nounwind {
-; CHECK-NOT: call i32 @foo
-  %1 = load i32* @gv, align 4
-  %2 = tail call i32 @foo(i32 %1)
-  unreachable
-}
-
-define internal i32 @foo(i32) alwaysinline {
-  br label %2
-
-; <label>:2                                       ; preds = %8, %1
-  %3 = phi i32 [ %0, %1 ], [ %10, %8 ]
-  %4 = phi i8* [ blockaddress(@foo, %2), %1 ], [ %6, %8 ]
-  %5 = icmp eq i32 %3, 1
-  %6 = select i1 %5, i8* blockaddress(@foo, %8), i8* %4
-  %7 = add nsw i32 %3, -1
-  br label %8
-
-; <label>:8                                       ; preds = %8, %2
-  %9 = phi i32 [ %7, %2 ], [ %10, %8 ]
-  %10 = add nsw i32 %9, -1
-  indirectbr i8* %6, [label %2, label %8]
-}
index 832e000eacc05320b046b7089282ee48400e5213..a8703b8987779a68d0ff3e0116360e560ff4b9d6 100644 (file)
@@ -78,7 +78,7 @@ entry:
   ret i32 %add
 }
 
   ret i32 %add
 }
 
-define i32 @inner5(i8* %addr) {
+define i32 @inner5(i8* %addr) alwaysinline {
 entry:
   indirectbr i8* %addr, [ label %one, label %two ]
 
 entry:
   indirectbr i8* %addr, [ label %one, label %two ]