[llvm-branch-commits] [llvm-branch] r278831 - Merging r278571:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 16 11:06:45 PDT 2016


Author: hans
Date: Tue Aug 16 13:06:44 2016
New Revision: 278831

URL: http://llvm.org/viewvc/llvm-project?rev=278831&view=rev
Log:
Merging r278571:
------------------------------------------------------------------------
r278571 | rnk | 2016-08-12 15:23:04 -0700 (Fri, 12 Aug 2016) | 6 lines

[Inliner] Don't treat inalloca allocas as static

They aren't static, and moving them to the entry block across something
else will only result in tears.

Root cause of http://crbug.com/636558.
------------------------------------------------------------------------

Added:
    llvm/branches/release_39/test/Transforms/Inline/inalloca-not-static.ll
      - copied unchanged from r278571, llvm/trunk/test/Transforms/Inline/inalloca-not-static.ll
Modified:
    llvm/branches/release_39/   (props changed)
    llvm/branches/release_39/lib/Transforms/Utils/InlineFunction.cpp

Propchange: llvm/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 16 13:06:44 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,275868-275870,275879,275898,275928,275935,275946,275978,275981,276015,276051,276077,276109,276119,276181,276209,276236-276237,276358,276364,276368,276389,276435,276438,276479,276510,276648,276676,276712,276740,276823,276956,276980,277093,277114,277135,277371,277399,277500,277504,277625,277691,277693,277773,278002,278086,278133,278157,278370,278413,278558,278569,278573,278575,278584
+/llvm/trunk:155241,275868-275870,275879,275898,275928,275935,275946,275978,275981,276015,276051,276077,276109,276119,276181,276209,276236-276237,276358,276364,276368,276389,276435,276438,276479,276510,276648,276676,276712,276740,276823,276956,276980,277093,277114,277135,277371,277399,277500,277504,277625,277691,277693,277773,278002,278086,278133,278157,278370,278413,278558,278569,278571,278573,278575,278584

Modified: llvm/branches/release_39/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/Transforms/Utils/InlineFunction.cpp?rev=278831&r1=278830&r2=278831&view=diff
==============================================================================
--- llvm/branches/release_39/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/branches/release_39/lib/Transforms/Utils/InlineFunction.cpp Tue Aug 16 13:06:44 2016
@@ -1294,6 +1294,13 @@ updateInlinedAtInfo(const DebugLoc &DL,
   return DebugLoc::get(DL.getLine(), DL.getCol(), DL.getScope(), Last);
 }
 
+/// Return the result of AI->isStaticAlloca() if AI were moved to the entry
+/// block. Allocas used in inalloca calls and allocas of dynamic array size
+/// cannot be static.
+static bool allocaWouldBeStaticInEntry(const AllocaInst *AI ) {
+  return isa<Constant>(AI->getArraySize()) && !AI->isUsedWithInAlloca();
+}
+
 /// Update inlined instructions' line numbers to
 /// to encode location where these instructions are inlined.
 static void fixupLineNumbers(Function *Fn, Function::iterator FI,
@@ -1328,7 +1335,7 @@ static void fixupLineNumbers(Function *F
 
         // Don't update static allocas, as they may get moved later.
         if (auto *AI = dyn_cast<AllocaInst>(BI))
-          if (isa<Constant>(AI->getArraySize()))
+          if (allocaWouldBeStaticInEntry(AI))
             continue;
 
         BI->setDebugLoc(TheCallDL);
@@ -1626,7 +1633,7 @@ bool llvm::InlineFunction(CallSite CS, I
         continue;
       }
 
-      if (!isa<Constant>(AI->getArraySize()))
+      if (!allocaWouldBeStaticInEntry(AI))
         continue;
       
       // Keep track of the static allocas that we inline into the caller.
@@ -1635,7 +1642,7 @@ bool llvm::InlineFunction(CallSite CS, I
       // Scan for the block of allocas that we can move over, and move them
       // all at once.
       while (isa<AllocaInst>(I) &&
-             isa<Constant>(cast<AllocaInst>(I)->getArraySize())) {
+             allocaWouldBeStaticInEntry(cast<AllocaInst>(I))) {
         IFI.StaticAllocas.push_back(cast<AllocaInst>(I));
         ++I;
       }




More information about the llvm-branch-commits mailing list