llvm.org GIT mirror llvm / e69c459
DebugInfo: preparation to implement DW_AT_alignment - Add alignment attribute to DIVariable family - Modify bitcode format to match new DIVariable representation - Update tests to match these changes (also add bitcode upgrade test) - Expect that frontend passes non-zero align value only when it is not default (was forcibly aligned by alignas()/_Alignas()/__atribute__(aligned()) Differential Revision: https://reviews.llvm.org/D25073 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284678 91177308-0d34-0410-b5e6-96231b3b80d8 Victor Leschuk 4 years ago
22 changed file(s) with 333 addition(s) and 192 deletion(s). Raw diff Collapse all Expand all
119119 /// type.
120120 /// \param Name Type name.
121121 /// \param SizeInBits Size of the type.
122 /// \param AlignInBits Type alignment.
123122 /// \param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
124123 DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
125 uint32_t AlignInBits, unsigned Encoding);
124 unsigned Encoding);
126125
127126 /// Create debugging information entry for a qualified
128127 /// type, e.g. 'const int'.
208207 /// \param Ty Parent type.
209208 DIDerivedType *createBitFieldMemberType(
210209 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
211 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
210 uint64_t SizeInBits, uint64_t OffsetInBits,
212211 uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty);
213212
214213 /// Create debugging information entry for a
220219 /// \param Ty Type of the static member.
221220 /// \param Flags Flags to encode member attribute, e.g. private.
222221 /// \param Val Const initializer of the member.
222 /// \param AlignInBits Member alignment.
223223 DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
224224 DIFile *File, unsigned LineNo,
225225 DIType *Ty, DINode::DIFlags Flags,
226 llvm::Constant *Val);
226 llvm::Constant *Val,
227 uint32_t AlignInBits = 0);
227228
228229 /// Create debugging information entry for Objective-C
229230 /// instance variable.
457458 /// \param Expr The location of the global relative to the attached
458459 /// GlobalVariable.
459460 /// \param Decl Reference to the corresponding declaration.
461 /// \param AlignInBits Variable alignment(or 0 if no alignment attr was
462 /// specified)
460463 DIGlobalVariable *createGlobalVariable(DIScope *Context, StringRef Name,
461464 StringRef LinkageName, DIFile *File,
462465 unsigned LineNo, DIType *Ty,
463466 bool isLocalToUnit,
464467 DIExpression *Expr = nullptr,
465 MDNode *Decl = nullptr);
468 MDNode *Decl = nullptr,
469 uint32_t AlignInBits = 0);
466470
467471 /// Identical to createGlobalVariable
468472 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
469473 DIGlobalVariable *createTempGlobalVariableFwdDecl(
470474 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
471475 unsigned LineNo, DIType *Ty, bool isLocalToUnit, DIExpression *Expr,
472 MDNode *Decl = nullptr);
476 MDNode *Decl = nullptr, uint32_t AlignInBits = 0);
473477
474478 /// Create a new descriptor for an auto variable. This is a local variable
475479 /// that is not a subprogram parameter.
482486 DILocalVariable *
483487 createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File,
484488 unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false,
485 DINode::DIFlags Flags = DINode::FlagZero);
489 DINode::DIFlags Flags = DINode::FlagZero,
490 uint32_t AlignInBits = 0);
486491
487492 /// Create a new descriptor for a parameter variable.
488493 ///
548548
549549 unsigned getLine() const { return Line; }
550550 uint64_t getSizeInBits() const { return SizeInBits; }
551 uint64_t getAlignInBits() const { return AlignInBits; }
551 uint32_t getAlignInBits() const { return AlignInBits; }
552 uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
552553 uint64_t getOffsetInBits() const { return OffsetInBits; }
553554 DIFlags getFlags() const { return Flags; }
554555
18251826 /// \brief Base class for variables.
18261827 class DIVariable : public DINode {
18271828 unsigned Line;
1829 uint64_t AlignInBits;
18281830
18291831 protected:
18301832 DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Line,
1831 ArrayRef Ops)
1832 : DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line) {}
1833 ArrayRef Ops, uint64_t AlignInBits = 0)
1834 : DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line),
1835 AlignInBits(AlignInBits) {}
18331836 ~DIVariable() = default;
18341837
18351838 public:
18381841 StringRef getName() const { return getStringOperand(1); }
18391842 DIFile *getFile() const { return cast_or_null(getRawFile()); }
18401843 DITypeRef getType() const { return DITypeRef(getRawType()); }
1844 uint64_t getAlignInBits() const { return AlignInBits; }
1845 uint64_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
18411846
18421847 StringRef getFilename() const {
18431848 if (auto *F = getFile())
20252030 bool IsDefinition;
20262031
20272032 DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
2028 bool IsLocalToUnit, bool IsDefinition,
2033 bool IsLocalToUnit, bool IsDefinition, uint64_t AlignInBits,
20292034 ArrayRef Ops)
2030 : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops),
2035 : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
20312036 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
20322037 ~DIGlobalVariable() = default;
20332038
20352040 getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
20362041 StringRef LinkageName, DIFile *File, unsigned Line, DITypeRef Type,
20372042 bool IsLocalToUnit, bool IsDefinition, DIExpression *Expr,
2038 DIDerivedType *StaticDataMemberDeclaration, StorageType Storage,
2039 bool ShouldCreate = true) {
2043 DIDerivedType *StaticDataMemberDeclaration, uint64_t AlignInBits,
2044 StorageType Storage, bool ShouldCreate = true) {
20402045 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
20412046 getCanonicalMDString(Context, LinkageName), File, Line, Type,
20422047 IsLocalToUnit, IsDefinition, Expr,
2043 StaticDataMemberDeclaration, Storage, ShouldCreate);
2048 StaticDataMemberDeclaration, AlignInBits, Storage,
2049 ShouldCreate);
20442050 }
20452051 static DIGlobalVariable *
20462052 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
20472053 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
20482054 bool IsLocalToUnit, bool IsDefinition, Metadata *Expr,
2049 Metadata *StaticDataMemberDeclaration, StorageType Storage,
2050 bool ShouldCreate = true);
2055 Metadata *StaticDataMemberDeclaration, uint64_t AlignInBits,
2056 StorageType Storage, bool ShouldCreate = true);
20512057
20522058 TempDIGlobalVariable cloneImpl() const {
20532059 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
20542060 getFile(), getLine(), getType(), isLocalToUnit(),
20552061 isDefinition(), getExpr(),
2056 getStaticDataMemberDeclaration());
2062 getStaticDataMemberDeclaration(), getAlignInBits());
20572063 }
20582064
20592065 public:
20602066 DEFINE_MDNODE_GET(DIGlobalVariable,
20612067 (DIScope * Scope, StringRef Name, StringRef LinkageName,
20622068 DIFile *File, unsigned Line, DITypeRef Type,
2063 bool IsLocalToUnit, bool IsDefinition, DIExpression *Expr,
2064 DIDerivedType *StaticDataMemberDeclaration),
2069 bool IsLocalToUnit, bool IsDefinition,
2070 DIExpression *Expr,
2071 DIDerivedType *StaticDataMemberDeclaration,
2072 uint64_t AlignInBits),
20652073 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2066 IsDefinition, Expr, StaticDataMemberDeclaration))
2074 IsDefinition, Expr, StaticDataMemberDeclaration,
2075 AlignInBits))
20672076 DEFINE_MDNODE_GET(DIGlobalVariable,
20682077 (Metadata * Scope, MDString *Name, MDString *LinkageName,
20692078 Metadata *File, unsigned Line, Metadata *Type,
2070 bool IsLocalToUnit, bool IsDefinition, Metadata *Expr,
2071 Metadata *StaticDataMemberDeclaration),
2079 bool IsLocalToUnit, bool IsDefinition,
2080 Metadata *Expr, Metadata *StaticDataMemberDeclaration,
2081 uint64_t AlignInBits),
20722082 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2073 IsDefinition, Expr, StaticDataMemberDeclaration))
2083 IsDefinition, Expr, StaticDataMemberDeclaration,
2084 AlignInBits))
20742085
20752086 TempDIGlobalVariable clone() const { return cloneImpl(); }
20762087
21082119 DIFlags Flags;
21092120
21102121 DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
2111 unsigned Arg, DIFlags Flags, ArrayRef Ops)
2112 : DIVariable(C, DILocalVariableKind, Storage, Line, Ops), Arg(Arg),
2113 Flags(Flags) {
2122 unsigned Arg, DIFlags Flags, uint64_t AlignInBits,
2123 ArrayRef Ops)
2124 : DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
2125 Arg(Arg), Flags(Flags) {
21142126 assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range");
21152127 }
21162128 ~DILocalVariable() = default;
21182130 static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
21192131 StringRef Name, DIFile *File, unsigned Line,
21202132 DITypeRef Type, unsigned Arg, DIFlags Flags,
2121 StorageType Storage,
2133 uint64_t AlignInBits, StorageType Storage,
21222134 bool ShouldCreate = true) {
21232135 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
2124 Line, Type, Arg, Flags, Storage, ShouldCreate);
2136 Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
21252137 }
21262138 static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope,
21272139 MDString *Name, Metadata *File, unsigned Line,
21282140 Metadata *Type, unsigned Arg, DIFlags Flags,
2129 StorageType Storage,
2141 uint64_t AlignInBits, StorageType Storage,
21302142 bool ShouldCreate = true);
21312143
21322144 TempDILocalVariable cloneImpl() const {
21332145 return getTemporary(getContext(), getScope(), getName(), getFile(),
2134 getLine(), getType(), getArg(), getFlags());
2146 getLine(), getType(), getArg(), getFlags(),
2147 getAlignInBits());
21352148 }
21362149
21372150 public:
21382151 DEFINE_MDNODE_GET(DILocalVariable,
21392152 (DILocalScope * Scope, StringRef Name, DIFile *File,
21402153 unsigned Line, DITypeRef Type, unsigned Arg,
2141 DIFlags Flags),
2142 (Scope, Name, File, Line, Type, Arg, Flags))
2154 DIFlags Flags, uint64_t AlignInBits),
2155 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
21432156 DEFINE_MDNODE_GET(DILocalVariable,
21442157 (Metadata * Scope, MDString *Name, Metadata *File,
21452158 unsigned Line, Metadata *Type, unsigned Arg,
2146 DIFlags Flags),
2147 (Scope, Name, File, Line, Type, Arg, Flags))
2159 DIFlags Flags, uint64_t AlignInBits),
2160 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
21482161
21492162 TempDILocalVariable clone() const { return cloneImpl(); }
21502163
41854185 /// ::= !DIGlobalVariable(scope: !0, name: "foo", linkageName: "foo",
41864186 /// file: !1, line: 7, type: !2, isLocal: false,
41874187 /// isDefinition: true, variable: i32* @foo,
4188 /// declaration: !3)
4188 /// declaration: !3, align: 8)
41894189 bool LLParser::ParseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
41904190 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
41914191 REQUIRED(name, MDStringField, (/* AllowEmpty */ false)); \
41974197 OPTIONAL(isLocal, MDBoolField, ); \
41984198 OPTIONAL(isDefinition, MDBoolField, (true)); \
41994199 OPTIONAL(expr, MDField, ); \
4200 OPTIONAL(declaration, MDField, );
4200 OPTIONAL(declaration, MDField, ); \
4201 OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));
42014202 PARSE_MD_FIELDS();
42024203 #undef VISIT_MD_FIELDS
42034204
42044205 Result = GET_OR_DISTINCT(DIGlobalVariable,
42054206 (Context, scope.Val, name.Val, linkageName.Val,
42064207 file.Val, line.Val, type.Val, isLocal.Val,
4207 isDefinition.Val, expr.Val, declaration.Val));
4208 isDefinition.Val, expr.Val, declaration.Val,
4209 align.Val));
42084210 return false;
42094211 }
42104212
42114213 /// ParseDILocalVariable:
42124214 /// ::= !DILocalVariable(arg: 7, scope: !0, name: "foo",
4213 /// file: !1, line: 7, type: !2, arg: 2, flags: 7)
4215 /// file: !1, line: 7, type: !2, arg: 2, flags: 7,
4216 /// align: 8)
42144217 /// ::= !DILocalVariable(scope: !0, name: "foo",
4215 /// file: !1, line: 7, type: !2, arg: 2, flags: 7)
4218 /// file: !1, line: 7, type: !2, arg: 2, flags: 7,
4219 /// align: 8)
42164220 bool LLParser::ParseDILocalVariable(MDNode *&Result, bool IsDistinct) {
42174221 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
42184222 REQUIRED(scope, MDField, (/* AllowNull */ false)); \
42214225 OPTIONAL(file, MDField, ); \
42224226 OPTIONAL(line, LineField, ); \
42234227 OPTIONAL(type, MDField, ); \
4224 OPTIONAL(flags, DIFlagField, );
4228 OPTIONAL(flags, DIFlagField, ); \
4229 OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));
42254230 PARSE_MD_FIELDS();
42264231 #undef VISIT_MD_FIELDS
42274232
42284233 Result = GET_OR_DISTINCT(DILocalVariable,
42294234 (Context, scope.Val, name.Val, file.Val, line.Val,
4230 type.Val, arg.Val, flags.Val));
4235 type.Val, arg.Val, flags.Val, align.Val));
42314236 return false;
42324237 }
42334238
27332733 break;
27342734 }
27352735 case bitc::METADATA_GLOBAL_VAR: {
2736 if (Record.size() != 11)
2736 if (Record.size() < 11 || Record.size() > 12)
27372737 return error("Invalid record");
27382738
27392739 IsDistinct = Record[0];
27412741 // Upgrade old metadata, which stored a global variable reference or a
27422742 // ConstantInt here.
27432743 Metadata *Expr = getMDOrNull(Record[9]);
2744 uint64_t AlignInBits = (Record.size() > 11) ? Record[11] : 0;
27442745 GlobalVariable *Attach = nullptr;
27452746 if (auto *CMD = dyn_cast_or_null(Expr)) {
27462747 if (auto *GV = dyn_cast(CMD->getValue())) {
27602761 (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
27612762 getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
27622763 getDITypeRefOrNull(Record[6]), Record[7], Record[8], Expr,
2763 getMDOrNull(Record[10])));
2764 getMDOrNull(Record[10]), AlignInBits));
27642765 MetadataList.assignValue(DGV, NextMetadataNo++);
27652766
27662767 if (Attach)
27732774 if (Record.size() < 8 || Record.size() > 10)
27742775 return error("Invalid record");
27752776
2777 IsDistinct = Record[0] & 1;
2778 bool HasAlignment = Record[0] & 2;
27762779 // 2nd field used to be an artificial tag, either DW_TAG_auto_variable or
2777 // DW_TAG_arg_variable.
2778 IsDistinct = Record[0];
2779 bool HasTag = Record.size() > 8;
2780 // DW_TAG_arg_variable, if we have alignment flag encoded it means, that
2781 // this is newer version of record which doesn't have artifical tag.
2782 bool HasTag = !HasAlignment && Record.size() > 8;
27802783 DINode::DIFlags Flags = static_cast(Record[7 + HasTag]);
2784 uint64_t AlignInBits = HasAlignment ? Record[8 + HasTag] : 0;
27812785 MetadataList.assignValue(
27822786 GET_OR_DISTINCT(DILocalVariable,
27832787 (Context, getMDOrNull(Record[1 + HasTag]),
27842788 getMDString(Record[2 + HasTag]),
27852789 getMDOrNull(Record[3 + HasTag]), Record[4 + HasTag],
27862790 getDITypeRefOrNull(Record[5 + HasTag]),
2787 Record[6 + HasTag], Flags)),
2791 Record[6 + HasTag], Flags, AlignInBits)),
27882792 NextMetadataNo++);
27892793 break;
27902794 }
17111711 Record.push_back(N->isDefinition());
17121712 Record.push_back(VE.getMetadataOrNullID(N->getRawExpr()));
17131713 Record.push_back(VE.getMetadataOrNullID(N->getStaticDataMemberDeclaration()));
1714 Record.push_back(N->getAlignInBits());
17141715
17151716 Stream.EmitRecord(bitc::METADATA_GLOBAL_VAR, Record, Abbrev);
17161717 Record.clear();
17191720 void ModuleBitcodeWriter::writeDILocalVariable(
17201721 const DILocalVariable *N, SmallVectorImpl &Record,
17211722 unsigned Abbrev) {
1722 Record.push_back(N->isDistinct());
1723 // In order to support all possible bitcode formats in BitcodeReader we need
1724 // to distiguish the following cases:
1725 // 1) Record has no artificial tag (Record[1]),
1726 // has no obsolete inlinedAt field (Record[9]).
1727 // In this case Record size will be 8, HasAlignment flag is false.
1728 // 2) Record has artificial tag (Record[1]),
1729 // has no obsolete inlignedAt field (Record[9]).
1730 // In this case Record size will be 9, HasAlignment flag is false.
1731 // 3) Record has both artificial tag (Record[1]) and
1732 // obsolete inlignedAt field (Record[9]).
1733 // In this case Record size will be 10, HasAlignment flag is false.
1734 // 4) Record has neither artificial tag, nor inlignedAt field, but
1735 // HasAlignment flag is true and Record[8] contains alignment value.
1736 const uint64_t HasAlignmentFlag = 1 << 1;
1737 Record.push_back(N->isDistinct() | HasAlignmentFlag);
17231738 Record.push_back(VE.getMetadataOrNullID(N->getScope()));
17241739 Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
17251740 Record.push_back(VE.getMetadataOrNullID(N->getFile()));
17271742 Record.push_back(VE.getMetadataOrNullID(N->getType()));
17281743 Record.push_back(N->getArg());
17291744 Record.push_back(N->getFlags());
1745 Record.push_back(N->getAlignInBits());
17301746
17311747 Stream.EmitRecord(bitc::METADATA_LOCAL_VAR, Record, Abbrev);
17321748 Record.clear();
14031403 addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);
14041404
14051405 uint64_t Offset = DT->getOffsetInBits();
1406 uint32_t Align = DT->getAlignInBits() ? DT->getAlignInBits()
1407 : FieldSize;
1408 uint32_t AlignMask = ~(Align - 1);
1406 // We can't use DT->getAlignInBits() here: AlignInBits for member type
1407 // is non-zero if and only if alignment was forced (e.g. _Alignas()),
1408 // which can't be done with bitfields. Thus we use FieldSize here.
1409 uint32_t AlignInBits = FieldSize;
1410 uint32_t AlignMask = ~(AlignInBits - 1);
14091411 // The bits from the start of the storage unit to the start of the field.
14101412 uint64_t StartBitOffset = Offset - (Offset & AlignMask);
14111413 // The byte offset of the field's aligned storage unit inside the struct.
18211821 Printer.printBool("isDefinition", N->isDefinition());
18221822 Printer.printMetadata("expr", N->getExpr());
18231823 Printer.printMetadata("declaration", N->getRawStaticDataMemberDeclaration());
1824 Printer.printInt("align", N->getAlignInBits());
18241825 Out << ")";
18251826 }
18261827
18361837 Printer.printInt("line", N->getLine());
18371838 Printer.printMetadata("type", N->getRawType());
18381839 Printer.printDIFlags("flags", N->getFlags());
1840 Printer.printInt("align", N->getAlignInBits());
18391841 Out << ")";
18401842 }
18411843
194194 }
195195
196196 DIBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
197 uint32_t AlignInBits,
198197 unsigned Encoding) {
199198 assert(!Name.empty() && "Unable to create type without name");
200199 return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
201 AlignInBits, Encoding);
200 0, Encoding);
202201 }
203202
204203 DIDerivedType *DIBuilder::createQualifiedType(unsigned Tag, DIType *FromTy) {
276275
277276 DIDerivedType *DIBuilder::createBitFieldMemberType(
278277 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
279 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
280 uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty) {
278 uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits,
279 DINode::DIFlags Flags, DIType *Ty) {
281280 Flags |= DINode::FlagBitField;
282281 return DIDerivedType::get(
283282 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
284 getNonCompileUnitScope(Scope), Ty, SizeInBits, AlignInBits, OffsetInBits,
285 Flags, ConstantAsMetadata::get(ConstantInt::get(
286 IntegerType::get(VMContext, 64), StorageOffsetInBits)));
283 getNonCompileUnitScope(Scope), Ty, SizeInBits, /* AlignInBits */ 0,
284 OffsetInBits, Flags,
285 ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64),
286 StorageOffsetInBits)));
287287 }
288288
289289 DIDerivedType *
290290 DIBuilder::createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File,
291291 unsigned LineNumber, DIType *Ty,
292 DINode::DIFlags Flags, llvm::Constant *Val) {
292 DINode::DIFlags Flags, llvm::Constant *Val,
293 uint32_t AlignInBits) {
293294 Flags |= DINode::FlagStaticMember;
294295 return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
295 LineNumber, getNonCompileUnitScope(Scope), Ty, 0, 0,
296 0, Flags, getConstantOrNull(Val));
296 LineNumber, getNonCompileUnitScope(Scope), Ty, 0,
297 AlignInBits, 0, Flags, getConstantOrNull(Val));
297298 }
298299
299300 DIDerivedType *
534535
535536 DIGlobalVariable *DIBuilder::createGlobalVariable(
536537 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
537 unsigned LineNumber, DIType *Ty, bool isLocalToUnit, DIExpression *Expr,
538 MDNode *Decl) {
538 unsigned LineNumber, DIType *Ty, bool isLocalToUnit,
539 DIExpression *Expr, MDNode *Decl, uint32_t AlignInBits) {
539540 checkGlobalVariableScope(Context);
540541
541542 auto *N = DIGlobalVariable::getDistinct(
542543 VMContext, cast_or_null(Context), Name, LinkageName, F,
543544 LineNumber, Ty, isLocalToUnit, true, Expr,
544 cast_or_null(Decl));
545 cast_or_null(Decl), AlignInBits);
545546 AllGVs.push_back(N);
546547 return N;
547548 }
548549
549550 DIGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl(
550551 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
551 unsigned LineNumber, DIType *Ty, bool isLocalToUnit, DIExpression *Expr,
552 MDNode *Decl) {
552 unsigned LineNumber, DIType *Ty, bool isLocalToUnit,
553 DIExpression *Expr, MDNode *Decl, uint32_t AlignInBits) {
553554 checkGlobalVariableScope(Context);
554555
555556 return DIGlobalVariable::getTemporary(
556557 VMContext, cast_or_null(Context), Name, LinkageName, F,
557558 LineNumber, Ty, isLocalToUnit, false, Expr,
558 cast_or_null(Decl))
559 cast_or_null(Decl), AlignInBits)
559560 .release();
560561 }
561562
563564 LLVMContext &VMContext,
564565 DenseMap> &PreservedVariables,
565566 DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
566 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags) {
567 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
568 uint32_t AlignInBits) {
567569 // FIXME: Why getNonCompileUnitScope()?
568570 // FIXME: Why is "!Context" okay here?
569571 // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
572574
573575 auto *Node =
574576 DILocalVariable::get(VMContext, cast_or_null(Context), Name,
575 File, LineNo, Ty, ArgNo, Flags);
577 File, LineNo, Ty, ArgNo, Flags, AlignInBits);
576578 if (AlwaysPreserve) {
577579 // The optimizer may remove local variables. If there is an interest
578580 // to preserve variable info in such situation then stash it in a
587589 DILocalVariable *DIBuilder::createAutoVariable(DIScope *Scope, StringRef Name,
588590 DIFile *File, unsigned LineNo,
589591 DIType *Ty, bool AlwaysPreserve,
590 DINode::DIFlags Flags) {
592 DINode::DIFlags Flags,
593 uint32_t AlignInBits) {
591594 return createLocalVariable(VMContext, PreservedVariables, Scope, Name,
592595 /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve,
593 Flags);
596 Flags, AlignInBits);
594597 }
595598
596599 DILocalVariable *DIBuilder::createParameterVariable(
598601 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags) {
599602 assert(ArgNo && "Expected non-zero argument number for parameter");
600603 return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo,
601 File, LineNo, Ty, AlwaysPreserve, Flags);
604 File, LineNo, Ty, AlwaysPreserve, Flags,
605 /* AlignInBits */0);
602606 }
603607
604608 DIExpression *DIBuilder::createExpression(ArrayRef Addr) {
509509 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
510510 Metadata *Variable,
511511 Metadata *StaticDataMemberDeclaration,
512 uint64_t AlignInBits,
512513 StorageType Storage, bool ShouldCreate) {
513514 assert(isCanonical(Name) && "Expected canonical MDString");
514515 assert(isCanonical(LinkageName) && "Expected canonical MDString");
515516 DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,
516517 (Scope, Name, LinkageName, File, Line, Type,
517518 IsLocalToUnit, IsDefinition, Variable,
518 StaticDataMemberDeclaration));
519 StaticDataMemberDeclaration, AlignInBits));
519520 Metadata *Ops[] = {Scope, Name, File, Type,
520521 Name, LinkageName, Variable, StaticDataMemberDeclaration};
521 DEFINE_GETIMPL_STORE(DIGlobalVariable, (Line, IsLocalToUnit, IsDefinition),
522 DEFINE_GETIMPL_STORE(DIGlobalVariable,
523 (Line, IsLocalToUnit, IsDefinition, AlignInBits),
522524 Ops);
523525 }
524526
526528 MDString *Name, Metadata *File,
527529 unsigned Line, Metadata *Type,
528530 unsigned Arg, DIFlags Flags,
531 uint64_t AlignInBits,
529532 StorageType Storage,
530533 bool ShouldCreate) {
531534 // 64K ought to be enough for any frontend.
534537 assert(Scope && "Expected scope");
535538 assert(isCanonical(Name) && "Expected canonical MDString");
536539 DEFINE_GETIMPL_LOOKUP(DILocalVariable,
537 (Scope, Name, File, Line, Type, Arg, Flags));
540 (Scope, Name, File, Line, Type, Arg, Flags,
541 AlignInBits));
538542 Metadata *Ops[] = {Scope, Name, File, Type};
539 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags), Ops);
543 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops);
540544 }
541545
542546 DIExpression *DIExpression::getImpl(LLVMContext &Context,
760760 bool IsDefinition;
761761 Metadata *Expr;
762762 Metadata *StaticDataMemberDeclaration;
763 uint64_t AlignInBits;
763764
764765 MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
765766 Metadata *File, unsigned Line, Metadata *Type,
766 bool IsLocalToUnit, bool IsDefinition, Metadata *Expr,
767 Metadata *StaticDataMemberDeclaration)
767 bool IsLocalToUnit, bool IsDefinition,
768 Metadata *Expr, Metadata *StaticDataMemberDeclaration,
769 uint64_t AlignInBits)
768770 : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
769771 Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
770772 IsDefinition(IsDefinition), Expr(Expr),
771 StaticDataMemberDeclaration(StaticDataMemberDeclaration) {}
773 StaticDataMemberDeclaration(StaticDataMemberDeclaration),
774 AlignInBits(AlignInBits) {}
772775 MDNodeKeyImpl(const DIGlobalVariable *N)
773776 : Scope(N->getRawScope()), Name(N->getRawName()),
774777 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
775778 Line(N->getLine()), Type(N->getRawType()),
776779 IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
777780 Expr(N->getRawExpr()),
778 StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()) {}
781 StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
782 AlignInBits(N->getAlignInBits()) {}
779783
780784 bool isKeyOf(const DIGlobalVariable *RHS) const {
781785 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
785789 IsDefinition == RHS->isDefinition() &&
786790 Expr == RHS->getRawExpr() &&
787791 StaticDataMemberDeclaration ==
788 RHS->getRawStaticDataMemberDeclaration();
789 }
790 unsigned getHashValue() const {
792 RHS->getRawStaticDataMemberDeclaration() &&
793 AlignInBits == RHS->getAlignInBits();
794 }
795 unsigned getHashValue() const {
796 // We do not use AlignInBits in hashing function here on purpose:
797 // in most cases this param for local variable is zero (for function param
798 // it is always zero). This leads to lots of hash collisions and errors on
799 // cases with lots of similar variables.
800 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
801 // generated IR is random for each run and test fails with Align included.
802 // TODO: make hashing work fine with such situations
791803 return hash_combine(Scope, Name, LinkageName, File, Line, Type,
792 IsLocalToUnit, IsDefinition, Expr,
804 IsLocalToUnit, IsDefinition, /* AlignInBits, */ Expr,
793805 StaticDataMemberDeclaration);
794806 }
795807 };
802814 Metadata *Type;
803815 unsigned Arg;
804816 unsigned Flags;
817 uint64_t AlignInBits;
805818
806819 MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
807 Metadata *Type, unsigned Arg, unsigned Flags)
820 Metadata *Type, unsigned Arg, unsigned Flags,
821 uint64_t AlignInBits)
808822 : Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
809 Flags(Flags) {}
823 Flags(Flags), AlignInBits(AlignInBits) {}
810824 MDNodeKeyImpl(const DILocalVariable *N)
811825 : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
812826 Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
813 Flags(N->getFlags()) {}
827 Flags(N->getFlags()), AlignInBits(N->getAlignInBits()) {}
814828
815829 bool isKeyOf(const DILocalVariable *RHS) const {
816830 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
817831 File == RHS->getRawFile() && Line == RHS->getLine() &&
818832 Type == RHS->getRawType() && Arg == RHS->getArg() &&
819 Flags == RHS->getFlags();
820 }
821 unsigned getHashValue() const {
833 Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits();
834 }
835 unsigned getHashValue() const {
836 // We do not use AlignInBits in hashing function here on purpose:
837 // in most cases this param for local variable is zero (for function param
838 // it is always zero). This leads to lots of hash collisions and errors on
839 // cases with lots of similar variables.
840 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
841 // generated IR is random for each run and test fails with Align included.
842 // TODO: make hashing work fine with such situations
822843 return hash_combine(Scope, Name, File, Line, Type, Arg, Flags);
823844 }
824845 };
1111 !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
1212 !4 = distinct !{}
1313
14 ; CHECK: !5 = !DIGlobalVariable(name: "foo", linkageName: "foo", scope: !0, file: !2, line: 7, type: !3, isLocal: true, isDefinition: false)
14 ; CHECK: !5 = !DIGlobalVariable(name: "foo", linkageName: "foo", scope: !0, file: !2, line: 7, type: !3, isLocal: true, isDefinition: false, align: 32)
1515 !5 = !DIGlobalVariable(name: "foo", linkageName: "foo", scope: !0,
1616 file: !2, line: 7, type: !3, isLocal: true,
17 isDefinition: false)
17 isDefinition: false, align: 32)
1818
1919 ; CHECK: !6 = !DIGlobalVariable(name: "foo", scope: !0, isLocal: false, isDefinition: true, expr: !7)
2020 ; CHECK: !7 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
1717 !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
1818 !4 = !DILocation(scope: !0)
1919
20 ; CHECK: !5 = !DILocalVariable(name: "foo", arg: 3, scope: !0, file: !2, line: 7, type: !3, flags: DIFlagArtificial)
20 ; CHECK: !5 = !DILocalVariable(name: "foo", arg: 3, scope: !0, file: !2, line: 7, type: !3, flags: DIFlagArtificial, align: 32)
2121 ; CHECK: !6 = !DILocalVariable(name: "foo", scope: !0, file: !2, line: 7, type: !3, flags: DIFlagArtificial)
2222 !5 = !DILocalVariable(name: "foo", arg: 3,
2323 scope: !0, file: !2, line: 7, type: !3,
24 flags: DIFlagArtificial)
24 flags: DIFlagArtificial, align: 32)
2525 !6 = !DILocalVariable(name: "foo", scope: !0,
2626 file: !2, line: 7, type: !3, flags: DIFlagArtificial)
2727
0 ; RUN: llvm-dis -o - %s.bc | FileCheck %s
1
2 ; CHECK: !9 = !DILocalVariable(name: "i", scope: !6, file: !1, line: 3, type: !10)
3 ; CHECK: !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
4
5 source_filename = "test.cpp"
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
8
9 ; Function Attrs: nounwind uwtable
10 define void @_Z1fv() #0 !dbg !6 {
11 entry:
12 %i = alloca i32, align 4
13 call void @llvm.dbg.declare(metadata i32* %i, metadata !10, metadata !12), !dbg !13
14 store i32 42, i32* %i, align 4, !dbg !13
15 ret void, !dbg !14
16 }
17
18 ; Function Attrs: nounwind readnone
19 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
20
21 attributes #0 = { nounwind uwtable }
22 attributes #1 = { nounwind readnone }
23
24 !llvm.dbg.cu = !{!0}
25 !llvm.module.flags = !{!3, !4}
26 !llvm.ident = !{!5}
27
28 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.1 (http://llvm.org/git/clang.git c3709e72d22432f53f8e2f14354def31a96734fe)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
29 !1 = !DIFile(filename: "test.cpp", directory: "/tmp")
30 !2 = !{}
31 !3 = !{i32 2, !"Dwarf Version", i32 4}
32 !4 = !{i32 2, !"Debug Info Version", i32 3}
33 !5 = !{!"clang version 3.9.1 (http://llvm.org/git/clang.git c3709e72d22432f53f8e2f14354def31a96734fe)"}
34 !6 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !7, file: !7, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
35 !7 = !DIFile(filename: "test.cpp", directory: "/tmp")
36 !8 = !DISubroutineType(types: !9)
37 !9 = !{null}
38 !10 = !DILocalVariable(name: "i", scope: !6, file: !7, line: 3, type: !11)
39 !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
40 !12 = !DIExpression()
41 !13 = !DILocation(line: 3, column: 7, scope: !6)
42 !14 = !DILocation(line: 4, column: 1, scope: !6)
5959 !3 = !{!4}
6060 !4 = !DIGlobalVariable(name: "b", scope: !0, file: !5, line: 8, type: !6, isLocal: false, isDefinition: true)
6161 !5 = !DIFile(filename: "bitfields.c", directory: "/")
62 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "bitfield", file: !5, line: 1, size: 96, align: 32, elements: !7)
62 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "bitfield", file: !5, line: 1, size: 96, elements: !7)
6363 !7 = !{!8, !10, !11, !12}
64 !8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !5, line: 2, baseType: !9, size: 2, align: 32)
65 !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
66 !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !5, line: 3, baseType: !9, size: 32, align: 32, offset: 32)
67 !11 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !6, file: !5, line: 4, baseType: !9, size: 1, align: 32, offset: 64)
68 !12 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !5, line: 5, baseType: !9, size: 28, align: 32, offset: 65)
64 !8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !5, line: 2, baseType: !9, size: 2)
65 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
66 !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !5, line: 3, baseType: !9, size: 32, offset: 32)
67 !11 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !6, file: !5, line: 4, baseType: !9, size: 1, offset: 64)
68 !12 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !5, line: 5, baseType: !9, size: 28, offset: 65)
6969 !13 = !{i32 2, !"Dwarf Version", i32 2}
7070 !14 = !{i32 2, !"Debug Info Version", i32 3}
7171 !15 = !{i32 1, !"PIC Level", i32 2}
2222 !2 = !{}
2323 !3 = !{!4}
2424 !4 = distinct !DIGlobalVariable(name: "s", scope: !0, file: !1, line: 6, type: !5, isLocal: false, isDefinition: true)
25 !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 1, size: 32, align: 32, elements: !6)
25 !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 1, size: 32, elements: !6)
2626 !6 = !{!7, !9, !10, !11}
2727 ; CHECK: DW_TAG_member
2828 ; CHECK-NEXT: DW_AT_name{{.*}}"j"
2929 ; CHECK-NOT: DW_TAG
3030 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x00)
31 !7 = !DIDerivedType(tag: DW_TAG_member, name: "j", scope: !5, file: !1, line: 2, baseType: !8, size: 5, align: 32)
32 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
31 !7 = !DIDerivedType(tag: DW_TAG_member, name: "j", scope: !5, file: !1, line: 2, baseType: !8, size: 5)
32 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
3333 ; CHECK: DW_TAG_member
3434 ; CHECK-NEXT: DW_AT_name{{.*}}"k"
3535 ; CHECK-NOT: DW_TAG
3636 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x05)
37 !9 = !DIDerivedType(tag: DW_TAG_member, name: "k", scope: !5, file: !1, line: 3, baseType: !8, size: 6, align: 32, offset: 5)
37 !9 = !DIDerivedType(tag: DW_TAG_member, name: "k", scope: !5, file: !1, line: 3, baseType: !8, size: 6, offset: 5)
3838 ; CHECK: DW_TAG_member
3939 ; CHECK-NEXT: DW_AT_name{{.*}}"m"
4040 ; CHECK-NOT: DW_TAG
4141 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x0b)
42 !10 = !DIDerivedType(tag: DW_TAG_member, name: "m", scope: !5, file: !1, line: 4, baseType: !8, size: 5, align: 32, offset: 11)
42 !10 = !DIDerivedType(tag: DW_TAG_member, name: "m", scope: !5, file: !1, line: 4, baseType: !8, size: 5, offset: 11)
4343 ; CHECK: DW_TAG_member
4444 ; CHECK-NEXT: DW_AT_name{{.*}}"n"
4545 ; CHECK-NOT: DW_TAG
4646 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x10)
47 !11 = !DIDerivedType(tag: DW_TAG_member, name: "n", scope: !5, file: !1, line: 5, baseType: !8, size: 8, align: 32, offset: 16)
47 !11 = !DIDerivedType(tag: DW_TAG_member, name: "n", scope: !5, file: !1, line: 5, baseType: !8, size: 8, offset: 16)
4848 !12 = !{i32 2, !"Dwarf Version", i32 4}
4949 !13 = !{i32 2, !"Debug Info Version", i32 3}
5050 !14 = !{i32 1, !"PIC Level", i32 2}
194194 !3 = !{!4, !10, !29}
195195 !4 = distinct !DIGlobalVariable(name: "s0", scope: !0, file: !5, line: 7, type: !6, isLocal: false, isDefinition: true)
196196 !5 = !DIFile(filename: "", directory: "/usr/local/google/home/majnemer/llvm/src")
197 !6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !5, line: 3, size: 24, align: 8, elements: !7)
197 !6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !5, line: 3, size: 24, elements: !7)
198198 !7 = !{!8}
199 !8 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !6, file: !5, line: 6, baseType: !9, size: 8, align: 16, offset: 16, flags: DIFlagBitField, extraData: i64 8)
200 !9 = !DIBasicType(name: "short", size: 16, align: 16, encoding: DW_ATE_signed)
199 !8 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !6, file: !5, line: 6, baseType: !9, size: 8, offset: 16, flags: DIFlagBitField, extraData: i64 8)
200 !9 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
201201 !10 = distinct !DIGlobalVariable(name: "s1", scope: !0, file: !5, line: 18, type: !11, isLocal: false, isDefinition: true)
202 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S1", file: !5, line: 10, size: 128, align: 8, elements: !12)
202 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S1", file: !5, line: 10, size: 128, elements: !12)
203203 !12 = !{!13, !18, !19, !21, !22, !23, !28}
204 !13 = !DIDerivedType(tag: DW_TAG_member, name: "x1", scope: !11, file: !5, line: 11, baseType: !14, size: 16, align: 8)
205 !14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !15, size: 16, align: 8, elements: !16)
206 !15 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
204 !13 = !DIDerivedType(tag: DW_TAG_member, name: "x1", scope: !11, file: !5, line: 11, baseType: !14, size: 16)
205 !14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !15, size: 16, elements: !16)
206 !15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
207207 !16 = !{!17}
208208 !17 = !DISubrange(count: 2)
209 !18 = !DIDerivedType(tag: DW_TAG_member, name: "x2", scope: !11, file: !5, line: 12, baseType: !15, size: 8, align: 8, offset: 16)
210 !19 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !5, line: 13, baseType: !20, size: 23, align: 32, offset: 24, flags: DIFlagBitField, extraData: i64 24)
211 !20 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
212 !21 = !DIDerivedType(tag: DW_TAG_member, name: "z", scope: !11, file: !5, line: 14, baseType: !20, size: 23, align: 32, offset: 56, flags: DIFlagBitField, extraData: i64 56)
213 !22 = !DIDerivedType(tag: DW_TAG_member, name: "w", scope: !11, file: !5, line: 15, baseType: !20, size: 2, align: 32, offset: 79, flags: DIFlagBitField, extraData: i64 56)
214 !23 = !DIDerivedType(tag: DW_TAG_member, name: "v", scope: !11, file: !5, line: 16, baseType: !24, size: 24, align: 8, offset: 88)
215 !24 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !11, file: !5, line: 16, size: 24, align: 8, elements: !25)
209 !18 = !DIDerivedType(tag: DW_TAG_member, name: "x2", scope: !11, file: !5, line: 12, baseType: !15, size: 8, offset: 16)
210 !19 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !5, line: 13, baseType: !20, size: 23, offset: 24, flags: DIFlagBitField, extraData: i64 24)
211 !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
212 !21 = !DIDerivedType(tag: DW_TAG_member, name: "z", scope: !11, file: !5, line: 14, baseType: !20, size: 23, offset: 56, flags: DIFlagBitField, extraData: i64 56)
213 !22 = !DIDerivedType(tag: DW_TAG_member, name: "w", scope: !11, file: !5, line: 15, baseType: !20, size: 2, offset: 79, flags: DIFlagBitField, extraData: i64 56)
214 !23 = !DIDerivedType(tag: DW_TAG_member, name: "v", scope: !11, file: !5, line: 16, baseType: !24, size: 24, offset: 88)
215 !24 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !11, file: !5, line: 16, size: 24, elements: !25)
216216 !25 = !{!26, !27}
217 !26 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !24, file: !5, line: 16, baseType: !15, size: 8, align: 8)
218 !27 = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: !24, file: !5, line: 16, baseType: !9, size: 16, align: 16, offset: 8)
219 !28 = !DIDerivedType(tag: DW_TAG_member, name: "u", scope: !11, file: !5, line: 17, baseType: !9, size: 3, align: 16, offset: 112, flags: DIFlagBitField, extraData: i64 112)
217 !26 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !24, file: !5, line: 16, baseType: !15, size: 8)
218 !27 = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: !24, file: !5, line: 16, baseType: !9, size: 16, offset: 8)
219 !28 = !DIDerivedType(tag: DW_TAG_member, name: "u", scope: !11, file: !5, line: 17, baseType: !9, size: 3, offset: 112, flags: DIFlagBitField, extraData: i64 112)
220220 !29 = distinct !DIGlobalVariable(name: "s2", scope: !0, file: !5, line: 24, type: !30, isLocal: false, isDefinition: true)
221 !30 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S2", file: !5, line: 21, size: 32, align: 8, elements: !31)
221 !30 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S2", file: !5, line: 21, size: 32, elements: !31)
222222 !31 = !{!32}
223 !32 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !30, file: !5, line: 23, baseType: !20, size: 1, align: 32, flags: DIFlagBitField, extraData: i64 0)
223 !32 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !30, file: !5, line: 23, baseType: !20, size: 1, flags: DIFlagBitField, extraData: i64 0)
224224 !33 = !{i32 2, !"CodeView", i32 1}
225225 !34 = !{i32 2, !"Debug Info Version", i32 3}
226226 !35 = !{i32 1, !"PIC Level", i32 2}
3131 !2 = !{}
3232 !3 = !{!4}
3333 !4 = distinct !DIGlobalVariable(name: "s", scope: !0, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true)
34 !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "PackedBits", file: !1, line: 3, size: 40, align: 8, elements: !6)
34 !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "PackedBits", file: !1, line: 3, size: 40, elements: !6)
3535 !6 = !{!7, !9, !13}
3636
3737 ; CHECK: DW_TAG_member
4040 ; CHECK-NOT: DW_AT_bit_offset
4141 ; CHECK-NOT: DW_AT_data_bit_offset
4242 ; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
43 !7 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !5, file: !1, line: 5, baseType: !8, size: 8, align: 8)
43 !7 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !5, file: !1, line: 5, baseType: !8, size: 8)
4444
45 !8 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
45 !8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
4646
4747 ; CHECK: DW_TAG_member
4848 ; CHECK-NEXT: DW_AT_name{{.*}}"b"
5353 ; CHECK-NOT: DW_AT_byte_size
5454 ; CHECK-NEXT: DW_AT_data_bit_offset [DW_FORM_data1] (0x08)
5555 ; CHECK-NOT: DW_AT_data_member_location
56 !9 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !1, line: 6, baseType: !10, size: 5, align: 32, offset: 8)
56 !9 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !1, line: 6, baseType: !10, size: 5, offset: 8)
5757
5858 !10 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !11, line: 183, baseType: !12)
5959 !11 = !DIFile(filename: "/Volumes/Data/llvm/_build.ninja.release/bin/../lib/clang/3.9.0/include/stdint.h", directory: "/Volumes/Data/llvm")
60 !12 = !DIBasicType(name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
60 !12 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
6161
6262 ; CHECK: DW_TAG_member
6363 ; CHECK-NEXT: DW_AT_name{{.*}}"c"
6868 ; CHECK-NEXT: DW_AT_data_bit_offset [DW_FORM_data1] (0x0d)
6969 ; CHECK-NOT: DW_AT_data_member_location
7070 ; CHECK: DW_TAG
71 !13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !1, line: 7, baseType: !10, size: 27, align: 32, offset: 13)
71 !13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !1, line: 7, baseType: !10, size: 27, offset: 13)
7272
7373 !14 = !{i32 2, !"Dwarf Version", i32 4}
7474 !15 = !{i32 2, !"Debug Info Version", i32 3}
5959 !3 = !{!4}
6060 !4 = !DIGlobalVariable(name: "b", scope: !0, file: !5, line: 8, type: !6, isLocal: false, isDefinition: true)
6161 !5 = !DIFile(filename: "bitfields.c", directory: "/")
62 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "bitfield", file: !5, line: 1, size: 96, align: 32, elements: !7)
62 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "bitfield", file: !5, line: 1, size: 96, elements: !7)
6363 !7 = !{!8, !10, !11, !12}
64 !8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !5, line: 2, baseType: !9, size: 2, align: 32)
65 !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
66 !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !5, line: 3, baseType: !9, size: 32, align: 32, offset: 32)
67 !11 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !6, file: !5, line: 4, baseType: !9, size: 1, align: 32, offset: 64)
68 !12 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !5, line: 5, baseType: !9, size: 28, align: 32, offset: 65)
64 !8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !5, line: 2, baseType: !9, size: 2)
65 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
66 !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !5, line: 3, baseType: !9, size: 32, offset: 32)
67 !11 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !6, file: !5, line: 4, baseType: !9, size: 1, offset: 64)
68 !12 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !5, line: 5, baseType: !9, size: 28, offset: 65)
6969 !13 = !{i32 2, !"Dwarf Version", i32 2}
7070 !14 = !{i32 2, !"Debug Info Version", i32 3}
7171 !15 = !{i32 1, !"PIC Level", i32 2}
153153 !3 = !{!4, !18, !25, !35}
154154 !4 = !DIGlobalVariable(name: "l0", scope: !0, file: !5, line: 88, type: !6, isLocal: false, isDefinition: true)
155155 !5 = !DIFile(filename: "/llvm/tools/clang/test/CodeGen/debug-info-packed-struct.c", directory: "/llvm/_build.ninja.release")
156 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout0", file: !5, line: 15, size: 192, align: 64, elements: !7)
156 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout0", file: !5, line: 15, size: 192, elements: !7)
157157 !7 = !{!8, !10, !17}
158 !8 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs0", scope: !6, file: !5, line: 16, baseType: !9, size: 8, align: 8)
159 !9 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
160 !10 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs8", scope: !6, file: !5, line: 17, baseType: !11, size: 64, align: 64, offset: 64)
161 !11 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8", file: !5, line: 11, size: 64, align: 64, elements: !12)
158 !8 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs0", scope: !6, file: !5, line: 16, baseType: !9, size: 8)
159 !9 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
160 !10 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs8", scope: !6, file: !5, line: 17, baseType: !11, size: 64, offset: 64)
161 !11 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8", file: !5, line: 11, size: 64, elements: !12)
162162 !12 = !{!13, !15}
163 !13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !11, file: !5, line: 12, baseType: !14, size: 4, align: 32)
164 !14 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
163 !13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !11, file: !5, line: 12, baseType: !14, size: 4)
164 !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
165165 !15 = !DIDerivedType(tag: DW_TAG_member, name: "l", scope: !11, file: !5, line: 13, baseType: !16, size: 60, offset: 4)
166 !16 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed)
167 !17 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs16", scope: !6, file: !5, line: 18, baseType: !14, size: 1, align: 32, offset: 128)
166 !16 = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed)
167 !17 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs16", scope: !6, file: !5, line: 18, baseType: !14, size: 1, offset: 128)
168168 !18 = !DIGlobalVariable(name: "l1", scope: !0, file: !5, line: 89, type: !19, isLocal: false, isDefinition: true)
169 !19 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout1", file: !5, line: 34, size: 96, align: 32, elements: !20)
169 !19 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout1", file: !5, line: 34, size: 96, elements: !20)
170170 !20 = !{!21, !22, !24}
171 !21 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs0", scope: !19, file: !5, line: 35, baseType: !9, size: 8, align: 8)
172 !22 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs1", scope: !19, file: !5, line: 36, baseType: !23, size: 64, align: 8, offset: 8)
173 !23 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_anon", file: !5, line: 30, size: 64, align: 8, elements: !2)
174 !24 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs9", scope: !19, file: !5, line: 37, baseType: !14, size: 1, align: 32, offset: 72)
171 !21 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs0", scope: !19, file: !5, line: 35, baseType: !9, size: 8)
172 !22 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs1", scope: !19, file: !5, line: 36, baseType: !23, size: 64, offset: 8)
173 !23 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_anon", file: !5, line: 30, size: 64, elements: !2)
174 !24 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs9", scope: !19, file: !5, line: 37, baseType: !14, size: 1, offset: 72)
175175 !25 = !DIGlobalVariable(name: "l2", scope: !0, file: !5, line: 90, type: !26, isLocal: false, isDefinition: true)
176 !26 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout2", file: !5, line: 54, size: 80, align: 8, elements: !27)
176 !26 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout2", file: !5, line: 54, size: 80, elements: !27)
177177 !27 = !{!28, !29, !34}
178 !28 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs0", scope: !26, file: !5, line: 55, baseType: !9, size: 8, align: 8)
179 !29 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1", scope: !26, file: !5, line: 56, baseType: !30, size: 64, align: 8, offset: 8)
180 !30 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_pack1", file: !5, line: 50, size: 64, align: 8, elements: !31)
178 !28 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs0", scope: !26, file: !5, line: 55, baseType: !9, size: 8)
179 !29 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1", scope: !26, file: !5, line: 56, baseType: !30, size: 64, offset: 8)
180 !30 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_pack1", file: !5, line: 50, size: 64, elements: !31)
181181 !31 = !{!32, !33}
182 !32 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !30, file: !5, line: 51, baseType: !14, size: 4, align: 32)
182 !32 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !30, file: !5, line: 51, baseType: !14, size: 4)
183183 !33 = !DIDerivedType(tag: DW_TAG_member, name: "l", scope: !30, file: !5, line: 52, baseType: !16, size: 60, offset: 4)
184 !34 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9", scope: !26, file: !5, line: 57, baseType: !14, size: 1, align: 32, offset: 72)
184 !34 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9", scope: !26, file: !5, line: 57, baseType: !14, size: 1, offset: 72)
185185 !35 = !DIGlobalVariable(name: "l3", scope: !0, file: !5, line: 91, type: !36, isLocal: false, isDefinition: true)
186 !36 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout3", file: !5, line: 76, size: 128, align: 32, elements: !37)
186 !36 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout3", file: !5, line: 76, size: 128, elements: !37)
187187 !37 = !{!38, !39, !44}
188 !38 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs0", scope: !36, file: !5, line: 77, baseType: !9, size: 8, align: 8)
189 !39 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4", scope: !36, file: !5, line: 78, baseType: !40, size: 64, align: 32, offset: 32)
190 !40 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_pack4", file: !5, line: 72, size: 64, align: 32, elements: !41)
188 !38 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs0", scope: !36, file: !5, line: 77, baseType: !9, size: 8)
189 !39 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4", scope: !36, file: !5, line: 78, baseType: !40, size: 64, offset: 32)
190 !40 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_pack4", file: !5, line: 72, size: 64, elements: !41)
191191 !41 = !{!42, !43}
192 !42 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !40, file: !5, line: 73, baseType: !14, size: 4, align: 32)
192 !42 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !40, file: !5, line: 73, baseType: !14, size: 4)
193193 !43 = !DIDerivedType(tag: DW_TAG_member, name: "l", scope: !40, file: !5, line: 74, baseType: !16, size: 60, offset: 4)
194 !44 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12", scope: !36, file: !5, line: 79, baseType: !14, size: 1, align: 32, offset: 96)
194 !44 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12", scope: !36, file: !5, line: 79, baseType: !14, size: 1, offset: 96)
195195 !45 = !{i32 2, !"Dwarf Version", i32 2}
196196 !46 = !{i32 2, !"Debug Info Version", i32 3}
197197 !47 = !{!"clang version 3.7.0 (trunk 240791) (llvm/trunk 240790)"}
18231823 auto *Expr2 = DIExpression::get(Context, {1, 2, 3});
18241824 DIDerivedType *StaticDataMemberDeclaration =
18251825 cast(getDerivedType());
1826 uint64_t AlignInBits = 8;
18261827
18271828 auto *N = DIGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
18281829 Type, IsLocalToUnit, IsDefinition,
1829 Expr, StaticDataMemberDeclaration);
1830 Expr, StaticDataMemberDeclaration,
1831 AlignInBits);
18301832 EXPECT_EQ(dwarf::DW_TAG_variable, N->getTag());
18311833 EXPECT_EQ(Scope, N->getScope());
18321834 EXPECT_EQ(Name, N->getName());
18381840 EXPECT_EQ(IsDefinition, N->isDefinition());
18391841 EXPECT_EQ(Expr, N->getExpr());
18401842 EXPECT_EQ(StaticDataMemberDeclaration, N->getStaticDataMemberDeclaration());
1843 EXPECT_EQ(AlignInBits, N->getAlignInBits());
18411844 EXPECT_EQ(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
18421845 Line, Type, IsLocalToUnit, IsDefinition,
1843 Expr, StaticDataMemberDeclaration));
1846 Expr, StaticDataMemberDeclaration,
1847 AlignInBits));
18441848
18451849 EXPECT_NE(N,
18461850 DIGlobalVariable::get(Context, getSubprogram(), Name, LinkageName,
18471851 File, Line, Type, IsLocalToUnit, IsDefinition,
1848 Expr, StaticDataMemberDeclaration));
1852 Expr, StaticDataMemberDeclaration,
1853 AlignInBits));
18491854 EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, "other", LinkageName, File,
18501855 Line, Type, IsLocalToUnit, IsDefinition,
1851 Expr, StaticDataMemberDeclaration));
1856 Expr, StaticDataMemberDeclaration,
1857 AlignInBits));
18521858 EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, "other", File, Line,
18531859 Type, IsLocalToUnit, IsDefinition, Expr,
1854 StaticDataMemberDeclaration));
1860 StaticDataMemberDeclaration,
1861 AlignInBits));
18551862 EXPECT_NE(N,
18561863 DIGlobalVariable::get(Context, Scope, Name, LinkageName, getFile(),
18571864 Line, Type, IsLocalToUnit, IsDefinition, Expr,
1858 StaticDataMemberDeclaration));
1865 StaticDataMemberDeclaration,
1866 AlignInBits));
18591867 EXPECT_NE(N,
18601868 DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
18611869 Line + 1, Type, IsLocalToUnit, IsDefinition,
1862 Expr, StaticDataMemberDeclaration));
1870 Expr, StaticDataMemberDeclaration,
1871 AlignInBits));
18631872 EXPECT_NE(N,
18641873 DIGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
18651874 getDerivedType(), IsLocalToUnit, IsDefinition,
1866 Expr, StaticDataMemberDeclaration));
1875 Expr, StaticDataMemberDeclaration,
1876 AlignInBits));
18671877 EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
18681878 Line, Type, !IsLocalToUnit, IsDefinition,
1869 Expr, StaticDataMemberDeclaration));
1879 Expr, StaticDataMemberDeclaration,
1880 AlignInBits));
18701881 EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
18711882 Line, Type, IsLocalToUnit, !IsDefinition,
1872 Expr, StaticDataMemberDeclaration));
1883 Expr, StaticDataMemberDeclaration,
1884 AlignInBits));
18731885 EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
18741886 Line, Type, IsLocalToUnit, IsDefinition,
1875 Expr2, StaticDataMemberDeclaration));
1887 Expr2, StaticDataMemberDeclaration,
1888 AlignInBits));
18761889 EXPECT_NE(N,
18771890 DIGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
18781891 Type, IsLocalToUnit, IsDefinition, Expr,
1879 cast(getDerivedType())));
1892 cast(getDerivedType()),
1893 AlignInBits));
1894 EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
1895 Line, Type, IsLocalToUnit, IsDefinition,
1896 Expr, StaticDataMemberDeclaration,
1897 (AlignInBits << 1)));
18801898
18811899 TempDIGlobalVariable Temp = N->clone();
18821900 EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
18921910 DIType *Type = getDerivedType();
18931911 unsigned Arg = 6;
18941912 DINode::DIFlags Flags = static_cast(7);
1913 uint64_t AlignInBits = 8;
18951914
18961915 auto *N =
1897 DILocalVariable::get(Context, Scope, Name, File, Line, Type, Arg, Flags);
1916 DILocalVariable::get(Context, Scope, Name, File, Line, Type, Arg, Flags,
1917 AlignInBits);
18981918 EXPECT_TRUE(N->isParameter());
18991919 EXPECT_EQ(Scope, N->getScope());
19001920 EXPECT_EQ(Name, N->getName());
19031923 EXPECT_EQ(Type, N->getType());
19041924 EXPECT_EQ(Arg, N->getArg());
19051925 EXPECT_EQ(Flags, N->getFlags());
1926 EXPECT_EQ(AlignInBits, N->getAlignInBits());
19061927 EXPECT_EQ(N, DILocalVariable::get(Context, Scope, Name, File, Line, Type, Arg,
1907 Flags));
1928 Flags, AlignInBits));
19081929
19091930 EXPECT_FALSE(
1910 DILocalVariable::get(Context, Scope, Name, File, Line, Type, 0, Flags)
1911 ->isParameter());
1931 DILocalVariable::get(Context, Scope, Name, File, Line, Type, 0, Flags,
1932 AlignInBits)->isParameter());
19121933 EXPECT_NE(N, DILocalVariable::get(Context, getSubprogram(), Name, File, Line,
1913 Type, Arg, Flags));
1934 Type, Arg, Flags, AlignInBits));
19141935 EXPECT_NE(N, DILocalVariable::get(Context, Scope, "other", File, Line, Type,
1915 Arg, Flags));
1936 Arg, Flags, AlignInBits));
19161937 EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, getFile(), Line, Type,
1917 Arg, Flags));
1938 Arg, Flags, AlignInBits));
19181939 EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line + 1, Type,
1919 Arg, Flags));
1940 Arg, Flags, AlignInBits));
19201941 EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line,
1921 getDerivedType(), Arg, Flags));
1942 getDerivedType(), Arg, Flags, AlignInBits));
19221943 EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line, Type,
1923 Arg + 1, Flags));
1944 Arg + 1, Flags, AlignInBits));
1945 EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line, Type,
1946 Arg, Flags, (AlignInBits << 1)));
19241947
19251948 TempDILocalVariable Temp = N->clone();
19261949 EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
19281951
19291952 TEST_F(DILocalVariableTest, getArg256) {
19301953 EXPECT_EQ(255u, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
1931 0, nullptr, 255, DINode::FlagZero)
1954 0, nullptr, 255, DINode::FlagZero, 0)
19321955 ->getArg());
19331956 EXPECT_EQ(256u, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
1934 0, nullptr, 256, DINode::FlagZero)
1957 0, nullptr, 256, DINode::FlagZero, 0)
19351958 ->getArg());
19361959 EXPECT_EQ(257u, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
1937 0, nullptr, 257, DINode::FlagZero)
1960 0, nullptr, 257, DINode::FlagZero, 0)
19381961 ->getArg());
19391962 unsigned Max = UINT16_MAX;
19401963 EXPECT_EQ(Max, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
1941 0, nullptr, Max, DINode::FlagZero)
1964 0, nullptr, Max, DINode::FlagZero, 0)
19421965 ->getArg());
19431966 }
19441967
252252 Instruction* Terminator = IBuilder.CreateRetVoid();
253253
254254 // Create a local variable around the alloca
255 auto *IntType =
256 DBuilder.createBasicType("int", 32, 0, dwarf::DW_ATE_signed);
255 auto *IntType = DBuilder.createBasicType("int", 32, dwarf::DW_ATE_signed);
257256 auto *E = DBuilder.createExpression();
258257 auto *Variable =
259258 DBuilder.createAutoVariable(Subprogram, "x", File, 5, IntType, true);