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 llvm-svn: 284678
This commit is contained in:
@@ -2734,7 +2734,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
|
||||
break;
|
||||
}
|
||||
case bitc::METADATA_GLOBAL_VAR: {
|
||||
if (Record.size() != 11)
|
||||
if (Record.size() < 11 || Record.size() > 12)
|
||||
return error("Invalid record");
|
||||
|
||||
IsDistinct = Record[0];
|
||||
@@ -2742,6 +2742,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
|
||||
// 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;
|
||||
GlobalVariable *Attach = nullptr;
|
||||
if (auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(Expr)) {
|
||||
if (auto *GV = dyn_cast<GlobalVariable>(CMD->getValue())) {
|
||||
@@ -2761,7 +2762,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
|
||||
(Context, getMDOrNull(Record[1]), getMDString(Record[2]),
|
||||
getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
|
||||
getDITypeRefOrNull(Record[6]), Record[7], Record[8], Expr,
|
||||
getMDOrNull(Record[10])));
|
||||
getMDOrNull(Record[10]), AlignInBits));
|
||||
MetadataList.assignValue(DGV, NextMetadataNo++);
|
||||
|
||||
if (Attach)
|
||||
@@ -2774,18 +2775,21 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
|
||||
if (Record.size() < 8 || Record.size() > 10)
|
||||
return error("Invalid record");
|
||||
|
||||
IsDistinct = Record[0] & 1;
|
||||
bool HasAlignment = Record[0] & 2;
|
||||
// 2nd field used to be an artificial tag, either DW_TAG_auto_variable or
|
||||
// DW_TAG_arg_variable.
|
||||
IsDistinct = Record[0];
|
||||
bool HasTag = Record.size() > 8;
|
||||
// DW_TAG_arg_variable, if we have alignment flag encoded it means, that
|
||||
// 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;
|
||||
MetadataList.assignValue(
|
||||
GET_OR_DISTINCT(DILocalVariable,
|
||||
(Context, getMDOrNull(Record[1 + HasTag]),
|
||||
getMDString(Record[2 + HasTag]),
|
||||
getMDOrNull(Record[3 + HasTag]), Record[4 + HasTag],
|
||||
getDITypeRefOrNull(Record[5 + HasTag]),
|
||||
Record[6 + HasTag], Flags)),
|
||||
Record[6 + HasTag], Flags, AlignInBits)),
|
||||
NextMetadataNo++);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user