summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-10-23 22:04:30 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-10-23 22:04:30 +0000
commit3b5c84008deb344a5e3c4957b753e532baf90a8f (patch)
treef78d6e550e37d0fb2f45b8c5b59d6b9ae0212260 /llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
parent29eec9a5203215443a36aea04bc6d3fbbebc31ef (diff)
downloadbcm5719-llvm-3b5c84008deb344a5e3c4957b753e532baf90a8f.tar.gz
bcm5719-llvm-3b5c84008deb344a5e3c4957b753e532baf90a8f.zip
DebugInfo: Sink DwarfDebug::addNonArgumentScopeVariable into DwarfFile.
llvm-svn: 220520
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
index 7ad28225e96..6b3d148ee06 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -176,4 +176,36 @@ bool DwarfFile::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) {
CurrentFnArguments[ArgNo - 1] = Var;
return true;
}
+
+void DwarfFile::addNonArgumentScopeVariable(LexicalScope *LS,
+ DbgVariable *Var) {
+ SmallVectorImpl<DbgVariable *> &Vars = DD.getScopeVariables()[LS];
+ DIVariable DV = Var->getVariable();
+ // Variables with positive arg numbers are parameters.
+ if (unsigned ArgNum = DV.getArgNumber()) {
+ // Keep all parameters in order at the start of the variable list to ensure
+ // function types are correct (no out-of-order parameters)
+ //
+ // This could be improved by only doing it for optimized builds (unoptimized
+ // builds have the right order to begin with), searching from the back (this
+ // would catch the unoptimized case quickly), or doing a binary search
+ // rather than linear search.
+ auto I = Vars.begin();
+ while (I != Vars.end()) {
+ unsigned CurNum = (*I)->getVariable().getArgNumber();
+ // A local (non-parameter) variable has been found, insert immediately
+ // before it.
+ if (CurNum == 0)
+ break;
+ // A later indexed parameter has been found, insert immediately before it.
+ if (CurNum > ArgNum)
+ break;
+ ++I;
+ }
+ Vars.insert(I, Var);
+ return;
+ }
+
+ Vars.push_back(Var);
+}
}
OpenPOWER on IntegriCloud