summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/LexicalScopes.cpp17
-rw-r--r--llvm/lib/IR/DebugLoc.cpp9
2 files changed, 7 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/LexicalScopes.cpp b/llvm/lib/CodeGen/LexicalScopes.cpp
index 2b356b4adee..45f312bb7b1 100644
--- a/llvm/lib/CodeGen/LexicalScopes.cpp
+++ b/llvm/lib/CodeGen/LexicalScopes.cpp
@@ -134,15 +134,13 @@ LexicalScope *LexicalScopes::findLexicalScope(const MDLocation *DL) {
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
/// not available then create new lexical scope.
-LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocation *DL) {
- if (!DL)
- return nullptr;
- MDLocalScope *Scope = DL->getScope();
- if (auto *InlinedAt = DL->getInlinedAt()) {
+LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocalScope *Scope,
+ const MDLocation *IA) {
+ if (IA) {
// Create an abstract scope for inlined function.
getOrCreateAbstractScope(Scope);
// Create an inlined scope for inlined function.
- return getOrCreateInlinedScope(Scope, InlinedAt);
+ return getOrCreateInlinedScope(Scope, IA);
}
return getOrCreateRegularScope(Scope);
@@ -158,11 +156,10 @@ LexicalScopes::getOrCreateRegularScope(const MDLocalScope *Scope) {
if (I != LexicalScopeMap.end())
return &I->second;
+ // FIXME: Should the following dyn_cast be MDLexicalBlock?
LexicalScope *Parent = nullptr;
- if (isa<MDLexicalBlockBase>(Scope)) // FIXME: Should this be MDLexicalBlock?
- Parent =
- getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(
- const_cast<MDLocalScope *>(Scope)).get());
+ if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope))
+ Parent = getOrCreateLexicalScope(Block->getScope());
I = LexicalScopeMap.emplace(std::piecewise_construct,
std::forward_as_tuple(Scope),
std::forward_as_tuple(Parent, Scope, nullptr,
diff --git a/llvm/lib/IR/DebugLoc.cpp b/llvm/lib/IR/DebugLoc.cpp
index 5a5f201fe12..95f6d67c542 100644
--- a/llvm/lib/IR/DebugLoc.cpp
+++ b/llvm/lib/IR/DebugLoc.cpp
@@ -66,15 +66,6 @@ DebugLoc DebugLoc::get(unsigned Line, unsigned Col,
return MDLocation::get(Scope->getContext(), Line, Col, Scope, InlinedAt);
}
-/// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc.
-DebugLoc DebugLoc::getFromDILexicalBlock(MDNode *N) {
- DILexicalBlock LexBlock(N);
- MDNode *Scope = LexBlock.getContext();
- if (!Scope) return DebugLoc();
- return get(LexBlock.getLineNumber(), LexBlock.getColumnNumber(), Scope,
- nullptr);
-}
-
void DebugLoc::dump() const {
#ifndef NDEBUG
if (!Loc)
OpenPOWER on IntegriCloud