From 7153e0d49b735df94eabd501a3ff984654dcf22c Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 13 Apr 2015 20:39:25 +0000 Subject: [PATCH] DebugInfo: Remove DIGlobalVariable::getGlobal() `DIGlobalVariable::getGlobal()` isn't really helpful, it just does a `dyn_cast_or_null<>`. Simplify its only user by doing the cast directly and delete the code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234796 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DebugInfo.h | 1 - lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 7 +++---- lib/IR/DebugInfo.cpp | 4 ---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index b2685da6573..f0832325e3c 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -681,7 +681,6 @@ public: StringRef getDirectory() const { return get()->getDirectory(); } DITypeRef getType() const { return get()->getType(); } - GlobalVariable *getGlobal() const; Constant *getConstant() const { return get()->getVariable(); } DIDerivedType getStaticDataMemberDeclaration() const { return DIDerivedType(get()->getStaticDataMemberDeclaration()); diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index d84b17a92f1..bc4d5e75fa0 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -140,12 +140,11 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(DIGlobalVariable GV) { // Add location. bool addToAccelTable = false; - bool isGlobalVariable = GV.getGlobal() != nullptr; - if (isGlobalVariable) { + if (auto *Global = dyn_cast_or_null(GV.getConstant())) { addToAccelTable = true; DIELoc *Loc = new (DIEValueAllocator) DIELoc(); - const MCSymbol *Sym = Asm->getSymbol(GV.getGlobal()); - if (GV.getGlobal()->isThreadLocal()) { + const MCSymbol *Sym = Asm->getSymbol(Global); + if (Global->isThreadLocal()) { // FIXME: Make this work with -gsplit-dwarf. unsigned PointerSize = Asm->getDataLayout().getPointerSize(); assert((PointerSize == 4 || PointerSize == 8) && diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index d7f5f6396aa..20467c93adb 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -49,10 +49,6 @@ bool DIVariable::isInlinedFnArgument(const Function *CurFn) { return !SP.describes(CurFn); } -GlobalVariable *DIGlobalVariable::getGlobal() const { - return dyn_cast_or_null(getConstant()); -} - void DICompileUnit::replaceSubprograms(DIArray Subprograms) { get()->replaceSubprograms(MDSubprogramArray(Subprograms)); } -- 2.34.1