[PATCH] D47614: [WebAssembly] Hide new Wasm EH behind its feature flag

Heejin Ahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 31 18:05:44 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC333716: [WebAssembly] Hide new Wasm EH behind its feature flag (authored by aheejin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47614?vs=149386&id=149387#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47614

Files:
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp


Index: test/CodeGenCXX/wasm-eh.cpp
===================================================================
--- test/CodeGenCXX/wasm-eh.cpp
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
-// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
 
 void may_throw();
 void dont_throw() noexcept;
Index: lib/CodeGen/CGException.cpp
===================================================================
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -154,30 +154,34 @@
 }
 
 static const EHPersonality &getCXXPersonality(const llvm::Triple &T,
-                                              const LangOptions &L) {
+                                              const LangOptions &L,
+                                              const TargetInfo &Target) {
   if (L.SjLjExceptions)
     return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
     return EHPersonality::GNU_CPlusPlus;
   if (T.isWindowsMSVCEnvironment())
     return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SEHExceptions)
     return EHPersonality::GNU_CPlusPlus_SEH;
-  if (T.getArch() == llvm::Triple::wasm32 ||
-      T.getArch() == llvm::Triple::wasm64)
+  // Wasm EH is a non-MVP feature for now.
+  if (Target.hasFeature("exception-handling") &&
+      (T.getArch() == llvm::Triple::wasm32 ||
+       T.getArch() == llvm::Triple::wasm64))
     return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
 
 /// Determines the personality function to use when both C++
 /// and Objective-C exceptions are being caught.
 static const EHPersonality &getObjCXXPersonality(const llvm::Triple &T,
-                                                 const LangOptions &L) {
+                                                 const LangOptions &L,
+                                                 const TargetInfo &Target) {
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.
   case ObjCRuntime::FragileMacOSX:
-    return getCXXPersonality(T, L);
+    return getCXXPersonality(T, L, Target);
 
   // The ObjC personality defers to the C++ personality for non-ObjC
   // handlers.  Unlike the C++ case, we use the same personality
@@ -209,14 +213,16 @@
                                         const FunctionDecl *FD) {
   const llvm::Triple &T = CGM.getTarget().getTriple();
   const LangOptions &L = CGM.getLangOpts();
+  const TargetInfo &Target = CGM.getTarget();
 
   // Functions using SEH get an SEH personality.
   if (FD && FD->usesSEHTry())
     return getSEHPersonalityMSVC(T);
 
   if (L.ObjC1)
-    return L.CPlusPlus ? getObjCXXPersonality(T, L) : getObjCPersonality(T, L);
-  return L.CPlusPlus ? getCXXPersonality(T, L) : getCPersonality(T, L);
+    return L.CPlusPlus ? getObjCXXPersonality(T, L, Target)
+                       : getObjCPersonality(T, L);
+  return L.CPlusPlus ? getCXXPersonality(T, L, Target) : getCPersonality(T, L);
 }
 
 const EHPersonality &EHPersonality::get(CodeGenFunction &CGF) {
@@ -313,7 +319,7 @@
 
   const EHPersonality &ObjCXX = EHPersonality::get(*this, /*FD=*/nullptr);
   const EHPersonality &CXX =
-      getCXXPersonality(getTarget().getTriple(), LangOpts);
+      getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
   if (&ObjCXX == &CXX)
     return;
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -4102,7 +4102,8 @@
 
 void WebAssemblyCXXABI::emitBeginCatch(CodeGenFunction &CGF,
                                        const CXXCatchStmt *C) {
-  CGF.EHStack.pushCleanup<CatchRetScope>(
-      NormalCleanup, cast<llvm::CatchPadInst>(CGF.CurrentFuncletPad));
+  if (CGF.getTarget().hasFeature("exception-handling"))
+    CGF.EHStack.pushCleanup<CatchRetScope>(
+        NormalCleanup, cast<llvm::CatchPadInst>(CGF.CurrentFuncletPad));
   ItaniumCXXABI::emitBeginCatch(CGF, C);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47614.149387.patch
Type: text/x-patch
Size: 4592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180601/f119e895/attachment-0001.bin>


More information about the cfe-commits mailing list