[llvm] r234835 - DebugInfo: Gut DILocation
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 13 18:35:55 PDT 2015
Author: dexonsmith
Date: Mon Apr 13 20:35:55 2015
New Revision: 234835
URL: http://llvm.org/viewvc/llvm-project?rev=234835&view=rev
Log:
DebugInfo: Gut DILocation
This is along the same lines as r234832, but for `DILocation`. Clean
out all accessors from `DILocation`. Any callers should be using
`MDLocation` directly (e.g., via `operator->()`).
Modified:
llvm/trunk/include/llvm/IR/DebugInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/lib/IR/DiagnosticInfo.cpp
llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp
llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp
Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234835&r1=234834&r2=234835&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 13 20:35:55 2015
@@ -663,28 +663,15 @@ public:
MDExpression &operator*() const { return *N; }
};
-/// \brief This object holds location information.
-///
-/// This object is not associated with any DWARF tag.
-class DILocation : public DIDescriptor {
-public:
- DILocation() = default;
- DILocation(const MDLocation *N) : DIDescriptor(N) {}
+class DILocation {
+ MDLocation *N;
- MDLocation *get() const {
- return cast_or_null<MDLocation>(DIDescriptor::get());
- }
- operator MDLocation *() const { return get(); }
- MDLocation *operator->() const { return get(); }
- MDLocation &operator*() const { return *get(); }
+public:
+ DILocation(const MDLocation *N = nullptr) : N(const_cast<MDLocation *>(N)) {}
- unsigned getLineNumber() const { return get()->getLine(); }
- unsigned getColumnNumber() const { return get()->getColumn(); }
- DIScope getScope() const { return DIScope(get()->getScope()); }
- DILocation getOrigLocation() const { return get()->getInlinedAt(); }
- StringRef getFilename() const { return get()->getFilename(); }
- StringRef getDirectory() const { return get()->getDirectory(); }
- unsigned getDiscriminator() const { return get()->getDiscriminator(); }
+ operator MDLocation *() const { return N; }
+ MDLocation *operator->() const { return N; }
+ MDLocation &operator*() const { return *N; }
};
class DIObjCProperty : public DIDescriptor {
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=234835&r1=234834&r2=234835&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Apr 13 20:35:55 2015
@@ -430,10 +430,10 @@ DwarfCompileUnit::constructInlinedScopeD
attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
// Add the call site information to the DIE.
- DILocation DL(Scope->getInlinedAt());
+ const MDLocation *IA = Scope->getInlinedAt();
addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
- getOrCreateSourceID(DL.getFilename(), DL.getDirectory()));
- addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, DL.getLineNumber());
+ getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));
+ addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());
// Add name to the name table, we do this here because we're guaranteed
// to have concrete versions of our DW_TAG_inlined_subprogram nodes.
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=234835&r1=234834&r2=234835&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr 13 20:35:55 2015
@@ -179,8 +179,8 @@ void DebugInfoFinder::processLocation(co
if (!Loc)
return;
InitializeTypeMap(M);
- processScope(Loc.getScope());
- processLocation(M, Loc.getOrigLocation());
+ processScope(Loc->getScope());
+ processLocation(M, Loc->getInlinedAt());
}
void DebugInfoFinder::processType(DIType DT) {
Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=234835&r1=234834&r2=234835&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Mon Apr 13 20:35:55 2015
@@ -136,10 +136,9 @@ void DiagnosticInfoOptimizationBase::get
unsigned *Line,
unsigned *Column) const {
MDLocation *L = getDebugLoc();
- DILocation DIL = L;
- *Filename = DIL.getFilename();
- *Line = DIL.getLineNumber();
- *Column = DIL.getColumnNumber();
+ *Filename = L->getFilename();
+ *Line = L->getLine();
+ *Column = L->getColumn();
}
const std::string DiagnosticInfoOptimizationBase::getLocationStr() const {
Modified: llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp?rev=234835&r1=234834&r2=234835&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp Mon Apr 13 20:35:55 2015
@@ -226,7 +226,7 @@ unsigned SampleProfileLoader::getInstWei
DILocation DIL = DLoc.get();
int LOffset = Lineno - HeaderLineno;
- unsigned Discriminator = DIL.getDiscriminator();
+ unsigned Discriminator = DIL->getDiscriminator();
unsigned Weight = Samples->samplesAt(LOffset, Discriminator);
DEBUG(dbgs() << " " << Lineno << "." << Discriminator << ":" << Inst
<< " (line offset: " << LOffset << "." << Discriminator
Modified: llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp?rev=234835&r1=234834&r2=234835&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp Mon Apr 13 20:35:55 2015
@@ -192,8 +192,8 @@ bool AddDiscriminators::runOnFunction(Fu
if (!FirstDIL->canDiscriminate(*LastDIL)) {
// Create a new lexical scope and compute a new discriminator
// number for it.
- StringRef Filename = FirstDIL.getFilename();
- DIScope Scope = FirstDIL.getScope();
+ StringRef Filename = FirstDIL->getFilename();
+ DIScope Scope = FirstDIL->getScope();
DIFile File = Builder.createFile(Filename, Scope.getDirectory());
// FIXME: Calculate the discriminator here, based on local information,
@@ -204,10 +204,10 @@ bool AddDiscriminators::runOnFunction(Fu
unsigned Discriminator = FirstDIL->computeNewDiscriminator();
DILexicalBlockFile NewScope =
Builder.createLexicalBlockFile(Scope, File, Discriminator);
- DILocation NewDIL =
+ auto *NewDIL =
MDLocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(),
NewScope, FirstDIL->getInlinedAt());
- DebugLoc newDebugLoc = NewDIL.get();
+ DebugLoc newDebugLoc = NewDIL;
// Attach this new debug location to First and every
// instruction following First that shares the same location.
@@ -216,9 +216,9 @@ bool AddDiscriminators::runOnFunction(Fu
if (I1->getDebugLoc().get() != FirstDIL)
break;
I1->setDebugLoc(newDebugLoc);
- DEBUG(dbgs() << NewDIL.getFilename() << ":" << NewDIL.getLineNumber()
- << ":" << NewDIL.getColumnNumber() << ":"
- << NewDIL.getDiscriminator() << *I1 << "\n");
+ DEBUG(dbgs() << NewDIL->getFilename() << ":" << NewDIL->getLine()
+ << ":" << NewDIL->getColumn() << ":"
+ << NewDIL->getDiscriminator() << *I1 << "\n");
}
DEBUG(dbgs() << "\n");
Changed = true;
More information about the llvm-commits
mailing list