[llvm-commits] [llvm] r94029 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp

Chris Lattner sabre at nondot.org
Wed Jan 20 13:16:15 PST 2010


Author: lattner
Date: Wed Jan 20 15:16:14 2010
New Revision: 94029

URL: http://llvm.org/viewvc/llvm-project?rev=94029&view=rev
Log:
eliminate the GVStubs and HiddenGVStubs maps, and use 
MachineModuleInfoMachO instead.  This eliminates two sources
of nondeterministic output in the ppc backend, but function
stubs are still bad.

Modified:
    llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=94029&r1=94028&r2=94029&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Jan 20 15:16:14 2010
@@ -27,10 +27,10 @@
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"
-#include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineModuleInfoImpls.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCSectionMachO.h"
@@ -95,7 +95,7 @@
     };
     
     DenseMap<const MCSymbol*, FnStubInfo> FnStubs;
-    DenseMap<const MCSymbol*, const MCSymbol*> GVStubs, HiddenGVStubs, TOC;
+    DenseMap<const MCSymbol*, const MCSymbol*> TOC;
     const PPCSubtarget &Subtarget;
     uint64_t LabelID;
   public:
@@ -424,15 +424,19 @@
     return;
   case MachineOperand::MO_ExternalSymbol: {
     // Computing the address of an external symbol, not calling it.
-    const MCSymbol *SymName = GetExternalSymbolSymbol(MO.getSymbolName());
     if (TM.getRelocationModel() == Reloc::Static) {
-      O << *SymName;
+      O << *GetExternalSymbolSymbol(MO.getSymbolName());
       return;
     }
+
     const MCSymbol *NLPSym = 
       OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+
                                    MO.getSymbolName()+"$non_lazy_ptr");
-    GVStubs[SymName] = NLPSym;
+    const MCSymbol *&StubSym = 
+      MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(NLPSym);
+    if (StubSym == 0)
+      StubSym = GetExternalSymbolSymbol(MO.getSymbolName());
+    
     O << *NLPSym;
     return;
   }
@@ -446,11 +450,19 @@
         (GV->isDeclaration() || GV->isWeakForLinker())) {
       if (!GV->hasHiddenVisibility()) {
         SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
-        GVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
+        const MCSymbol *&StubSym = 
+       MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(SymToPrint);
+        if (StubSym == 0)
+          StubSym = GetGlobalValueSymbol(GV);
       } else if (GV->isDeclaration() || GV->hasCommonLinkage() ||
                  GV->hasAvailableExternallyLinkage()) {
         SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
-        HiddenGVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
+        
+        const MCSymbol *&StubSym = 
+          MMI->getObjFileInfo<MachineModuleInfoMachO>().
+                    getHiddenGVStubEntry(SymToPrint);
+        if (StubSym == 0)
+          StubSym = GetGlobalValueSymbol(GV);
       } else {
         SymToPrint = GetGlobalValueSymbol(GV);
       }
@@ -838,12 +850,12 @@
   // Darwin/PPC always uses mach-o.
   TargetLoweringObjectFileMachO &TLOFMacho = 
     static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
-
+  MachineModuleInfoMachO &MMIMacho =
+    MMI->getObjFileInfo<MachineModuleInfoMachO>();
   
   const MCSection *LSPSection = 0;
   if (!FnStubs.empty()) // .lazy_symbol_pointer
     LSPSection = TLOFMacho.getLazySymbolPointerSection();
-    
   
   // Output stubs for dynamically-linked functions
   if (TM.getRelocationModel() == Reloc::PIC_ && !FnStubs.empty()) {
@@ -912,35 +924,39 @@
     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[GetGlobalValueSymbol(*I)] =
+      if (*I) {
+        const MCSymbol *NLPSym = 
           GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr");
+        const MCSymbol *&StubSym = MMIMacho.getGVStubEntry(NLPSym);
+        StubSym = GetGlobalValueSymbol(*I);
+      }
     }
   }
 
+  // Output stubs for dynamically-linked functions.
+  MachineModuleInfoMachO::SymbolListTy Stubs = MMIMacho.GetGVStubList();
+  
   // Output macho stubs for external and common global variables.
-  if (!GVStubs.empty()) {
+  if (!Stubs.empty()) {
     // Switch with ".non_lazy_symbol_pointer" directive.
     OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
     EmitAlignment(isPPC64 ? 3 : 2);
     
-    // FIXME: This is nondeterminstic.
-    for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator
-         I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) {
-      O << *I->second << ":\n";
-      O << "\t.indirect_symbol " << *I->first << '\n';
+    for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
+      O << *Stubs[i].first << ":\n";
+      O << "\t.indirect_symbol " << *Stubs[i].second << '\n';
       O << (isPPC64 ? "\t.quad\t0\n" : "\t.long\t0\n");
     }
   }
 
-  if (!HiddenGVStubs.empty()) {
+  Stubs = MMIMacho.GetHiddenGVStubList();
+  if (!Stubs.empty()) {
     OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
     EmitAlignment(isPPC64 ? 3 : 2);
-    // FIXME: This is nondeterminstic.
-    for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator
-         I = HiddenGVStubs.begin(), E = HiddenGVStubs.end(); I != E; ++I) {
-      O << *I->second << ":\n";
-      O << (isPPC64 ? "\t.quad\t" : "\t.long\t") << *I->first << '\n';
+    
+    for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
+      O << *Stubs[i].first << ":\n";
+      O << (isPPC64 ? "\t.quad\t" : "\t.long\t") << *Stubs[i].second << '\n';
     }
   }
 





More information about the llvm-commits mailing list