diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-11-14 06:19:49 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-11-14 06:19:49 +0000 |
commit | 8f9c22646bfcbc311daf1cfcc82523af7f528ac2 (patch) | |
tree | 4af9d72662c600ac22d66e80658bfcacd0c44b90 /llvm/lib | |
parent | c53e2ecf0296a55d3c33c19fb70a3aa7f81f2732 (diff) | |
download | bcm5719-llvm-8f9c22646bfcbc311daf1cfcc82523af7f528ac2.tar.gz bcm5719-llvm-8f9c22646bfcbc311daf1cfcc82523af7f528ac2.zip |
Fix debug info crashes for PIC16.
llvm-svn: 88761
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/PIC16/PIC16DebugInfo.cpp | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 7c5c23b268f..6d660a60c3e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -138,7 +138,7 @@ bool AsmPrinter::doInitialization(Module &M) { if (MMI) MMI->AnalyzeModule(M); DW = getAnalysisIfAvailable<DwarfWriter>(); - if (DW) + if (DW && MAI->doesSupportDebugInformation()) DW->BeginModule(&M, MMI, O, this, MAI); return false; diff --git a/llvm/lib/Target/PIC16/PIC16DebugInfo.cpp b/llvm/lib/Target/PIC16/PIC16DebugInfo.cpp index 0ed44d21fc4..49df457af7e 100644 --- a/llvm/lib/Target/PIC16/PIC16DebugInfo.cpp +++ b/llvm/lib/Target/PIC16/PIC16DebugInfo.cpp @@ -467,12 +467,18 @@ void PIC16DbgInfo::EmitVarDebugInfo(Module &M) { void PIC16DbgInfo::SwitchToCU(MDNode *CU) { // Get the file path from CU. DICompileUnit cu(CU); - std::string DirName = cu.getDirectory(); - std::string FileName = cu.getFilename(); - std::string FilePath = DirName + "/" + FileName; + std::string FilePath = ""; + if (cu.getDirectory()) { + std::string DirName = cu.getDirectory(); + FilePath = FilePath + DirName + "/"; + } + if (cu.getFilename()) { + std::string FileName = cu.getFilename(); + FilePath = FilePath + FileName; + } - // Nothing to do if source file is still same. - if ( FilePath == CurFile ) return; + // Nothing to do if source file is still same or it is empty. + if ( FilePath == CurFile || FilePath == "") return; // Else, close the current one and start a new. if (CurFile != "") O << "\n\t.eof"; |