Skip to content

Commit 733a7cf

Browse files
Merge pull request #31371 from aschwaighofer/irgen_fix_62443743_5.3
[5.3] IRGen: Fix alignment of global variable buffer for non-fixed types
2 parents 63b740a + 6a244a4 commit 733a7cf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ Address IRGenModule::getAddrOfSILGlobalVariable(SILGlobalVariable *var,
22242224
inFixedBuffer = true;
22252225
storageType = getFixedBufferTy();
22262226
fixedSize = Size(DataLayout.getTypeAllocSize(storageType));
2227-
fixedAlignment = Alignment(DataLayout.getABITypeAlignment(storageType));
2227+
fixedAlignment = getFixedBufferAlignment(*this);
22282228
}
22292229

22302230
// Check whether we've created the global variable already.

test/IRGen/global_resilience.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct SmallResilientStruct {
2222
let x: Int32 = 0
2323
}
2424

25-
// CHECK: @smallGlobal = {{(dllexport )?}}{{(protected )?}}global [[BUFFER:\[(12|24) x i8\]]] zeroinitializer
25+
// CHECK: @smallGlobal = {{(dllexport )?}}{{(protected )?}}global [[BUFFER:\[(12|24) x i8\]]] zeroinitializer{{.*}}align {{(8|4)}}
2626
sil_global [let] @smallGlobal : $SmallResilientStruct
2727

2828
//
@@ -77,7 +77,7 @@ bb0:
7777
sil @testLargeGlobal : $@convention(thin) () -> () {
7878
bb0:
7979
// CHECK: [[ALLOC:%.*]] = call noalias i8* @swift_slowAlloc([[INT]] 32, [[INT]] 7)
80-
// CHECK: store i8* [[ALLOC]], i8** bitcast ([[BUFFER]]* @largeGlobal to i8**), align 1
80+
// CHECK: store i8* [[ALLOC]], i8** bitcast ([[BUFFER]]* @largeGlobal to i8**), align {{(8|4)}}
8181
alloc_global @largeGlobal
8282

8383
// CHECK: [[VALUE:%.*]] = load %T17global_resilience20LargeResilientStructV*, %T17global_resilience20LargeResilientStructV** bitcast ([[BUFFER]]* @largeGlobal to %T17global_resilience20LargeResilientStructV**)

0 commit comments

Comments
 (0)