[llvm-commits] [llvm] r80404 - in /llvm/trunk: lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMConstantPoolValue.cpp lib/Target/ARM/ARMConstantPoolValue.h lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/stubs.ll test/CodeGen/Thumb2/thumb2-call.ll

Evan Cheng evan.cheng at apple.com
Fri Aug 28 16:18:09 PDT 2009


Author: evancheng
Date: Fri Aug 28 18:18:09 2009
New Revision: 80404

URL: http://llvm.org/viewvc/llvm-project?rev=80404&view=rev
Log:
Let Darwin linker auto-synthesize stubs and lazy-pointers. This deletes a bunch of nasty code in ARM asm printer.

Removed:
    llvm/trunk/test/CodeGen/ARM/stubs.ll
Modified:
    llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp
    llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp
    llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h
    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
    llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
    llvm/trunk/lib/Target/ARM/ARMSubtarget.h
    llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
    llvm/trunk/test/CodeGen/Thumb2/thumb2-call.ll

Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Fri Aug 28 18:18:09 2009
@@ -417,16 +417,9 @@
 
     GlobalValue *GV = ACPV->getGV();
     if (GV) {
-      assert(!ACPV->isStub() && "Don't know how to deal this yet!");
-      if (ACPV->isNonLazyPointer())
-        MCE.addRelocation(MachineRelocation::getIndirectSymbol(
-                  MCE.getCurrentPCOffset(), ARM::reloc_arm_machine_cp_entry, GV,
-                  (intptr_t)ACPV, false));
-      else
-        emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
-                          ACPV->isStub() || isa<Function>(GV), (intptr_t)ACPV);
+      emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
+                        isa<Function>(GV), (intptr_t)ACPV);
      } else  {
-      assert(!ACPV->isNonLazyPointer() && "Don't know how to deal this yet!");
       emitExternalSymbolAddress(ACPV->getSymbol(), ARM::reloc_arm_absolute);
     }
     emitWordLE(0);

Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp Fri Aug 28 18:18:09 2009
@@ -20,29 +20,25 @@
 using namespace llvm;
 
 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
-                                           ARMCP::ARMCPKind k,
                                            unsigned char PCAdj,
                                            const char *Modif,
                                            bool AddCA)
   : MachineConstantPoolValue((const Type*)gv->getType()),
-    GV(gv), S(NULL), LabelId(id), Kind(k), PCAdjust(PCAdj),
+    GV(gv), S(NULL), LabelId(id), PCAdjust(PCAdj),
     Modifier(Modif), AddCurrentAddress(AddCA) {}
 
 ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
                                            const char *s, unsigned id,
-                                           ARMCP::ARMCPKind k,
                                            unsigned char PCAdj,
                                            const char *Modif,
                                            bool AddCA)
   : MachineConstantPoolValue((const Type*)Type::getInt32Ty(C)),
-    GV(NULL), S(strdup(s)), LabelId(id), Kind(k), PCAdjust(PCAdj),
+    GV(NULL), S(strdup(s)), LabelId(id), PCAdjust(PCAdj),
     Modifier(Modif), AddCurrentAddress(AddCA) {}
 
-ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv,
-                                           ARMCP::ARMCPKind k,
-                                           const char *Modif)
+ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, const char *Modif)
   : MachineConstantPoolValue((const Type*)Type::getInt32Ty(gv->getContext())),
-    GV(gv), S(NULL), LabelId(0), Kind(k), PCAdjust(0),
+    GV(gv), S(NULL), LabelId(0), PCAdjust(0),
     Modifier(Modif) {}
 
 int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
@@ -57,7 +53,6 @@
       if (CPV->GV == GV &&
           CPV->S == S &&
           CPV->LabelId == LabelId &&
-          CPV->Kind == Kind &&
           CPV->PCAdjust == PCAdjust)
         return i;
     }
@@ -75,7 +70,6 @@
   ID.AddPointer(GV);
   ID.AddPointer(S);
   ID.AddInteger(LabelId);
-  ID.AddInteger((unsigned)Kind);
   ID.AddInteger(PCAdjust);
 }
 
@@ -89,8 +83,6 @@
     O << GV->getName();
   else
     O << S;
-  if (isNonLazyPointer()) O << "$non_lazy_ptr";
-  else if (isStub()) O << "$stub";
   if (Modifier) O << "(" << Modifier << ")";
   if (PCAdjust != 0) {
     O << "-(LPC" << LabelId << "+" << (unsigned)PCAdjust;

Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h (original)
+++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h Fri Aug 28 18:18:09 2009
@@ -21,14 +21,6 @@
 class GlobalValue;
 class LLVMContext;
 
-namespace ARMCP {
-  enum ARMCPKind {
-    CPValue,
-    CPNonLazyPtr,
-    CPStub
-  };
-}
-
 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
 /// represent PC relative displacement between the address of the load
 /// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
@@ -36,7 +28,6 @@
   GlobalValue *GV;         // GlobalValue being loaded.
   const char *S;           // ExtSymbol being loaded.
   unsigned LabelId;        // Label id of the load.
-  ARMCP::ARMCPKind Kind;   // non_lazy_ptr or stub?
   unsigned char PCAdjust;  // Extra adjustment if constantpool is pc relative.
                            // 8 for ARM, 4 for Thumb.
   const char *Modifier;    // GV modifier i.e. (&GV(modifier)-(LPIC+8))
@@ -44,15 +35,12 @@
 
 public:
   ARMConstantPoolValue(GlobalValue *gv, unsigned id,
-                       ARMCP::ARMCPKind Kind = ARMCP::CPValue,
                        unsigned char PCAdj = 0, const char *Modifier = NULL,
                        bool AddCurrentAddress = false);
   ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
-                       ARMCP::ARMCPKind Kind = ARMCP::CPValue,
                        unsigned char PCAdj = 0, const char *Modifier = NULL,
                        bool AddCurrentAddress = false);
-  ARMConstantPoolValue(GlobalValue *GV, ARMCP::ARMCPKind Kind,
-                       const char *Modifier);
+  ARMConstantPoolValue(GlobalValue *GV, const char *Modifier);
   ARMConstantPoolValue();
   ~ARMConstantPoolValue();
 
@@ -63,8 +51,6 @@
   bool hasModifier() const { return Modifier != NULL; }
   bool mustAddCurrentAddress() const { return AddCurrentAddress; }
   unsigned getLabelId() const { return LabelId; }
-  bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
-  bool isStub() const { return Kind == ARMCP::CPStub; }
   unsigned char getPCAdjustment() const { return PCAdjust; }
 
   virtual unsigned getRelocationInfo() const {

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Aug 28 18:18:09 2009
@@ -968,8 +968,8 @@
     isLocalARMFunc = !Subtarget->isThumb() && !isExt;
     // tBX takes a register source operand.
     if (isARMFunc && Subtarget->isThumb1Only() && !Subtarget->hasV5TOps()) {
-      ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV, ARMPCLabelIndex,
-                                                           ARMCP::CPStub, 4);
+      ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV,
+                                                           ARMPCLabelIndex, 4);
       SDValue CPAddr = DAG.getTargetConstantPool(CPV, getPointerTy(), 4);
       CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
       Callee = DAG.getLoad(getPointerTy(), dl,
@@ -988,8 +988,7 @@
     const char *Sym = S->getSymbol();
     if (isARMFunc && Subtarget->isThumb1Only() && !Subtarget->hasV5TOps()) {
       ARMConstantPoolValue *CPV = new ARMConstantPoolValue(*DAG.getContext(),
-                                                          Sym, ARMPCLabelIndex,
-                                                           ARMCP::CPStub, 4);
+                                                       Sym, ARMPCLabelIndex, 4);
       SDValue CPAddr = DAG.getTargetConstantPool(CPV, getPointerTy(), 4);
       CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
       Callee = DAG.getLoad(getPointerTy(), dl,
@@ -1166,7 +1165,7 @@
   EVT PtrVT = getPointerTy();
   unsigned char PCAdj = Subtarget->isThumb() ? 4 : 8;
   ARMConstantPoolValue *CPV =
-    new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex, ARMCP::CPValue,
+    new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex,
                              PCAdj, "tlsgd", true);
   SDValue Argument = DAG.getTargetConstantPool(CPV, PtrVT, 4);
   Argument = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Argument);
@@ -1208,7 +1207,7 @@
     // initial exec model
     unsigned char PCAdj = Subtarget->isThumb() ? 4 : 8;
     ARMConstantPoolValue *CPV =
-      new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex, ARMCP::CPValue,
+      new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex,
                                PCAdj, "gottpoff", true);
     Offset = DAG.getTargetConstantPool(CPV, PtrVT, 4);
     Offset = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Offset);
@@ -1221,8 +1220,7 @@
     Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, NULL, 0);
   } else {
     // local exec model
-    ARMConstantPoolValue *CPV =
-      new ARMConstantPoolValue(GV, ARMCP::CPValue, "tpoff");
+    ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV, "tpoff");
     Offset = DAG.getTargetConstantPool(CPV, PtrVT, 4);
     Offset = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Offset);
     Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, NULL, 0);
@@ -1256,7 +1254,7 @@
   if (RelocM == Reloc::PIC_) {
     bool UseGOTOFF = GV->hasLocalLinkage() || GV->hasHiddenVisibility();
     ARMConstantPoolValue *CPV =
-      new ARMConstantPoolValue(GV, ARMCP::CPValue, UseGOTOFF ? "GOTOFF":"GOT");
+      new ARMConstantPoolValue(GV, UseGOTOFF ? "GOTOFF" : "GOT");
     SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4);
     CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
     SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(),
@@ -1274,34 +1272,19 @@
   }
 }
 
-/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol
-/// even in non-static mode.
-static bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) {
-  // If symbol visibility is hidden, the extra load is not needed if
-  // the symbol is definitely defined in the current translation unit.
-  bool isDecl = GV->isDeclaration() || GV->hasAvailableExternallyLinkage();
-  if (GV->hasHiddenVisibility() && (!isDecl && !GV->hasCommonLinkage()))
-    return false;
-  return RelocM != Reloc::Static && (isDecl || GV->isWeakForLinker());
-}
-
 SDValue ARMTargetLowering::LowerGlobalAddressDarwin(SDValue Op,
                                                     SelectionDAG &DAG) {
   EVT PtrVT = getPointerTy();
   DebugLoc dl = Op.getDebugLoc();
   GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
   Reloc::Model RelocM = getTargetMachine().getRelocationModel();
-  bool IsIndirect = GVIsIndirectSymbol(GV, RelocM);
   SDValue CPAddr;
   if (RelocM == Reloc::Static)
     CPAddr = DAG.getTargetConstantPool(GV, PtrVT, 4);
   else {
-    unsigned PCAdj = (RelocM != Reloc::PIC_)
-      ? 0 : (Subtarget->isThumb() ? 4 : 8);
-    ARMCP::ARMCPKind Kind = IsIndirect ? ARMCP::CPNonLazyPtr
-      : ARMCP::CPValue;
-    ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV, ARMPCLabelIndex,
-                                                         Kind, PCAdj);
+    unsigned PCAdj = (RelocM != Reloc::PIC_) ? 0 : (Subtarget->isThumb()?4:8);
+    ARMConstantPoolValue *CPV =
+      new ARMConstantPoolValue(GV, ARMPCLabelIndex, PCAdj);
     CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4);
   }
   CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
@@ -1313,7 +1296,8 @@
     SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
     Result = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel);
   }
-  if (IsIndirect)
+
+  if (Subtarget->GVIsIndirectSymbol(GV, RelocM == Reloc::Static))
     Result = DAG.getLoad(PtrVT, dl, Chain, Result, NULL, 0);
 
   return Result;
@@ -1328,8 +1312,7 @@
   unsigned PCAdj = Subtarget->isThumb() ? 4 : 8;
   ARMConstantPoolValue *CPV = new ARMConstantPoolValue(*DAG.getContext(),
                                                        "_GLOBAL_OFFSET_TABLE_",
-                                                       ARMPCLabelIndex,
-                                                       ARMCP::CPValue, PCAdj);
+                                                       ARMPCLabelIndex, PCAdj);
   SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4);
   CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
   SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, NULL, 0);
@@ -1403,14 +1386,13 @@
     SDValue CPAddr;
     unsigned PCAdj = (RelocM != Reloc::PIC_)
       ? 0 : (Subtarget->isThumb() ? 4 : 8);
-    ARMCP::ARMCPKind Kind = ARMCP::CPValue;
     // Save off the LSDA name for the AsmPrinter to use when it's time
     // to emit the table
     std::string LSDAName = "L_lsda_";
     LSDAName += MF.getFunction()->getName();
     ARMConstantPoolValue *CPV =
       new ARMConstantPoolValue(*DAG.getContext(), LSDAName.c_str(), 
-                               ARMPCLabelIndex, Kind, PCAdj);
+                               ARMPCLabelIndex, PCAdj);
     CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4);
     CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
     SDValue Result =

Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Fri Aug 28 18:18:09 2009
@@ -13,6 +13,7 @@
 
 #include "ARMSubtarget.h"
 #include "ARMGenSubtarget.inc"
+#include "llvm/GlobalValue.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Support/CommandLine.h"
 using namespace llvm;
@@ -92,3 +93,13 @@
   if (isTargetDarwin())
     IsR9Reserved = ReserveR9 | (ARMArchVersion < V6);
 }
+
+/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
+bool ARMSubtarget::GVIsIndirectSymbol(GlobalValue *GV, bool isStatic) const {
+  // If symbol visibility is hidden, the extra load is not needed if
+  // the symbol is definitely defined in the current translation unit.
+  bool isDecl = GV->isDeclaration() || GV->hasAvailableExternallyLinkage();
+  if (GV->hasHiddenVisibility() && (!isDecl && !GV->hasCommonLinkage()))
+    return false;
+  return !isStatic && (isDecl || GV->isWeakForLinker());
+}

Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original)
+++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Fri Aug 28 18:18:09 2009
@@ -19,6 +19,7 @@
 #include <string>
 
 namespace llvm {
+class GlobalValue;
 
 class ARMSubtarget : public TargetSubtarget {
 protected:
@@ -129,6 +130,10 @@
   /// stack frame on entry to the function and which must be maintained by every
   /// function for this subtarget.
   unsigned getStackAlignment() const { return stackAlignment; }
+
+  /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
+  /// symbol.
+  bool GVIsIndirectSymbol(GlobalValue *GV, bool isStatic) const;
 };
 } // End llvm namespace
 

Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Aug 28 18:18:09 2009
@@ -79,34 +79,6 @@
     /// visibility that require non-lazy-pointers for indirect access.
     StringMap<std::string> HiddenGVNonLazyPtrs;
 
-    struct FnStubInfo {
-      std::string Stub, LazyPtr, SLP, SCV;
-      
-      FnStubInfo() {}
-      
-      void Init(const GlobalValue *GV, Mangler *Mang) {
-        // Already initialized.
-        if (!Stub.empty()) return;
-        Stub = Mang->getMangledName(GV, "$stub", true);
-        LazyPtr = Mang->getMangledName(GV, "$lazy_ptr", true);
-        SLP = Mang->getMangledName(GV, "$slp", true);
-        SCV = Mang->getMangledName(GV, "$scv", true);
-      }
-      
-      void Init(const std::string &GV, Mangler *Mang) {
-        // Already initialized.
-        if (!Stub.empty()) return;
-        Stub = Mang->makeNameProper(GV + "$stub", Mangler::Private);
-        LazyPtr = Mang->makeNameProper(GV + "$lazy_ptr", Mangler::Private);
-        SLP = Mang->makeNameProper(GV + "$slp", Mangler::Private);
-        SCV = Mang->makeNameProper(GV + "$scv", Mangler::Private);
-      }
-    };
-    
-    /// FnStubs - Keeps the set of external function GlobalAddresses that the
-    /// asm printer should generate stubs for.
-    StringMap<FnStubInfo> FnStubs;
-
     /// True if asm printer is printing a series of CONSTPOOL_ENTRY.
     bool InCPMode;
   public:
@@ -188,36 +160,26 @@
       GlobalValue *GV = ACPV->getGV();
       std::string Name;
       
-      
-      if (ACPV->isNonLazyPointer()) {
-        std::string SymName = Mang->getMangledName(GV);
-        Name = Mang->getMangledName(GV, "$non_lazy_ptr", true);
-        
-        if (GV->hasHiddenVisibility())
-          HiddenGVNonLazyPtrs[SymName] = Name;
-        else
-          GVNonLazyPtrs[SymName] = Name;
-      } else if (ACPV->isStub()) {
-        if (GV) {
-          FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)];
-          FnInfo.Init(GV, Mang);
-          Name = FnInfo.Stub;
-        } else {
-          FnStubInfo &FnInfo = FnStubs[Mang->makeNameProper(ACPV->getSymbol())];
-          FnInfo.Init(ACPV->getSymbol(), Mang);
-          Name = FnInfo.Stub;
-        }
-      } else {
-        if (GV)
+      if (GV) {
+        bool isIndirect = Subtarget->isTargetDarwin() &&
+          Subtarget->GVIsIndirectSymbol(GV,
+                                        TM.getRelocationModel() == Reloc::Static);
+        if (!isIndirect)
           Name = Mang->getMangledName(GV);
-        else if (!strncmp(ACPV->getSymbol(), "L_lsda_", 7))
-          Name = ACPV->getSymbol();
-        else
-          Name = Mang->makeNameProper(ACPV->getSymbol());
-      }
-      O << Name;
-      
-      
+        else {
+          // FIXME: Remove this when Darwin transition to @GOT like syntax.
+          std::string SymName = Mang->getMangledName(GV);
+          Name = Mang->getMangledName(GV, "$non_lazy_ptr", true);
+          if (GV->hasHiddenVisibility())
+            HiddenGVNonLazyPtrs[SymName] = Name;
+          else
+            GVNonLazyPtrs[SymName] = Name;
+        }
+      } else if (!strncmp(ACPV->getSymbol(), "L_lsda_", 7))
+        Name = ACPV->getSymbol();
+      else
+        Name = Mang->makeNameProper(ACPV->getSymbol());
+      O << Name;      
       
       if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")";
       if (ACPV->getPCAdjustment() != 0) {
@@ -372,18 +334,7 @@
   case MachineOperand::MO_GlobalAddress: {
     bool isCallOp = Modifier && !strcmp(Modifier, "call");
     GlobalValue *GV = MO.getGlobal();
-    std::string Name;
-    bool isExt = GV->isDeclaration() || GV->isWeakForLinker();
-    if (isExt && isCallOp && Subtarget->isTargetDarwin() &&
-        TM.getRelocationModel() != Reloc::Static) {
-      FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)];
-      FnInfo.Init(GV, Mang);
-      Name = FnInfo.Stub;
-    } else {
-      Name = Mang->getMangledName(GV);
-    }
-    
-    O << Name;
+    O << Mang->getMangledName(GV);
 
     printOffset(MO.getOffset());
 
@@ -394,14 +345,7 @@
   }
   case MachineOperand::MO_ExternalSymbol: {
     bool isCallOp = Modifier && !strcmp(Modifier, "call");
-    std::string Name;
-    if (isCallOp && Subtarget->isTargetDarwin() &&
-        TM.getRelocationModel() != Reloc::Static) {
-      FnStubInfo &FnInfo = FnStubs[Mang->makeNameProper(MO.getSymbolName())];
-      FnInfo.Init(MO.getSymbolName(), Mang);
-      Name = FnInfo.Stub;
-    } else
-      Name = Mang->makeNameProper(MO.getSymbolName());
+    std::string Name = Mang->makeNameProper(MO.getSymbolName());
     
     O << Name;
     if (isCallOp && Subtarget->isTargetELF() &&
@@ -1277,55 +1221,7 @@
       static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
     
     O << '\n';
-    
-    if (!FnStubs.empty()) {
-      unsigned StubSize = 12;
-      const char *StubSectionName = "__symbol_stub4";
-      
-      if (TM.getRelocationModel() == Reloc::PIC_) {
-        StubSize = 16;
-        StubSectionName = "__picsymbolstub4";
-      }
-      
-      const MCSection *StubSection
-        = TLOFMacho.getMachOSection("__TEXT", StubSectionName,
-                                    MCSectionMachO::S_SYMBOL_STUBS,
-                                    StubSize, SectionKind::getText());
 
-      const MCSection *LazySymbolPointerSection
-        = TLOFMacho.getLazySymbolPointerSection();
-    
-      // Output stubs for dynamically-linked functions
-      for (StringMap<FnStubInfo>::iterator I = FnStubs.begin(),
-           E = FnStubs.end(); I != E; ++I) {
-        const FnStubInfo &Info = I->second;
-        
-        OutStreamer.SwitchSection(StubSection);
-        EmitAlignment(2);
-        O << "\t.code\t32\n";
-
-        O << Info.Stub << ":\n";
-        O << "\t.indirect_symbol " << I->getKeyData() << '\n';
-        O << "\tldr ip, " << Info.SLP << '\n';
-        if (TM.getRelocationModel() == Reloc::PIC_) {
-          O << Info.SCV << ":\n";
-          O << "\tadd ip, pc, ip\n";
-        }
-        O << "\tldr pc, [ip, #0]\n";
-        O << Info.SLP << ":\n";
-        O << "\t.long\t" << Info.LazyPtr;
-        if (TM.getRelocationModel() == Reloc::PIC_)
-          O << "-(" << Info.SCV << "+8)";
-        O << '\n';
-        
-        OutStreamer.SwitchSection(LazySymbolPointerSection);
-        O << Info.LazyPtr << ":\n";
-        O << "\t.indirect_symbol " << I->getKeyData() << "\n";
-        O << "\t.long\tdyld_stub_binding_helper\n";
-      }
-      O << '\n';
-    }
-    
     // Output non-lazy-pointers for external and common global variables.
     if (!GVNonLazyPtrs.empty()) {
       // Switch with ".non_lazy_symbol_pointer" directive.
@@ -1349,7 +1245,6 @@
       }
     }
 
-
     // Funny Darwin hack: This flag tells the linker that no global symbols
     // contain code that falls through to other global symbols (e.g. the obvious
     // implementation of multiple entry points).  If this doesn't occur, the

Removed: llvm/trunk/test/CodeGen/ARM/stubs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/stubs.ll?rev=80403&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/ARM/stubs.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/stubs.ll (removed)
@@ -1,67 +0,0 @@
-; RUN: llvm-as < %s | llc -relocation-model=static | FileCheck %s -check-prefix=STATIC
-; RUN: llvm-as < %s | llc -relocation-model=pic | FileCheck %s -check-prefix=PIC
-; RUN: llvm-as < %s | llc -relocation-model=dynamic-no-pic | FileCheck %s -check-prefix=DYNAMIC
-; PR4482
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
-target triple = "armv6-apple-darwin2"
-
-define i32 @foo(i64 %x) nounwind {
-entry:
-; STATIC: _foo:
-; STATIC: bl _exact_log2
-; STATIC: ldmfd sp!, {r7, pc}
-; STATIC: .subsections_via_symbols
-
-; PIC: _foo:
-; PIC: bl L_exact_log2$stub
-; PIC: ldmfd sp!, {r7, pc}
-
-; DYNAMIC: _foo:
-; DYNAMIC: bl L_exact_log2$stub
-; DYNAMIC: ldmfd sp!, {r7, pc}
-
- 	%A = call i32 @exact_log2(i64 %x)
-	ret i32 %A
-}
-
-define available_externally i32 @exact_log2(i64 %x) nounwind {
-  ret i32 4
-}
-
-
-; PIC: .section __TEXT,__picsymbolstub4,symbol_stubs,none,16
-; PIC: L_exact_log2$stub:
-; PIC: .indirect_symbol _exact_log2
-; PIC: ldr ip, L_exact_log2$slp
-; PIC: L_exact_log2$scv:
-; PIC: add ip, pc, ip
-; PIC: ldr pc, [ip, #0]
-; PIC: L_exact_log2$slp:
-; PIC: .long	L_exact_log2$lazy_ptr-(L_exact_log2$scv+8)
-
-; PIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
-; PIC: L_exact_log2$lazy_ptr:
-; PIC: .indirect_symbol _exact_log2
-; PIC: .long	dyld_stub_binding_helper
-
-; PIC: .subsections_via_symbols
-
-
-; DYNAMIC: .section __TEXT,__symbol_stub4,symbol_stubs,none,12
-; DYNAMIC: L_exact_log2$stub:
-; DYNAMIC: .indirect_symbol _exact_log2
-; DYNAMIC: ldr ip, L_exact_log2$slp
-; DYNAMIC: ldr pc, [ip, #0]
-; DYNAMIC: L_exact_log2$slp:
-; DYNAMIC: .long	L_exact_log2$lazy_ptr
-
-; DYNAMIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
-; DYNAMIC: L_exact_log2$lazy_ptr:
-; DYNAMIC: .indirect_symbol _exact_log2
-; DYNAMIC: .long	dyld_stub_binding_helper
-; DYNAMIC: .subsections_via_symbols
-
-
-
-
-

Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-call.ll?rev=80404&r1=80403&r2=80404&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/Thumb2/thumb2-call.ll (original)
+++ llvm/trunk/test/CodeGen/Thumb2/thumb2-call.ll Fri Aug 28 18:18:09 2009
@@ -7,7 +7,7 @@
 
 define void @f() {
 ; DARWIN: f:
-; DARWIN: blx L_g$stub
+; DARWIN: blx _g
 
 ; LINUX: f:
 ; LINUX: bl g





More information about the llvm-commits mailing list