Eliminate the remaining uses of getTypeSize. This
[oota-llvm.git] / lib / Target / X86 / X86AsmPrinter.cpp
index b7de8f002db3a1761098f652aa762951cb004d78..078709bb7af294fd15b71350cb1f6767062baffe 100644 (file)
@@ -51,7 +51,7 @@ static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
   for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
        AI != AE; ++AI)
     // Size should be aligned to DWORD boundary
-    Size += ((TD->getTypeSize(AI->getType()) + 3)/4)*4;
+    Size += ((TD->getABITypeSize(AI->getType()) + 3)/4)*4;
   
   // We're not supporting tooooo huge arguments :)
   Info.setBytesToPopOnReturn((unsigned int)Size);
@@ -156,7 +156,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
     std::string name = Mang->getValueName(I);
     Constant *C = I->getInitializer();
     const Type *Type = C->getType();
-    unsigned Size = TD->getTypeSize(Type);
+    unsigned Size = TD->getABITypeSize(Type);
     unsigned Align = TD->getPreferredAlignmentLog(I);
 
     if (I->hasHiddenVisibility()) {
@@ -170,7 +170,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
     if (Subtarget->isTargetELF())
       O << "\t.type\t" << name << ",@object\n";
     
-    if (C->isNullValue()) {
+    if (C->isNullValue() && !I->hasSection()) {
       if (I->hasExternalLinkage()) {
         if (const char *Directive = TAI->getZeroFillDirective()) {
           O << "\t.globl\t" << name << "\n";
@@ -180,7 +180,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
         }
       }
       
-      if (!I->hasSection() && !I->isThreadLocal() &&
+      if (!I->isThreadLocal() &&
           (I->hasInternalLinkage() || I->hasWeakLinkage() ||
            I->hasLinkOnceLinkage())) {
         if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
@@ -213,7 +213,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
     case GlobalValue::LinkOnceLinkage:
     case GlobalValue::WeakLinkage:
       if (Subtarget->isTargetDarwin()) {
-        O << "\t.globl " << name << "\n"
+        O << "\t.globl\t" << name << "\n"
           << "\t.weak_definition " << name << "\n";
         SwitchToDataSection(".section __DATA,__const_coal,coalesced", I);
       } else if (Subtarget->isTargetCygMing()) {
@@ -221,7 +221,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
                                 name +
                                 ",\"aw\"");
         SwitchToDataSection(SectionName.c_str(), I);
-        O << "\t.globl " << name << "\n"
+        O << "\t.globl\t" << name << "\n"
           << "\t.linkonce same_size\n";
       } else {
         std::string SectionName("\t.section\t.llvm.linkonce.d." +
@@ -239,7 +239,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
       // their name or something.  For now, just emit them as external.
     case GlobalValue::ExternalLinkage:
       // If external or appending, declare as a global symbol
-      O << "\t.globl " << name << "\n";
+      O << "\t.globl\t" << name << "\n";
       // FALL THROUGH
     case GlobalValue::InternalLinkage: {
       if (I->isConstant()) {
@@ -316,7 +316,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
   }
   
   // Output linker support code for dllexported globals
-  if (DLLExportedGVs.begin() != DLLExportedGVs.end()) {
+  if (!DLLExportedGVs.empty()) {
     SwitchToDataSection(".section .drectve");
   }
 
@@ -326,7 +326,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
     O << "\t.ascii \" -export:" << *i << ",data\"\n";
   }    
 
-  if (DLLExportedFns.begin() != DLLExportedFns.end()) {
+  if (!DLLExportedFns.empty()) {
     SwitchToDataSection(".section .drectve");
   }
 
@@ -352,7 +352,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
 
     O << "\n";
 
-    if (MMI) {
+    if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI) {
       // Add the (possibly multiple) personalities to the set of global values.
       const std::vector<Function *>& Personalities = MMI->getPersonalities();
 
@@ -362,7 +362,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
     }
 
     // Output stubs for external and common global variables.
-    if (GVStubs.begin() != GVStubs.end())
+    if (!GVStubs.empty())
       SwitchToDataSection(
                     ".section __IMPORT,__pointers,non_lazy_symbol_pointers");
     for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();