]> granicus.if.org Git - llvm/commitdiff
Inliner: Don't remove calls to readnone+nounwind (but not always_inline) functions...
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 12 Jun 2017 23:01:17 +0000 (23:01 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 12 Jun 2017 23:01:17 +0000 (23:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305245 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/Inliner.cpp
test/Transforms/Inline/always-inline.ll

index c0dfeede05c5a8c7a425064dc468e0e9b9ac3e9e..1de4a21d7f21caff3bbc8d02370f2e0ef2430134 100644 (file)
@@ -523,6 +523,16 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG,
       if (!Callee || Callee->isDeclaration())
         continue;
 
+      // FIXME for new PM: because of the old PM we currently generate ORE and
+      // in turn BFI on demand.  With the new PM, the ORE dependency should
+      // just become a regular analysis dependency.
+      OptimizationRemarkEmitter ORE(Caller);
+
+      // If the policy determines that we should inline this function,
+      // delete the call instead.
+      if (!shouldInline(CS, GetInlineCost, ORE))
+        continue;
+
       // If this call site is dead and it is to a readonly function, we should
       // just delete the call instead of trying to inline it, regardless of
       // size.  This happens because IPSCCP propagates the result out of the
@@ -548,15 +558,6 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG,
         // Get DebugLoc to report. CS will be invalid after Inliner.
         DebugLoc DLoc = CS.getInstruction()->getDebugLoc();
         BasicBlock *Block = CS.getParent();
-        // FIXME for new PM: because of the old PM we currently generate ORE and
-        // in turn BFI on demand.  With the new PM, the ORE dependency should
-        // just become a regular analysis dependency.
-        OptimizationRemarkEmitter ORE(Caller);
-
-        // If the policy determines that we should inline this function,
-        // try to do so.
-        if (!shouldInline(CS, GetInlineCost, ORE))
-          continue;
 
         // Attempt to inline the function.
         using namespace ore;
index 5366b5a16cc77b80e185ad7537068bad2af92ef0..791eb94779b70b4339c411dc1af4bcf266eb4dac 100644 (file)
@@ -305,3 +305,14 @@ entry:
   ret void
 ; CHECK: ret void
 }
+
+define void @inner14() readnone nounwind {
+; CHECK: define void @inner14
+  ret void
+}
+
+define void @outer14() {
+; CHECK: call void @inner14
+  call void @inner14()
+  ret void
+}