diff options
author | Siddharth Bhat <siddu.druid@gmail.com> | 2017-08-01 12:15:51 +0000 |
---|---|---|
committer | Siddharth Bhat <siddu.druid@gmail.com> | 2017-08-01 12:15:51 +0000 |
commit | f2cfd2a4db0553bb12ce8bacf0f204a7332df4a5 (patch) | |
tree | a8e59536abe8702fc4dfeba81921cf3b97172aa5 | |
parent | 69e90bb096a6adda37991f85077cdeb903d1a58c (diff) | |
download | bcm5719-llvm-f2cfd2a4db0553bb12ce8bacf0f204a7332df4a5.tar.gz bcm5719-llvm-f2cfd2a4db0553bb12ce8bacf0f204a7332df4a5.zip |
[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
-rw-r--r-- | polly/include/polly/CodeGen/IslNodeBuilder.h | 8 | ||||
-rw-r--r-- | polly/lib/CodeGen/IslNodeBuilder.cpp | 13 |
2 files changed, 16 insertions, 5 deletions
diff --git a/polly/include/polly/CodeGen/IslNodeBuilder.h b/polly/include/polly/CodeGen/IslNodeBuilder.h index f7e07e7e832..1d94d41c496 100644 --- a/polly/include/polly/CodeGen/IslNodeBuilder.h +++ b/polly/include/polly/CodeGen/IslNodeBuilder.h @@ -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 diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp index aee7e209714..ecc84f40998 100644 --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -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, |