The personality function on Darwin needs a global stub. We then refer to
authorBill Wendling <isanbard@gmail.com>
Tue, 11 Sep 2007 08:27:17 +0000 (08:27 +0000)
committerBill Wendling <isanbard@gmail.com>
Tue, 11 Sep 2007 08:27:17 +0000 (08:27 +0000)
that global stub instead of doing the ".set" thingy we were doing before.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41838 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetAsmInfo.h
lib/CodeGen/DwarfWriter.cpp
lib/Target/TargetAsmInfo.cpp
lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.h
lib/Target/X86/X86TargetAsmInfo.cpp

index 92d6192bea633f505ae0f4f6ebfe2d69c241ae60..97eaa3598cbcbe8bd1a83e969f5ac5ac1710ffad 100644 (file)
@@ -110,6 +110,12 @@ namespace llvm {
     const char *FunctionAddrPrefix;       // Defaults to ""
     const char *FunctionAddrSuffix;       // Defaults to ""
 
+    /// PersonalityPrefix/Suffix - If these are nonempty, these strings will
+    /// enclose any personality function in the common frame section.
+    /// 
+    const char *PersonalityPrefix;        // Defaults to ""
+    const char *PersonalitySuffix;        // Defaults to ""
+
     /// InlineAsmStart/End - If these are nonempty, they contain a directive to
     /// emit before and after an inline assembly statement.
     const char *InlineAsmStart;           // Defaults to "#APP\n"
@@ -428,6 +434,12 @@ namespace llvm {
     const char *getFunctionAddrSuffix() const {
       return FunctionAddrSuffix;
     }
+    const char *getPersonalityPrefix() const {
+      return PersonalityPrefix;
+    }
+    const char *getPersonalitySuffix() const {
+      return PersonalitySuffix;
+    }
     const char *getInlineAsmStart() const {
       return InlineAsmStart;
     }
index 073cb4a31a1ff8a043a9c095f8c0314594267da9..2b4b4ce135f3ffe7e769e4826621c0f07bd7a8a6 100644 (file)
@@ -2789,26 +2789,15 @@ private:
     if (Personality) {
       Asm->EmitULEB128Bytes(7);
       Asm->EOL("Augmentation Size");
-      Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4);
-      Asm->EOL("Personality (pcrel sdata4)");
+      Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect);
+      Asm->EOL("Personality (pcrel sdata4 indirect)");
       
-      if (TAI->needsSet()) {
-        O << "\t.set\t";
-        PrintLabelName("set", SetCounter);
-        O << ",";
-        Asm->EmitExternalGlobal((const GlobalVariable *)(Personality));
-        O << "-" << TAI->getPCSymbol();
-        Asm->EOL("Set Personality");
-        PrintRelDirective();
-        PrintLabelName("set", SetCounter);
-        Asm->EOL("Personality");
-        ++SetCounter;
-      } else {
-        PrintRelDirective();
-        Asm->EmitExternalGlobal((const GlobalVariable *)(Personality));
-        O << "-" << TAI->getPCSymbol();
-        Asm->EOL("Personality");
-      }
+      PrintRelDirective();
+      O << TAI->getPersonalityPrefix();
+      Asm->EmitExternalGlobal((const GlobalVariable *)(Personality));
+      O << TAI->getPersonalitySuffix();
+      O << "-" << TAI->getPCSymbol();
+      Asm->EOL("Personality");
 
       Asm->EmitULEB128Bytes(DW_EH_PE_pcrel);
       Asm->EOL("LSDA Encoding (pcrel)");
@@ -3297,7 +3286,7 @@ public:
     const std::vector<Function *> Personalities = MMI->getPersonalities();
     for (unsigned i =0; i < Personalities.size(); ++i)
       EmitCommonEHFrame(Personalities[i], i);
-    
+
     for (std::vector<FunctionEHFrameInfo>::iterator I = EHFrames.begin(),
            E = EHFrames.end(); I != E; ++I)
       EmitEHFrame(*I);
index df7a2ec78d1487fa1981c539bb6848c43f57cf48..09a8d5ab8e772e1340aecc8d380f82d5f847d97e 100644 (file)
@@ -38,6 +38,8 @@ TargetAsmInfo::TargetAsmInfo() :
   GlobalVarAddrSuffix(""),
   FunctionAddrPrefix(""),
   FunctionAddrSuffix(""),
+  PersonalityPrefix(""),
+  PersonalitySuffix(""),
   InlineAsmStart("#APP"),
   InlineAsmEnd("#NO_APP"),
   AssemblerDialect(0),
index b0e6ed127d4be1c4d5d8d7e5ba8fc12809d111f9..3d54d69ebb5a5d2b91df0e3666ca4463e7ca2830 100644 (file)
@@ -74,7 +74,8 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   if (TAI->doesSupportDebugInformation()) {
     // Let PassManager know we need debug information and relay
     // the MachineModuleInfo address on to DwarfWriter.
-    DW.SetModuleInfo(&getAnalysis<MachineModuleInfo>());
+    MMI = &getAnalysis<MachineModuleInfo>();
+    DW.SetModuleInfo(MMI);
   }
 
   SetupMachineFunction(MF);
index a06cc6f61b15fd290c2756f78bd35d483f1ccd2f..b7de8f002db3a1761098f652aa762951cb004d78 100644 (file)
@@ -352,6 +352,15 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
 
     O << "\n";
 
+    if (MMI) {
+      // Add the (possibly multiple) personalities to the set of global values.
+      const std::vector<Function *>& Personalities = MMI->getPersonalities();
+
+      for (std::vector<Function *>::const_iterator I = Personalities.begin(),
+             E = Personalities.end(); I != E; ++I)
+        if (*I) GVStubs.insert("_" + (*I)->getName());
+    }
+
     // Output stubs for external and common global variables.
     if (GVStubs.begin() != GVStubs.end())
       SwitchToDataSection(
index 45be89eb2161b1bf1ea039875238787e49ba3ba9..49110f415dc162dd05529b1669b2bbd9cab69eb9 100644 (file)
@@ -30,10 +30,11 @@ namespace llvm {
 
 struct VISIBILITY_HIDDEN X86SharedAsmPrinter : public AsmPrinter {
   DwarfWriter DW;
+  MachineModuleInfo *MMI;
 
   X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM,
                       const TargetAsmInfo *T)
-    : AsmPrinter(O, TM, T), DW(O, this, T) {
+    : AsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
     Subtarget = &TM.getSubtarget<X86Subtarget>();
   }
 
index 07a1a197f3ad492e0c94c4816d6bda28c2c6e2b4..414782ee4db8c7062dd0103befc68e66b8cac47b 100644 (file)
@@ -68,6 +68,8 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
       StaticCtorsSection = ".mod_init_func";
       StaticDtorsSection = ".mod_term_func";
     }
+    PersonalityPrefix = "L";
+    PersonalitySuffix = "$non_lazy_ptr";
     InlineAsmStart = "# InlineAsm Start";
     InlineAsmEnd = "# InlineAsm End";
     SetDirective = "\t.set";