[polly] r253330 - ScopInfo: Ensure unique names for parameter names coming from load instructions

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 03:54:53 PST 2015


Author: grosser
Date: Tue Nov 17 05:54:51 2015
New Revision: 253330

URL: http://llvm.org/viewvc/llvm-project?rev=253330&view=rev
Log:
ScopInfo: Ensure unique names for parameter names coming from load instructions

In case the original parameter instruction does not have a name, but it comes
from a load instruction where the base pointer has a name we used the name of
the load instruction to give some more intuition of where the parameter came
from. To ensure this works also through GEPs which may have complex offsets,
we originally just dropped the offsets and _only_ used the base pointer name.
As this can result in multiple parameters to get the same name, we now prefix
the parameter ID to ensure parameter names are unique. This will make it easier
to understand debug output.

This change does not affect correctness, as parameter IDs (even of the same
name) can always be distinguished through the SCEV pointer stored inside them.

Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/test/Isl/Ast/runtime_context_with_error_blocks.ll

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=253330&r1=253329&r2=253330&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Nov 17 05:54:51 2015
@@ -1603,18 +1603,26 @@ __isl_give isl_id *Scop::getIdForParam(c
 
   std::string ParameterName;
 
+  ParameterName = "p_" + utostr_32(IdIter->second);
+
   if (const SCEVUnknown *ValueParameter = dyn_cast<SCEVUnknown>(Parameter)) {
     Value *Val = ValueParameter->getValue();
-    ParameterName = Val->getName();
-    if (!Val->hasName())
-      if (LoadInst *LI = dyn_cast<LoadInst>(Val))
-        ParameterName =
+
+    // If this parameter references a specific Value and this value has a name
+    // we use this name as it is likely to be unique and more useful than just
+    // a number.
+    if (Val->hasName())
+      ParameterName = Val->getName();
+    else if (LoadInst *LI = dyn_cast<LoadInst>(Val)) {
+      auto LoadOrigin = LI->getPointerOperand()->stripInBoundsOffsets();
+      if (LoadOrigin->hasName()) {
+        ParameterName += "_loaded_from_";
+        ParameterName +=
             LI->getPointerOperand()->stripInBoundsOffsets()->getName();
+      }
+    }
   }
 
-  if (ParameterName == "" || ParameterName.substr(0, 2) == "p_")
-    ParameterName = "p_" + utostr_32(IdIter->second);
-
   return isl_id_alloc(getIslCtx(), ParameterName.c_str(),
                       const_cast<void *>((const void *)Parameter));
 }

Modified: polly/trunk/test/Isl/Ast/runtime_context_with_error_blocks.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/runtime_context_with_error_blocks.ll?rev=253330&r1=253329&r2=253330&view=diff
==============================================================================
--- polly/trunk/test/Isl/Ast/runtime_context_with_error_blocks.ll (original)
+++ polly/trunk/test/Isl/Ast/runtime_context_with_error_blocks.ll Tue Nov 17 05:54:51 2015
@@ -4,7 +4,7 @@
 ; constraints as the test contains an error block that influenced the domains
 ; already.
 ;
-; CHECK: if (this <= -1 || this >= 1)
+; CHECK: if (p_0_loaded_from_this <= -1 || p_0_loaded_from_this >= 1)
 ;
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 




More information about the llvm-commits mailing list