mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 15:13:49 -04: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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
Reference in New Issue
Block a user