[llvm-branch-commits] [llvm] ExpandVariadics: Report a change when rewriting a function without calls (PR #244986)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Nov 21 19:33:27 PST 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/244986

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 at anthropic.com>

>From 1779f116b8dcf153af153814758b59f26603d756 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sat, 21 Nov 2026 19:52:58 -0500
Subject: [PATCH] ExpandVariadics: Report a change when rewriting a function
 without calls

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 at anthropic.com>
---
 llvm/lib/Transforms/IPO/ExpandVariadics.cpp     | 11 ++++-------
 .../ExpandVariadics/no-callers-report-change.ll | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 7 deletions(-)
 create mode 100644 llvm/test/Transforms/ExpandVariadics/no-callers-report-change.ll

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
+}



More information about the llvm-branch-commits mailing list