diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 88c727796e0df..2db1b6493cc47 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -48,6 +48,12 @@ static cl::opt WasmDisableExplicitLocals( " instruction output for test purposes only."), cl::init(false)); +static cl::opt 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 X( @@ -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.