@@ -549,7 +549,8 @@ class DIType : public DIScope {
549549
550550 unsigned getLine () const { return Line; }
551551 uint64_t getSizeInBits () const { return SizeInBits; }
552- uint64_t getAlignInBits () const { return AlignInBits; }
552+ uint32_t getAlignInBits () const { return AlignInBits; }
553+ uint32_t getAlignInBytes () const { return getAlignInBits () / CHAR_BIT; }
553554 uint64_t getOffsetInBits () const { return OffsetInBits; }
554555 DIFlags getFlags () const { return Flags; }
555556
@@ -1826,11 +1827,13 @@ class DITemplateValueParameter : public DITemplateParameter {
18261827// / \brief Base class for variables.
18271828class DIVariable : public DINode {
18281829 unsigned Line;
1830+ uint64_t AlignInBits;
18291831
18301832protected:
18311833 DIVariable (LLVMContext &C, unsigned ID, StorageType Storage, unsigned Line,
1832- ArrayRef<Metadata *> Ops)
1833- : DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line) {}
1834+ ArrayRef<Metadata *> Ops, uint64_t AlignInBits = 0 )
1835+ : DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line),
1836+ AlignInBits (AlignInBits) {}
18341837 ~DIVariable () = default ;
18351838
18361839public:
@@ -1839,6 +1842,8 @@ class DIVariable : public DINode {
18391842 StringRef getName () const { return getStringOperand (1 ); }
18401843 DIFile *getFile () const { return cast_or_null<DIFile>(getRawFile ()); }
18411844 DITypeRef getType () const { return DITypeRef (getRawType ()); }
1845+ uint64_t getAlignInBits () const { return AlignInBits; }
1846+ uint64_t getAlignInBytes () const { return getAlignInBits () / CHAR_BIT; }
18421847
18431848 StringRef getFilename () const {
18441849 if (auto *F = getFile ())
@@ -2026,52 +2031,58 @@ class DIGlobalVariable : public DIVariable {
20262031 bool IsDefinition;
20272032
20282033 DIGlobalVariable (LLVMContext &C, StorageType Storage, unsigned Line,
2029- bool IsLocalToUnit, bool IsDefinition,
2034+ bool IsLocalToUnit, bool IsDefinition, uint64_t AlignInBits,
20302035 ArrayRef<Metadata *> Ops)
2031- : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops),
2036+ : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits ),
20322037 IsLocalToUnit (IsLocalToUnit), IsDefinition(IsDefinition) {}
20332038 ~DIGlobalVariable () = default ;
20342039
20352040 static DIGlobalVariable *
20362041 getImpl (LLVMContext &Context, DIScope *Scope, StringRef Name,
20372042 StringRef LinkageName, DIFile *File, unsigned Line, DITypeRef Type,
20382043 bool IsLocalToUnit, bool IsDefinition, DIExpression *Expr,
2039- DIDerivedType *StaticDataMemberDeclaration, StorageType Storage ,
2040- bool ShouldCreate = true ) {
2044+ DIDerivedType *StaticDataMemberDeclaration, uint64_t AlignInBits ,
2045+ StorageType Storage, bool ShouldCreate = true ) {
20412046 return getImpl (Context, Scope, getCanonicalMDString (Context, Name),
20422047 getCanonicalMDString (Context, LinkageName), File, Line, Type,
20432048 IsLocalToUnit, IsDefinition, Expr,
2044- StaticDataMemberDeclaration, Storage, ShouldCreate);
2049+ StaticDataMemberDeclaration, AlignInBits, Storage,
2050+ ShouldCreate);
20452051 }
20462052 static DIGlobalVariable *
20472053 getImpl (LLVMContext &Context, Metadata *Scope, MDString *Name,
20482054 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
20492055 bool IsLocalToUnit, bool IsDefinition, Metadata *Expr,
2050- Metadata *StaticDataMemberDeclaration, StorageType Storage ,
2051- bool ShouldCreate = true );
2056+ Metadata *StaticDataMemberDeclaration, uint64_t AlignInBits ,
2057+ StorageType Storage, bool ShouldCreate = true );
20522058
20532059 TempDIGlobalVariable cloneImpl () const {
20542060 return getTemporary (getContext (), getScope (), getName (), getLinkageName (),
20552061 getFile (), getLine (), getType (), isLocalToUnit (),
20562062 isDefinition (), getExpr (),
2057- getStaticDataMemberDeclaration ());
2063+ getStaticDataMemberDeclaration (), getAlignInBits () );
20582064 }
20592065
20602066public:
20612067 DEFINE_MDNODE_GET (DIGlobalVariable,
20622068 (DIScope * Scope, StringRef Name, StringRef LinkageName,
20632069 DIFile *File, unsigned Line, DITypeRef Type,
2064- bool IsLocalToUnit, bool IsDefinition, DIExpression *Expr,
2065- DIDerivedType *StaticDataMemberDeclaration),
2070+ bool IsLocalToUnit, bool IsDefinition,
2071+ DIExpression *Expr,
2072+ DIDerivedType *StaticDataMemberDeclaration,
2073+ uint64_t AlignInBits),
20662074 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2067- IsDefinition, Expr, StaticDataMemberDeclaration))
2075+ IsDefinition, Expr, StaticDataMemberDeclaration,
2076+ AlignInBits))
20682077 DEFINE_MDNODE_GET(DIGlobalVariable,
20692078 (Metadata * Scope, MDString *Name, MDString *LinkageName,
20702079 Metadata *File, unsigned Line, Metadata *Type,
2071- bool IsLocalToUnit, bool IsDefinition, Metadata *Expr,
2072- Metadata *StaticDataMemberDeclaration),
2080+ bool IsLocalToUnit, bool IsDefinition,
2081+ Metadata *Expr, Metadata *StaticDataMemberDeclaration,
2082+ uint64_t AlignInBits),
20732083 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2074- IsDefinition, Expr, StaticDataMemberDeclaration))
2084+ IsDefinition, Expr, StaticDataMemberDeclaration,
2085+ AlignInBits))
20752086
20762087 TempDIGlobalVariable clone() const { return cloneImpl (); }
20772088
@@ -2109,43 +2120,45 @@ class DILocalVariable : public DIVariable {
21092120 DIFlags Flags;
21102121
21112122 DILocalVariable (LLVMContext &C, StorageType Storage, unsigned Line,
2112- unsigned Arg, DIFlags Flags, ArrayRef<Metadata *> Ops)
2113- : DIVariable(C, DILocalVariableKind, Storage, Line, Ops), Arg(Arg),
2114- Flags (Flags) {
2123+ unsigned Arg, DIFlags Flags, uint64_t AlignInBits,
2124+ ArrayRef<Metadata *> Ops)
2125+ : DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
2126+ Arg (Arg), Flags(Flags) {
21152127 assert (Arg < (1 << 16 ) && " DILocalVariable: Arg out of range" );
21162128 }
21172129 ~DILocalVariable () = default ;
21182130
21192131 static DILocalVariable *getImpl (LLVMContext &Context, DIScope *Scope,
21202132 StringRef Name, DIFile *File, unsigned Line,
21212133 DITypeRef Type, unsigned Arg, DIFlags Flags,
2122- StorageType Storage,
2134+ uint64_t AlignInBits, StorageType Storage,
21232135 bool ShouldCreate = true ) {
21242136 return getImpl (Context, Scope, getCanonicalMDString (Context, Name), File,
2125- Line, Type, Arg, Flags, Storage, ShouldCreate);
2137+ Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
21262138 }
21272139 static DILocalVariable *getImpl (LLVMContext &Context, Metadata *Scope,
21282140 MDString *Name, Metadata *File, unsigned Line,
21292141 Metadata *Type, unsigned Arg, DIFlags Flags,
2130- StorageType Storage,
2142+ uint64_t AlignInBits, StorageType Storage,
21312143 bool ShouldCreate = true );
21322144
21332145 TempDILocalVariable cloneImpl () const {
21342146 return getTemporary (getContext (), getScope (), getName (), getFile (),
2135- getLine (), getType (), getArg (), getFlags ());
2147+ getLine (), getType (), getArg (), getFlags (),
2148+ getAlignInBits ());
21362149 }
21372150
21382151public:
21392152 DEFINE_MDNODE_GET (DILocalVariable,
21402153 (DILocalScope * Scope, StringRef Name, DIFile *File,
21412154 unsigned Line, DITypeRef Type, unsigned Arg,
2142- DIFlags Flags),
2143- (Scope, Name, File, Line, Type, Arg, Flags))
2155+ DIFlags Flags, uint64_t AlignInBits ),
2156+ (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits ))
21442157 DEFINE_MDNODE_GET(DILocalVariable,
21452158 (Metadata * Scope, MDString *Name, Metadata *File,
21462159 unsigned Line, Metadata *Type, unsigned Arg,
2147- DIFlags Flags),
2148- (Scope, Name, File, Line, Type, Arg, Flags))
2160+ DIFlags Flags, uint64_t AlignInBits ),
2161+ (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits ))
21492162
21502163 TempDILocalVariable clone() const { return cloneImpl (); }
21512164
0 commit comments