[WebAssembly] Support 'unreachable' expression
[oota-llvm.git] / lib / Target / WebAssembly / WebAssemblyISelLowering.cpp
index 1c7d86b293ab65cb729ff15044a3f68edbe515c7..baf5b2554bba67c21a4a8bca26747e977242e9ee 100644 (file)
@@ -172,6 +172,9 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
   for (auto T : MVT::integer_valuetypes())
     for (auto Ext : {ISD::EXTLOAD, ISD::ZEXTLOAD, ISD::SEXTLOAD})
       setLoadExtAction(Ext, T, MVT::i1, Promote);
+
+  // Trap lowers to wasm unreachable
+  setOperationAction(ISD::TRAP, MVT::Other, Legal);
 }
 
 FastISel *WebAssemblyTargetLowering::createFastISel(