diff options
Diffstat (limited to 'llvm/lib')
8 files changed, 26 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 992eb40a025..979a03cf107 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -353,6 +353,9 @@ bool AsmPrinter::doInitialization(Module &M) { break; } break; + case ExceptionHandling::Wasm: + // TODO to prevent warning + break; } if (ES) Handlers.push_back(HandlerInfo(ES, EHTimerName, EHTimerDescription, diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index 962836398e1..bfe8f152a71 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -653,6 +653,9 @@ void TargetPassConfig::addPassesToHandleExceptions() { addPass(createWinEHPass()); addPass(createDwarfEHPass()); break; + case ExceptionHandling::Wasm: + // TODO to prevent warning + break; case ExceptionHandling::None: addPass(createLowerInvokePass()); diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp index 5f8c78ed168..c00dc19019c 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp @@ -43,9 +43,6 @@ WebAssemblyMCAsmInfoELF::WebAssemblyMCAsmInfoELF(const Triple &T) { SupportsDebugInformation = true; - // For now, WebAssembly does not support exceptions. - ExceptionsType = ExceptionHandling::None; - // TODO: UseIntegratedAssembler? // WebAssembly's stack is never executable. @@ -76,8 +73,5 @@ WebAssemblyMCAsmInfo::WebAssemblyMCAsmInfo(const Triple &T) { SupportsDebugInformation = true; - // For now, WebAssembly does not support exceptions. - ExceptionsType = ExceptionHandling::None; - // TODO: UseIntegratedAssembler? } diff --git a/llvm/lib/Target/WebAssembly/WebAssembly.td b/llvm/lib/Target/WebAssembly/WebAssembly.td index 76b3ddbbfff..9d626bdfd78 100644 --- a/llvm/lib/Target/WebAssembly/WebAssembly.td +++ b/llvm/lib/Target/WebAssembly/WebAssembly.td @@ -37,6 +37,10 @@ def FeatureSignExt : "HasSignExt", "true", "Enable sign extension operators">; +def FeatureExceptionHandling : + SubtargetFeature<"exception-handling", "HasExceptionHandling", "true", + "Enable Wasm exception handling">; + //===----------------------------------------------------------------------===// // Architectures. //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td index 245d5abbf26..f5a1be14fc8 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td @@ -39,6 +39,16 @@ def NotHasSignExt : AssemblerPredicate<"!FeatureSignExt", "sign-ext">; +def HasExceptionHandling : + Predicate<"Subtarget->hasExceptionHandling()">, + AssemblerPredicate<"FeatureExceptionHandling", + "exception-handling">; + +def NotHasExceptionHandling : + Predicate<"!Subtarget->hasExceptionHandling()">, + AssemblerPredicate<"!FeatureExceptionHandling", + "exception-handling">; + //===----------------------------------------------------------------------===// // WebAssembly-specific DAG Node Types. //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp b/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp index 78602a35e64..6addaa39d71 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp @@ -42,8 +42,8 @@ WebAssemblySubtarget::WebAssemblySubtarget(const Triple &TT, const TargetMachine &TM) : WebAssemblyGenSubtargetInfo(TT, CPU, FS), HasSIMD128(false), HasAtomics(false), HasNontrappingFPToInt(false), HasSignExt(false), - CPUString(CPU), TargetTriple(TT), FrameLowering(), - InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(), + HasExceptionHandling(false), CPUString(CPU), TargetTriple(TT), + FrameLowering(), InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(), TLInfo(TM, *this) {} bool WebAssemblySubtarget::enableMachineScheduler() const { diff --git a/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h b/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h index c999f501a9c..c2ced236dbd 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h +++ b/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h @@ -33,6 +33,7 @@ class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { bool HasAtomics; bool HasNontrappingFPToInt; bool HasSignExt; + bool HasExceptionHandling; /// String name of used CPU. std::string CPUString; @@ -80,6 +81,7 @@ public: bool hasAtomics() const { return HasAtomics; } bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } bool hasSignExt() const { return HasSignExt; } + bool hasExceptionHandling() const { return HasExceptionHandling; } /// Parses features string setting specified subtarget options. Definition of /// function is auto generated by tblgen. diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index d38cde74d2e..a686e773cb5 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -190,7 +190,8 @@ void WebAssemblyPassConfig::addIRPasses() { // blocks. Lowering invokes when there is no EH support is done in // TargetPassConfig::addPassesToHandleExceptions, but this runs after this // function and SjLj handling expects all invokes to be lowered before. - if (!EnableEmException) { + if (!EnableEmException && + TM->Options.ExceptionModel == ExceptionHandling::None) { addPass(createLowerInvokePass()); // The lower invoke pass may create unreachable code. Remove it in order not // to process dead blocks in setjmp/longjmp handling. |