@@ -549,7 +549,8 @@ class DIType : public DIScope {
549
549
550
550
unsigned getLine () const { return Line; }
551
551
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; }
553
554
uint64_t getOffsetInBits () const { return OffsetInBits; }
554
555
DIFlags getFlags () const { return Flags; }
555
556
@@ -1826,11 +1827,13 @@ class DITemplateValueParameter : public DITemplateParameter {
1826
1827
// / \brief Base class for variables.
1827
1828
class DIVariable : public DINode {
1828
1829
unsigned Line;
1830
+ uint64_t AlignInBits;
1829
1831
1830
1832
protected:
1831
1833
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) {}
1834
1837
~DIVariable () = default ;
1835
1838
1836
1839
public:
@@ -1839,6 +1842,8 @@ class DIVariable : public DINode {
1839
1842
StringRef getName () const { return getStringOperand (1 ); }
1840
1843
DIFile *getFile () const { return cast_or_null<DIFile>(getRawFile ()); }
1841
1844
DITypeRef getType () const { return DITypeRef (getRawType ()); }
1845
+ uint64_t getAlignInBits () const { return AlignInBits; }
1846
+ uint64_t getAlignInBytes () const { return getAlignInBits () / CHAR_BIT; }
1842
1847
1843
1848
StringRef getFilename () const {
1844
1849
if (auto *F = getFile ())
@@ -2026,52 +2031,58 @@ class DIGlobalVariable : public DIVariable {
2026
2031
bool IsDefinition;
2027
2032
2028
2033
DIGlobalVariable (LLVMContext &C, StorageType Storage, unsigned Line,
2029
- bool IsLocalToUnit, bool IsDefinition,
2034
+ bool IsLocalToUnit, bool IsDefinition, uint64_t AlignInBits,
2030
2035
ArrayRef<Metadata *> Ops)
2031
- : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops),
2036
+ : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits ),
2032
2037
IsLocalToUnit (IsLocalToUnit), IsDefinition(IsDefinition) {}
2033
2038
~DIGlobalVariable () = default ;
2034
2039
2035
2040
static DIGlobalVariable *
2036
2041
getImpl (LLVMContext &Context, DIScope *Scope, StringRef Name,
2037
2042
StringRef LinkageName, DIFile *File, unsigned Line, DITypeRef Type,
2038
2043
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 ) {
2041
2046
return getImpl (Context, Scope, getCanonicalMDString (Context, Name),
2042
2047
getCanonicalMDString (Context, LinkageName), File, Line, Type,
2043
2048
IsLocalToUnit, IsDefinition, Expr,
2044
- StaticDataMemberDeclaration, Storage, ShouldCreate);
2049
+ StaticDataMemberDeclaration, AlignInBits, Storage,
2050
+ ShouldCreate);
2045
2051
}
2046
2052
static DIGlobalVariable *
2047
2053
getImpl (LLVMContext &Context, Metadata *Scope, MDString *Name,
2048
2054
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
2049
2055
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 );
2052
2058
2053
2059
TempDIGlobalVariable cloneImpl () const {
2054
2060
return getTemporary (getContext (), getScope (), getName (), getLinkageName (),
2055
2061
getFile (), getLine (), getType (), isLocalToUnit (),
2056
2062
isDefinition (), getExpr (),
2057
- getStaticDataMemberDeclaration ());
2063
+ getStaticDataMemberDeclaration (), getAlignInBits () );
2058
2064
}
2059
2065
2060
2066
public:
2061
2067
DEFINE_MDNODE_GET (DIGlobalVariable,
2062
2068
(DIScope * Scope, StringRef Name, StringRef LinkageName,
2063
2069
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),
2066
2074
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2067
- IsDefinition, Expr, StaticDataMemberDeclaration))
2075
+ IsDefinition, Expr, StaticDataMemberDeclaration,
2076
+ AlignInBits))
2068
2077
DEFINE_MDNODE_GET(DIGlobalVariable,
2069
2078
(Metadata * Scope, MDString *Name, MDString *LinkageName,
2070
2079
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),
2073
2083
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2074
- IsDefinition, Expr, StaticDataMemberDeclaration))
2084
+ IsDefinition, Expr, StaticDataMemberDeclaration,
2085
+ AlignInBits))
2075
2086
2076
2087
TempDIGlobalVariable clone() const { return cloneImpl (); }
2077
2088
@@ -2109,43 +2120,45 @@ class DILocalVariable : public DIVariable {
2109
2120
DIFlags Flags;
2110
2121
2111
2122
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) {
2115
2127
assert (Arg < (1 << 16 ) && " DILocalVariable: Arg out of range" );
2116
2128
}
2117
2129
~DILocalVariable () = default ;
2118
2130
2119
2131
static DILocalVariable *getImpl (LLVMContext &Context, DIScope *Scope,
2120
2132
StringRef Name, DIFile *File, unsigned Line,
2121
2133
DITypeRef Type, unsigned Arg, DIFlags Flags,
2122
- StorageType Storage,
2134
+ uint64_t AlignInBits, StorageType Storage,
2123
2135
bool ShouldCreate = true ) {
2124
2136
return getImpl (Context, Scope, getCanonicalMDString (Context, Name), File,
2125
- Line, Type, Arg, Flags, Storage, ShouldCreate);
2137
+ Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
2126
2138
}
2127
2139
static DILocalVariable *getImpl (LLVMContext &Context, Metadata *Scope,
2128
2140
MDString *Name, Metadata *File, unsigned Line,
2129
2141
Metadata *Type, unsigned Arg, DIFlags Flags,
2130
- StorageType Storage,
2142
+ uint64_t AlignInBits, StorageType Storage,
2131
2143
bool ShouldCreate = true );
2132
2144
2133
2145
TempDILocalVariable cloneImpl () const {
2134
2146
return getTemporary (getContext (), getScope (), getName (), getFile (),
2135
- getLine (), getType (), getArg (), getFlags ());
2147
+ getLine (), getType (), getArg (), getFlags (),
2148
+ getAlignInBits ());
2136
2149
}
2137
2150
2138
2151
public:
2139
2152
DEFINE_MDNODE_GET (DILocalVariable,
2140
2153
(DILocalScope * Scope, StringRef Name, DIFile *File,
2141
2154
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 ))
2144
2157
DEFINE_MDNODE_GET(DILocalVariable,
2145
2158
(Metadata * Scope, MDString *Name, Metadata *File,
2146
2159
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 ))
2149
2162
2150
2163
TempDILocalVariable clone() const { return cloneImpl (); }
2151
2164
0 commit comments