[llvm] r229193 - Unify the two EH personality classification routines I wrote

Reid Kleckner reid at kleckner.net
Fri Feb 13 16:21:02 PST 2015


Author: rnk
Date: Fri Feb 13 18:21:02 2015
New Revision: 229193

URL: http://llvm.org/viewvc/llvm-project?rev=229193&view=rev
Log:
Unify the two EH personality classification routines I wrote

We only need one.

Modified:
    llvm/trunk/include/llvm/Analysis/LibCallSemantics.h
    llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
    llvm/trunk/lib/Analysis/LibCallSemantics.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
    llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/include/llvm/Analysis/LibCallSemantics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LibCallSemantics.h?rev=229193&r1=229192&r2=229193&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LibCallSemantics.h (original)
+++ llvm/trunk/include/llvm/Analysis/LibCallSemantics.h Fri Feb 13 18:21:02 2015
@@ -177,7 +177,7 @@ class InvokeInst;
   /// \brief See if the given exception handling personality function is one
   /// that we understand.  If so, return a description of it; otherwise return
   /// Unknown.
-  EHPersonality classifyEHPersonality(Value *Pers);
+  EHPersonality classifyEHPersonality(const Value *Pers);
 
   /// \brief Returns true if this personality function catches asynchronous
   /// exceptions.

Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=229193&r1=229192&r2=229193&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Fri Feb 13 18:21:02 2015
@@ -35,6 +35,7 @@
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/LibCallSemantics.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/ValueHandle.h"
@@ -46,13 +47,6 @@
 
 namespace llvm {
 
-/// Different personality functions used by a function.
-enum class EHPersonality {
-  None,     /// No exception handling
-  Itanium,  /// An Itanium C++ EH personality like __gxx_personality_seh0
-  Win64SEH, /// x86_64 SEH, uses __C_specific_handler
-};
-
 //===----------------------------------------------------------------------===//
 // Forward declarations.
 class Constant;
@@ -178,8 +172,6 @@ class MachineModuleInfo : public Immutab
 
   EHPersonality PersonalityTypeCache;
 
-  EHPersonality getPersonalityTypeSlow();
-
 public:
   static char ID; // Pass identification, replacement for typeid
 
@@ -425,11 +417,7 @@ public:
   const Function *getPersonality() const;
 
   /// Classify the personality function amongst known EH styles.
-  EHPersonality getPersonalityType() {
-    if (PersonalityTypeCache != EHPersonality::None)
-      return PersonalityTypeCache;
-    return getPersonalityTypeSlow();
-  }
+  EHPersonality getPersonalityType();
 
   /// setVariableDbgInfo - Collect information used to emit debugging
   /// information of a variable.

Modified: llvm/trunk/lib/Analysis/LibCallSemantics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LibCallSemantics.cpp?rev=229193&r1=229192&r2=229193&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LibCallSemantics.cpp (original)
+++ llvm/trunk/lib/Analysis/LibCallSemantics.cpp Fri Feb 13 18:21:02 2015
@@ -64,8 +64,8 @@ LibCallInfo::getFunctionInfo(const Funct
 
 /// See if the given exception handling personality function is one that we
 /// understand.  If so, return a description of it; otherwise return Unknown.
-EHPersonality llvm::classifyEHPersonality(Value *Pers) {
-  Function *F = dyn_cast<Function>(Pers->stripPointerCasts());
+EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
+  const Function *F = dyn_cast<Function>(Pers->stripPointerCasts());
   if (!F)
     return EHPersonality::Unknown;
   return StringSwitch<EHPersonality>(F->getName())

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp?rev=229193&r1=229192&r2=229193&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp Fri Feb 13 18:21:02 2015
@@ -106,7 +106,7 @@ void Win64Exception::endFunction(const M
     // Emit the tables appropriate to the personality function in use. If we
     // don't recognize the personality, assume it uses an Itanium-style LSDA.
     EHPersonality Per = MMI->getPersonalityType();
-    if (Per == EHPersonality::Win64SEH)
+    if (Per == EHPersonality::MSVC_Win64SEH)
       emitCSpecificHandlerTable();
     else
       emitExceptionTable();

Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=229193&r1=229192&r2=229193&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Fri Feb 13 18:21:02 2015
@@ -9,6 +9,7 @@
 
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/Analysis/LibCallSemantics.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
@@ -276,7 +277,7 @@ bool MachineModuleInfo::doInitialization
   DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr = false;
   // Always emit some info, by default "no personality" info.
   Personalities.push_back(nullptr);
-  PersonalityTypeCache = EHPersonality::None;
+  PersonalityTypeCache = EHPersonality::Unknown;
   AddrLabelSymbols = nullptr;
   TheModule = nullptr;
 
@@ -561,17 +562,11 @@ const Function *MachineModuleInfo::getPe
   return nullptr;
 }
 
-EHPersonality MachineModuleInfo::getPersonalityTypeSlow() {
-  const Function *Per = getPersonality();
-  if (!Per)
-    PersonalityTypeCache = EHPersonality::None;
-  else if (Per->getName() == "__C_specific_handler")
-    PersonalityTypeCache = EHPersonality::Win64SEH;
-  else // Assume everything else is Itanium.
-    PersonalityTypeCache = EHPersonality::Itanium;
+EHPersonality MachineModuleInfo::getPersonalityType() {
+  if (PersonalityTypeCache == EHPersonality::Unknown)
+    PersonalityTypeCache = classifyEHPersonality(getPersonality());
   return PersonalityTypeCache;
 }
-
 /// getPersonalityIndex - Return unique index for current personality
 /// function. NULL/first personality function should always get zero index.
 unsigned MachineModuleInfo::getPersonalityIndex() const {

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=229193&r1=229192&r2=229193&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Feb 13 18:21:02 2015
@@ -930,7 +930,7 @@ void SelectionDAGISel::PrepareEHLandingP
   const LandingPadInst *LPadInst = LLVMBB->getLandingPadInst();
   MF->getMMI().addPersonality(
       MBB, cast<Function>(LPadInst->getPersonalityFn()->stripPointerCasts()));
-  if (MF->getMMI().getPersonalityType() == EHPersonality::Win64SEH) {
+  if (MF->getMMI().getPersonalityType() == EHPersonality::MSVC_Win64SEH) {
     // Make virtual registers and a series of labels that fill in values for the
     // clauses.
     auto &RI = MF->getRegInfo();





More information about the llvm-commits mailing list