[llvm] 139378e - [GlobalOpt] Add test that requires splitting up global into many.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 11 16:34:39 PDT 2022
Author: Florian Hahn
Date: 2022-07-11T16:34:07-07:00
New Revision: 139378ef8e651db9deaf3b7a7f71aafa043237ca
URL: https://github.com/llvm/llvm-project/commit/139378ef8e651db9deaf3b7a7f71aafa043237ca
DIFF: https://github.com/llvm/llvm-project/commit/139378ef8e651db9deaf3b7a7f71aafa043237ca.diff
LOG: [GlobalOpt] Add test that requires splitting up global into many.
Add test that hits the limit introduced in 4796b4ae7bccc7.
Added:
llvm/test/Transforms/GlobalOpt/sra-many-stores.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GlobalOpt/sra-many-stores.ll b/llvm/test/Transforms/GlobalOpt/sra-many-stores.ll
new file mode 100644
index 0000000000000..db590f9a11072
--- /dev/null
+++ b/llvm/test/Transforms/GlobalOpt/sra-many-stores.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
+; RUN: opt -passes=globalopt -S %s | FileCheck %s
+
+%struct.widget = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
+
+ at global = internal global %struct.widget zeroinitializer
+
+;.
+; CHECK: @[[GLOBAL:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global [[STRUCT_WIDGET:%.*]] zeroinitializer
+;.
+define internal i32 @fn1() {
+; CHECK-LABEL: @fn1(
+; CHECK-NEXT: ret i32 0
+;
+ ret i32 0
+}
+
+define internal void @fn2() {
+; CHECK-LABEL: @fn2(
+; CHECK-NEXT: [[TMP:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_WIDGET:%.*]], ptr @global, i64 0, i32 16), align 8
+; CHECK-NEXT: ret void
+;
+ %tmp = load ptr, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 16), align 8
+ ret void
+}
+
+define internal void @write() {
+; CHECK-LABEL: @write(
+; CHECK-NEXT: store ptr null, ptr @global, align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET:%.*]], ptr @global, i64 0, i32 1), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 2), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 3), align 8
+; CHECK-NEXT: store ptr @fn1, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 4), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 5), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 6), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 7), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 8), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 9), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 10), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 11), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 12), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 13), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 14), align 8
+; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_WIDGET]], ptr @global, i64 0, i32 15), align 8
+; CHECK-NEXT: tail call fastcc void @fn2()
+; CHECK-NEXT: ret void
+;
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 0), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 1), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 2), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 3), align 8
+ store ptr @fn1, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 4), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 5), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 6), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 7), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 8), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 9), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 10), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 11), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 12), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 13), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 14), align 8
+ store ptr null, ptr getelementptr inbounds (%struct.widget, ptr @global, i64 0, i32 15), align 8
+ tail call void @fn2()
+ ret void
+}
+
+define i32 @main() {
+; CHECK-LABEL: @main(
+; CHECK-NEXT: [[TMP:%.*]] = tail call i32 @write(ptr null)
+; CHECK-NEXT: ret i32 [[TMP]]
+;
+ %tmp = tail call i32 @write(ptr null)
+ ret i32 %tmp
+}
More information about the llvm-commits
mailing list