[llvm] r285242 - DebugInfo: fix incorrect alignment type (NFC)
Victor Leschuk via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 26 14:32:30 PDT 2016
Author: vleschuk
Date: Wed Oct 26 16:32:29 2016
New Revision: 285242
URL: http://llvm.org/viewvc/llvm-project?rev=285242&view=rev
Log:
DebugInfo: fix incorrect alignment type (NFC)
Change type of some missed DebugInfo-related alignment variables,
that are still uint64_t, to uint32_t.
Original change introduced in r284482.
Modified:
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/lib/IR/DebugInfoMetadata.cpp
llvm/trunk/lib/IR/LLVMContextImpl.h
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=285242&r1=285241&r2=285242&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Wed Oct 26 16:32:29 2016
@@ -1846,11 +1846,11 @@ public:
/// \brief Base class for variables.
class DIVariable : public DINode {
unsigned Line;
- uint64_t AlignInBits;
+ uint32_t AlignInBits;
protected:
DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Line,
- ArrayRef<Metadata *> Ops, uint64_t AlignInBits = 0)
+ ArrayRef<Metadata *> Ops, uint32_t AlignInBits = 0)
: DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line),
AlignInBits(AlignInBits) {}
~DIVariable() = default;
@@ -2050,7 +2050,7 @@ class DIGlobalVariable : public DIVariab
bool IsDefinition;
DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
- bool IsLocalToUnit, bool IsDefinition, uint64_t AlignInBits,
+ bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
ArrayRef<Metadata *> Ops)
: DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
@@ -2060,7 +2060,7 @@ class DIGlobalVariable : public DIVariab
getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
StringRef LinkageName, DIFile *File, unsigned Line, DITypeRef Type,
bool IsLocalToUnit, bool IsDefinition, DIExpression *Expr,
- DIDerivedType *StaticDataMemberDeclaration, uint64_t AlignInBits,
+ DIDerivedType *StaticDataMemberDeclaration, uint32_t AlignInBits,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
getCanonicalMDString(Context, LinkageName), File, Line, Type,
@@ -2072,7 +2072,7 @@ class DIGlobalVariable : public DIVariab
getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition, Metadata *Expr,
- Metadata *StaticDataMemberDeclaration, uint64_t AlignInBits,
+ Metadata *StaticDataMemberDeclaration, uint32_t AlignInBits,
StorageType Storage, bool ShouldCreate = true);
TempDIGlobalVariable cloneImpl() const {
@@ -2089,7 +2089,7 @@ public:
bool IsLocalToUnit, bool IsDefinition,
DIExpression *Expr,
DIDerivedType *StaticDataMemberDeclaration,
- uint64_t AlignInBits),
+ uint32_t AlignInBits),
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
IsDefinition, Expr, StaticDataMemberDeclaration,
AlignInBits))
@@ -2098,7 +2098,7 @@ public:
Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition,
Metadata *Expr, Metadata *StaticDataMemberDeclaration,
- uint64_t AlignInBits),
+ uint32_t AlignInBits),
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
IsDefinition, Expr, StaticDataMemberDeclaration,
AlignInBits))
@@ -2139,7 +2139,7 @@ class DILocalVariable : public DIVariabl
DIFlags Flags;
DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
- unsigned Arg, DIFlags Flags, uint64_t AlignInBits,
+ unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
ArrayRef<Metadata *> Ops)
: DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
Arg(Arg), Flags(Flags) {
@@ -2150,7 +2150,7 @@ class DILocalVariable : public DIVariabl
static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
StringRef Name, DIFile *File, unsigned Line,
DITypeRef Type, unsigned Arg, DIFlags Flags,
- uint64_t AlignInBits, StorageType Storage,
+ uint32_t AlignInBits, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
@@ -2158,7 +2158,7 @@ class DILocalVariable : public DIVariabl
static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, Metadata *File, unsigned Line,
Metadata *Type, unsigned Arg, DIFlags Flags,
- uint64_t AlignInBits, StorageType Storage,
+ uint32_t AlignInBits, StorageType Storage,
bool ShouldCreate = true);
TempDILocalVariable cloneImpl() const {
@@ -2171,12 +2171,12 @@ public:
DEFINE_MDNODE_GET(DILocalVariable,
(DILocalScope * Scope, StringRef Name, DIFile *File,
unsigned Line, DITypeRef Type, unsigned Arg,
- DIFlags Flags, uint64_t AlignInBits),
+ DIFlags Flags, uint32_t AlignInBits),
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
DEFINE_MDNODE_GET(DILocalVariable,
(Metadata * Scope, MDString *Name, Metadata *File,
unsigned Line, Metadata *Type, unsigned Arg,
- DIFlags Flags, uint64_t AlignInBits),
+ DIFlags Flags, uint32_t AlignInBits),
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
TempDILocalVariable clone() const { return cloneImpl(); }
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=285242&r1=285241&r2=285242&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Oct 26 16:32:29 2016
@@ -2742,7 +2742,12 @@ std::error_code BitcodeReader::parseMeta
// Upgrade old metadata, which stored a global variable reference or a
// ConstantInt here.
Metadata *Expr = getMDOrNull(Record[9]);
- uint64_t AlignInBits = (Record.size() > 11) ? Record[11] : 0;
+ uint32_t AlignInBits = 0;
+ if (Record.size() > 11) {
+ if (Record[11] > (uint64_t)std::numeric_limits<uint32_t>::max())
+ return error("Alignment value is too large");
+ AlignInBits = Record[11];
+ }
GlobalVariable *Attach = nullptr;
if (auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(Expr)) {
if (auto *GV = dyn_cast<GlobalVariable>(CMD->getValue())) {
@@ -2782,7 +2787,13 @@ std::error_code BitcodeReader::parseMeta
// this is newer version of record which doesn't have artifical tag.
bool HasTag = !HasAlignment && Record.size() > 8;
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(Record[7 + HasTag]);
- uint64_t AlignInBits = HasAlignment ? Record[8 + HasTag] : 0;
+ uint32_t AlignInBits = 0;
+ if (HasAlignment) {
+ if (Record[8 + HasTag] >
+ (uint64_t)std::numeric_limits<uint32_t>::max())
+ return error("Alignment value is too large");
+ AlignInBits = Record[8 + HasTag];
+ }
MetadataList.assignValue(
GET_OR_DISTINCT(DILocalVariable,
(Context, getMDOrNull(Record[1 + HasTag]),
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=285242&r1=285241&r2=285242&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed Oct 26 16:32:29 2016
@@ -1009,7 +1009,7 @@ void DwarfUnit::constructTypeDIE(DIE &Bu
RLang);
// Add align info if available.
- if (uint64_t AlignInBytes = CTy->getAlignInBytes())
+ if (uint32_t AlignInBytes = CTy->getAlignInBytes())
addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
AlignInBytes);
}
@@ -1399,7 +1399,7 @@ void DwarfUnit::constructMemberDIE(DIE &
} else {
uint64_t Size = DT->getSizeInBits();
uint64_t FieldSize = DD->getBaseTypeSize(DT);
- uint64_t AlignInBytes = DT->getAlignInBytes();
+ uint32_t AlignInBytes = DT->getAlignInBytes();
uint64_t OffsetInBytes;
bool IsBitfield = FieldSize && Size != FieldSize;
@@ -1516,7 +1516,7 @@ DIE *DwarfUnit::getOrCreateStaticMemberD
if (const ConstantFP *CFP = dyn_cast_or_null<ConstantFP>(DT->getConstant()))
addConstantFPValue(StaticMemberDIE, CFP);
- if (uint64_t AlignInBytes = DT->getAlignInBytes())
+ if (uint32_t AlignInBytes = DT->getAlignInBytes())
addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
AlignInBytes);
Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=285242&r1=285241&r2=285242&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Wed Oct 26 16:32:29 2016
@@ -515,7 +515,7 @@ DIGlobalVariable::getImpl(LLVMContext &C
Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
Metadata *Variable,
Metadata *StaticDataMemberDeclaration,
- uint64_t AlignInBits,
+ uint32_t AlignInBits,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(LinkageName) && "Expected canonical MDString");
@@ -534,7 +534,7 @@ DILocalVariable *DILocalVariable::getImp
MDString *Name, Metadata *File,
unsigned Line, Metadata *Type,
unsigned Arg, DIFlags Flags,
- uint64_t AlignInBits,
+ uint32_t AlignInBits,
StorageType Storage,
bool ShouldCreate) {
// 64K ought to be enough for any frontend.
Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=285242&r1=285241&r2=285242&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Wed Oct 26 16:32:29 2016
@@ -761,13 +761,13 @@ template <> struct MDNodeKeyImpl<DIGloba
bool IsDefinition;
Metadata *Expr;
Metadata *StaticDataMemberDeclaration;
- uint64_t AlignInBits;
+ uint32_t AlignInBits;
MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition,
Metadata *Expr, Metadata *StaticDataMemberDeclaration,
- uint64_t AlignInBits)
+ uint32_t AlignInBits)
: Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
IsDefinition(IsDefinition), Expr(Expr),
@@ -815,11 +815,11 @@ template <> struct MDNodeKeyImpl<DILocal
Metadata *Type;
unsigned Arg;
unsigned Flags;
- uint64_t AlignInBits;
+ uint32_t AlignInBits;
MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
Metadata *Type, unsigned Arg, unsigned Flags,
- uint64_t AlignInBits)
+ uint32_t AlignInBits)
: Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
Flags(Flags), AlignInBits(AlignInBits) {}
MDNodeKeyImpl(const DILocalVariable *N)
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=285242&r1=285241&r2=285242&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Wed Oct 26 16:32:29 2016
@@ -1824,7 +1824,7 @@ TEST_F(DIGlobalVariableTest, get) {
auto *Expr2 = DIExpression::get(Context, {1, 2, 3});
DIDerivedType *StaticDataMemberDeclaration =
cast<DIDerivedType>(getDerivedType());
- uint64_t AlignInBits = 8;
+ uint32_t AlignInBits = 8;
auto *N = DIGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition,
@@ -1911,7 +1911,7 @@ TEST_F(DILocalVariableTest, get) {
DIType *Type = getDerivedType();
unsigned Arg = 6;
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
- uint64_t AlignInBits = 8;
+ uint32_t AlignInBits = 8;
auto *N =
DILocalVariable::get(Context, Scope, Name, File, Line, Type, Arg, Flags,
More information about the llvm-commits
mailing list