mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:40:38 +00:00
[AMDGPU] Preserve original symbol during attribute propagation
AMDGPUPropagateAttributes can swap names while cloning a function. Only do it if original symbol was not externally visible. Differential Revision: https://reviews.llvm.org/D76789
This commit is contained in:
parent
931c0525ee
commit
b2f5e79308
@ -269,17 +269,15 @@ AMDGPUPropagateAttributes::cloneWithFeatures(Function &F,
|
||||
ValueToValueMapTy dummy;
|
||||
Function *NewF = CloneFunction(&F, dummy);
|
||||
setFeatures(*NewF, NewFeatures);
|
||||
NewF->setVisibility(GlobalValue::DefaultVisibility);
|
||||
NewF->setLinkage(GlobalValue::InternalLinkage);
|
||||
|
||||
// Swap names. If that is the only clone it will retain the name of now
|
||||
// dead value.
|
||||
if (F.hasName()) {
|
||||
// dead value. Preserve original name for externally visible functions.
|
||||
if (F.hasName() && F.hasLocalLinkage()) {
|
||||
std::string NewName = std::string(NewF->getName());
|
||||
NewF->takeName(&F);
|
||||
F.setName(NewName);
|
||||
|
||||
// Name has changed, it does not need an external symbol.
|
||||
F.setVisibility(GlobalValue::DefaultVisibility);
|
||||
F.setLinkage(GlobalValue::InternalLinkage);
|
||||
}
|
||||
|
||||
return NewF;
|
||||
|
@ -437,11 +437,11 @@ void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
|
||||
}
|
||||
PM.add(createAMDGPUUnifyMetadataPass());
|
||||
PM.add(createAMDGPUPrintfRuntimeBinding());
|
||||
PM.add(createAMDGPUPropagateAttributesLatePass(this));
|
||||
if (Internalize) {
|
||||
if (Internalize)
|
||||
PM.add(createInternalizePass(mustPreserveGV));
|
||||
PM.add(createAMDGPUPropagateAttributesLatePass(this));
|
||||
if (Internalize)
|
||||
PM.add(createGlobalDCEPass());
|
||||
}
|
||||
if (EarlyInline)
|
||||
PM.add(createAMDGPUAlwaysInlinePass(false));
|
||||
});
|
||||
|
@ -1,15 +1,23 @@
|
||||
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck -check-prefix=OPT %s
|
||||
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck -check-prefixes=OPT,OPT-EXT %s
|
||||
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -O1 --amdgpu-internalize-symbols < %s | FileCheck -check-prefixes=OPT,OPT-INT %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s
|
||||
|
||||
; OPT: declare void @foo4() local_unnamed_addr #0
|
||||
; OPT: define internal fastcc void @foo3.2() unnamed_addr #1
|
||||
; OPT: define void @foo2() local_unnamed_addr #1
|
||||
; OPT: define internal fastcc void @foo1.1() unnamed_addr #1
|
||||
; OPT: define internal fastcc void @0() unnamed_addr #1
|
||||
; OPT-EXT: define void @foo3() local_unnamed_addr #1
|
||||
; OPT-INT: define internal fastcc void @foo3.2() unnamed_addr #1
|
||||
; OPT-EXT: define void @foo2() local_unnamed_addr #1
|
||||
; OPT-INT: define internal fastcc void @foo2() unnamed_addr #1
|
||||
; OPT-EXT: define void @foo1() local_unnamed_addr #1
|
||||
; OPT-INT: define internal fastcc void @foo1.1() unnamed_addr #1
|
||||
; OPT: define amdgpu_kernel void @kernel1() local_unnamed_addr #2
|
||||
; OPT: define amdgpu_kernel void @kernel2() local_unnamed_addr #3
|
||||
; OPT: define amdgpu_kernel void @kernel3() local_unnamed_addr #3
|
||||
; OPT: define void @foo1() local_unnamed_addr #4
|
||||
; OPT: define void @foo3() local_unnamed_addr #4
|
||||
; OPT-EXT: define internal fastcc void @foo1.1() unnamed_addr #4
|
||||
; OPT-INT: define internal fastcc void @foo1() unnamed_addr #4
|
||||
; OPT: define internal fastcc void @1() unnamed_addr #4
|
||||
; OPT-EXT: define internal fastcc void @foo3.2() unnamed_addr #4
|
||||
; OPT-INT: define internal fastcc void @foo3() unnamed_addr #4
|
||||
; OPT: attributes #0 = { {{.*}} "target-features"="+wavefrontsize64" }
|
||||
; OPT: attributes #1 = { {{.*}} "target-features"="{{.*}},-wavefrontsize16,-wavefrontsize32,+wavefrontsize64{{.*}}" }
|
||||
; OPT: attributes #2 = { {{.*}} "target-features"="+wavefrontsize32" }
|
||||
@ -29,6 +37,8 @@
|
||||
; LLC: foo2@gotpcrel32@hi+4
|
||||
; LLC: foo1@gotpcrel32@lo+4
|
||||
; LLC: foo1@gotpcrel32@hi+4
|
||||
; LLC: __unnamed_1@gotpcrel32@lo+4
|
||||
; LLC: __unnamed_1@gotpcrel32@hi+4
|
||||
; LLC: kernel1:
|
||||
; LLC: foo1@gotpcrel32@lo+4
|
||||
; LLC: foo1@gotpcrel32@hi+4
|
||||
@ -41,6 +51,12 @@
|
||||
|
||||
declare void @foo4() #1
|
||||
|
||||
define void @0() #1 {
|
||||
entry:
|
||||
call void asm sideeffect "; sample asm", ""()
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @foo3() #1 {
|
||||
entry:
|
||||
call void asm sideeffect "; sample asm", ""()
|
||||
@ -60,6 +76,7 @@ entry:
|
||||
tail call void @foo2()
|
||||
tail call void @foo2()
|
||||
tail call void @foo1()
|
||||
tail call void @0()
|
||||
ret void
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user