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

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: Forgot a small change. 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
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..f0b30f26264a162f51592a3a666074beec822a65 100644
--- a/test/Transforms/NaCl/expand-struct-regs.ll
+++ b/test/Transforms/NaCl/expand-struct-regs.ll
@@ -124,3 +124,71 @@ 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, align 1
+; CHECK-NEXT: %a3.index.index1 = getelementptr { i32, i64 }* %a3.index, i32 0, i32 1
+; CHECK-NEXT: store i64 6, i64* %a3.index.index1, align 1
+
+define void @nested_structs_phi_load() {
Mark Seaborn 2014/12/09 20:39:46 I'm not sure what this test case is intended to te
Richard Diamond 2014/12/10 00:58:06 It's not. JF asked for a test with phi and load in
+entry:
+ %a3 = alloca { { i32, i64 }* }
+ %a = insertvalue { i32, i64 } undef, i32 5, 0
+ %b = insertvalue { i32, i64 } %a, i64 6, 1
+ %a4 = getelementptr { { i32, i64 }* }* %a3, i32 0, i32 0
+ br label %next
+
+next:
+ %n1 = phi { i32, i64 } [ %b, %entry ]
+ %n2 = phi { i32, i64 }** [ %a4, %entry ]
+ %n3 = load { i32, i64 }** %n2
+ store { i32, i64 } %n1, { i32, i64 }* %n3
+ %n4 = load { i32, i64 }* %n3
+ %n5 = extractvalue { i32, i64 } %n4, 0
+ %n6 = extractvalue { i32, i64 } %n4, 1
+ ret void
+}
+; CHECK-LABEL: define void @nested_structs_phi_load()
+; CHECK-NEXT: entry:
+; CHECK-NEXT: %a3 = alloca { { i32, i64 }* }
+; CHECK-NEXT: %a4 = getelementptr { { i32, i64 }* }* %a3, i32 0, i32 0
+; CHECK-NEXT: br label %next
+; CHECK: next:
+; CHECK-NEXT: %n1.index = phi i32 [ 5, %entry ]
+; CHECK-NEXT: %n1.index1 = phi i64 [ 6, %entry ]
+; CHECK-NEXT: %n2 = phi { i32, i64 }** [ %a4, %entry ]
+; CHECK-NEXT: %n3 = load { i32, i64 }** %n2
+; CHECK-NEXT: %n3.index = getelementptr { i32, i64 }* %n3, i32 0, i32 0
+; CHECK-NEXT: store i32 %n1.index, i32* %n3.index, align 1
+; CHECK-NEXT: %n3.index4 = getelementptr { i32, i64 }* %n3, i32 0, i32 1
+; CHECK-NEXT: store i64 %n1.index1, i64* %n3.index4, align 1
+; CHECK-NEXT: %n4.index = getelementptr { i32, i64 }* %n3, i32 0, i32 0
+; CHECK-NEXT: %n4.field = load i32* %n4.index, align 1
+; CHECK-NEXT: %n4.index5 = getelementptr { i32, i64 }* %n3, i32 0, i32 1
+; CHECK-NEXT: %n4.field6 = load i64* %n4.index5, align 1
+; CHECK-NEXT: ret void
« lib/Transforms/NaCl/ExpandStructRegs.cpp ('K') | « lib/Transforms/NaCl/ExpandStructRegs.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698