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

Unified Diff: test/Transforms/MinSFI/allocate-data-segment.ll

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 months 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/MinSFI/allocate-data-segment.ll
diff --git a/test/Transforms/MinSFI/allocate-data-segment.ll b/test/Transforms/MinSFI/allocate-data-segment.ll
new file mode 100644
index 0000000000000000000000000000000000000000..9327221de78ecc6456a755782ec283d2c8202cb0
--- /dev/null
+++ b/test/Transforms/MinSFI/allocate-data-segment.ll
@@ -0,0 +1,46 @@
+; RUN: opt %s -minsfi-allocate-data-segment -S | FileCheck %s
+
+target datalayout = "p:32:32:32"
+target triple = "le32-unknown-nacl"
+
+; Every global variable in PNaCl IR must have an initializer. This is an
+; exhaustive list of all the possible formats.
+
+@a = global [1 x i8] zeroinitializer ; no alignment
+@b = global [3 x i8] c"ABC" ; no alignment
+@c = global [5 x i8] c"ABCDE", align 16 ; explicit 16B align
+@d = global i32 ptrtoint ([3 x i8]* @b to i32) ; implicit 4B align
+@e = global i32 add (i32 ptrtoint ([5 x i8]* @c to i32), i32 3), align 2
+ ; implicit 4B align
+@f = global <{ [1 x i8], i32 }>
+ <{ [1 x i8] zeroinitializer,
+ i32 ptrtoint ([5 x i8]* @c to i32) }> ; no alignment
+@g = global [1 x i8] zeroinitializer ; no alignment
+
+; Use each variable to verify its location
+
+define void @use_variables() {
+ %a = load [1 x i8]* @a
+ %b = load [3 x i8]* @b
+ %c = load [5 x i8]* @c
+ %d = load i32* @d
+ %e = load i32* @e
+ %f = load <{ [1 x i8], i32 }>* @f
+ %g = load [1 x i8]* @g
+ ret void
+}
+
+; CHECK: %__sfi_data_segment = type <{ [1 x i8], [3 x i8], [12 x i8], [5 x i8], [3 x i8], i32, i32, <{ [1 x i8], i32 }>, [1 x i8] }>
+; CHECK: @__sfi_data_segment = constant %__sfi_data_segment <{ [1 x i8] zeroinitializer, [3 x i8] c"ABC", [12 x i8] zeroinitializer, [5 x i8] c"ABCDE", [3 x i8] zeroinitializer, i32 65537, i32 65555, <{ [1 x i8], i32 }> <{ [1 x i8] zeroinitializer, i32 65552 }>, [1 x i8] zeroinitializer }>
+; CHECK: @__sfi_data_segment_size = constant i32 38
+
+; CHECK-LABEL: define void @use_variables() {
+; CHECK-NEXT: %a = load [1 x i8]* inttoptr (i32 65536 to [1 x i8]*)
+; CHECK-NEXT: %b = load [3 x i8]* inttoptr (i32 65537 to [3 x i8]*)
+; CHECK-NEXT: %c = load [5 x i8]* inttoptr (i32 65552 to [5 x i8]*)
+; CHECK-NEXT: %d = load i32* inttoptr (i32 65560 to i32*)
+; CHECK-NEXT: %e = load i32* inttoptr (i32 65564 to i32*)
+; CHECK-NEXT: %f = load <{ [1 x i8], i32 }>* inttoptr (i32 65568 to <{ [1 x i8], i32 }>*)
+; CHECK-NEXT: %g = load [1 x i8]* inttoptr (i32 65573 to [1 x i8]*)
+; CHECK-NEXT: ret void
+; CHECK-NEXT: }

Powered by Google App Engine
This is Rietveld 408576698