mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[IR] Add missing GlobalAlias copying of ThreadLocalMode attribute
Summary: Previously, GlobalAlias::copyAttributesFrom did not preserve ThreadLocalMode, causing incorrect IR generation in IR linking flows. This patch pushes the code responsible for copying this attribute from GlobalVariable::copyAttributesFrom down to GlobalValue::copyAttributesFrom so that it is shared by GlobalAlias. Fixes PR46297. Reviewers: tejohnson, pcc, hans Reviewed By: tejohnson, hans Subscribers: hiraditya, ibookstein, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81605
This commit is contained in:
parent
22b4f1c9e7
commit
c00c4a1533
@ -65,6 +65,7 @@ Value *GlobalValue::handleOperandChangeImpl(Value *From, Value *To) {
|
|||||||
void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
|
void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
|
||||||
setVisibility(Src->getVisibility());
|
setVisibility(Src->getVisibility());
|
||||||
setUnnamedAddr(Src->getUnnamedAddr());
|
setUnnamedAddr(Src->getUnnamedAddr());
|
||||||
|
setThreadLocalMode(Src->getThreadLocalMode());
|
||||||
setDLLStorageClass(Src->getDLLStorageClass());
|
setDLLStorageClass(Src->getDLLStorageClass());
|
||||||
setDSOLocal(Src->isDSOLocal());
|
setDSOLocal(Src->isDSOLocal());
|
||||||
setPartition(Src->getPartition());
|
setPartition(Src->getPartition());
|
||||||
@ -419,7 +420,6 @@ void GlobalVariable::setInitializer(Constant *InitVal) {
|
|||||||
/// from the GlobalVariable Src to this one.
|
/// from the GlobalVariable Src to this one.
|
||||||
void GlobalVariable::copyAttributesFrom(const GlobalVariable *Src) {
|
void GlobalVariable::copyAttributesFrom(const GlobalVariable *Src) {
|
||||||
GlobalObject::copyAttributesFrom(Src);
|
GlobalObject::copyAttributesFrom(Src);
|
||||||
setThreadLocalMode(Src->getThreadLocalMode());
|
|
||||||
setExternallyInitialized(Src->isExternallyInitialized());
|
setExternallyInitialized(Src->isExternallyInitialized());
|
||||||
setAttributes(Src->getAttributes());
|
setAttributes(Src->getAttributes());
|
||||||
}
|
}
|
||||||
|
2
test/Linker/Inputs/alias-threadlocal-defs.ll
Normal file
2
test/Linker/Inputs/alias-threadlocal-defs.ll
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@tlsvar1 = thread_local global i32 0, align 4
|
||||||
|
@tlsvar2 = hidden thread_local alias i32, i32* @tlsvar1
|
9
test/Linker/alias-threadlocal.ll
Normal file
9
test/Linker/alias-threadlocal.ll
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
; RUN: llvm-link %s %p/Inputs/alias-threadlocal-defs.ll -S -o - | FileCheck %s
|
||||||
|
|
||||||
|
; PR46297
|
||||||
|
; Verify that linking GlobalAliases preserves the thread_local attribute
|
||||||
|
|
||||||
|
; CHECK: @tlsvar1 = thread_local global i32 0, align 4
|
||||||
|
; CHECK: @tlsvar2 = hidden thread_local alias i32, i32* @tlsvar1
|
||||||
|
|
||||||
|
@tlsvar2 = external thread_local global i32, align 4
|
Loading…
x
Reference in New Issue
Block a user