Skip to content

Commit

Permalink
[WebAssembly] add: hidden option to disable slow wasm pass (#67715)
Browse files Browse the repository at this point in the history
Currently for any wasm target, llvm will make a pass that removes
irreducible control flow. (See
[here](https://llvm.org/doxygen/WebAssemblyFixIrreducibleControlFlow_8cpp.html)).
This can result in O(NumBlocks * NumNestedLoops * NumIrreducibleLoops +
NumLoops * NumLoops) build time, which has resulted in exceedingly long
build times when testing. This PR introduces a hidden flag to skip this
pass, which brings some of our build times down from 30 minutes to ~6
seconds.
  • Loading branch information
ajbt200128 committed Oct 18, 2023
1 parent 3745e70 commit 85b8958
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ static cl::opt<bool> WasmDisableExplicitLocals(
" instruction output for test purposes only."),
cl::init(false));

static cl::opt<bool> WasmDisableFixIrreducibleControlFlowPass(
"wasm-disable-fix-irreducible-control-flow-pass", cl::Hidden,
cl::desc("webassembly: disables the fix "
" irreducible control flow optimization pass"),
cl::init(false));

extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() {
// Register the target.
RegisterTargetMachine<WebAssemblyTargetMachine> X(
Expand Down Expand Up @@ -538,7 +544,8 @@ void WebAssemblyPassConfig::addPreEmitPass() {
addPass(createWebAssemblyNullifyDebugValueLists());

// Eliminate multiple-entry loops.
addPass(createWebAssemblyFixIrreducibleControlFlow());
if (!WasmDisableFixIrreducibleControlFlowPass)
addPass(createWebAssemblyFixIrreducibleControlFlow());

// Do various transformations for exception handling.
// Every CFG-changing optimizations should come before this.
Expand Down

0 comments on commit 85b8958

Please sign in to comment.