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

Unified Diff: test/NaCl/Bitcode/globalvars.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
« no previous file with comments | « test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll ('k') | test/NaCl/Bitcode/implicit-datalayout.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/NaCl/Bitcode/globalvars.ll
diff --git a/test/NaCl/Bitcode/globalvars.ll b/test/NaCl/Bitcode/globalvars.ll
new file mode 100644
index 0000000000000000000000000000000000000000..3bd9890aa8285ea9726bd379d29d0c4e3be454dd
--- /dev/null
+++ b/test/NaCl/Bitcode/globalvars.ll
@@ -0,0 +1,106 @@
+; RUN: llvm-as < %s | pnacl-freeze | pnacl-thaw | llvm-dis - | FileCheck %s
+; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump-records \
+; RUN: | FileCheck %s -check-prefix=BC
+
+; Test that we generate appropriate bitcode values for global variables.
+
+; Make sure that no struct/array/pointer types are generated by the
+; global variables.
+; BC: <TYPE_BLOCK_ID
+; BC-NEXT: <NUMENTRY
+; BC-NEXT: <VOID/>
+; BC-NEXT: <FUNCTION
+; BC-NEXT: </TYPE_BLOCK_ID>
+
+; Make sure that the function declaration for function func (below)
+; appears before the global variables block.
+; BC: <FUNCTION op0=1 op1=0 op2=0 op3=0/>
+
+; Make sure we begin the globals block after function declarations.
+; BC-NEXT: <GLOBALVAR_BLOCK
+; BC-NEXT: <COUNT op0=15/>
+
+@bytes = internal global [7 x i8] c"abcdefg"
+; CHECK: @bytes = internal global [7 x i8] c"abcdefg"
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <DATA op0=97 op1=98 op2=99 op3=100 op4=101 op5=102 op6=103/>
+
+
+@ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32)
+; CHECK: @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=5/>
+
+@ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32)
+; CHECK: @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=0/>
+
+@compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }>
+; CHECK: @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }>
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <COMPOUND op0=2/>
+; BC-NEXT: <DATA op0=102 op1=111 op2=111/>
+; BC-NEXT: <RELOC op0=0/>
+
+@ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32)
+; CHECK: @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=1/>
+
+@addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1)
+; CHECK: @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=5 op1=1/>
+
+@addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1)
+; CHECK: @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=5 op1=4294967295/>
+
+@addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1)
+; CHECK: @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=1 op1=1/>
+
+@addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7)
+; CHECK: @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=1 op1=7/>
+
+@addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9)
+; CHECK: @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=1 op1=9/>
+
+@addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1)
+; CHECK: @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=4 op1=1/>
+
+@addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4)
+; CHECK: @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4)
+; BC-NEXT: <VAR op0=0 op1=0/>
+; BC-NEXT: <RELOC op0=4 op1=4/>
+
+@ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8
+; CHECK: @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8
+; BC-NEXT: <VAR op0=4 op1=0/>
+; BC-NEXT: <RELOC op0=0/>
+
+@char = internal constant [1 x i8] c"0"
+; CHECK: @char = internal constant [1 x i8] c"0"
+; BC-NEXT: <VAR op0=0 op1=1/>
+; BC-NEXT: <DATA op0=48/>
+
+@short = internal constant [2 x i8] zeroinitializer
+; CHECK: @short = internal constant [2 x i8] zeroinitializer
+; BC-NEXT: <VAR op0=0 op1=1/>
+; BC-NEXT: <ZEROFILL op0=2/>
+
+; BC-NEXT: </GLOBALVAR_BLOCK>
+
+define void @func() {
+ ret void
+}
+
« no previous file with comments | « test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll ('k') | test/NaCl/Bitcode/implicit-datalayout.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698