[PATCH] D86630: [ArgumentPromotion]: Copy function annotation after promoting arguments

Ettore Tiotto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 08:29:21 PDT 2020


etiotto created this revision.
etiotto added reviewers: bmahjour, Whitney, Meinersbur, fhahn.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
etiotto requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86630

Files:
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/test/Transforms/ArgumentPromotion/profile.ll


Index: llvm/test/Transforms/ArgumentPromotion/profile.ll
===================================================================
--- llvm/test/Transforms/ArgumentPromotion/profile.ll
+++ llvm/test/Transforms/ArgumentPromotion/profile.ll
@@ -15,9 +15,9 @@
   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 @@
 declare void @use_i32(i32)
 
 !0 = !{!"branch_weights", i32 30}
+!1 = !{!"function_entry_count”, i64 100}
Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
===================================================================
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -215,6 +215,7 @@
   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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86630.287987.patch
Type: text/x-patch
Size: 1258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/9bc8a00f/attachment.bin>


More information about the llvm-commits mailing list