[llvm] [Transforms][IPO] Add func suffix in ArgumentPromotion and DeadArgume… (PR #105742)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 14:59:17 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: None (yonghong-song)

<details>
<summary>Changes</summary>

…ntElimination

ArgumentPromotion and DeadArgumentElimination passes could change function signatures but the function name remains the same as before the transformation. This makes it hard for tracing with bpf programs where user tends to use function signature in the source. See discussion [1] for details.

This patch added suffix to functions whose signatures are changed. The suffix lets users know that function signature has changed and they need to impact the IR or binary to find modified signature before tracing those functions.

The suffix for ArgumentPromotion is ".argpromotion" and the suffix for DeadArgumentElimination is ".deadargelim". The suffix also gives user hints about what kind of transformation has been done.

With this patch, I built a recent linux kernel with full LTO enabled. I got 4 functions with only argpromotion like
```
  set_track_update.deadargelim.argpromotion
  pmd_trans_huge_lock.argpromotion
  ...
```
I got 1058 functions with only deadargelim like
```
  process_bit0.deadargelim
  pci_io_ecs_init.deadargelim
  ...
```
I got 3 functions with both argpromotion and deadargelim
```
  set_track_update.deadargelim.argpromotion
  zero_pud_populate.deadargelim.argpromotion
  zero_pmd_populate.deadargelim.argpromotion
```

  [1] https://github.com/llvm/llvm-project/issues/104678

---
Full diff: https://github.com/llvm/llvm-project/pull/105742.diff


2 Files Affected:

- (modified) llvm/lib/Transforms/IPO/ArgumentPromotion.cpp (+1) 
- (modified) llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp (+1) 


``````````diff
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 452fff7898d0ea..f3cbf15b46a09c 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -200,6 +200,7 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
 
   F->getParent()->getFunctionList().insert(F->getIterator(), NF);
   NF->takeName(F);
+  NF->setName(NF->getName() + ".argpromotion");
 
   // Loop over all the callers of the function, transforming the call sites to
   // pass in the loaded pointers.
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index f5a7ab26a49e96..b54d3b3fd7ad0d 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -876,6 +876,7 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
   // it again.
   F->getParent()->getFunctionList().insert(F->getIterator(), NF);
   NF->takeName(F);
+  NF->setName(NF->getName() + ".deadargelim");
   NF->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat;
 
   // Loop over all the callers of the function, transforming the call sites to

``````````

</details>


https://github.com/llvm/llvm-project/pull/105742


More information about the llvm-commits mailing list