[llvm-commits] [llvm] r152904 - in /llvm/trunk: lib/Transforms/IPO/InlineSimple.cpp test/Transforms/Inline/2007-06-06-NoInline.ll

Chandler Carruth chandlerc at gmail.com
Thu Mar 15 23:10:15 PDT 2012


Author: chandlerc
Date: Fri Mar 16 01:10:15 2012
New Revision: 152904

URL: http://llvm.org/viewvc/llvm-project?rev=152904&view=rev
Log:
Rip out support for 'llvm.noinline'. This thing has a strange history...

It was added in 2007 as the first cut at supporting no-inline
attributes, but we didn't have function attributes of any form at the
time. However, it was added without any mention in the LangRef or other
documentation.

Later on, in 2008, Devang added function notes for 'inline=never' and
then turned them into proper function attributes. From that point
onward, as far as I can tell, the world moved on, and no one has touched
'llvm.noinline' in any meaningful way since.

It's time has now come. We have had better mechanisms for doing this for
a long time, all the frontends I'm aware of use them, and this is just
holding back progress. Given that it was never a documented feature of
the IR, I've provided no auto-upgrade support. If people know of real,
in-the-wild bitcode that relies on this, yell at me and I'll add it, but
I *seriously* doubt anyone cares.

Removed:
    llvm/trunk/test/Transforms/Inline/2007-06-06-NoInline.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp

Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=152904&r1=152903&r2=152904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Fri Mar 16 01:10:15 2012
@@ -23,15 +23,12 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/InlinerPass.h"
 #include "llvm/Target/TargetData.h"
-#include "llvm/ADT/SmallPtrSet.h"
 
 using namespace llvm;
 
 namespace {
 
   class SimpleInliner : public Inliner {
-    // Functions that are never inlined
-    SmallPtrSet<const Function*, 16> NeverInline;
     InlineCostAnalyzer CA;
   public:
     SimpleInliner() : Inliner(ID) {
@@ -43,15 +40,6 @@
     }
     static char ID; // Pass identification, replacement for typeid
     InlineCost getInlineCost(CallSite CS) {
-      // Filter out functions which should never be inlined due to the global
-      // 'llvm.noinline'.
-      // FIXME: I'm 99% certain that this is an ancient bit of legacy that we
-      // no longer need to support, but I don't want to blindly nuke it just
-      // yet.
-      if (Function *Callee = CS.getCalledFunction())
-        if (NeverInline.count(Callee))
-          return InlineCost::getNever();
-
       return CA.getInlineCost(CS);
     }
     float getInlineFudgeFactor(CallSite CS) {
@@ -87,39 +75,6 @@
 // annotated with the noinline attribute.
 bool SimpleInliner::doInitialization(CallGraph &CG) {
   CA.setTargetData(getAnalysisIfAvailable<TargetData>());
-
-  Module &M = CG.getModule();
-
-  // Get llvm.noinline
-  GlobalVariable *GV = M.getNamedGlobal("llvm.noinline");
-
-  if (GV == 0)
-    return false;
-
-  // Don't crash on invalid code
-  if (!GV->hasDefinitiveInitializer())
-    return false;
-
-  const ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
-
-  if (InitList == 0)
-    return false;
-
-  // Iterate over each element and add to the NeverInline set
-  for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
-
-    // Get Source
-    const Constant *Elt = InitList->getOperand(i);
-
-    if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(Elt))
-      if (CE->getOpcode() == Instruction::BitCast)
-        Elt = CE->getOperand(0);
-
-    // Insert into set of functions to never inline
-    if (const Function *F = dyn_cast<Function>(Elt))
-      NeverInline.insert(F);
-  }
-
   return false;
 }
 

Removed: llvm/trunk/test/Transforms/Inline/2007-06-06-NoInline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/2007-06-06-NoInline.ll?rev=152903&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Inline/2007-06-06-NoInline.ll (original)
+++ llvm/trunk/test/Transforms/Inline/2007-06-06-NoInline.ll (removed)
@@ -1,46 +0,0 @@
-; RUN: opt < %s -inline -S | grep "define internal i32 @bar"
- at llvm.noinline = appending global [1 x i8*] [ i8* bitcast (i32 (i32, i32)* @bar to i8*) ], section "llvm.metadata"		; <[1 x i8*]*> [#uses=0]
-
-define internal i32 @bar(i32 %x, i32 %y) {
-entry:
-	%x_addr = alloca i32		; <i32*> [#uses=2]
-	%y_addr = alloca i32		; <i32*> [#uses=2]
-	%retval = alloca i32, align 4		; <i32*> [#uses=2]
-	%tmp = alloca i32, align 4		; <i32*> [#uses=2]
-	%"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]
-	store i32 %x, i32* %x_addr
-	store i32 %y, i32* %y_addr
-	%tmp1 = load i32* %x_addr		; <i32> [#uses=1]
-	%tmp2 = load i32* %y_addr		; <i32> [#uses=1]
-	%tmp3 = add i32 %tmp1, %tmp2		; <i32> [#uses=1]
-	store i32 %tmp3, i32* %tmp
-	%tmp4 = load i32* %tmp		; <i32> [#uses=1]
-	store i32 %tmp4, i32* %retval
-	br label %return
-
-return:		; preds = %entry
-	%retval5 = load i32* %retval		; <i32> [#uses=1]
-	ret i32 %retval5
-}
-
-define i32 @foo(i32 %a, i32 %b) {
-entry:
-	%a_addr = alloca i32		; <i32*> [#uses=2]
-	%b_addr = alloca i32		; <i32*> [#uses=2]
-	%retval = alloca i32, align 4		; <i32*> [#uses=2]
-	%tmp = alloca i32, align 4		; <i32*> [#uses=2]
-	%"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]
-	store i32 %a, i32* %a_addr
-	store i32 %b, i32* %b_addr
-	%tmp1 = load i32* %b_addr		; <i32> [#uses=1]
-	%tmp2 = load i32* %a_addr		; <i32> [#uses=1]
-	%tmp3 = call i32 @bar( i32 %tmp1, i32 %tmp2 )		; <i32> [#uses=1]
-	store i32 %tmp3, i32* %tmp
-	%tmp4 = load i32* %tmp		; <i32> [#uses=1]
-	store i32 %tmp4, i32* %retval
-	br label %return
-
-return:		; preds = %entry
-	%retval5 = load i32* %retval		; <i32> [#uses=1]
-	ret i32 %retval5
-}





More information about the llvm-commits mailing list