diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-05-25 21:00:44 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-05-25 21:00:44 +0000 |
commit | 3d4f3a0da90bd1a34ff3ef4c3b99c1dbcca2e6cb (patch) | |
tree | ed3b040c0d4251b2811be13f5ef71cb7ee52bf3d /llvm/lib/Linker/IRMover.cpp | |
parent | 971abe8256a122c7afe6dc08250b86b1d61b57f7 (diff) | |
download | bcm5719-llvm-3d4f3a0da90bd1a34ff3ef4c3b99c1dbcca2e6cb.tar.gz bcm5719-llvm-3d4f3a0da90bd1a34ff3ef4c3b99c1dbcca2e6cb.zip |
IRLinker: fix double scheduling of mapping a global value because of an alias
This test was hitting an assertion in the value mapper because
the IRLinker was trying to map two times @A while materializing
the initializer for @C.
Fix http://llvm.org/PR27850
Differential Revision: http://reviews.llvm.org/D20586
llvm-svn: 270757
Diffstat (limited to 'llvm/lib/Linker/IRMover.cpp')
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 9a2cedfc59e..d357bbfeb17 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -557,6 +557,17 @@ void IRLinker::materializeInitFor(GlobalValue *New, GlobalValue *Old, return; } + // When linking a global for an alias, it will always be linked. However we + // need to check if it was not already scheduled to satify a reference from a + // regular global value initializer. We know if it has been schedule if the + // "New" GlobalValue that is mapped here for the alias is the same as the one + // already mapped. If there is an entry in the ValueMap but the value is + // different, it means that the value already had a definition in the + // destination module (linkonce for instance), but we need a new definition + // for the alias ("New" will be different. + if (ForAlias && ValueMap.lookup(Old) == New) + return; + if (ForAlias || shouldLink(New, *Old)) linkGlobalValueBody(*New, *Old); } |