mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-12 15:51:35 +00:00
[IR] Copy comdats in GlobalObject::copyAttributesFrom
This is probably correct for all uses except cross-module IR linking, where we need to move the comdat from the source module to the destination module. Fixes PR27870. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D20631 llvm-svn: 270743
This commit is contained in:
parent
8c7c869714
commit
31bb5b2278
@ -96,6 +96,7 @@ void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
|
||||
if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
|
||||
setAlignment(GV->getAlignment());
|
||||
setSection(GV->getSection());
|
||||
setComdat(const_cast<GlobalObject *>(GV)->getComdat());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -622,6 +622,11 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV,
|
||||
|
||||
NewGV->copyAttributesFrom(SGV);
|
||||
|
||||
// Don't copy the comdat, it's from the original module. We'll handle it
|
||||
// later.
|
||||
if (auto *NewGO = dyn_cast<GlobalObject>(NewGV))
|
||||
NewGO->setComdat(nullptr);
|
||||
|
||||
// Remove these copied constants in case this stays a declaration, since
|
||||
// they point to the source module. If the def is linked the values will
|
||||
// be mapped in during linkFunctionBody.
|
||||
|
14
test/Transforms/DeadArgElim/comdat.ll
Normal file
14
test/Transforms/DeadArgElim/comdat.ll
Normal file
@ -0,0 +1,14 @@
|
||||
; RUN: opt -S < %s -deadargelim | FileCheck %s
|
||||
|
||||
$f = comdat any
|
||||
|
||||
define void @f() comdat {
|
||||
call void @g(i32 0)
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal void @g(i32 %dead) comdat($f) {
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: define internal void @g() comdat($f) {
|
Loading…
x
Reference in New Issue
Block a user