[polly] r255506 - BlockGenerator: Do not use fast-path for external constants

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 14 08:19:59 PST 2015


Author: grosser
Date: Mon Dec 14 10:19:59 2015
New Revision: 255506

URL: http://llvm.org/viewvc/llvm-project?rev=255506&view=rev
Log:
BlockGenerator: Do not use fast-path for external constants

This change should not change the behavior of Polly today, but it allows
external constants to be remapped e.g. when targetting multiple LLVM modules.

Modified:
    polly/trunk/lib/CodeGen/BlockGenerators.cpp

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=255506&r1=255505&r2=255506&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Mon Dec 14 10:19:59 2015
@@ -91,9 +91,12 @@ Value *BlockGenerator::trySynthesizeNewV
 
 Value *BlockGenerator::getNewValue(ScopStmt &Stmt, Value *Old, ValueMapT &BBMap,
                                    LoopToScevMapT &LTS, Loop *L) const {
-  // We assume constants never change.
-  // This avoids map lookups for many calls to this function.
-  if (isa<Constant>(Old))
+  // Constants that do not reference any named value can always remain
+  // unchanged. Handle them early to avoid expensive map loopups. We do not take
+  // the fast-path for external constants which are referenced through globals
+  // as these may need to be rewritten when distributing code accross different
+  // LLVM modules.
+  if (isa<Constant>(Old) && !isa<GlobalValue>(Old))
     return Old;
 
   if (Value *New = GlobalMap.lookup(Old)) {




More information about the llvm-commits mailing list