Skip to content

Commit 182181e

Browse files
committed
[LLVM] Add 'ExpandVariadicsPass' to LTO default pipeline
Summary: This pass expands variadic functions into non-variadic function calls according to the target ABI. Currently, this is used as the lowering for the NVPTX, AMDGPU, and WASM targets. This pass is currently only run late in the target's backend. However, during LTO we want to run it before the inliner pass so that the expanded functions can be inlined using standard heuristics. This pass is a no-op for unsupported targets, so this won't apply to any code that isn't already using it.
1 parent 2e3ee31 commit 182181e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "llvm/Transforms/IPO/DeadArgumentElimination.h"
4949
#include "llvm/Transforms/IPO/ElimAvailExtern.h"
5050
#include "llvm/Transforms/IPO/EmbedBitcodePass.h"
51+
#include "llvm/Transforms/IPO/ExpandVariadics.h"
5152
#include "llvm/Transforms/IPO/ForceFunctionAttrs.h"
5253
#include "llvm/Transforms/IPO/FunctionAttrs.h"
5354
#include "llvm/Transforms/IPO/GlobalDCE.h"
@@ -1874,6 +1875,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
18741875
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(PeepholeFPM),
18751876
PTO.EagerlyInvalidateAnalyses));
18761877

1878+
// Lower variadic functions for supported targets prior to inlining.
1879+
MPM.addPass(ExpandVariadicsPass(ExpandVariadicsMode::Optimize));
1880+
18771881
// Note: historically, the PruneEH pass was run first to deduce nounwind and
18781882
// generally clean up exception handling overhead. It isn't clear this is
18791883
// valuable as the inliner doesn't currently care whether it is inlining an

llvm/test/Other/new-pm-lto-defaults.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
; CHECK-EP: Running pass: NoOpModulePass
3131
; CHECK-O: Running pass: CrossDSOCFIPass
32+
; CHECK-O-NEXT: Running pass: ExpandVariadicsPass
3233
; CHECK-O-NEXT: Running pass: OpenMPOptPass
3334
; CHECK-O-NEXT: Running pass: GlobalDCEPass
3435
; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass

0 commit comments

Comments
 (0)