@@ -388,15 +388,29 @@ using WebAssembly::WasmEnableEmSjLj;
388388using WebAssembly::WasmEnableSjLj;
389389
390390static void basicCheckForEHAndSjLj (TargetMachine *TM) {
391- // Before checking, we make sure TargetOptions.ExceptionModel is the same as
391+
392+ // You can't enable two modes of EH at the same time
393+ if (WasmEnableEmEH && WasmEnableEH)
394+ report_fatal_error (
395+ " -enable-emscripten-cxx-exceptions not allowed with -wasm-enable-eh" );
396+ // You can't enable two modes of SjLj at the same time
397+ if (WasmEnableEmSjLj && WasmEnableSjLj)
398+ report_fatal_error (
399+ " -enable-emscripten-sjlj not allowed with -wasm-enable-sjlj" );
400+ // You can't mix Emscripten EH with Wasm SjLj.
401+ if (WasmEnableEmEH && WasmEnableSjLj)
402+ report_fatal_error (
403+ " -enable-emscripten-cxx-exceptions not allowed with -wasm-enable-sjlj" );
404+
405+ // Here we make sure TargetOptions.ExceptionModel is the same as
392406 // MCAsmInfo.ExceptionsType. Normally these have to be the same, because clang
393407 // stores the exception model info in LangOptions, which is later transferred
394408 // to TargetOptions and MCAsmInfo. But when clang compiles bitcode directly,
395409 // clang's LangOptions is not used and thus the exception model info is not
396410 // correctly transferred to TargetOptions and MCAsmInfo, so we make sure we
397- // have the correct exception model in WebAssemblyMCAsmInfo constructor.
398- // But in this case TargetOptions is still not updated, so we make sure they
399- // are the same.
411+ // have the correct exception model in WebAssemblyMCAsmInfo constructor. But
412+ // in this case TargetOptions is still not updated, so we make sure they are
413+ // the same.
400414 TM->Options .ExceptionModel = TM->getMCAsmInfo ()->getExceptionHandlingType ();
401415
402416 // Basic Correctness checking related to -exception-model
@@ -418,18 +432,6 @@ static void basicCheckForEHAndSjLj(TargetMachine *TM) {
418432 " -exception-model=wasm only allowed with at least one of "
419433 " -wasm-enable-eh or -wasm-enable-sjlj" );
420434
421- // You can't enable two modes of EH at the same time
422- if (WasmEnableEmEH && WasmEnableEH)
423- report_fatal_error (
424- " -enable-emscripten-cxx-exceptions not allowed with -wasm-enable-eh" );
425- // You can't enable two modes of SjLj at the same time
426- if (WasmEnableEmSjLj && WasmEnableSjLj)
427- report_fatal_error (
428- " -enable-emscripten-sjlj not allowed with -wasm-enable-sjlj" );
429- // You can't mix Emscripten EH with Wasm SjLj.
430- if (WasmEnableEmEH && WasmEnableSjLj)
431- report_fatal_error (
432- " -enable-emscripten-cxx-exceptions not allowed with -wasm-enable-sjlj" );
433435 // Currently it is allowed to mix Wasm EH with Emscripten SjLj as an interim
434436 // measure, but some code will error out at compile time in this combination.
435437 // See WebAssemblyLowerEmscriptenEHSjLj pass for details.
0 commit comments