forked from OSchip/llvm-project
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. llvm-svn: 253330
This commit is contained in:
parent
246b21f66a
commit
b39c96aa19
|
@ -1603,17 +1603,25 @@ __isl_give isl_id *Scop::getIdForParam(const SCEV *Parameter) {
|
|||
|
||||
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 =
|
||||
LI->getPointerOperand()->stripInBoundsOffsets()->getName();
|
||||
}
|
||||
|
||||
if (ParameterName == "" || ParameterName.substr(0, 2) == "p_")
|
||||
ParameterName = "p_" + utostr_32(IdIter->second);
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isl_id_alloc(getIslCtx(), ParameterName.c_str(),
|
||||
const_cast<void *>((const void *)Parameter));
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue