mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-02 21:36:05 +00:00
[ArgumentPromotion]: Copy function metadata after promoting arguments
The argument promotion pass currently fails to copy function annotations over to the modified function after promoting arguments. This patch copies the original function annotation to the new function. Reviewed By: fhann Differential Revision: https://reviews.llvm.org/D86630
This commit is contained in:
parent
009cd4e491
commit
6b13cfe739
@ -215,9 +215,11 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
|
||||
Function *NF = Function::Create(NFTy, F->getLinkage(), F->getAddressSpace(),
|
||||
F->getName());
|
||||
NF->copyAttributesFrom(F);
|
||||
NF->copyMetadata(F, 0);
|
||||
|
||||
// Patch the pointer to LLVM function in debug info descriptor.
|
||||
NF->setSubprogram(F->getSubprogram());
|
||||
// The new function will have the !dbg metadata copied from the original
|
||||
// function. The original function may not be deleted, and dbg metadata need
|
||||
// to be unique so we need to drop it.
|
||||
F->setSubprogram(nullptr);
|
||||
|
||||
LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"
|
||||
|
@ -15,9 +15,9 @@ define void @caller() #0 {
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal void @promote_i32_ptr(i32* %xp) {
|
||||
define internal void @promote_i32_ptr(i32* %xp) !prof !1 {
|
||||
; CHECK-LABEL: define {{[^@]+}}@promote_i32_ptr
|
||||
; CHECK-SAME: (i32 [[XP_VAL:%.*]])
|
||||
; CHECK-SAME: (i32 [[XP_VAL:%.*]]) !prof !1
|
||||
; CHECK-NEXT: call void @use_i32(i32 [[XP_VAL]])
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
@ -29,3 +29,4 @@ define internal void @promote_i32_ptr(i32* %xp) {
|
||||
declare void @use_i32(i32)
|
||||
|
||||
!0 = !{!"branch_weights", i32 30}
|
||||
!1 = !{!"function_entry_count", i64 100}
|
||||
|
Loading…
x
Reference in New Issue
Block a user