From: Anton Korobeynikov Date: Mon, 19 Nov 2012 21:17:20 +0000 (+0000) Subject: Make AsmPrinter::EmitTTypeReference() more robust - put X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=097b0e9d6a8f2499617fe11059bdfbd7e136ad28;p=platform%2Fupstream%2Fllvm.git Make AsmPrinter::EmitTTypeReference() more robust - put the zero GV check inside, so we won't forget it at the caller side. llvm-svn: 168328 --- diff --git a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp index bbbdfd3..dec80a4 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp @@ -113,11 +113,7 @@ void ARMException::EmitTypeInfos(unsigned TTypeEncoding) { const GlobalVariable *GV = *I; if (VerboseAsm) Asm->OutStreamer.AddComment("TypeInfo " + Twine(Entry--)); - if (GV) - Asm->EmitTTypeReference(GV, TTypeEncoding); - else - Asm->OutStreamer.EmitIntValue(0,Asm->GetSizeOfEncodedValue(TTypeEncoding), - 0); + Asm->EmitTTypeReference(GV, TTypeEncoding); } // Emit the Exception Specifications. @@ -135,10 +131,7 @@ void ARMException::EmitTypeInfos(unsigned TTypeEncoding) { Asm->OutStreamer.AddComment("FilterInfo " + Twine(Entry)); } - if (TypeID == 0) - Asm->OutStreamer.EmitIntValue(0,Asm->GetSizeOfEncodedValue(TTypeEncoding), - 0); - else - Asm->EmitTTypeReference(TypeInfos[TypeID - 1], TTypeEncoding); + Asm->EmitTTypeReference((TypeID == 0 ? 0 : TypeInfos[TypeID - 1]), + TTypeEncoding); } } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp index b214f5a..e88a766 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp @@ -120,11 +120,14 @@ unsigned AsmPrinter::GetSizeOfEncodedValue(unsigned Encoding) const { } void AsmPrinter::EmitTTypeReference(const GlobalValue *GV, unsigned Encoding)const{ - const TargetLoweringObjectFile &TLOF = getObjFileLowering(); + if (GV) { + const TargetLoweringObjectFile &TLOF = getObjFileLowering(); - const MCExpr *Exp = - TLOF.getTTypeGlobalReference(GV, Mang, MMI, Encoding, OutStreamer); - OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0); + const MCExpr *Exp = + TLOF.getTTypeGlobalReference(GV, Mang, MMI, Encoding, OutStreamer); + OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0); + } else + OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding), 0); } /// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp index 4ebb75b..0bcb1b5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp @@ -696,11 +696,7 @@ void DwarfException::EmitTypeInfos(unsigned TTypeEncoding) { const GlobalVariable *GV = *I; if (VerboseAsm) Asm->OutStreamer.AddComment("TypeInfo " + Twine(Entry--)); - if (GV) - Asm->EmitTTypeReference(GV, TTypeEncoding); - else - Asm->OutStreamer.EmitIntValue(0,Asm->GetSizeOfEncodedValue(TTypeEncoding), - 0); + Asm->EmitTTypeReference(GV, TTypeEncoding); } // Emit the Exception Specifications.