[llvm-branch-commits] [llvm-branch] r296761 - Merging r296642:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 2 08:44:47 PST 2017


Author: hans
Date: Thu Mar  2 10:44:46 2017
New Revision: 296761

URL: http://llvm.org/viewvc/llvm-project?rev=296761&view=rev
Log:
Merging r296642:
------------------------------------------------------------------------
r296642 | hans | 2017-03-01 09:15:08 -0800 (Wed, 01 Mar 2017) | 5 lines

[GVNHoist] Don't hoist unsafe scalars at -Oz (PR31729)

Based on Aditya Kumar's patch:

Differential Revision: https://reviews.llvm.org/D29092
------------------------------------------------------------------------

Added:
    llvm/branches/release_40/test/Transforms/GVNHoist/hoist-unsafe-pr31729.ll
      - copied unchanged from r296642, llvm/trunk/test/Transforms/GVNHoist/hoist-unsafe-pr31729.ll
Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/lib/Transforms/Scalar/GVNHoist.cpp

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar  2 10:44:46 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293124,293230,293259,293273,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295116,295213,295215,295230,295486,295490,295512,295762,295990,296003,296030,296093,296260
+/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293124,293230,293259,293273,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295116,295213,295215,295230,295486,295490,295512,295762,295990,296003,296030,296093,296260,296642

Modified: llvm/branches/release_40/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Transforms/Scalar/GVNHoist.cpp?rev=296761&r1=296760&r2=296761&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/branches/release_40/lib/Transforms/Scalar/GVNHoist.cpp Thu Mar  2 10:44:46 2017
@@ -200,13 +200,11 @@ static void combineKnownMetadata(Instruc
 class GVNHoist {
 public:
   GVNHoist(DominatorTree *DT, AliasAnalysis *AA, MemoryDependenceResults *MD,
-           MemorySSA *MSSA, bool OptForMinSize)
-      : DT(DT), AA(AA), MD(MD), MSSA(MSSA), OptForMinSize(OptForMinSize),
-        HoistingGeps(OptForMinSize), HoistedCtr(0) {
-      // Hoist as far as possible when optimizing for code-size.
-      if (OptForMinSize)
-        MaxNumberOfBBSInPath = -1;
-  }
+           MemorySSA *MSSA)
+      : DT(DT), AA(AA), MD(MD), MSSA(MSSA),
+        HoistingGeps(false),
+        HoistedCtr(0)
+  { }
 
   bool run(Function &F) {
     VN.setDomTree(DT);
@@ -251,7 +249,6 @@ private:
   AliasAnalysis *AA;
   MemoryDependenceResults *MD;
   MemorySSA *MSSA;
-  const bool OptForMinSize;
   const bool HoistingGeps;
   DenseMap<const Value *, unsigned> DFSNumber;
   BBSideEffectsSet BBSideEffects;
@@ -505,11 +502,6 @@ private:
   bool safeToHoistScalar(const BasicBlock *HoistBB,
                          SmallPtrSetImpl<const BasicBlock *> &WL,
                          int &NBBsOnAllPaths) {
-    // Enable scalar hoisting at -Oz as it is safe to hoist scalars to a place
-    // where they are partially needed.
-    if (OptForMinSize)
-      return true;
-
     // Check that the hoisted expression is needed on all paths.
     if (!hoistingFromAllPaths(HoistBB, WL))
       return false;
@@ -923,13 +915,8 @@ private:
                 Intr->getIntrinsicID() == Intrinsic::assume)
               continue;
           }
-          if (Call->mayHaveSideEffects()) {
-            if (!OptForMinSize)
-              break;
-            // We may continue hoisting across calls which write to memory.
-            if (Call->mayThrow())
-              break;
-          }
+          if (Call->mayHaveSideEffects())
+            break;
 
           if (Call->isConvergent())
             break;
@@ -971,7 +958,7 @@ public:
     auto &MD = getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
     auto &MSSA = getAnalysis<MemorySSAWrapperPass>().getMSSA();
 
-    GVNHoist G(&DT, &AA, &MD, &MSSA, F.optForMinSize());
+    GVNHoist G(&DT, &AA, &MD, &MSSA);
     return G.run(F);
   }
 
@@ -991,7 +978,7 @@ PreservedAnalyses GVNHoistPass::run(Func
   AliasAnalysis &AA = AM.getResult<AAManager>(F);
   MemoryDependenceResults &MD = AM.getResult<MemoryDependenceAnalysis>(F);
   MemorySSA &MSSA = AM.getResult<MemorySSAAnalysis>(F).getMSSA();
-  GVNHoist G(&DT, &AA, &MD, &MSSA, F.optForMinSize());
+  GVNHoist G(&DT, &AA, &MD, &MSSA);
   if (!G.run(F))
     return PreservedAnalyses::all();
 




More information about the llvm-branch-commits mailing list