Avoid compiler warning (in -Asserts mode)
[oota-llvm.git] / lib / Target / PIC16 / PIC16AsmPrinter.cpp
index 743ce9f09fec09811028cde079cdaf095b46be4e..e98cf41b5400cd3b62da447fb6decfdb60cf7271 100644 (file)
 #include "llvm/Function.h"
 #include "llvm/Module.h"
 #include "llvm/CodeGen/DwarfWriter.h"
-#include "llvm/Support/FormattedStream.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/Support/Mangler.h"
-#include "llvm/Support/ErrorHandling.h"
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
+#include "llvm/MC/MCSection.h"
 #include "llvm/Target/TargetRegistry.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
-
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/Mangler.h"
 using namespace llvm;
 
 #include "PIC16GenAsmWriter.inc"
@@ -71,9 +71,9 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   std::string T = PAN::getCodeSectionName(CurrentFnName);
   const char *codeSection = T.c_str();
  
-  const Section *fCodeSection = 
+  const MCSection *fCodeSection = 
     getObjFileLowering().getOrCreateSection(codeSection, false, 
-                                            SectionKind::Text);
+                                           SectionKind::getText());
   // Start the Code Section.
   O <<  "\n";
   SwitchToSection(fCodeSection);
@@ -238,7 +238,9 @@ bool PIC16AsmPrinter::doInitialization(Module &M) {
   // Set the section names for all globals.
   for (Module::global_iterator I = M.global_begin(), E = M.global_end();
        I != E; ++I)
-    I->setSection(getObjFileLowering().SectionForGlobal(I, Mang,TM)->getName());
+    if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage())
+      I->setSection(getObjFileLowering().
+                    SectionForGlobal(I, Mang,TM)->getName());
 
   DbgInfo.BeginModule(M);
   EmitFunctionDecls(M);
@@ -348,9 +350,9 @@ void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) {
   std::string T = PAN::getFrameSectionName(CurrentFnName);
   const char *SectionName = T.c_str();
 
-  const Section *fPDataSection =
+  const MCSection *fPDataSection =
     getObjFileLowering().getOrCreateSection(SectionName, false,
-                                            SectionKind::DataRel);
+                                        SectionKind::getDataRel());
   SwitchToSection(fPDataSection);
   
   // Emit function frame label