[NFC] [IslNodeBuilder, GPUNodeBuilder] Unify mechanism for looking up replacement Values.

We populate `IslNodeBuilder::ValueMap` which contains replacements for
`llvm::Value`s. There was no simple method to pick up a replacement if
it exists, otherwise fall back to the original.

Create a method `IslNodeBuilder::getLatestValue` which provides this
functionality.

This will be used in a later patch to fix bugs in `PPCGCodeGeneration`
where the latest value is not being used.

Differential Revision: https://reviews.llvm.org/D36000

llvm-svn: 309674
This commit is contained in:
Siddharth Bhat
2017-08-01 12:15:51 +00:00
parent 69e90bb096
commit f2cfd2a4db
2 changed files with 16 additions and 5 deletions

View File

@@ -262,6 +262,14 @@ protected:
/// @param NewValues A map that maps certain llvm::Values to new llvm::Values.
void updateValues(ValueMapT &NewValues);
/// Return the most up-to-date version of the llvm::Value for code generation.
/// @param Original The Value to check for an up to date version.
/// @returns A remapped `Value` from ValueMap, or `Original` if no mapping
/// exists.
/// @see IslNodeBuilder::updateValues
/// @see IslNodeBuilder::ValueMap
Value *getLatestValue(Value *Original) const;
/// Generate code for a marker now.
///
/// For mark nodes with an unknown name, we just forward the code generation

View File

@@ -324,11 +324,7 @@ void IslNodeBuilder::getReferencesInSubtree(__isl_keep isl_ast_node *For,
// 2. test/Isl/CodeGen/OpenMP/loop-body-references-outer-values-3.ll
SetVector<Value *> ReplacedValues;
for (Value *V : Values) {
auto It = ValueMap.find(V);
if (It == ValueMap.end())
ReplacedValues.insert(V);
else
ReplacedValues.insert(It->second);
ReplacedValues.insert(getLatestValue(V));
}
Values = ReplacedValues;
}
@@ -349,6 +345,13 @@ void IslNodeBuilder::updateValues(ValueMapT &NewValues) {
}
}
Value *IslNodeBuilder::getLatestValue(Value *Original) const {
auto It = ValueMap.find(Original);
if (It == ValueMap.end())
return Original;
return It->second;
}
void IslNodeBuilder::createUserVector(__isl_take isl_ast_node *User,
std::vector<Value *> &IVS,
__isl_take isl_id *IteratorID,