diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 19:40:20 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 19:40:20 +0000 |
commit | 0fdaf8c9c263857a775f58aa3aac7a94d70f8b5f (patch) | |
tree | a1413225a4b97dd486cda5cc84f438b87911aec0 /llvm/lib/Transforms/Utils/ValueMapper.cpp | |
parent | caa11696535d1e03ce6be057c514f672498157e8 (diff) | |
download | llvm-0fdaf8c9c263857a775f58aa3aac7a94d70f8b5f.zip llvm-0fdaf8c9c263857a775f58aa3aac7a94d70f8b5f.tar.gz llvm-0fdaf8c9c263857a775f58aa3aac7a94d70f8b5f.tar.bz2 |
Linker: Don't double-schedule appending variables
Add an assertion to ValueMapper that prevents double-scheduling of
GlobalValues to remap, and fix the one place it happened. There are
tons of tests that fail with this assertion in place and without the
code change, so I'm not adding another.
Although it looks related, r266563 was, indeed, removing dead code.
AFAICT, this cross-file double-scheduling started in r266510 when the
cross-file recursion was removed.
llvm-svn: 266569
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 84dcb42..8ab6626 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/ValueMapper.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DebugInfoMetadata.h" @@ -99,6 +100,10 @@ class MDNodeMapper; class Mapper { friend class MDNodeMapper; +#ifndef NDEBUG + DenseSet<GlobalValue *> AlreadyScheduled; +#endif + RemapFlags Flags; ValueMapTypeRemapper *TypeMapper; unsigned CurrentMCID = 0; @@ -965,6 +970,7 @@ void Mapper::mapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix, void Mapper::scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init, unsigned MCID) { + assert(AlreadyScheduled.insert(&GV).second && "Should not reschedule"); assert(MCID < MCs.size() && "Invalid mapping context"); WorklistEntry WE; @@ -980,6 +986,7 @@ void Mapper::scheduleMapAppendingVariable(GlobalVariable &GV, bool IsOldCtorDtor, ArrayRef<Constant *> NewMembers, unsigned MCID) { + assert(AlreadyScheduled.insert(&GV).second && "Should not reschedule"); assert(MCID < MCs.size() && "Invalid mapping context"); WorklistEntry WE; @@ -995,6 +1002,7 @@ void Mapper::scheduleMapAppendingVariable(GlobalVariable &GV, void Mapper::scheduleMapGlobalAliasee(GlobalAlias &GA, Constant &Aliasee, unsigned MCID) { + assert(AlreadyScheduled.insert(&GA).second && "Should not reschedule"); assert(MCID < MCs.size() && "Invalid mapping context"); WorklistEntry WE; @@ -1006,6 +1014,7 @@ void Mapper::scheduleMapGlobalAliasee(GlobalAlias &GA, Constant &Aliasee, } void Mapper::scheduleRemapFunction(Function &F, unsigned MCID) { + assert(AlreadyScheduled.insert(&F).second && "Should not reschedule"); assert(MCID < MCs.size() && "Invalid mapping context"); WorklistEntry WE; |