[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:58:43 PDT 2024
https://github.com/yonghong-song created https://github.com/llvm/llvm-project/pull/105742
…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
>From 9500f4260ad1b737c5e9e66a41c8d87cf2662e0e Mon Sep 17 00:00:00 2001
From: Yonghong Song <yonghong.song at linux.dev>
Date: Thu, 22 Aug 2024 14:52:31 -0700
Subject: [PATCH] [Transforms][IPO] Add func suffix in ArgumentPromotion and
DeadArgumentElimination
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
---
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 1 +
llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp | 1 +
2 files changed, 2 insertions(+)
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
More information about the llvm-commits
mailing list