Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: test/Transforms/NaCl/expand-struct-regs.ll

Issue 460053003: PNaCl: Handle nested structure types in -expand-struct-regs. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/Transforms/NaCl/ExpandStructRegs.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Transforms/NaCl/expand-struct-regs.ll
diff --git a/test/Transforms/NaCl/expand-struct-regs.ll b/test/Transforms/NaCl/expand-struct-regs.ll
index 0cc2c6db855f230118730efbdde5da067b873bdb..d760cf3786d2d44135e4633bdcc01959d4ed846f 100644
--- a/test/Transforms/NaCl/expand-struct-regs.ll
+++ b/test/Transforms/NaCl/expand-struct-regs.ll
@@ -5,6 +5,8 @@
; CLEANUP-NOT: extractvalue
; CLEANUP-NOT: insertvalue
+target datalayout = "p:32:32:32"
+
%struct = type { i8, i32 }
@@ -18,9 +20,9 @@ define void @struct_load(%struct* %p, i8* %out0, i32* %out1) {
}
; CHECK: define void @struct_load
; CHECK-NEXT: %val.index{{.*}} = getelementptr %struct* %p, i32 0, i32 0
-; CHECK-NEXT: %val.field{{.*}} = load i8* %val.index{{.*}}, align 1
+; CHECK-NEXT: %val.field{{.*}} = load i8* %val.index{{.*}}
; CHECK-NEXT: %val.index{{.*}} = getelementptr %struct* %p, i32 0, i32 1
-; CHECK-NEXT: %val.field{{.*}} = load i32* %val.index{{.*}}, align 1
+; CHECK-NEXT: %val.field{{.*}} = load i32* %val.index{{.*}}
; CHECK-NEXT: store i8 %val.field{{.*}}, i8* %out0
; CHECK-NEXT: store i32 %val.field{{.*}}, i32* %out1
@@ -32,13 +34,13 @@ define void @struct_store(%struct* %in_ptr, %struct* %out_ptr) {
}
; CHECK: define void @struct_store
; CHECK-NEXT: %val.index{{.*}} = getelementptr %struct* %in_ptr, i32 0, i32 0
-; CHECK-NEXT: %val.field{{.*}} = load i8* %val.index{{.*}}, align 1
+; CHECK-NEXT: %val.field{{.*}} = load i8* %val.index{{.*}}
; CHECK-NEXT: %val.index{{.*}} = getelementptr %struct* %in_ptr, i32 0, i32 1
-; CHECK-NEXT: %val.field{{.*}} = load i32* %val.index{{.*}}, align 1
+; CHECK-NEXT: %val.field{{.*}} = load i32* %val.index{{.*}}
; CHECK-NEXT: %out_ptr.index{{.*}} = getelementptr %struct* %out_ptr, i32 0, i32 0
-; CHECK-NEXT: store i8 %val.field{{.*}}, i8* %out_ptr.index{{.*}}, align 1
+; CHECK-NEXT: store i8 %val.field{{.*}}, i8* %out_ptr.index{{.*}}
; CHECK-NEXT: %out_ptr.index{{.*}} = getelementptr %struct* %out_ptr, i32 0, i32 1
-; CHECK-NEXT: store i32 %val.field{{.*}}, i32* %out_ptr.index{{.*}}, align 1
+; CHECK-NEXT: store i32 %val.field{{.*}}, i32* %out_ptr.index{{.*}}
; Ensure that the pass works correctly across basic blocks.
@@ -124,3 +126,103 @@ define i32 @extract_from_constant() {
}
; CHECK: define i32 @extract_from_constant() {
; CHECK-NEXT: ret i32 888
+
+define void @nested_structs() {
+ %a1 = alloca i64
+ %a2 = alloca i32
+ %a3 = alloca { { i32, i64 } }
+ %a = insertvalue { i32, i64 } undef, i32 5, 0
+ %b = insertvalue { i32, i64 } %a, i64 6, 1
+ %c = insertvalue { { i32, i64 } } undef, { i32, i64 } %b, 0
+ %d = insertvalue { { { i32, i64 } }, i64 } undef, { { i32, i64 } } %c, 0
+ %e = insertvalue { { { i32, i64 } }, i64 } undef, { i32, i64 } %b, 0, 0
+
+ %f = extractvalue { { { i32, i64 } }, i64 } %d, 0, 0, 1
+ %g = extractvalue { { { i32, i64 } }, i64 } %e, 0, 0, 0
+ %h = extractvalue { { { i32, i64 } }, i64 } %e, 0
+ store i64 %f, i64* %a1
+ store i32 %g, i32* %a2
+ store { { i32, i64 } } %h, { { i32, i64 } }* %a3
+ ret void
+}
+; CHECK-LABEL: define void @nested_structs()
+; CHECK-NEXT: %a1 = alloca i64
+; CHECK-NEXT: %a2 = alloca i32
+; CHECK-NEXT: %a3 = alloca { { i32, i64 } }
+; CHECK-NEXT: store i64 6, i64* %a1
+; CHECK-NEXT: store i32 5, i32* %a2
+; CHECK-NEXT: %a3.index = getelementptr { { i32, i64 } }* %a3, i32 0, i32 0
+; CHECK-NEXT: %a3.index.index = getelementptr { i32, i64 }* %a3.index, i32 0, i32 0
+; CHECK-NEXT: store i32 5, i32* %a3.index.index
+; CHECK-NEXT: %a3.index.index1 = getelementptr { i32, i64 }* %a3.index, i32 0, i32 1
+; CHECK-NEXT: store i64 6, i64* %a3.index.index1
+
+define void @load_another_pass() {
+ %a = alloca { { i8, i64 } }
+ %b = load { { i8, i64 } }* %a
+ %c = load { { i8, i64 } }* %a, align 16
+ ret void
+}
+; CHECK-LABEL: define void @load_another_pass()
+; CHECK: %b.field.field = load i8* %b.field.index
+; CHECK: %b.field.field{{.*}} = load i64* %b.field.index{{.*}}
+; CHECK: %c.field.field = load i8* %c.field.index, align 16
+; CHECK: %c.field.field{{.*}} = load i64* %c.field.index{{.*}}, align 4
+
+define void @store_another_pass() {
+ %a = alloca { { i16, i64 } }
+ store { { i16, i64 } } undef, { { i16, i64 } }* %a
+ store { { i16, i64 } } undef, { { i16, i64 } }* %a, align 16
+ ret void
+}
+; CHECK-LABEL: define void @store_another_pass()
+; CHECK: store i16 undef, i16* %a.index.index
+; CHECK: store i64 undef, i64* %a.index.index{{.*}}
+; CHECK: store i16 undef, i16* %a.index1.index, align 16
+; CHECK: store i64 undef, i64* %a.index1.index{{.*}}, align 4
+
+define void @select_another_pass() {
+ %a = load { { i8, i64 } }* null
+ %b = load { { i8, i64 } }* null
+ %c = select i1 undef, { { i8, i64 } } %a, { { i8, i64 } } %b
+ store { { i8, i64 } } %c, { { i8, i64 } }* null
+ ret void
+}
+; CHECK-LABEL: define void @select_another_pass()
+; CHECK-NEXT: %a.index = getelementptr { { i8, i64 } }* null, i32 0, i32 0
+; CHECK-NEXT: %a.field.index = getelementptr { i8, i64 }* %a.index, i32 0, i32 0
+; CHECK-NEXT: %a.field.field = load i8* %a.field.index
+; CHECK-NEXT: %a.field.index2 = getelementptr { i8, i64 }* %a.index, i32 0, i32 1
+; CHECK-NEXT: %a.field.field3 = load i64* %a.field.index2
+; CHECK-NEXT: %b.index = getelementptr { { i8, i64 } }* null, i32 0, i32 0
+; CHECK-NEXT: %b.field.index = getelementptr { i8, i64 }* %b.index, i32 0, i32 0
+; CHECK-NEXT: %b.field.field = load i8* %b.field.index
+; CHECK-NEXT: %b.field.index5 = getelementptr { i8, i64 }* %b.index, i32 0, i32 1
+; CHECK-NEXT: %b.field.field6 = load i64* %b.field.index5
+; CHECK-NEXT: %c.index.index = select i1 undef, i8 %a.field.field, i8 %b.field.field
+; CHECK-NEXT: %c.index.index11 = select i1 undef, i64 %a.field.field3, i64 %b.field.field6
+; CHECK-NEXT: %.index = getelementptr { { i8, i64 } }* null, i32 0, i32 0
+; CHECK-NEXT: %.index.index = getelementptr { i8, i64 }* %.index, i32 0, i32 0
+; CHECK-NEXT: store i8 %c.index.index, i8* %.index.index
+; CHECK-NEXT: %.index.index13 = getelementptr { i8, i64 }* %.index, i32 0, i32 1
+; CHECK-NEXT: store i64 %c.index.index11, i64* %.index.index13
+; CHECK-NEXT: ret void
+
+define void @phi_another_pass() {
+entry:
+ br i1 false, label %next, label %not_next
+
+not_next:
+ %a = alloca { { i64, i16 }, i8* }
+ %b = load { { i64, i16 }, i8* }* %a
+ br label %next
+
+next:
+ %c = phi { { i64, i16 }, i8* } [ undef, %entry ], [ %b, %not_next ]
+ store { { i64, i16 }, i8* } %c, { { i64, i16 }, i8* }* null
+ ret void
+}
+; CHECK-LABEL: define void @phi_another_pass()
+; CHECK: %c.index.index = phi i64 [ undef, %entry ], [ %b.field.field, %not_next ]
+; CHECK: %c.index.index{{.*}} = phi i16 [ undef, %entry ], [ %b.field.field{{.*}}, %not_next ]
+; CHECK: %c.index{{.*}} = phi i8* [ undef, %entry ], [ %b.field{{.*}}, %not_next ]
« no previous file with comments | « lib/Transforms/NaCl/ExpandStructRegs.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698