Skip to content

Commit 601476c

Browse files
Merge pull request #231 from llvm-swift/alignment-radix
[DIBuilder.buildTypedef] Use radix to determine alignment rather than assume data layout
2 parents ca22dde + 8387ce9 commit 601476c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: Sources/LLVM/DIBuilder.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ extension DIBuilder {
868868
/// - Parameters:
869869
/// - type: Original type.
870870
/// - name: Typedef name.
871-
/// - alignment: Alignment of the type
871+
/// - alignment: Alignment of the type.
872872
/// - scope: The surrounding context for the typedef.
873873
/// - file: File where this type is defined.
874874
/// - line: Line number.
@@ -880,10 +880,11 @@ extension DIBuilder {
880880
file: FileMetadata,
881881
line: Int
882882
) -> DIType {
883+
let radix = UInt32(self.module.dataLayout.intPointerType().width)
883884
guard let ty = LLVMDIBuilderCreateTypedef(
884885
self.llvm, type.asMetadata(), name, name.count,
885886
file.asMetadata(), UInt32(line), scope.asMetadata(),
886-
alignment.rawValue * 8)
887+
alignment.rawValue * radix)
887888
else {
888889
fatalError("Failed to allocate metadata")
889890
}

0 commit comments

Comments
 (0)