diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-06-06 02:48:30 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-06-06 02:48:30 +0000 |
commit | 03aef0969e34e6d8c704b5b59aae0226ed5d1891 (patch) | |
tree | c62eef3b8c38af4fc1514f9b526bfd4235dbb217 | |
parent | f47f2c23ff8a4a7f50c33ffc81be9d7333b09c86 (diff) | |
download | llvm-03aef0969e34e6d8c704b5b59aae0226ed5d1891.zip llvm-03aef0969e34e6d8c704b5b59aae0226ed5d1891.tar.gz llvm-03aef0969e34e6d8c704b5b59aae0226ed5d1891.tar.bz2 |
fix insertion of values in BBMap
In GDB when "step" through generateScalarLoad and "finish" the call, the
returned value is non NULL, however when printing the value contained in
BBMap[Load] after this stmt:
BBMap[Load] = generateScalarLoad(...);
the value in BBMap[Load] is NULL, and the BBMap.count(Load) is 1.
The only intuitive idea that I have to explain this behavior is that we are
playing with the undefined behavior of eval order of the params for the function
standing for "BBMap[Load] = generateScalarLoad()". "BBMap[Load] = " may be
executed before generateScalarLoad is called.
Here are some other possible explanations from Will Dietz <w@wdtz.org>:
The error is likely due to BBMap[Load] being evaluated first (creating
a {Load -> uninitialized } entry in the DenseMap), then
generateScalarLoad eventually accesses the same element and finds it
to be NULL (DenseMap[Old]).. Offhand I'm not sure if this is
guaranteed to be NULL or if it's uninitialized and happens to be NULL.
The same issue can also go wrong in an even worse way: the second
DenseMap access can trigger a rehash and *invalidate* the an earlier
evaluated expression (for example LHS of the assignment), leading to a
crash when performing the assignment store.
Merged from: https://llvm.org/svn/llvm-project/polly/trunk@182655
llvm-svn: 183379
-rw-r--r-- | polly/lib/CodeGen/BlockGenerators.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 436f721..f0931e1 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -185,6 +185,7 @@ Value *BlockGenerator::getNewValue(const Value *Old, ValueMapT &BBMap, } if (BBMap.count(Old)) { + assert(BBMap[Old] && "BBMap[Old] should not be NULL!"); return BBMap[Old]; } @@ -354,12 +355,14 @@ void BlockGenerator::copyInstruction(const Instruction *Inst, ValueMapT &BBMap, return; if (const LoadInst *Load = dyn_cast<LoadInst>(Inst)) { - BBMap[Load] = generateScalarLoad(Load, BBMap, GlobalMap, LTS); + Value *NewLoad = generateScalarLoad(Load, BBMap, GlobalMap, LTS); + BBMap[Load] = NewLoad; return; } if (const StoreInst *Store = dyn_cast<StoreInst>(Inst)) { - BBMap[Store] = generateScalarStore(Store, BBMap, GlobalMap, LTS); + Value *NewStore = generateScalarStore(Store, BBMap, GlobalMap, LTS); + BBMap[Store] = NewStore; return; } |