aboutsummaryrefslogtreecommitdiff
path: root/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r--lib/IR/DebugInfo.cpp107
1 files changed, 90 insertions, 17 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index 9fa31773b598..ce47ef207434 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -1,9 +1,8 @@
//===- DebugInfo.cpp - Debug Information Helper Classes -------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -82,7 +81,7 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
continue;
auto *GV = DIG->getVariable();
processScope(GV->getScope());
- processType(GV->getType().resolve());
+ processType(GV->getType());
}
for (auto *ET : CU->getEnumTypes())
processType(ET);
@@ -92,7 +91,7 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
else
processSubprogram(cast<DISubprogram>(RT));
for (auto *Import : CU->getImportedEntities()) {
- auto *Entity = Import->getEntity().resolve();
+ auto *Entity = Import->getEntity();
if (auto *T = dyn_cast<DIType>(Entity))
processType(T);
else if (auto *SP = dyn_cast<DISubprogram>(Entity))
@@ -125,14 +124,14 @@ void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) {
void DebugInfoFinder::processType(DIType *DT) {
if (!addType(DT))
return;
- processScope(DT->getScope().resolve());
+ processScope(DT->getScope());
if (auto *ST = dyn_cast<DISubroutineType>(DT)) {
- for (DITypeRef Ref : ST->getTypeArray())
- processType(Ref.resolve());
+ for (DIType *Ref : ST->getTypeArray())
+ processType(Ref);
return;
}
if (auto *DCT = dyn_cast<DICompositeType>(DT)) {
- processType(DCT->getBaseType().resolve());
+ processType(DCT->getBaseType());
for (Metadata *D : DCT->getElements()) {
if (auto *T = dyn_cast<DIType>(D))
processType(T);
@@ -142,7 +141,7 @@ void DebugInfoFinder::processType(DIType *DT) {
return;
}
if (auto *DDT = dyn_cast<DIDerivedType>(DT)) {
- processType(DDT->getBaseType().resolve());
+ processType(DDT->getBaseType());
}
}
@@ -175,7 +174,7 @@ void DebugInfoFinder::processScope(DIScope *Scope) {
void DebugInfoFinder::processSubprogram(DISubprogram *SP) {
if (!addSubprogram(SP))
return;
- processScope(SP->getScope().resolve());
+ processScope(SP->getScope());
// Some of the users, e.g. CloneFunctionInto / CloneModule, need to set up a
// ValueMap containing identity mappings for all of the DICompileUnit's, not
// just DISubprogram's, referenced from anywhere within the Function being
@@ -188,9 +187,9 @@ void DebugInfoFinder::processSubprogram(DISubprogram *SP) {
processType(SP->getType());
for (auto *Element : SP->getTemplateParams()) {
if (auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
- processType(TType->getType().resolve());
+ processType(TType->getType());
} else if (auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
- processType(TVal->getType().resolve());
+ processType(TVal->getType());
}
}
}
@@ -208,7 +207,7 @@ void DebugInfoFinder::processDeclare(const Module &M,
if (!NodesSeen.insert(DV).second)
return;
processScope(DV->getScope());
- processType(DV->getType().resolve());
+ processType(DV->getType());
}
void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
@@ -223,7 +222,7 @@ void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
if (!NodesSeen.insert(DV).second)
return;
processScope(DV->getScope());
- processType(DV->getType().resolve());
+ processType(DV->getType());
}
bool DebugInfoFinder::addType(DIType *DT) {
@@ -429,7 +428,8 @@ private:
StringRef LinkageName = MDS->getName().empty() ? MDS->getLinkageName() : "";
DISubprogram *Declaration = nullptr;
auto *Type = cast_or_null<DISubroutineType>(map(MDS->getType()));
- DITypeRef ContainingType(map(MDS->getContainingType()));
+ DIType *ContainingType =
+ cast_or_null<DIType>(map(MDS->getContainingType()));
auto *Unit = cast_or_null<DICompileUnit>(map(MDS->getUnit()));
auto Variables = nullptr;
auto TemplateParams = nullptr;
@@ -900,6 +900,43 @@ LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location) {
return wrap(unwrapDI<DILocation>(Location)->getScope());
}
+LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location) {
+ return wrap(unwrapDI<DILocation>(Location)->getInlinedAt());
+}
+
+LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope) {
+ return wrap(unwrapDI<DIScope>(Scope)->getFile());
+}
+
+const char *LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len) {
+ auto Dir = unwrapDI<DIFile>(File)->getDirectory();
+ *Len = Dir.size();
+ return Dir.data();
+}
+
+const char *LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len) {
+ auto Name = unwrapDI<DIFile>(File)->getFilename();
+ *Len = Name.size();
+ return Name.data();
+}
+
+const char *LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len) {
+ if (auto Src = unwrapDI<DIFile>(File)->getSource()) {
+ *Len = Src->size();
+ return Src->data();
+ }
+ *Len = 0;
+ return "";
+}
+
+LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
+ const char *Name, size_t NameLen,
+ int64_t Value,
+ LLVMBool IsUnsigned) {
+ return wrap(unwrap(Builder)->createEnumerator({Name, NameLen}, Value,
+ IsUnsigned != 0));
+}
+
LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
@@ -1237,6 +1274,27 @@ LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
nullptr, AlignInBits));
}
+LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE) {
+ return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getVariable());
+}
+
+LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(
+ LLVMMetadataRef GVE) {
+ return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getExpression());
+}
+
+LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var) {
+ return wrap(unwrapDI<DIVariable>(Var)->getFile());
+}
+
+LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var) {
+ return wrap(unwrapDI<DIVariable>(Var)->getScope());
+}
+
+unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var) {
+ return unwrapDI<DIVariable>(Var)->getLine();
+}
+
LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data,
size_t Count) {
return wrap(
@@ -1348,6 +1406,21 @@ void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP) {
unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP));
}
+unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram) {
+ return unwrapDI<DISubprogram>(Subprogram)->getLine();
+}
+
+LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst) {
+ return wrap(unwrap<Instruction>(Inst)->getDebugLoc().getAsMDNode());
+}
+
+void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc) {
+ if (Loc)
+ unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc(unwrap<MDNode>(Loc)));
+ else
+ unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc());
+}
+
LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata) {
switch(unwrap(Metadata)->getMetadataID()) {
#define HANDLE_METADATA_LEAF(CLASS) \