diff options
| author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-11-11 04:30:07 +0000 |
|---|---|---|
| committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-11-11 04:30:07 +0000 |
| commit | fc4bfc465afa391da841ce58c5acff8c723425da (patch) | |
| tree | 00943ef144f189fb5ae0008e6cd51e5f2877d967 /polly/lib/CodeGen/IslNodeBuilder.cpp | |
| parent | d619eaaae421f70574b9618bb51f8c6959491fa5 (diff) | |
| download | bcm5719-llvm-fc4bfc465afa391da841ce58c5acff8c723425da.tar.gz bcm5719-llvm-fc4bfc465afa391da841ce58c5acff8c723425da.zip | |
[FIX] Create empty invariant equivalence classes
We now create all invariant equivalence classes for required invariant loads
instead of creating them on-demand. This way we can check if a parameter
references an invariant load that is actually not executed and was therefor
not materialized. If that happens the parameter is not materialized either.
This fixes bug 25469.
llvm-svn: 252701
Diffstat (limited to 'polly/lib/CodeGen/IslNodeBuilder.cpp')
| -rw-r--r-- | polly/lib/CodeGen/IslNodeBuilder.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp index 639c29ce543..ab762e6797a 100644 --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -819,6 +819,7 @@ bool IslNodeBuilder::materializeValue(isl_id *Id) { // If the Id is already mapped, skip it. if (!IDToValue.count(Id)) { auto *ParamSCEV = (const SCEV *)isl_id_get_user(Id); + Value *V = nullptr; // Parameters could refere to invariant loads that need to be // preloaded before we can generate code for the parameter. Thus, @@ -827,13 +828,22 @@ bool IslNodeBuilder::materializeValue(isl_id *Id) { SetVector<Value *> Values; findValues(ParamSCEV, Values); for (auto *Val : Values) - if (const auto *IAClass = S.lookupInvariantEquivClass(Val)) + if (const auto *IAClass = S.lookupInvariantEquivClass(Val)) { + + // Check if this invariant access class is empty, hence if we never + // actually added a loads instruction to it. In that case it has no + // (meaningful) users and we should not try to code generate it. + if (std::get<1>(*IAClass).empty()) + V = UndefValue::get(ParamSCEV->getType()); + if (!preloadInvariantEquivClass(*IAClass)) { isl_id_free(Id); return false; } + } - auto *V = generateSCEV(ParamSCEV); + if (!V) + V = generateSCEV(ParamSCEV); IDToValue[Id] = V; } @@ -947,7 +957,9 @@ bool IslNodeBuilder::preloadInvariantEquivClass( // elements of the class to the one preloaded load as they are referenced // during the code generation and therefor need to be mapped. const MemoryAccessList &MAs = std::get<1>(IAClass); - assert(!MAs.empty()); + if (MAs.empty()) + return true; + MemoryAccess *MA = MAs.front(); assert(MA->isExplicit() && MA->isRead()); |

