-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GlobalOpt] Fix global SRA incorrect alignment on some elements (#115328
) The logic had a flaw where the alignment from the original aggregate is unintentionally retained for elements when the calculated known alignment is not higher than the element's ABI type alignment. Fixes #115282.
- Loading branch information
1 parent
5a48162
commit 20d8f8c
Showing
5 changed files
with
61 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5 | ||
; RUN: opt < %s -passes=globalopt -S | FileCheck %s | ||
|
||
@params = internal global [4 x i32] zeroinitializer, align 32 | ||
|
||
;. | ||
; CHECK: @params.0 = internal unnamed_addr global i32 0, align 32 | ||
; CHECK: @params.1 = internal unnamed_addr global i32 0, align 4 | ||
; CHECK: @params.2 = internal unnamed_addr global i32 0, align 8 | ||
; CHECK: @params.3 = internal unnamed_addr global i32 0, align 4 | ||
;. | ||
define void @set(i32 %a, i32 %b, i32 %c, i32 %d) { | ||
; CHECK-LABEL: define void @set( | ||
; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]], i32 [[D:%.*]]) local_unnamed_addr { | ||
; CHECK-NEXT: store i32 [[A]], ptr @params.0, align 32 | ||
; CHECK-NEXT: store i32 [[B]], ptr @params.1, align 4 | ||
; CHECK-NEXT: store i32 [[C]], ptr @params.2, align 8 | ||
; CHECK-NEXT: store i32 [[D]], ptr @params.3, align 4 | ||
; CHECK-NEXT: ret void | ||
; | ||
store i32 %a, ptr @params | ||
store i32 %b, ptr getelementptr ([4 x i32], ptr @params, i32 0, i32 1) | ||
store i32 %c, ptr getelementptr ([4 x i32], ptr @params, i32 0, i32 2) | ||
store i32 %d, ptr getelementptr ([4 x i32], ptr @params, i32 0, i32 3) | ||
ret void | ||
} | ||
|
||
%S = type { i32, i32, i32, i32 } | ||
|
||
define %S @get() { | ||
; CHECK-LABEL: define %S @get() local_unnamed_addr { | ||
; CHECK-NEXT: [[A:%.*]] = load i32, ptr @params.0, align 32 | ||
; CHECK-NEXT: [[SA:%.*]] = insertvalue [[S:%.*]] undef, i32 [[A]], 0 | ||
; CHECK-NEXT: [[B:%.*]] = load i32, ptr @params.1, align 4 | ||
; CHECK-NEXT: [[SB:%.*]] = insertvalue [[S]] [[SA]], i32 [[B]], 1 | ||
; CHECK-NEXT: [[C:%.*]] = load i32, ptr @params.2, align 8 | ||
; CHECK-NEXT: [[SC:%.*]] = insertvalue [[S]] [[SB]], i32 [[C]], 2 | ||
; CHECK-NEXT: [[D:%.*]] = load i32, ptr @params.3, align 4 | ||
; CHECK-NEXT: [[SD:%.*]] = insertvalue [[S]] [[SC]], i32 [[D]], 3 | ||
; CHECK-NEXT: ret [[S]] [[SD]] | ||
; | ||
%a = load i32, ptr @params | ||
%sa = insertvalue %S undef, i32 %a, 0 | ||
%b = load i32, ptr getelementptr ([4 x i32], ptr @params, i32 0, i32 1) | ||
%sb = insertvalue %S %sa, i32 %b, 1 | ||
%c = load i32, ptr getelementptr ([4 x i32], ptr @params, i32 0, i32 2) | ||
%sc = insertvalue %S %sb, i32 %c, 2 | ||
%d = load i32, ptr getelementptr ([4 x i32], ptr @params, i32 0, i32 3) | ||
%sd = insertvalue %S %sc, i32 %d, 3 | ||
ret %S %sd | ||
} |