summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/CodeGen/CommandFlags.def4
-rw-r--r--llvm/include/llvm/MC/MCTargetOptions.h1
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp3
-rw-r--r--llvm/lib/CodeGen/TargetPassConfig.cpp3
-rw-r--r--llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp6
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssembly.td4
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td10
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp4
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h2
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp3
10 files changed, 30 insertions, 10 deletions
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.def b/llvm/include/llvm/CodeGen/CommandFlags.def
index d7a5c946ad5..84cfe9deed2 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.def
+++ b/llvm/include/llvm/CodeGen/CommandFlags.def
@@ -98,7 +98,9 @@ static cl::opt<llvm::ExceptionHandling> ExceptionModel(
clEnumValN(ExceptionHandling::SjLj, "sjlj", "SjLj exception handling"),
clEnumValN(ExceptionHandling::ARM, "arm", "ARM EHABI exceptions"),
clEnumValN(ExceptionHandling::WinEH, "wineh",
- "Windows exception model")));
+ "Windows exception model"),
+ clEnumValN(ExceptionHandling::Wasm, "wasm",
+ "WebAssembly exception handling")));
static cl::opt<TargetMachine::CodeGenFileType> FileType(
"filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h b/llvm/include/llvm/MC/MCTargetOptions.h
index 5509bb3bdc7..f5d330fbeb2 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -21,6 +21,7 @@ enum class ExceptionHandling {
SjLj, /// setjmp/longjmp based exceptions
ARM, /// ARM EHABI
WinEH, /// Windows Exception Handling
+ Wasm, /// WebAssembly Exception Handling
};
enum class DebugCompressionType {
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.
OpenPOWER on IntegriCloud