llvm.org GIT mirror llvm / 93b97c9
Debug info: split out complex DIVariable address expressions into a separate MDNode so they can be uniqued via folding set magic. To conserve space, DIVariable nodes are still variable-length, with the last two fields being optional. No functional change. http://reviews.llvm.org/D3526 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212050 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 5 years ago
12 changed file(s) with 62 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
569569 metadata, ;; Reference to the type descriptor
570570 i32, ;; flags
571571 metadata ;; (optional) Reference to inline location
572 metadata ;; (optional) Reference to a complex expression (see below)
572573 }
573574
574575 These descriptors are used to define variables local to a sub program. The
689689 /// HasComplexAddr - Return true if the variable has a complex address.
690690 bool hasComplexAddress() const { return getNumAddrElements() > 0; }
691691
692 unsigned getNumAddrElements() const;
693
694 uint64_t getAddrElement(unsigned Idx) const {
695 return getUInt64Field(Idx + 8);
696 }
692 /// \brief Return the size of this variable's complex address or
693 /// zero if there is none.
694 unsigned getNumAddrElements() const {
695 if (DbgNode->getNumOperands() < 9)
696 return 0;
697 return getDescriptorField(8)->getNumOperands();
698 }
699
700 /// \brief return the Idx'th complex address element.
701 uint64_t getAddrElement(unsigned Idx) const;
697702
698703 /// isBlockByrefVariable - Return true if the variable was declared as
699704 /// a "__block" variable (Apple Blocks).
10741074 DITypeRef Ty,
10751075 ArrayRef Addr,
10761076 unsigned ArgNo) {
1077 SmallVector Elts;
1078 Elts.push_back(GetTagConstant(VMContext, Tag));
1079 Elts.push_back(getNonCompileUnitScope(Scope)),
1080 Elts.push_back(MDString::get(VMContext, Name));
1081 Elts.push_back(F);
1082 Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext),
1083 (LineNo | (ArgNo << 24))));
1084 Elts.push_back(Ty);
1085 Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
1086 Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
1087 Elts.append(Addr.begin(), Addr.end());
1088
1077 assert(Addr.size() > 0 && "complex address is empty");
1078 Value *Elts[] = {
1079 GetTagConstant(VMContext, Tag),
1080 getNonCompileUnitScope(Scope),
1081 MDString::get(VMContext, Name),
1082 F,
1083 ConstantInt::get(Type::getInt32Ty(VMContext),
1084 (LineNo | (ArgNo << 24))),
1085 Ty,
1086 Constant::getNullValue(Type::getInt32Ty(VMContext)),
1087 Constant::getNullValue(Type::getInt32Ty(VMContext)),
1088 MDNode::get(VMContext, Addr)
1089 };
10891090 return DIVariable(MDNode::get(VMContext, Elts));
10901091 }
10911092
137137 }
138138 }
139139
140 unsigned DIVariable::getNumAddrElements() const {
141 return DbgNode->getNumOperands() - 8;
140 uint64_t DIVariable::getAddrElement(unsigned Idx) const {
141 DIDescriptor ComplexExpr = getDescriptorField(8);
142 if (Idx < ComplexExpr->getNumOperands())
143 if (auto *CI = dyn_cast_or_null(ComplexExpr->getOperand(Idx)))
144 return CI->getZExtValue();
145
146 assert(false && "non-existing complex address element requested");
147 return 0;
142148 }
143149
144150 /// getInlinedAt - If this variable is inlined then return inline location.
565571 // Make sure that type @ field 5 is a DITypeRef.
566572 if (!fieldIsTypeRef(DbgNode, 5))
567573 return false;
568 return DbgNode->getNumOperands() >= 8;
574
575 // Variable without a complex expression.
576 if (DbgNode->getNumOperands() == 8)
577 return true;
578
579 // Make sure the complex expression is an MDNode.
580 return (DbgNode->getNumOperands() == 9 && fieldIsMDNode(DbgNode, 8));
569581 }
570582
571583 /// Verify - Verify that a location descriptor is well formed.
230230 !133 = metadata !{i32 609, i32 175, metadata !23, null}
231231 !134 = metadata !{i32 786689, metadata !23, metadata !"data", metadata !24, i32 67109473, metadata !108, i32 0, null} ; [ DW_TAG_arg_variable ]
232232 !135 = metadata !{i32 609, i32 190, metadata !23, null}
233 !136 = metadata !{i32 786688, metadata !23, metadata !"mydata", metadata !24, i32 604, metadata !50, i32 0, null, i64 1, i64 20, i64 2, i64 1, i64 4, i64 2, i64 1, i64 24} ; [ DW_TAG_auto_variable ]
233 !136 = metadata !{i32 786688, metadata !23, metadata !"mydata", metadata !24, i32 604, metadata !50, i32 0, null, metadata !163} ; [ DW_TAG_auto_variable ]
234234 !137 = metadata !{i32 604, i32 49, metadata !23, null}
235 !138 = metadata !{i32 786688, metadata !23, metadata !"self", metadata !40, i32 604, metadata !90, i32 0, null, i64 1, i64 24} ; [ DW_TAG_auto_variable ]
236 !139 = metadata !{i32 786688, metadata !23, metadata !"semi", metadata !24, i32 607, metadata !125, i32 0, null, i64 1, i64 28} ; [ DW_TAG_auto_variable ]
235 !138 = metadata !{i32 786688, metadata !23, metadata !"self", metadata !40, i32 604, metadata !90, i32 0, null, metadata !164} ; [ DW_TAG_auto_variable ]
236 !139 = metadata !{i32 786688, metadata !23, metadata !"semi", metadata !24, i32 607, metadata !125, i32 0, null, metadata !165} ; [ DW_TAG_auto_variable ]
237237 !140 = metadata !{i32 607, i32 30, metadata !23, null}
238238 !141 = metadata !{i32 610, i32 17, metadata !142, null}
239239 !142 = metadata !{i32 786443, metadata !152, metadata !23, i32 609, i32 200, i32 94} ; [ DW_TAG_lexical_block ]
257257 !160 = metadata !{metadata !"header.h", metadata !"/Volumes/Sandbox/llvm"}
258258 !161 = metadata !{metadata !"header2.h", metadata !"/Volumes/Sandbox/llvm"}
259259 !162 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
260 !163 = metadata !{i64 1, i64 20, i64 2, i64 1, i64 4, i64 2, i64 1, i64 24}
261 !164 = metadata !{i64 1, i64 24}
262 !165 = metadata !{i64 1, i64 28}
117117 !50 = metadata !{i32 786445, metadata !63, metadata !6, metadata !"block", i32 7, i64 64, i64 64, i64 256, i32 0, metadata !9} ; [ DW_TAG_member ]
118118 !51 = metadata !{i32 7, i32 18, metadata !28, null}
119119 !52 = metadata !{i32 7, i32 19, metadata !28, null}
120 !53 = metadata !{i32 786688, metadata !28, metadata !"block", metadata !6, i32 5, metadata !9, i32 0, i32 0, i64 1, i64 32} ; [ DW_TAG_auto_variable ]
120 !53 = metadata !{i32 786688, metadata !28, metadata !"block", metadata !6, i32 5, metadata !9, i32 0, i32 0, metadata !65} ; [ DW_TAG_auto_variable ]
121121 !54 = metadata !{i32 5, i32 27, metadata !28, null}
122122 !55 = metadata !{i32 8, i32 22, metadata !56, null}
123123 !56 = metadata !{i32 786443, metadata !6, metadata !57, i32 7, i32 26, i32 2} ; [ DW_TAG_lexical_block ]
129129 !62 = metadata !{i32 9, i32 20, metadata !56, null}
130130 !63 = metadata !{metadata !"foo.m", metadata !"/Users/echristo"}
131131 !64 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
132 !65 = metadata !{i64 1, i64 32}
169169 !20 = metadata !{i32 786468}
170170 !21 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
171171 !22 = metadata !{i32 2, metadata !"Dwarf Version", i32 3}
172 !23 = metadata !{i32 786689, metadata !4, metadata !"", metadata !5, i32 16777222, metadata !21, i32 0, i32 0, i64 2} ; [ DW_TAG_arg_variable ] [line 6]
172 !23 = metadata !{i32 786689, metadata !4, metadata !"", metadata !5, i32 16777222, metadata !21, i32 0, i32 0, metadata !28} ; [ DW_TAG_arg_variable ] [line 6]
173173 !24 = metadata !{i32 786688, metadata !4, metadata !"a", metadata !5, i32 7, metadata !8, i32 8192, i32 0} ; [ DW_TAG_auto_variable ] [a] [line 7]
174174 !25 = metadata !{i32 7, i32 0, metadata !4, null}
175175 !26 = metadata !{i32 8, i32 0, metadata !4, null} ; [ DW_TAG_imported_declaration ]
176176 !27 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
177 !28 = metadata !{i64 2}
100100 !41 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, null} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
101101 !42 = metadata !{i32 786478, metadata !1, metadata !1, metadata !"__24-[Main initWithContext:]_block_invoke_2", metadata !"__24-[Main initWithContext:]_block_invoke_2", metadata !"", i32 35, metadata !39, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i8*, i8*)* @"__24-[Main initWithContext:]_block_invoke_2", null, null, metadata !15, i32 35} ; [ DW_TAG_subprogram ] [line 35] [local] [def] [__24-[Main initWithContext:]_block_invoke_2]
102102 !84 = metadata !{i32 33, i32 0, metadata !38, null}
103 !86 = metadata !{i32 786688, metadata !38, metadata !"self", metadata !1, i32 41, metadata !34, i32 0, i32 0, i64 1, i64 32} ; [ DW_TAG_auto_variable ] [self] [line 41]
103 !86 = metadata !{i32 786688, metadata !38, metadata !"self", metadata !1, i32 41, metadata !34, i32 0, i32 0, metadata !110} ; [ DW_TAG_auto_variable ] [self] [line 41]
104104 !87 = metadata !{i32 41, i32 0, metadata !38, null}
105105 !103 = metadata !{i32 35, i32 0, metadata !42, null}
106 !105 = metadata !{i32 786688, metadata !42, metadata !"self", metadata !1, i32 40, metadata !34, i32 0, i32 0, i64 1, i64 32} ; [ DW_TAG_auto_variable ] [self] [line 40]
106 !105 = metadata !{i32 786688, metadata !42, metadata !"self", metadata !1, i32 40, metadata !34, i32 0, i32 0, metadata !109} ; [ DW_TAG_auto_variable ] [self] [line 40]
107107 !106 = metadata !{i32 40, i32 0, metadata !42, null}
108108 !107 = metadata !{metadata !"llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m", metadata !""}
109109 !108 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
110 !109 = metadata !{i64 1, i64 32}
111 !110 = metadata !{i64 1, i64 32}
358358 !86 = metadata !{i32 786451, metadata !1, null, metadata !"__block_descriptor_withcopydispose", i32 49, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [__block_descriptor_withcopydispose] [line 49, size 0, align 0, offset 0] [decl] [from ]
359359 !87 = metadata !{i32 786445, metadata !5, metadata !6, metadata !"self", i32 49, i64 64, i64 64, i64 256, i32 0, metadata !61} ; [ DW_TAG_member ] [self] [line 49, size 64, align 64, offset 256] [from ]
360360 !88 = metadata !{i32 49, i32 0, metadata !27, null}
361 !89 = metadata !{i32 786688, metadata !27, metadata !"self", metadata !32, i32 52, metadata !23, i32 0, i32 0, i64 2, i64 1, i64 32} ; [ DW_TAG_auto_variable ] [self] [line 52]
361 !89 = metadata !{i32 786688, metadata !27, metadata !"self", metadata !32, i32 52, metadata !23, i32 0, i32 0, metadata !111} ; [ DW_TAG_auto_variable ] [self] [line 52]
362362 !90 = metadata !{i32 52, i32 0, metadata !27, null}
363363 !91 = metadata !{i32 786688, metadata !92, metadata !"d", metadata !6, i32 50, metadata !93, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [d] [line 50]
364364 !92 = metadata !{i32 786443, metadata !5, metadata !27, i32 49, i32 0, i32 2} ; [ DW_TAG_lexical_block ] [llvm/tools/clang/test/CodeGenObjC/debug-info-blocks.m]
380380 !108 = metadata !{i32 61, i32 0, metadata !36, null}
381381 !109 = metadata !{i32 62, i32 0, metadata !36, null}
382382 !110 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
383 !111 = metadata !{i64 2, i64 1, i64 32}
180180 !9 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
181181 !10 = metadata !{i32 2, metadata !"Debug Info Version", i32 1}
182182 !11 = metadata !{metadata !"clang version 3.5.0 (209308)"}
183 !12 = metadata !{i32 786689, metadata !4, metadata !"y", metadata !5, i32 16777217, metadata !8, i32 0, i32 0, i64 2} ; [ DW_TAG_arg_variable ] [y] [line 1]
183 !12 = metadata !{i32 786689, metadata !4, metadata !"y", metadata !5, i32 16777217, metadata !8, i32 0, i32 0, metadata !14} ; [ DW_TAG_arg_variable ] [y] [line 1]
184184 !13 = metadata !{i32 2, i32 0, metadata !4, null}
185
185 !14 = metadata !{i64 2}
8888 !11 = metadata !{i32 1, i32 26, metadata !5, null}
8989 !12 = metadata !{i32 3, i32 13, metadata !13, null}
9090 !13 = metadata !{i32 786443, metadata !28, metadata !5, i32 2, i32 1, i32 0} ; [ DW_TAG_lexical_block ]
91 !14 = metadata !{i32 786688, metadata !13, metadata !"vla", metadata !6, i32 3, metadata !15, i32 8192, i32 0, i64 2} ; [ DW_TAG_auto_variable ]
91 !14 = metadata !{i32 786688, metadata !13, metadata !"vla", metadata !6, i32 3, metadata !15, i32 8192, i32 0, metadata !30} ; [ DW_TAG_auto_variable ]
9292 !15 = metadata !{i32 786433, null, null, metadata !"", i32 0, i64 0, i64 32, i32 0, i32 0, metadata !9, metadata !16, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int]
9393 !16 = metadata !{metadata !17}
9494 !17 = metadata !{i32 786465, i64 0, i64 -1} ; [ DW_TAG_subrange_type ]
104104 !27 = metadata !{i32 8, i32 1, metadata !13, null}
105105 !28 = metadata !{metadata !"bar.c", metadata !"/Users/echristo/tmp"}
106106 !29 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
107 !30 = metadata !{i64 2}
4646
4747 ; Verify that debug descriptors for argument and local variable will be replaced
4848 ; with descriptors that end with OpDeref (encoded as 2).
49 ; CHECK: ![[ARG_ID]] = metadata {{.*}} i64 2} ; [ DW_TAG_arg_variable ] [p] [line 1]
50 ; CHECK: ![[VAR_ID]] = metadata {{.*}} i64 2} ; [ DW_TAG_auto_variable ] [r] [line 2]
49 ; CHECK: ![[ARG_ID]] = {{.*}}metadata ![[OPDEREF:[0-9]+]]} ; [ DW_TAG_arg_variable ] [p] [line 1]
50 ; CHECK: ![[OPDEREF]] = metadata !{i64 2}
51 ; CHECK: ![[VAR_ID]] = {{.*}}metadata ![[OPDEREF]]} ; [ DW_TAG_auto_variable ] [r] [line 2]
5152 ; Verify that there are no more variable descriptors.
5253 ; CHECK-NOT: DW_TAG_arg_variable
5354 ; CHECK-NOT: DW_TAG_auto_variable