Introduce a new technique for merging BasicBlock with Instruction sentinel by superpo...
[oota-llvm.git] / lib / Target / DarwinTargetAsmInfo.cpp
index 20866d7617e1b07c0578b9b0f9cf90454cb78d6d..cc05c09c5170a1b401706e4317e49f11410b98de 100644 (file)
@@ -24,8 +24,8 @@
 
 using namespace llvm;
 
-DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) {
-  DTM = &TM;
+DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) 
+  : TargetAsmInfo(TM) {
 
   CStringSection_ = getUnnamedSection("\t.cstring",
                                 SectionFlags::Mergeable | SectionFlags::Strings);
@@ -61,7 +61,7 @@ DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
                                           Mangler *Mang) const {
   if (GV==0)
     return false;
-  if (GV->hasInternalLinkage() && !isa<Function>(GV) &&
+  if (GV->hasLocalLinkage() && !isa<Function>(GV) &&
       ((strlen(getPrivateGlobalPrefix()) != 0 &&
         Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) ==
           getPrivateGlobalPrefix()) ||
@@ -76,7 +76,7 @@ const Section*
 DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
   SectionKind::Kind Kind = SectionKindForGlobal(GV);
   bool isWeak = GV->mayBeOverridden();
-  bool isNonStatic = (DTM->getRelocationModel() != Reloc::Static);
+  bool isNonStatic = TM.getRelocationModel() != Reloc::Static;
 
   switch (Kind) {
    case SectionKind::Text:
@@ -108,17 +108,17 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
   }
 
   // FIXME: Do we have any extra special weird cases?
+  return NULL;
 }
 
 const Section*
 DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
-  const TargetData *TD = DTM->getTargetData();
+  const TargetData *TD = TM.getTargetData();
   Constant *C = cast<GlobalVariable>(GV)->getInitializer();
-  const Type *Type = cast<ConstantArray>(C)->getType()->getElementType();
+  const Type *Ty = cast<ArrayType>(C->getType())->getElementType();
 
-  unsigned Size = TD->getABITypeSize(Type);
+  unsigned Size = TD->getTypePaddedSize(Ty);
   if (Size) {
-    const TargetData *TD = DTM->getTargetData();
     unsigned Align = TD->getPreferredAlignment(GV);
     if (Align <= 32)
       return getCStringSection_();
@@ -136,9 +136,9 @@ DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
 
 inline const Section*
 DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
-  const TargetData *TD = DTM->getTargetData();
+  const TargetData *TD = TM.getTargetData();
 
-  unsigned Size = TD->getABITypeSize(Ty);
+  unsigned Size = TD->getTypePaddedSize(Ty);
   if (Size == 4)
     return FourByteConstantSection;
   else if (Size == 8)
@@ -155,7 +155,7 @@ DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
 
   // Handle weird special case, when compiling PIC stuff.
   if (S == getReadOnlySection() &&
-      DTM->getRelocationModel() != Reloc::Static)
+      TM.getRelocationModel() != Reloc::Static)
     return ConstDataSection;
 
   return S;