r333716 - [WebAssembly] Hide new Wasm EH behind its feature flag

Heejin Ahn via cfe-commits cfe-commits at lists.llvm.org
Thu May 31 18:01:37 PDT 2018


Author: aheejin
Date: Thu May 31 18:01:37 2018
New Revision: 333716

URL: http://llvm.org/viewvc/llvm-project?rev=333716&view=rev
Log:
[WebAssembly] Hide new Wasm EH behind its feature flag

Summary:
clang's current wasm EH implementation is a non-MVP feature in progress.
We had a `-mexception-handling` wasm feature but were not using it. This
patch hides the non-MVP wasm EH behind a flag, so it does not affect
other code for now.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits

Differential Revision: https://reviews.llvm.org/D47614

Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
    cfe/trunk/test/CodeGenCXX/wasm-eh.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=333716&r1=333715&r2=333716&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu May 31 18:01:37 2018
@@ -154,7 +154,8 @@ static const EHPersonality &getObjCPerso
 }
 
 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)
@@ -163,8 +164,10 @@ static const EHPersonality &getCXXPerson
     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;
 }
@@ -172,12 +175,13 @@ static const EHPersonality &getCXXPerson
 /// 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 EHPersonality &EHPersonality::get(
                                         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 @@ void CodeGenModule::SimplifyPersonality(
 
   const EHPersonality &ObjCXX = EHPersonality::get(*this, /*FD=*/nullptr);
   const EHPersonality &CXX =
-      getCXXPersonality(getTarget().getTriple(), LangOpts);
+      getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
   if (&ObjCXX == &CXX)
     return;
 

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=333716&r1=333715&r2=333716&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 31 18:01:37 2018
@@ -4102,7 +4102,8 @@ ItaniumCXXABI::LoadVTablePtr(CodeGenFunc
 
 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);
 }

Modified: cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-eh.cpp?rev=333716&r1=333715&r2=333716&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/wasm-eh.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/wasm-eh.cpp Thu May 31 18:01:37 2018
@@ -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;




More information about the cfe-commits mailing list