vleschuk updated this revision to Diff 73537.
vleschuk added a comment.
Pass alignment in bits instead of bytes to backend (conversion is done when
emitting DW_AT_alignment).
https://reviews.llvm.org/D24426
Files:
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h
test/CodeGen/debug-info-packed-struct.c
test/CodeGen/debug-info-vector.c
test/CodeGenCXX/debug-info-calling-conventions.cpp
test/CodeGenCXX/debug-info-enum-class.cpp
test/CodeGenCXX/debug-info-indirect-field-decl.cpp
test/CodeGenCXX/debug-info-ms-bitfields.cpp
test/CodeGenCXX/debug-info-ms-ptr-to-member.cpp
test/CodeGenCXX/debug-info-rvalue-ref.cpp
test/CodeGenCXX/debug-info-template-quals.cpp
test/CodeGenCXX/debug-info-template.cpp
test/CodeGenCXX/debug-info-union.cpp
test/CodeGenCXX/debug-info-uuid.cpp
test/CodeGenCXX/debug-info-vla.cpp
test/CodeGenCXX/debug-info-zero-length-arrays.cpp
test/CodeGenCXX/debug-info.cpp
test/CodeGenCXX/debug-lambda-this.cpp
test/CodeGenObjC/block-byref-debuginfo.m
test/CodeGenObjC/debug-info-block-type.m
test/CodeGenObjC/debug-info-ivars-extension.m
test/CodeGenObjC/debug-info-ivars-private.m
test/CodeGenObjC/debug-info-ivars.m
test/CodeGenObjCXX/debug-info-cyclic.mm
Index: test/CodeGenObjCXX/debug-info-cyclic.mm
===================================================================
--- test/CodeGenObjCXX/debug-info-cyclic.mm
+++ test/CodeGenObjCXX/debug-info-cyclic.mm
@@ -3,7 +3,7 @@
struct B {
// CHECK: ![[B:[0-9]+]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "B"
// CHECK-SAME: line: [[@LINE-2]],
-// CHECK-SAME: size: 8, align: 8,
+// CHECK-SAME: size: 8,
// CHECK-NOT: offset:
// CHECK-NOT: DIFlagFwdDecl
// CHECK-SAME: elements: ![[BMEMBERS:[0-9]+]]
Index: test/CodeGenObjC/debug-info-ivars.m
===================================================================
--- test/CodeGenObjC/debug-info-ivars.m
+++ test/CodeGenObjC/debug-info-ivars.m
@@ -21,24 +21,24 @@
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i"
// CHECK-SAME: line: 10
// CHECK-SAME: baseType: ![[INT:[0-9]+]]
-// CHECK-SAME: size: 32, align: 32,
+// CHECK-SAME: size: 32,
// CHECK-NOT: offset:
// CHECK-SAME: flags: DIFlagProtected
// CHECK: ![[INT]] = !DIBasicType(name: "int"
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_1"
// CHECK-SAME: line: 11
// CHECK-SAME: baseType: ![[UNSIGNED:[0-9]+]]
-// CHECK-SAME: size: 9, align: 32,
+// CHECK-SAME: size: 9,
// CHECK-NOT: offset:
// CHECK-SAME: flags: DIFlagProtected
// CHECK: ![[UNSIGNED]] = !DIBasicType(name: "unsigned int"
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_2"
// CHECK-SAME: line: 12
// CHECK-SAME: baseType: ![[UNSIGNED]]
-// CHECK-SAME: size: 9, align: 32, offset: 1,
+// CHECK-SAME: size: 9, offset: 1,
// CHECK-SAME: flags: DIFlagProtected
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_3"
// CHECK-SAME: line: 14
// CHECK-SAME: baseType: ![[UNSIGNED]]
-// CHECK-SAME: size: 9, align: 32, offset: 3,
+// CHECK-SAME: size: 9, offset: 3,
// CHECK-SAME: flags: DIFlagProtected
Index: test/CodeGenObjC/debug-info-ivars-private.m
===================================================================
--- test/CodeGenObjC/debug-info-ivars-private.m
+++ test/CodeGenObjC/debug-info-ivars-private.m
@@ -35,13 +35,13 @@
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "foo"
// CHECK-SAME: line: 14
// CHECK-SAME: baseType: ![[INT:[0-9]+]]
-// CHECK-SAME: size: 32, align: 32,
+// CHECK-SAME: size: 32,
// CHECK-NOT: offset:
// CHECK-SAME: flags: DIFlagProtected
// CHECK: ![[INT]] = !DIBasicType(name: "int"
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "bar"
// CHECK-SAME: line: 27
// CHECK-SAME: baseType: ![[INT:[0-9]+]]
-// CHECK-SAME: size: 32, align: 32,
+// CHECK-SAME: size: 32,
// CHECK-NOT: offset:
// CHECK-SAME: flags: DIFlagPrivate
Index: test/CodeGenObjC/debug-info-ivars-extension.m
===================================================================
--- test/CodeGenObjC/debug-info-ivars-extension.m
+++ test/CodeGenObjC/debug-info-ivars-extension.m
@@ -30,7 +30,7 @@
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "a"
// CHECK-SAME: line: 7
// CHECK-SAME: baseType: ![[INT:[0-9]+]]
-// CHECK-SAME: size: 32, align: 32
+// CHECK-SAME: size: 32
// CHECK-NOT: offset:
// CHECK-SAME: flags: DIFlagPublic
// CHECK: ![[INT]] = !DIBasicType(name: "int"
@@ -42,6 +42,6 @@
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "b"
// CHECK-SAME: line: 18
// CHECK-SAME: baseType: ![[INT]]
-// CHECK-SAME: size: 32, align: 32
+// CHECK-SAME: size: 32
// CHECK-NOT: offset:
// CHECK-SAME: flags: DIFlagPublic
Index: test/CodeGenObjC/debug-info-block-type.m
===================================================================
--- test/CodeGenObjC/debug-info-block-type.m
+++ test/CodeGenObjC/debug-info-block-type.m
@@ -17,6 +17,6 @@
SomeKindOfPredicate p = ^BOOL(id obj) { return obj != nil; };
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr",
// CHECK-SAME: line: [[@LINE-2]]
- // CHECK-SAME: size: 64, align: 64, offset: 128,
+ // CHECK-SAME: size: 64, offset: 128,
return p(nil);
}
Index: test/CodeGenObjC/block-byref-debuginfo.m
===================================================================
--- test/CodeGenObjC/block-byref-debuginfo.m
+++ test/CodeGenObjC/block-byref-debuginfo.m
@@ -5,7 +5,6 @@
// expression (256) that locates it inside of the byref descriptor:
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "foo",
// CHECK-NOT: line:
-// CHECK-SAME: align: 64
// CHECK-SAME: offset: 256
struct Foo {
Index: test/CodeGenCXX/debug-lambda-this.cpp
===================================================================
--- test/CodeGenCXX/debug-lambda-this.cpp
+++ test/CodeGenCXX/debug-lambda-this.cpp
@@ -13,10 +13,10 @@
}
// CHECK: ![[D:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D",
-// CHECK: ![[POINTER:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[D]], size: 64, align: 64)
+// CHECK: ![[POINTER:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[D]], size: 64)
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "this",
// CHECK-SAME: line: 11
// CHECK-SAME: baseType: ![[POINTER]]
-// CHECK-SAME: size: 64, align: 64
+// CHECK-SAME: size: 64
// CHECK-NOT: offset: 0
// CHECK-SAME: ){{$}}
Index: test/CodeGenCXX/debug-info.cpp
===================================================================
--- test/CodeGenCXX/debug-info.cpp
+++ test/CodeGenCXX/debug-info.cpp
@@ -68,8 +68,8 @@
struct A { int a; };
struct B : virtual A { int b; };
// BOTH: ![[VBASE_B:[0-9]+]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "B",{{.*}} line: [[@LINE-1]],
-// MSVC-SAME: size: 96, align: 32
-// CHECK-SAME: size: 128, align: 64,
+// MSVC-SAME: size: 96
+// CHECK-SAME: size: 128,
// BOTH-NOT: offset:
// BOTH-NOT: DIFlagFwdDecl
// BOTH-SAME: elements: [[VBASE_B_DEF:![0-9]+]]
Index: test/CodeGenCXX/debug-info-zero-length-arrays.cpp
===================================================================
--- test/CodeGenCXX/debug-info-zero-length-arrays.cpp
+++ test/CodeGenCXX/debug-info-zero-length-arrays.cpp
@@ -10,7 +10,6 @@
// CHECK-SAME: baseType: [[ARRAY_TYPE:![0-9]+]]
// CHECK: [[ARRAY_TYPE]] = !DICompositeType(tag: DW_TAG_array_type,
// CHECK-NOT: size:
-// CHECK-SAME: align: 32
// CHECK-SAME: elements: [[ELEM_TYPE:![0-9]+]]
// CHECK: [[ELEM_TYPE]] = !{[[SUBRANGE:.*]]}
// CHECK: [[SUBRANGE]] = !DISubrange(count: -1)
Index: test/CodeGenCXX/debug-info-vla.cpp
===================================================================
--- test/CodeGenCXX/debug-info-vla.cpp
+++ test/CodeGenCXX/debug-info-vla.cpp
@@ -7,7 +7,6 @@
// CHECK: !DICompositeType(tag: DW_TAG_array_type,
// CHECK-NOT: size:
-// CHECK-SAME: align: 32
// CHECK-SAME: elements: [[ELEM_TYPE:![0-9]+]]
// CHECK: [[ELEM_TYPE]] = !{[[SUB1:.*]], [[SUB2:.*]]}
// CHECK: [[SUB1]] = !DISubrange(count: 3)
Index: test/CodeGenCXX/debug-info-uuid.cpp
===================================================================
--- test/CodeGenCXX/debug-info-uuid.cpp
+++ test/CodeGenCXX/debug-info-uuid.cpp
@@ -22,7 +22,6 @@
// CHECK: [[CONST_GUID_PTR]] = !DIDerivedType(tag: DW_TAG_pointer_type
// CHECK-SAME: baseType: [[CONST_GUID:![0-9]*]]
// CHECK-SAME: size: 64
-// CHECK-SAME: align: 64
// CHECK-ITANIUM: !DICompositeType(tag: DW_TAG_structure_type, name: "tmpl_guid2<__uuidof(uuid)>"
// CHECK-ITANIUM-SAME: identifier: "_ZTS10tmpl_guid2IXu8__uuidoft4uuidEE"
Index: test/CodeGenCXX/debug-info-union.cpp
===================================================================
--- test/CodeGenCXX/debug-info-union.cpp
+++ test/CodeGenCXX/debug-info-union.cpp
@@ -12,7 +12,7 @@
// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "E"
// CHECK-SAME: line: 3
-// CHECK-SAME: size: 32, align: 32
+// CHECK-SAME: size: 32
// CHECK-NOT: offset:
// CHECK-SAME: {{$}}
// CHECK: !DISubprogram(name: "bb"{{.*}}, line: 6
Index: test/CodeGenCXX/debug-info-template.cpp
===================================================================
--- test/CodeGenCXX/debug-info-template.cpp
+++ test/CodeGenCXX/debug-info-template.cpp
@@ -62,7 +62,7 @@
// CHECK: [[FARG1]] = !DIDerivedType(tag: DW_TAG_pointer_type,
// CHECK-SAME: baseType: ![[FOO]]
// CHECK-NOT: line:
-// CHECK-SAME: size: 64, align: 64
+// CHECK-SAME: size: 64
// CHECK-NOT: offset: 0
// CHECK-SAME: DIFlagArtificial
// CHECK: [[FUNTYPE:![0-9]*]] = !DISubroutineType(types: [[FUNARGS:![0-9]*]])
@@ -151,7 +151,7 @@
// CHECK-SAME: templateParams: [[PTOARGS:![0-9]*]]
// CHECK: [[PTOARGS]] = !{[[PTOARG1:![0-9]*]]}
// CHECK: [[PTOARG1]] = !DITemplateValueParameter(type: [[CONST_PADDINGATEND_PTR:![0-9]*]], value: %struct.PaddingAtEnd* @PaddedObj)
-// CHECK: [[CONST_PADDINGATEND_PTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[PADDINGATEND]], size: 64, align: 64)
+// CHECK: [[CONST_PADDINGATEND_PTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[PADDINGATEND]], size: 64)
template <PaddingAtEnd *>
struct PaddingAtEndTemplate {
};
Index: test/CodeGenCXX/debug-info-template-quals.cpp
===================================================================
--- test/CodeGenCXX/debug-info-template-quals.cpp
+++ test/CodeGenCXX/debug-info-template-quals.cpp
@@ -17,10 +17,10 @@
// CHECK: [[P:![0-9]*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[CON:![0-9]*]]
// CHECK: [[CON]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: [[CH:![0-9]*]]
-// CHECK: [[CH]] = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
+// CHECK: [[CH]] = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
// CHECK: [[BS:.*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "basic_string<char>"
// CHECK-SAME: line: 4
-// CHECK-SAME: size: 8, align: 8
+// CHECK-SAME: size: 8
// CHECK: [[TYPE:![0-9]*]] = !DISubroutineType(types: [[ARGS:.*]])
// CHECK: [[ARGS]] = !{!{{.*}}, !{{.*}}, [[P]], [[R:.*]]}
Index: test/CodeGenCXX/debug-info-rvalue-ref.cpp
===================================================================
--- test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -8,5 +8,5 @@
printf("%d\n", i);
}
-// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64, align: 64)
+// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
// CHECK: ![[INT]] = !DIBasicType(name: "int"
Index: test/CodeGenCXX/debug-info-ms-ptr-to-member.cpp
===================================================================
--- test/CodeGenCXX/debug-info-ms-ptr-to-member.cpp
+++ test/CodeGenCXX/debug-info-ms-ptr-to-member.cpp
@@ -44,10 +44,10 @@
// CHECK-SAME: ){{$}}
// CHECK: distinct !DIGlobalVariable(name: "ppmd", {{.*}} type: ![[ppmd:[^, ]*]], {{.*}})
-// CHECK: ![[ppmd]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[ppmd2:[^ ]*]], size: 64, align: 64)
+// CHECK: ![[ppmd]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[ppmd2:[^ ]*]], size: 64)
// CHECK: ![[ppmd2]] = !DIDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !{{[0-9]*}}, extraData: !{{[0-9]*}}){{$}}
// CHECK: distinct !DIGlobalVariable(name: "ppmf", {{.*}} type: ![[ppmf:[^, ]*]], {{.*}})
-// CHECK: ![[ppmf]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[ppmf2:[^ ]*]], size: 64, align: 64)
+// CHECK: ![[ppmf]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[ppmf2:[^ ]*]], size: 64)
// CHECK: ![[ppmf2]] = !DIDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !{{[0-9]*}}, extraData: !{{[0-9]*}}){{$}}
// CHECK: ![[pmd_a]] = !DIDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !{{.*}}, size: 32, flags: DIFlagSingleInheritance, {{.*}})
Index: test/CodeGenCXX/debug-info-ms-bitfields.cpp
===================================================================
--- test/CodeGenCXX/debug-info-ms-bitfields.cpp
+++ test/CodeGenCXX/debug-info-ms-bitfields.cpp
@@ -7,4 +7,4 @@
short x : 8;
} s;
-// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "x", {{.*}}, size: 8, align: 16, offset: 16, flags: DIFlagBitField, extraData: i64 8)
+// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "x", {{.*}}, size: 8, offset: 16, flags: DIFlagBitField, extraData: i64 8)
Index: test/CodeGenCXX/debug-info-indirect-field-decl.cpp
===================================================================
--- test/CodeGenCXX/debug-info-indirect-field-decl.cpp
+++ test/CodeGenCXX/debug-info-indirect-field-decl.cpp
@@ -11,13 +11,13 @@
// CHECK: !DIDerivedType(tag: DW_TAG_member, scope:
// CHECK-SAME: line: [[@LINE+4]]
// CHECK-SAME: baseType: ![[UNION:[0-9]+]]
- // CHECK-SAME: size: 32, align: 32, offset: 32
+ // CHECK-SAME: size: 32, offset: 32
// CHECK: ![[UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
union {
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i2",
// CHECK-SAME: line: [[@LINE+5]]
// CHECK-SAME: baseType: ![[INT]]
- // CHECK-SAME: size: 32, align: 32
+ // CHECK-SAME: size: 32
// CHECK-NOT: offset:
// CHECK-SAME: ){{$}}
int i2;
Index: test/CodeGenCXX/debug-info-enum-class.cpp
===================================================================
--- test/CodeGenCXX/debug-info-enum-class.cpp
+++ test/CodeGenCXX/debug-info-enum-class.cpp
@@ -13,23 +13,23 @@
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "A"
// CHECK-SAME: line: 3
// CHECK-SAME: baseType: ![[INT:[0-9]+]]
-// CHECK-SAME: size: 32, align: 32
+// CHECK-SAME: size: 32
// CHECK-NOT: offset:
// CHECK-NOT: flags:
// CHECK-SAME: ){{$}}
// CHECK: ![[INT]] = !DIBasicType(name: "int"
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "B"
// CHECK-SAME: line: 4
// CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
-// CHECK-SAME: size: 64, align: 64
+// CHECK-SAME: size: 64
// CHECK-NOT: offset:
// CHECK-NOT: flags:
// CHECK-SAME: ){{$}}
// CHECK: ![[ULONG]] = !DIBasicType(name: "long unsigned int"
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "C"
// CHECK-SAME: line: 5
// CHECK-NOT: baseType:
-// CHECK-SAME: size: 32, align: 32
+// CHECK-SAME: size: 32
// CHECK-NOT: offset:
// CHECK-NOT: flags:
// CHECK-SAME: ){{$}}
@@ -91,7 +91,7 @@
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "D"
// CHECK-SAME: line: 6
-// CHECK-SAME: size: 16, align: 16
+// CHECK-SAME: size: 16
// CHECK-NOT: offset:
// CHECK-SAME: flags: DIFlagFwdDecl
Index: test/CodeGenCXX/debug-info-calling-conventions.cpp
===================================================================
--- test/CodeGenCXX/debug-info-calling-conventions.cpp
+++ test/CodeGenCXX/debug-info-calling-conventions.cpp
@@ -8,7 +8,7 @@
// CHECK: !DISubprogram(name: "thiscallcc", {{.*}} type: ![[thiscallty:[^,]*]], {{.*}})
// CHECK: ![[thiscallty]] = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: ![[thisargs:[^,)]*]])
// CHECK: ![[thisargs]] = !{null, ![[thisptrty:[^,}]*]]}
-// CHECK: ![[thisptrty]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !{{.*}}, size: 32, align: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK: ![[thisptrty]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !{{.*}}, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
void cdeclcc() {}
void __fastcall fastcallcc() {}
Index: test/CodeGen/debug-info-vector.c
===================================================================
--- test/CodeGen/debug-info-vector.c
+++ test/CodeGen/debug-info-vector.c
@@ -6,6 +6,6 @@
// Test that we get an array type that's also a vector out of debug.
// CHECK: !DICompositeType(tag: DW_TAG_array_type,
// CHECK-SAME: baseType: ![[INT:[0-9]+]]
-// CHECK-SAME: size: 128, align: 128
+// CHECK-SAME: size: 128
// CHECK-SAME: DIFlagVector
// CHECK: ![[INT]] = !DIBasicType(name: "int"
Index: test/CodeGen/debug-info-packed-struct.c
===================================================================
--- test/CodeGen/debug-info-packed-struct.c
+++ test/CodeGen/debug-info-packed-struct.c
@@ -19,9 +19,9 @@
};
// CHECK: l0_ofs0
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs8",
-// CHECK-SAME: {{.*}}size: 64, align: 64, offset: 64)
+// CHECK-SAME: {{.*}}size: 64, offset: 64)
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs16",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 128, flags: DIFlagBitField, extraData: i64 128)
+// CHECK-SAME: {{.*}}size: 1, offset: 128, flags: DIFlagBitField, extraData: i64 128)
// ---------------------------------------------------------------------
@@ -38,9 +38,9 @@
};
// CHECK: l1_ofs0
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs1",
-// CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8)
+// CHECK-SAME: {{.*}}size: 64, offset: 8)
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs9",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72, flags: DIFlagBitField, extraData: i64 72)
+// CHECK-SAME: {{.*}}size: 1, offset: 72, flags: DIFlagBitField, extraData: i64 72)
// ---------------------------------------------------------------------
@@ -59,9 +59,9 @@
#pragma pack()
// CHECK: l2_ofs0
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1",
-// CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8)
+// CHECK-SAME: {{.*}}size: 64, offset: 8)
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72, flags: DIFlagBitField, extraData: i64 72)
+// CHECK-SAME: {{.*}}size: 1, offset: 72, flags: DIFlagBitField, extraData: i64 72)
@@ -81,9 +81,9 @@
#pragma pack()
// CHECK: l3_ofs0
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4",
-// CHECK-SAME: {{.*}}size: 64, align: 32, offset: 32)
+// CHECK-SAME: {{.*}}size: 64, offset: 32)
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 96, flags: DIFlagBitField, extraData: i64 96)
+// CHECK-SAME: {{.*}}size: 1, offset: 96, flags: DIFlagBitField, extraData: i64 96)
struct layout3 l3;
struct layout0 l0;
Index: lib/CodeGen/CGDebugInfo.h
===================================================================
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -235,9 +235,18 @@
llvm::DIType *createFieldType(StringRef name, QualType type,
SourceLocation loc, AccessSpecifier AS,
+ uint64_t offsetInBits, uint64_t AlignInBytes,
+ llvm::DIFile *tunit, llvm::DIScope *scope,
+ const RecordDecl *RD = nullptr);
+
+ llvm::DIType *createFieldType(StringRef name, QualType type,
+ SourceLocation loc, AccessSpecifier AS,
uint64_t offsetInBits, llvm::DIFile *tunit,
llvm::DIScope *scope,
- const RecordDecl *RD = nullptr);
+ const RecordDecl *RD = nullptr) {
+ return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope,
+ RD);
+ }
/// Create new bit field member.
llvm::DIType *createBitFieldType(const FieldDecl *BitFieldDecl,
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -44,6 +44,19 @@
using namespace clang;
using namespace clang::CodeGen;
+static uint64_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx) {
+ auto TI = Ctx.getTypeInfo(Ty);
+ return TI.AlignIsRequired ? TI.Align : 0;
+}
+
+static uint64_t getTypeAlignIfRequired(QualType Ty, const ASTContext &Ctx) {
+ return getTypeAlignIfRequired(Ty.getTypePtr(), Ctx);
+}
+
+static uint64_t getDeclAlignIfRequired(const Decl *D, const ASTContext &Ctx) {
+ return D->hasAttr<AlignedAttr>() ? D->getMaxAlignment() : 0;
+}
+
CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
: CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
@@ -594,21 +607,19 @@
BTName = BT->getName(CGM.getLangOpts());
break;
}
- // Bit size, align and offset of the type.
+ // Bit size and offset of the type.
uint64_t Size = CGM.getContext().getTypeSize(BT);
- uint64_t Align = CGM.getContext().getTypeAlign(BT);
- return DBuilder.createBasicType(BTName, Size, Align, Encoding);
+ return DBuilder.createBasicType(BTName, Size, Encoding);
}
llvm::DIType *CGDebugInfo::CreateType(const ComplexType *Ty) {
- // Bit size, align and offset of the type.
+ // Bit size and offset of the type.
llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float;
if (Ty->isComplexIntegerType())
Encoding = llvm::dwarf::DW_ATE_lo_user;
uint64_t Size = CGM.getContext().getTypeSize(Ty);
- uint64_t Align = CGM.getContext().getTypeAlign(Ty);
- return DBuilder.createBasicType("complex", Size, Align, Encoding);
+ return DBuilder.createBasicType("complex", Size, Encoding);
}
llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty,
@@ -726,7 +737,7 @@
const RecordDecl *D = RD->getDefinition();
if (D && D->isCompleteDefinition()) {
Size = CGM.getContext().getTypeSize(Ty);
- Align = CGM.getContext().getTypeAlign(Ty);
+ Align = getDeclAlignIfRequired(D, CGM.getContext());
}
// Create the type.
@@ -749,7 +760,7 @@
// because that does not return the correct value for references.
unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
uint64_t Size = CGM.getTarget().getPointerWidth(AS);
- uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+ uint64_t Align = getTypeAlignIfRequired(Ty, CGM.getContext());
if (Tag == llvm::dwarf::DW_TAG_reference_type ||
Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
@@ -965,38 +976,38 @@
CGM.getTypes().getCGRecordLayout(RD).getBitFieldInfo(BitFieldDecl);
uint64_t SizeInBits = BitFieldInfo.Size;
assert(SizeInBits > 0 && "found named 0-width bitfield");
- unsigned AlignInBits = CGM.getContext().getTypeAlign(Ty);
uint64_t StorageOffsetInBits =
CGM.getContext().toBits(BitFieldInfo.StorageOffset);
uint64_t OffsetInBits = StorageOffsetInBits + BitFieldInfo.Offset;
llvm::DINode::DIFlags Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
return DBuilder.createBitFieldMemberType(
- RecordTy, Name, File, Line, SizeInBits, AlignInBits, OffsetInBits,
- StorageOffsetInBits, Flags, DebugType);
+ RecordTy, Name, File, Line, SizeInBits, OffsetInBits, StorageOffsetInBits,
+ Flags, DebugType);
}
llvm::DIType *
CGDebugInfo::createFieldType(StringRef name, QualType type, SourceLocation loc,
AccessSpecifier AS, uint64_t offsetInBits,
- llvm::DIFile *tunit, llvm::DIScope *scope,
- const RecordDecl *RD) {
+ uint64_t AlignInBits, llvm::DIFile *tunit,
+ llvm::DIScope *scope, const RecordDecl *RD) {
llvm::DIType *debugType = getOrCreateType(type, tunit);
// Get the location for the field.
llvm::DIFile *file = getOrCreateFile(loc);
unsigned line = getLineNumber(loc);
uint64_t SizeInBits = 0;
- unsigned AlignInBits = 0;
+ uint64_t Align = AlignInBits;
if (!type->isIncompleteArrayType()) {
TypeInfo TI = CGM.getContext().getTypeInfo(type);
SizeInBits = TI.Width;
- AlignInBits = TI.Align;
+ if (!Align)
+ Align = getTypeAlignIfRequired(type, CGM.getContext());
}
llvm::DINode::DIFlags flags = getAccessFlag(AS, RD);
return DBuilder.createMemberType(scope, name, file, line, SizeInBits,
- AlignInBits, offsetInBits, flags, debugType);
+ Align, offsetInBits, flags, debugType);
}
void CGDebugInfo::CollectRecordLambdaFields(
@@ -1018,9 +1029,10 @@
VarDecl *V = C.getCapturedVar();
StringRef VName = V->getName();
llvm::DIFile *VUnit = getOrCreateFile(Loc);
+ uint64_t Align = getDeclAlignIfRequired(V, CGM.getContext());
llvm::DIType *FieldType = createFieldType(
VName, Field->getType(), Loc, Field->getAccess(),
- layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl);
+ layout.getFieldOffset(fieldno), Align, VUnit, RecordTy, CXXDecl);
elements.push_back(FieldType);
} else if (C.capturesThis()) {
// TODO: Need to handle 'this' in some way by probably renaming the
@@ -1062,8 +1074,9 @@
}
llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
+ uint64_t Align = getDeclAlignIfRequired(Var, CGM.getContext());
llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
- RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);
+ RecordTy, VName, VUnit, LineNumber, VTy, Flags, C, Align);
StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
return GV;
}
@@ -1083,9 +1096,10 @@
if (field->isBitField()) {
FieldType = createBitFieldType(field, RecordTy, RD);
} else {
+ uint64_t Align = getDeclAlignIfRequired(field, CGM.getContext());
FieldType =
createFieldType(name, type, field->getLocation(), field->getAccess(),
- OffsetInBits, tunit, RecordTy, RD);
+ OffsetInBits, Align, tunit, RecordTy, RD);
}
elements.push_back(FieldType);
@@ -1181,7 +1195,7 @@
QualType PointeeTy = ThisPtrTy->getPointeeType();
unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
uint64_t Size = CGM.getTarget().getPointerWidth(AS);
- uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy);
+ uint64_t Align = getTypeAlignIfRequired(ThisPtrTy, CGM.getContext());
llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit);
llvm::DIType *ThisPtrType =
DBuilder.createPointerType(PointeeType, Size, Align);
@@ -1968,7 +1982,7 @@
// Bit size, align and offset of the type.
uint64_t Size = CGM.getContext().getTypeSize(Ty);
- uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+ uint64_t Align = getTypeAlignIfRequired(Ty, CGM.getContext());
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
if (ID->getImplementation())
@@ -2060,7 +2074,7 @@
FieldSize = Field->isBitField()
? Field->getBitWidthValue(CGM.getContext())
: CGM.getContext().getTypeSize(FType);
- FieldAlign = CGM.getContext().getTypeAlign(FType);
+ FieldAlign = getTypeAlignIfRequired(FType, CGM.getContext());
}
uint64_t FieldOffset;
@@ -2134,7 +2148,7 @@
llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
uint64_t Size = CGM.getContext().getTypeSize(Ty);
- uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+ uint64_t Align = getTypeAlignIfRequired(Ty, CGM.getContext());
return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray);
}
@@ -2146,21 +2160,21 @@
// FIXME: make getTypeAlign() aware of VLAs and incomplete array types
if (const auto *VAT = dyn_cast<VariableArrayType>(Ty)) {
Size = 0;
- Align =
- CGM.getContext().getTypeAlign(CGM.getContext().getBaseElementType(VAT));
+ Align = getTypeAlignIfRequired(CGM.getContext().getBaseElementType(VAT),
+ CGM.getContext());
} else if (Ty->isIncompleteArrayType()) {
Size = 0;
if (Ty->getElementType()->isIncompleteType())
Align = 0;
else
- Align = CGM.getContext().getTypeAlign(Ty->getElementType());
+ Align = getTypeAlignIfRequired(Ty->getElementType(), CGM.getContext());
} else if (Ty->isIncompleteType()) {
Size = 0;
Align = 0;
} else {
// Size and align of the whole array, not the element type.
Size = CGM.getContext().getTypeSize(Ty);
- Align = CGM.getContext().getTypeAlign(Ty);
+ Align = getTypeAlignIfRequired(Ty, CGM.getContext());
}
// Add the dimensions of the array. FIXME: This loses CV qualifiers from
@@ -2267,7 +2281,7 @@
uint64_t Align = 0;
if (!ED->getTypeForDecl()->isIncompleteType()) {
Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
- Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl());
+ Align = getDeclAlignIfRequired(ED, CGM.getContext());
}
SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
@@ -2310,7 +2324,7 @@
uint64_t Align = 0;
if (!ED->getTypeForDecl()->isIncompleteType()) {
Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
- Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl());
+ Align = getDeclAlignIfRequired(ED, CGM.getContext());
}
SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
@@ -2607,7 +2621,7 @@
return getOrCreateRecordFwdDecl(Ty, RDContext);
uint64_t Size = CGM.getContext().getTypeSize(Ty);
- uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+ uint64_t Align = getDeclAlignIfRequired(D, CGM.getContext());
SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
@@ -2676,7 +2690,7 @@
StringRef Name, uint64_t *Offset) {
llvm::DIType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
uint64_t FieldSize = CGM.getContext().getTypeSize(FType);
- unsigned FieldAlign = CGM.getContext().getTypeAlign(FType);
+ unsigned FieldAlign = getTypeAlignIfRequired(FType, CGM.getContext());
llvm::DIType *Ty =
DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize, FieldAlign,
*Offset, llvm::DINode::FlagZero, FieldTy);
@@ -2810,9 +2824,10 @@
unsigned Line = getLineNumber(Loc);
collectVarDeclProps(VD, Unit, Line, T, Name, LinkageName, DContext);
+ uint64_t Align = getDeclAlignIfRequired(VD, CGM.getContext());
auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
- !VD->isExternallyVisible(), nullptr, nullptr);
+ !VD->isExternallyVisible(), nullptr, nullptr, Align);
FwdDeclReplaceMap.emplace_back(
std::piecewise_construct,
std::make_tuple(cast<VarDecl>(VD->getCanonicalDecl())),
@@ -3136,8 +3151,7 @@
SmallVector<llvm::Metadata *, 5> EltTys;
QualType FType;
- uint64_t FieldSize, FieldOffset;
- unsigned FieldAlign;
+ uint64_t FieldSize, FieldOffset, FieldAlign;
llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());
QualType Type = VD->getType();
@@ -3187,7 +3201,7 @@
FType = Type;
llvm::DIType *FieldTy = getOrCreateType(FType, Unit);
FieldSize = CGM.getContext().getTypeSize(FType);
- FieldAlign = CGM.getContext().toBits(Align);
+ FieldAlign = getTypeAlignIfRequired(FType, CGM.getContext());
*XOffset = FieldOffset;
FieldTy = DBuilder.createMemberType(Unit, VD->getName(), Unit, 0, FieldSize,
@@ -3241,6 +3255,9 @@
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
if (VD->isImplicit())
Flags |= llvm::DINode::FlagArtificial;
+
+ uint64_t Align = getDeclAlignIfRequired(VD, CGM.getContext());
+
// If this is the first argument and it is implicit then
// give it an object pointer flag.
// FIXME: There has to be a better way to do this, but for static
@@ -3275,7 +3292,7 @@
? DBuilder.createParameterVariable(Scope, VD->getName(),
*ArgNo, Unit, Line, Ty)
: DBuilder.createAutoVariable(Scope, VD->getName(), Unit,
- Line, Ty);
+ Line, Ty, Align);
// Insert an llvm.dbg.declare into the current block.
DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
@@ -3305,9 +3322,10 @@
continue;
// Use VarDecl's Tag, Scope and Line number.
+ uint64_t FieldAlign = getDeclAlignIfRequired(Field, CGM.getContext());
auto *D = DBuilder.createAutoVariable(
Scope, FieldName, Unit, Line, FieldTy, CGM.getLangOpts().Optimize,
- Flags | llvm::DINode::FlagArtificial);
+ Flags | llvm::DINode::FlagArtificial, FieldAlign);
// Insert an llvm.dbg.declare into the current block.
DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
@@ -3318,13 +3336,13 @@
}
// Create the descriptor for the variable.
- auto *D =
- ArgNo
- ? DBuilder.createParameterVariable(Scope, Name, *ArgNo, Unit, Line,
- Ty, CGM.getLangOpts().Optimize,
- Flags)
- : DBuilder.createAutoVariable(Scope, Name, Unit, Line, Ty,
- CGM.getLangOpts().Optimize, Flags);
+ auto *D = ArgNo
+ ? DBuilder.createParameterVariable(
+ Scope, Name, *ArgNo, Unit, Line, Ty,
+ CGM.getLangOpts().Optimize, Flags)
+ : DBuilder.createAutoVariable(Scope, Name, Unit, Line, Ty,
+ CGM.getLangOpts().Optimize, Flags,
+ Align);
// Insert an llvm.dbg.declare into the current block.
DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
@@ -3403,9 +3421,10 @@
}
// Create the descriptor for the variable.
+ uint64_t Align = getDeclAlignIfRequired(VD, CGM.getContext());
auto *D = DBuilder.createAutoVariable(
cast<llvm::DILocalScope>(LexicalBlockStack.back()), VD->getName(), Unit,
- Line, Ty);
+ Line, Ty, false, llvm::DINode::FlagZero, Align);
// Insert an llvm.dbg.declare into the current block.
auto DL = llvm::DebugLoc::get(Line, Column, LexicalBlockStack.back());
@@ -3534,17 +3553,19 @@
llvm::DIType *fieldType;
if (capture->isByRef()) {
TypeInfo PtrInfo = C.getTypeInfo(C.VoidPtrTy);
+ uint64_t Align = PtrInfo.AlignIsRequired ? PtrInfo.Align : 0;
// FIXME: this creates a second copy of this type!
uint64_t xoffset;
fieldType = EmitTypeForVarWithBlocksAttr(variable, &xoffset);
fieldType = DBuilder.createPointerType(fieldType, PtrInfo.Width);
- fieldType = DBuilder.createMemberType(
- tunit, name, tunit, line, PtrInfo.Width, PtrInfo.Align, offsetInBits,
- llvm::DINode::FlagZero, fieldType);
+ fieldType = DBuilder.createMemberType(tunit, name, tunit, line,
+ PtrInfo.Width, Align, offsetInBits,
+ llvm::DINode::FlagZero, fieldType);
} else {
+ uint64_t Align = getDeclAlignIfRequired(variable, CGM.getContext());
fieldType = createFieldType(name, variable->getType(), loc, AS_public,
- offsetInBits, tunit, tunit);
+ offsetInBits, Align, tunit, tunit);
}
fields.push_back(fieldType);
}
@@ -3557,8 +3578,7 @@
llvm::DIType *type =
DBuilder.createStructType(tunit, typeName.str(), tunit, line,
- CGM.getContext().toBits(block.BlockSize),
- CGM.getContext().toBits(block.BlockAlign),
+ CGM.getContext().toBits(block.BlockSize), 0,
llvm::DINode::FlagZero, nullptr, fieldsArray);
type = DBuilder.createPointerType(type, CGM.PointerWidthInBits);
@@ -3652,10 +3672,11 @@
"unnamed non-anonymous struct or union?");
GV = CollectAnonRecordDecls(RD, Unit, LineNo, LinkageName, Var, DContext);
} else {
+ uint64_t Align = getDeclAlignIfRequired(D, CGM.getContext());
GV = DBuilder.createGlobalVariable(
DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit),
Var->hasLocalLinkage(), /*Expr=*/nullptr,
- getOrCreateStaticDataMemberDeclarationOrNull(D));
+ getOrCreateStaticDataMemberDeclarationOrNull(D), Align);
Var->addDebugInfo(GV);
}
DeclCache[D->getCanonicalDecl()].reset(GV);
@@ -3665,6 +3686,7 @@
assert(DebugKind >= codegenoptions::LimitedDebugInfo);
if (VD->hasAttr<NoDebugAttr>())
return;
+ uint64_t Align = getDeclAlignIfRequired(VD, CGM.getContext());
// Create the descriptor for the variable.
llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());
StringRef Name = VD->getName();
@@ -3707,7 +3729,8 @@
DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
GV.reset(DBuilder.createGlobalVariable(
DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,
- true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD)));
+ true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),
+ Align));
}
llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits