summaryrefslogtreecommitdiffstats
path: root/contrib/llvm
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2014-04-23 18:25:11 +0000
committeremaste <emaste@FreeBSD.org>2014-04-23 18:25:11 +0000
commitf244473dd4ab3d7c89c5914fde75672376314517 (patch)
tree20b32a8d5abf0929691054fd9b6c22c7116e1419 /contrib/llvm
parent360d54aa503e80d5afb1da1cc3fa69132c7b9908 (diff)
downloadFreeBSD-src-f244473dd4ab3d7c89c5914fde75672376314517.zip
FreeBSD-src-f244473dd4ab3d7c89c5914fde75672376314517.tar.gz
Merge LLVM r202188:
Debug info: Support variadic functions. Variadic functions have an unspecified parameter tag after the last argument. In IR this is represented as an unspecified parameter in the subroutine type. Paired commit with CFE r202185. rdar://problem/13690847 This re-applies r202184 + a bugfix in DwarfDebug's argument handling. This merge includes a change to use the LLVM 3.4 API in lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp: DwarfUnit -> CompileUnit Sponsored by: DARPA, AFRL
Diffstat (limited to 'contrib/llvm')
-rw-r--r--contrib/llvm/include/llvm/DIBuilder.h2
-rw-r--r--contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp43
-rw-r--r--contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h3
-rw-r--r--contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp32
4 files changed, 51 insertions, 29 deletions
diff --git a/contrib/llvm/include/llvm/DIBuilder.h b/contrib/llvm/include/llvm/DIBuilder.h
index bac1679..c371d3d 100644
--- a/contrib/llvm/include/llvm/DIBuilder.h
+++ b/contrib/llvm/include/llvm/DIBuilder.h
@@ -439,7 +439,7 @@ namespace llvm {
/// through debug info anchors.
void retainType(DIType T);
- /// createUnspecifiedParameter - Create unspeicified type descriptor
+ /// createUnspecifiedParameter - Create unspecified type descriptor
/// for a subroutine type.
DIDescriptor createUnspecifiedParameter();
diff --git a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 97ef687..50f5cc9 100644
--- a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1116,6 +1116,22 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
addSourceLine(&Buffer, DTy);
}
+/// constructSubprogramArguments - Construct function argument DIEs.
+void CompileUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
+ for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
+ DIDescriptor Ty = Args.getElement(i);
+ if (Ty.isUnspecifiedParameter()) {
+ assert(i == N-1 && "ellipsis must be the last argument");
+ createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
+ } else {
+ DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
+ addType(Arg, DIType(Ty));
+ if (DIType(Ty).isArtificial())
+ addFlag(Arg, dwarf::DW_AT_artificial);
+ }
+ }
+}
+
/// Return true if the type is appropriately scoped to be contained inside
/// its own type unit.
static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) {
@@ -1170,19 +1186,12 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
addType(&Buffer, RTy);
bool isPrototyped = true;
- // Add arguments.
- for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
- DIDescriptor Ty = Elements.getElement(i);
- if (Ty.isUnspecifiedParameter()) {
- createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
- isPrototyped = false;
- } else {
- DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
- addType(Arg, DIType(Ty));
- if (DIType(Ty).isArtificial())
- addFlag(Arg, dwarf::DW_AT_artificial);
- }
- }
+ if (Elements.getNumElements() == 2 &&
+ Elements.getElement(1).isUnspecifiedParameter())
+ isPrototyped = false;
+
+ constructSubprogramArguments(Buffer, Elements);
+
// Add prototype flag if we're dealing with a C language and the
// function has been prototyped.
uint16_t Language = getLanguage();
@@ -1475,13 +1484,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// Add arguments. Do not add arguments for subprogram definition. They will
// be handled while processing variables.
- for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
- DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
- DIType ATy(Args.getElement(i));
- addType(Arg, ATy);
- if (ATy.isArtificial())
- addFlag(Arg, dwarf::DW_AT_artificial);
- }
+ constructSubprogramArguments(*SPDie, Args);
}
if (SP.isArtificial())
diff --git a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index 69a96df..b9e941e 100644
--- a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -342,6 +342,9 @@ public:
void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym);
private:
+ /// constructSubprogramArguments - Construct function argument DIEs.
+ void constructSubprogramArguments(DIE &Buffer, DIArray Args);
+
/// constructTypeDIE - Construct basic type die from DIBasicType.
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
diff --git a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index d1e1ad1..d922433 100644
--- a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -404,15 +404,21 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram SP) {
DIArray Args = SPTy.getTypeArray();
uint16_t SPTag = SPTy.getTag();
if (SPTag == dwarf::DW_TAG_subroutine_type)
+ // FIXME: Use DwarfUnit::constructSubprogramArguments() here.
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
- DIE *Arg =
- SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
DIType ATy(Args.getElement(i));
- SPCU->addType(Arg, ATy);
- if (ATy.isArtificial())
- SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
- if (ATy.isObjectPointer())
- SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
+ if (ATy.isUnspecifiedParameter()) {
+ assert(i == N-1 && "ellipsis must be the last argument");
+ SPCU->createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, *SPDie);
+ } else {
+ DIE *Arg =
+ SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
+ SPCU->addType(Arg, ATy);
+ if (ATy.isArtificial())
+ SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
+ if (ATy.isObjectPointer())
+ SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
+ }
}
DIE *SPDeclDie = SPDie;
SPDie =
@@ -579,7 +585,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(CompileUnit *TheCU, LexicalScope *Scope,
DIE *ObjectPointer = NULL;
// Collect arguments for current function.
- if (LScopes.isCurrentFunctionScope(Scope))
+ if (LScopes.isCurrentFunctionScope(Scope)) {
for (unsigned i = 0, N = CurrentFnArguments.size(); i < N; ++i)
if (DbgVariable *ArgDV = CurrentFnArguments[i])
if (DIE *Arg =
@@ -588,6 +594,16 @@ DIE *DwarfDebug::createScopeChildrenDIE(CompileUnit *TheCU, LexicalScope *Scope,
if (ArgDV->isObjectPointer()) ObjectPointer = Arg;
}
+ // Create the unspecified parameter that marks a function as variadic.
+ DISubprogram SP(Scope->getScopeNode());
+ assert(SP.Verify());
+ DIArray FnArgs = SP.getType().getTypeArray();
+ if (FnArgs.getElement(FnArgs.getNumElements()-1).isUnspecifiedParameter()) {
+ DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);
+ Children.push_back(Ellipsis);
+ }
+ }
+
// Collect lexical scope children first.
const SmallVectorImpl<DbgVariable *> &Variables =ScopeVariables.lookup(Scope);
for (unsigned i = 0, N = Variables.size(); i < N; ++i)
OpenPOWER on IntegriCloud