[PATCH] D18100: Simplify Logic in IRMover
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 15:12:23 PST 2016
joker.eph updated this revision to Diff 50488.
joker.eph added a comment.
Enforce invariant with an assertion
http://reviews.llvm.org/D18100
Files:
lib/Linker/IRMover.cpp
Index: lib/Linker/IRMover.cpp
===================================================================
--- lib/Linker/IRMover.cpp
+++ lib/Linker/IRMover.cpp
@@ -388,7 +388,6 @@
/// due to the use of Value handles which the Linker doesn't actually need,
/// but this allows us to reuse the ValueMapper code.
ValueToValueMapTy ValueMap;
- ValueToValueMapTy AliasValueMap;
DenseSet<GlobalValue *> ValuesToLink;
std::vector<GlobalValue *> Worklist;
@@ -1056,15 +1055,15 @@
bool ShouldLink = shouldLink(DGV, *SGV);
- // just missing from map
+ /// First verify if the value hasn't been alreay linked, which should not be
+ /// possible without ShouldLink
if (ShouldLink) {
auto I = ValueMap.find(SGV);
if (I != ValueMap.end())
return cast<Constant>(I->second);
-
- I = AliasValueMap.find(SGV);
- if (I != AliasValueMap.end())
- return cast<Constant>(I->second);
+ } else {
+ assert(ValueMap.find(SGV) == ValueMap.end() &&
+ "'!ShouldLink' GV shouldn't be in the ValueMap, broken invariant");
}
if (!ShouldLink && ForAlias)
@@ -1196,7 +1195,7 @@
void IRLinker::linkAliasBody(GlobalAlias &Dst, GlobalAlias &Src) {
Constant *Aliasee = Src.getAliasee();
- Constant *Val = MapValue(Aliasee, AliasValueMap, ValueMapperFlags, &TypeMap,
+ Constant *Val = MapValue(Aliasee, ValueMap, ValueMapperFlags, &TypeMap,
&LValMaterializer);
Dst.setAliasee(Val);
}
@@ -1555,8 +1554,7 @@
Worklist.pop_back();
// Already mapped.
- if (ValueMap.find(GV) != ValueMap.end() ||
- AliasValueMap.find(GV) != AliasValueMap.end())
+ if (ValueMap.find(GV) != ValueMap.end())
continue;
assert(!GV->isDeclaration());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18100.50488.patch
Type: text/x-patch
Size: 1735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160311/54321eba/attachment.bin>
More information about the llvm-commits
mailing list