Factor local liveness computation out into its own function.
[oota-llvm.git] / lib / CodeGen / AsmPrinter.cpp
index 3f89792053b42185dc9ec68f7149a15cf43bfa26..366b8b398f9a1b8a971b89591b7b91631e05d5f1 100644 (file)
@@ -293,13 +293,16 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
   // the appropriate section.
   TargetLowering *LoweringInfo = TM.getTargetLowering();
 
-  const char* JumpTableDataSection = TAI->getJumpTableDataSection();  
+  const char* JumpTableDataSection = TAI->getJumpTableDataSection();
+  const Function *F = MF.getFunction();
+  unsigned SectionFlags = TAI->SectionFlagsForGlobal(F);
   if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) ||
-     !JumpTableDataSection) {
+     !JumpTableDataSection ||
+      SectionFlags & SectionFlags::Linkonce) {
     // In PIC mode, we need to emit the jump table to the same section as the
     // function body itself, otherwise the label differences won't make sense.
-    // We should also do if the section name is NULL.
-    const Function *F = MF.getFunction();
+    // We should also do if the section name is NULL or function is declared in
+    // discardable section.
     SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
   } else {
     SwitchToDataSection(JumpTableDataSection);
@@ -1445,14 +1448,23 @@ void AsmPrinter::printDataDirective(const Type *type) {
   }
 }
 
-void AsmPrinter::printSuffixedName(const char *Name, const char* Suffix) {
+void AsmPrinter::printSuffixedName(const char *Name, const char *Suffix,
+                                   const char *Prefix) {
   if (Name[0]=='\"')
-    O << '\"' << TAI->getPrivateGlobalPrefix() << 
-         Name[1] << Suffix << '\"';
+    O << '\"';
+  O << TAI->getPrivateGlobalPrefix();
+  if (Prefix) O << Prefix;
+  if (Name[0]=='\"')
+    O << '\"';
+  if (Name[0]=='\"')
+    O << Name[1];
   else
-    O << TAI->getPrivateGlobalPrefix() << Name << Suffix;
+    O << Name;
+  O << Suffix;
+  if (Name[0]=='\"')
+    O << '\"';
 }
 
-void AsmPrinter::printSuffixedName(std::string &Name, const char* Suffix) {
+void AsmPrinter::printSuffixedName(const std::string &Name, const char* Suffix) {
   printSuffixedName(Name.c_str(), Suffix);
 }