Index: polly/trunk/include/polly/CodeGen/IslNodeBuilder.h =================================================================== --- polly/trunk/include/polly/CodeGen/IslNodeBuilder.h +++ polly/trunk/include/polly/CodeGen/IslNodeBuilder.h @@ -262,6 +262,14 @@ /// @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 Index: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp =================================================================== --- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp +++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp @@ -324,11 +324,7 @@ // 2. test/Isl/CodeGen/OpenMP/loop-body-references-outer-values-3.ll SetVector 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 @@ } } +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 &IVS, __isl_take isl_id *IteratorID,