[llvm-branch-commits] [llvm] ExpandVariadics: Report a change when rewriting a function without calls (PR #244986)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Nov 21 19:34:17 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
This only reported a change if it rewrote a call, but it always
rewrites the function itself. In lowering mode a variadic function
without callers was changed without being reported.
Co-authored-by: Claude Opus 5.5 <noreply@<!-- -->anthropic.com>
---
Full diff: https://github.com/llvm/llvm-project/pull/244986.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/IPO/ExpandVariadics.cpp (+4-7)
- (added) llvm/test/Transforms/ExpandVariadics/no-callers-report-change.ll (+17)
``````````diff
diff --git a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
index 500d58817c9ac..c6aa17e37b653 100644
--- a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
+++ b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
@@ -422,10 +422,8 @@ bool ExpandVariadics::runOnModule(Module &M) {
bool ExpandVariadics::runOnFunction(Module &M, IRBuilder<> &Builder,
Function *OriginalFunction) {
- bool Changed = false;
-
if (!expansionApplicableToFunction(M, OriginalFunction))
- return Changed;
+ return false;
[[maybe_unused]] const bool OriginalFunctionIsDeclaration =
OriginalFunction->isDeclaration();
@@ -469,9 +467,8 @@ bool ExpandVariadics::runOnFunction(Module &M, IRBuilder<> &Builder,
if (CallBase *CB = dyn_cast<CallBase>(U)) {
Value *CalledOperand = CB->getCalledOperand();
if (VariadicWrapper == CalledOperand)
- Changed |=
- expandCall(M, Builder, CB, VariadicWrapper->getFunctionType(),
- FixedArityReplacement);
+ expandCall(M, Builder, CB, VariadicWrapper->getFunctionType(),
+ FixedArityReplacement);
}
}
@@ -506,7 +503,7 @@ bool ExpandVariadics::runOnFunction(Module &M, IRBuilder<> &Builder,
eraseFunction(VariadicWrapper);
}
- return Changed;
+ return true;
}
Function *
diff --git a/llvm/test/Transforms/ExpandVariadics/no-callers-report-change.ll b/llvm/test/Transforms/ExpandVariadics/no-callers-report-change.ll
new file mode 100644
index 0000000000000..2cd8ea7ffd10b
--- /dev/null
+++ b/llvm/test/Transforms/ExpandVariadics/no-callers-report-change.ll
@@ -0,0 +1,17 @@
+; RUN: opt -mtriple=wasm32-unknown-unknown -expand-variadics-override=lowering -disable-output -debug-pass-manager -passes='function(require<domtree>),expand-variadics,function(require<domtree>)' %s 2>&1 | FileCheck %s
+; REQUIRES: webassembly-registered-target
+
+; Rewriting @vararg changes the module even though it has no callers, so the
+; analyses of @other should be invalidated.
+
+; CHECK: Running pass: ExpandVariadicsPass on [module]{{$}}
+; CHECK-NEXT: Clearing all analysis results for: {{$}}
+; CHECK-NEXT: Invalidating analysis: DominatorTreeAnalysis on other{{$}}
+
+define void @vararg(...) {
+ ret void
+}
+
+define void @other() {
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/244986
More information about the llvm-branch-commits
mailing list