Skip to content

Commit dac7688

Browse files
committed
[DIBuilder] Remove .zero default alignments
Putting 0 alignments in here goes against DWARF
1 parent 392221c commit dac7688

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Sources/LLVM/DIBuilder.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ extension DIBuilder {
394394
named name: String,
395395
scope: DIScope, file: FileMetadata, line: Int,
396396
type: DIType, alwaysPreserve: Bool = false,
397-
flags: DIFlags = [], alignment: Alignment = .zero
397+
flags: DIFlags = [], alignment: Alignment
398398
) -> LocalVariableMetadata {
399399
let radix = UInt32(self.module.dataLayout.intPointerType().width)
400400
guard let variable = LLVMDIBuilderCreateAutoVariable(
@@ -502,7 +502,7 @@ extension DIBuilder {
502502
/// - file: File where this member is defined.
503503
/// - line: Line number.
504504
/// - size: Member size.
505-
/// - alignmemnt: Member alignment.
505+
/// - alignment: Member alignment.
506506
/// - elements: Enumeration elements.
507507
/// - numElements: Number of enumeration elements.
508508
/// - underlyingType: Underlying type of a C++11/ObjC fixed enum.
@@ -675,7 +675,7 @@ extension DIBuilder {
675675
/// - addressSpace: The address space the pointer type reside in.
676676
/// - name: The name of the pointer type.
677677
public func buildPointerType(
678-
pointee: DIType, size: Size, alignment: Alignment = .zero,
678+
pointee: DIType, size: Size, alignment: Alignment,
679679
addressSpace: AddressSpace = .zero, name: String = ""
680680
) -> DIType {
681681
let radix = UInt32(self.module.dataLayout.intPointerType().width)
@@ -1258,15 +1258,14 @@ extension DIBuilder {
12581258
/// - expression: The location of the global relative to the attached
12591259
/// GlobalVariable.
12601260
/// - declaration: Reference to the corresponding declaration.
1261-
/// - alignment: Variable alignment(or 0 if no alignment attr was
1262-
/// specified)
1261+
/// - alignment: Variable alignment
12631262
public func buildGlobalExpression(
12641263
named name: String, linkageName: String, type: DIType,
12651264
scope: DIScope, file: FileMetadata, line: Int,
12661265
isLocal: Bool = true,
12671266
expression: ExpressionMetadata? = nil,
12681267
declaration: IRMetadata? = nil,
1269-
alignment: Alignment = .zero
1268+
alignment: Alignment
12701269
) -> ExpressionMetadata {
12711270
let radix = UInt32(self.module.dataLayout.intPointerType().width)
12721271
guard let ty = LLVMDIBuilderCreateGlobalVariableExpression(

Tests/LLVMTests/BFC.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,13 @@ private func compileProgramBody(
261261
encoding: .signed, flags: [],
262262
size: builder.module.dataLayout.abiSize(of: cellType))
263263
let diPtrTy = dibuilder.buildPointerType(pointee: diDataTy,
264-
size: builder.module.dataLayout.pointerSize())
264+
size: builder.module.dataLayout.pointerSize(),
265+
alignment: .one)
265266
let diVariable = dibuilder.buildLocalVariable(named: "this",
266267
scope: entryScope,
267268
file: file, line: startPoint.0,
268-
type: diPtrTy, flags: .artificial)
269+
type: diPtrTy, flags: .artificial,
270+
alignment: .one)
269271

270272
var sourceLine = startPoint.0 + 1
271273
var sourceColumn = startPoint.1 + 1

Tests/LLVMTests/DIBuilderSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DIBuilderSpec : XCTestCase {
4747
// DIEXPRESSION: !{{[0-9]+}} = !DIGlobalVariableExpression(var: !{{[0-9]+}}, expr: !{{[0-9]+}})
4848
let expr = debugBuilder.buildGlobalExpression(
4949
named: "global", linkageName: "global", type: globalTy,
50-
scope: cu, file: file, line: 42)
50+
scope: cu, file: file, line: 42, alignment: global.alignment)
5151
// DIEXPRESSION: !{{[0-9]+}} = distinct !DIGlobalVariable(name: "unattached", linkageName: "unattached", scope: !0, file: !{{[0-9]+}}, line: 42, type: !{{[0-9]+}}, isLocal: true, isDefinition: true)
5252
_ = debugBuilder.buildGlobalExpression(
5353
named: "unattached", linkageName: "unattached",

0 commit comments

Comments
 (0)