llvm.org GIT mirror llvm / 9913271
DebugInfo: Remove DwarfDebug::CurrentFnArguments since we have to handle argument ordering of other arguments (abstract arguments) in the same way and already have code for that too. While refactoring this code I was confused by both the name I had introduced (addNonArgumentVariable... but it has all this logic to handle argument numbering and keep things in order?) and by the redundancy. Seems when I fixed the misordered inlined argument handling, I didn't realize it was mostly redundant with the argument ordering code (which I may've also written, I'm not sure). So let's just rely on the more general case. The only oddity in output this produces is that it means when we emit all the variables for the current function, we don't track when we've finished the argument variables and are about to start the local variables and insert DW_AT_unspecified_parameters (for varargs functions) there. Instead it ends up after the local variables, scopes, etc. But this isn't invalid and doesn't cause DWARF consumers problems that I know of... so we'll just go with that because it makes the code nice & simple. (though, let's see what the buildbots have to say about this - *crosses fingers*) There will be some cleanup commits to follow to remove the now trivial wrappers, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220527 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 5 years ago
6 changed file(s) with 12 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
555555
556556 DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
557557
558 // Collect arguments for current function.
559 DIE *ObjectPointer = nullptr;
560 for (DbgVariable *ArgDV : DD->getCurrentFnArguments())
561 if (ArgDV)
562 ScopeDIE.addChild(constructVariableDIE(*ArgDV, *Scope, ObjectPointer));
563
564558 // If this is a variadic function, add an unspecified parameter.
565559 DITypeArray FnArgs = Sub.getType().getTypeArray();
560
561 // Collect lexical scope children first.
562 // ObjectPointer might be a local (non-argument) local variable if it's a
563 // block's synthetic this pointer.
564 if (DIE *ObjectPointer = createAndAddScopeChildren(Scope, ScopeDIE))
565 addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
566
566567 // If we have a single element of null, it is a function that returns void.
567568 // If we have more than one elements and the last one is null, it is a
568569 // variadic function.
569570 if (FnArgs.getNumElements() > 1 &&
570571 !FnArgs.getElement(FnArgs.getNumElements() - 1))
571572 ScopeDIE.addChild(make_unique(dwarf::DW_TAG_unspecified_parameters));
572
573 // Collect lexical scope children first.
574 // ObjectPointer might be a local (non-argument) local variable if it's a
575 // block's synthetic this pointer.
576 if (DIE *BlockObjPtr = createAndAddScopeChildren(Scope, ScopeDIE)) {
577 assert(!ObjectPointer && "multiple object pointers can't be described");
578 ObjectPointer = BlockObjPtr;
579 }
580
581 if (ObjectPointer)
582 addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
583573 }
584574
585575 DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,
12531253 }
12541254
12551255 void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
1256 if (InfoHolder.addCurrentFnArgument(Var, LS))
1257 return;
12581256 InfoHolder.addNonArgumentScopeVariable(LS, Var);
12591257 }
12601258
12961294 if (TheCU.getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly &&
12971295 LScopes.getAbstractScopesList().empty() && !IsDarwin) {
12981296 assert(ScopeVariables.empty());
1299 assert(CurrentFnArguments.empty());
13001297 assert(DbgValues.empty());
13011298 // FIXME: This wouldn't be true in LTO with a -g (with inlining) CU followed
13021299 // by a -gmlt CU. Add a test and remove this assertion.
13361333 // DbgVariables except those that are also in AbstractVariables (since they
13371334 // can be used cross-function)
13381335 ScopeVariables.clear();
1339 CurrentFnArguments.clear();
13401336 DbgValues.clear();
13411337 LabelsBeforeInsn.clear();
13421338 LabelsAfterInsn.clear();
193193 typedef DenseMap > SectionMapType;
194194 SectionMapType SectionMap;
195195
196 // List of arguments for current function.
197 SmallVector CurrentFnArguments;
198
199196 LexicalScopes LScopes;
200197
201198 // Collection of abstract subprogram DIEs.
674671 SmallPtrSet &getProcessedSPNodes() {
675672 return ProcessedSPNodes;
676673 }
677
678 SmallVector &getCurrentFnArguments() {
679 return CurrentFnArguments;
680 }
681674 };
682675 } // End of namespace llvm
683676
154154 StrPool.emit(*Asm, StrSection, OffsetSection);
155155 }
156156
157 // If Var is a current function argument then add it to CurrentFnArguments list.
158 bool DwarfFile::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) {
159 if (Scope->getParent())
160 return false;
161 DIVariable DV = Var->getVariable();
162 if (DV.getTag() != dwarf::DW_TAG_arg_variable)
163 return false;
164 unsigned ArgNo = DV.getArgNumber();
165 if (ArgNo == 0)
166 return false;
167
168 auto &CurrentFnArguments = DD.getCurrentFnArguments();
169
170 // llvm::Function argument size is not good indicator of how many
171 // arguments does the function have at source level.
172 if (ArgNo > CurrentFnArguments.size())
173 CurrentFnArguments.resize(ArgNo * 2);
174 assert(!CurrentFnArguments[ArgNo - 1]);
175 CurrentFnArguments[ArgNo - 1] = Var;
176 return true;
177 }
178
179157 void DwarfFile::addNonArgumentScopeVariable(LexicalScope *LS,
180158 DbgVariable *Var) {
181159 SmallVectorImpl &Vars = DD.getScopeVariables()[LS];
199177 // A later indexed parameter has been found, insert immediately before it.
200178 if (CurNum > ArgNum)
201179 break;
180 assert(CurNum != ArgNum);
202181 ++I;
203182 }
204183 Vars.insert(I, Var);
8383 /// \brief Returns the string pool.
8484 DwarfStringPool &getStringPool() { return StrPool; }
8585
86 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
8786 void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
8887 };
8988 }
2525 ; CHECK: DW_AT_name {{.*}} "b"
2626 ; CHECK-NOT: DW_TAG
2727 ; CHECK: DW_TAG_formal_parameter
28 ; CHECK-NOT: DW_TAG
29 ; CHECK: DW_TAG_variable
30 ; CHECK-NOT: DW_TAG
31 ; CHECK: DW_TAG_variable
2832 ; CHECK-NOT: DW_TAG
2933 ; CHECK: DW_TAG_unspecified_parameters
3034 ;