Ensure bitcode encoding stays stable.

This includes constants, attributes, and some additional instructions not covered by previous tests.

Work was done by lama.saba@intel.com.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Kuperstein 2014-09-23 08:48:01 +00:00
parent 72bffaafb4
commit 5f843038fb
12 changed files with 390 additions and 58 deletions

View File

@ -0,0 +1,124 @@
; RUN: llvm-dis < %s.bc| FileCheck %s
; constantsTest.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
; The test checks that LLVM does not misread binary float instructions of
; older bitcode files.
;global variable address
; CHECK: @X = global i32 0
@X = global i32 0
; CHECK: @Y = global i32 1
@Y = global i32 1
; CHECK: @Z = global [2 x i32*] [i32* @X, i32* @Y]
@Z = global [2 x i32*] [i32* @X, i32* @Y]
define void @SimpleConstants(i32 %x) {
entry:
; null
; CHECK: store i32 %x, i32* null
store i32 %x, i32* null
; boolean
; CHECK-NEXT: %res1 = fcmp true float 1.000000e+00, 1.000000e+00
%res1 = fcmp true float 1.0, 1.0
; CHECK-NEXT: %res2 = fcmp false float 1.000000e+00, 1.000000e+00
%res2 = fcmp false float 1.0, 1.0
;integer
; CHECK-NEXT: %res3 = add i32 0, 0
%res3 = add i32 0, 0
;float
; CHECK-NEXT: %res4 = fadd float 0.000000e+00, 0.000000e+00
%res4 = fadd float 0.0, 0.0
ret void
}
define void @ComplexConstants(<2 x i32> %x){
entry:
;constant structure
; CHECK: %res1 = extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
%res1 = extractvalue {i32, float} {i32 1, float 2.0}, 0
;const array
; CHECK-NEXT: %res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
%res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
;const vector
; CHECK-NEXT: %res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
%res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
;zeroinitializer
; CHECK-NEXT: %res4 = add <2 x i32> %x, zeroinitializer
%res4 = add <2 x i32> %x, zeroinitializer
ret void
}
define void @OtherConstants(i32 %x, i8* %Addr){
entry:
;undef
; CHECK: %res1 = add i32 %x, undef
%res1 = add i32 %x, undef
;poison
; CHECK-NEXT: %poison = sub nuw i32 0, 1
%poison = sub nuw i32 0, 1
;address of basic block
; CHECK-NEXT: %res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
%res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
br label %Next
Next:
ret void
}
define void @OtherConstants2(){
entry:
; CHECK: trunc i32 1 to i8
trunc i32 1 to i8
; CHECK-NEXT: zext i8 1 to i32
zext i8 1 to i32
; CHECK-NEXT: sext i8 1 to i32
sext i8 1 to i32
; CHECK-NEXT: fptrunc double 1.000000e+00 to float
fptrunc double 1.0 to float
; CHECK-NEXT: fpext float 1.000000e+00 to double
fpext float 1.0 to double
; CHECK-NEXT: fptosi float 1.000000e+00 to i32
fptosi float 1.0 to i32
; CHECK-NEXT: uitofp i32 1 to float
uitofp i32 1 to float
; CHECK-NEXT: sitofp i32 -1 to float
sitofp i32 -1 to float
; CHECK-NEXT: ptrtoint i32* @X to i32
ptrtoint i32* @X to i32
; CHECK-NEXT: inttoptr i8 1 to i8*
inttoptr i8 1 to i8*
; CHECK-NEXT: bitcast i32 1 to <2 x i16>
bitcast i32 1 to <2 x i16>
; CHECK-NEXT: getelementptr i32* @X, i32 0
getelementptr i32* @X, i32 0
; CHECK-NEXT: getelementptr inbounds i32* @X, i32 0
getelementptr inbounds i32* @X, i32 0
; CHECK: select i1 true, i32 1, i32 0
select i1 true ,i32 1, i32 0
; CHECK-NEXT: icmp eq i32 1, 0
icmp eq i32 1, 0
; CHECK-NEXT: fcmp oeq float 1.000000e+00, 0.000000e+00
fcmp oeq float 1.0, 0.0
; CHECK-NEXT: extractelement <2 x i32> <i32 1, i32 1>, i32 1
extractelement <2 x i32> <i32 1, i32 1>, i32 1
; CHECK-NEXT: insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
; CHECK-NEXT: shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
; CHECK-NEXT: extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
extractvalue { i32, float } { i32 1, float 2.0 }, 0
; CHECK-NEXT: insertvalue { i32, float } { i32 1, float 2.000000e+00 }, i32 0, 0
insertvalue { i32, float } { i32 1, float 2.0 }, i32 0, 0
ret void
}

Binary file not shown.

View File

@ -1,7 +1,6 @@
; RUN: llvm-dis < %s.bc| FileCheck %s
; RUN: verify-uselistorder < %s.bc
; RUN: llvm-dis < %s.bc| FileCheck %s
; conversionOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
; conversionInstructions.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
; The test checks that LLVM does not misread conversion instructions from
; older bitcode files.
@ -9,7 +8,7 @@ define void @trunc(i32 %src){
entry:
; CHECK: %res1 = trunc i32 %src to i8
%res1 = trunc i32 %src to i8
ret void
}
@ -17,7 +16,7 @@ define void @zext(i32 %src){
entry:
; CHECK: %res1 = zext i32 %src to i64
%res1 = zext i32 %src to i64
ret void
}
@ -25,7 +24,7 @@ define void @sext(i32 %src){
entry:
; CHECK: %res1 = sext i32 %src to i64
%res1 = sext i32 %src to i64
ret void
}
@ -33,7 +32,7 @@ define void @fptrunc(double %src){
entry:
; CHECK: %res1 = fptrunc double %src to float
%res1 = fptrunc double %src to float
ret void
}
@ -41,7 +40,7 @@ define void @fpext(float %src){
entry:
; CHECK: %res1 = fpext float %src to double
%res1 = fpext float %src to double
ret void
}
@ -49,7 +48,7 @@ define void @fptoui(float %src){
entry:
; CHECK: %res1 = fptoui float %src to i32
%res1 = fptoui float %src to i32
ret void
}
@ -57,7 +56,7 @@ define void @fptosi(float %src){
entry:
; CHECK: %res1 = fptosi float %src to i32
%res1 = fptosi float %src to i32
ret void
}
@ -65,7 +64,7 @@ define void @uitofp(i32 %src){
entry:
; CHECK: %res1 = uitofp i32 %src to float
%res1 = uitofp i32 %src to float
ret void
}
@ -73,7 +72,7 @@ define void @sitofp(i32 %src){
entry:
; CHECK: %res1 = sitofp i32 %src to float
%res1 = sitofp i32 %src to float
ret void
}
@ -81,7 +80,7 @@ define void @ptrtoint(i32* %src){
entry:
; CHECK: %res1 = ptrtoint i32* %src to i8
%res1 = ptrtoint i32* %src to i8
ret void
}
@ -89,7 +88,7 @@ define void @inttoptr(i32 %src){
entry:
; CHECK: %res1 = inttoptr i32 %src to i32*
%res1 = inttoptr i32 %src to i32*
ret void
}
@ -97,9 +96,29 @@ define void @bitcast(i32 %src1, i32* %src2){
entry:
; CHECK: %res1 = bitcast i32 %src1 to i32
%res1 = bitcast i32 %src1 to i32
; CHECK: %res2 = bitcast i32* %src2 to i64*
%res2 = bitcast i32* %src2 to i64*
ret void
}
define void @ptrtointInstr(i32* %ptr, <4 x i32*> %vecPtr){
entry:
; CHECK: %res1 = ptrtoint i32* %ptr to i8
%res1 = ptrtoint i32* %ptr to i8
; CHECK-NEXT: %res2 = ptrtoint <4 x i32*> %vecPtr to <4 x i64>
%res2 = ptrtoint <4 x i32*> %vecPtr to <4 x i64>
ret void
}
define void @inttoptrInstr(i32 %x, <4 x i32> %vec){
entry:
; CHECK: %res1 = inttoptr i32 %x to i64*
%res1 = inttoptr i32 %x to i64*
; CHECK-NEXT: inttoptr <4 x i32> %vec to <4 x i8*>
%res2 = inttoptr <4 x i32> %vec to <4 x i8*>
ret void
}

View File

@ -0,0 +1,86 @@
; RUN: llvm-dis < %s.bc| FileCheck %s
; highLevelStructure.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
; The test checks that LLVM does not misread binary float instructions of
; older bitcode files.
; Data Layout Test
; CHECK: target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-f80:32-n8:16:32-S32"
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-a0:0:64-f80:32:32-n8:16:32-S32"
; Module-Level Inline Assembly Test
; CHECK: module asm "some assembly"
module asm "some assembly"
; Named Types Test
; CHECK: %mytype = type { %mytype*, i32 }
%mytype = type { %mytype*, i32 }
; Aliases Test
; CHECK: @glob1 = global i32 1
@glob1 = global i32 1
; CHECK: @aliased1 = alias i32* @glob1
@aliased1 = alias i32* @glob1
; CHECK-NEXT: @aliased2 = internal alias i32* @glob1
@aliased2 = internal alias i32* @glob1
; CHECK-NEXT: @aliased3 = alias i32* @glob1
@aliased3 = external alias i32* @glob1
; CHECK-NEXT: @aliased4 = weak alias i32* @glob1
@aliased4 = weak alias i32* @glob1
; CHECK-NEXT: @aliased5 = weak_odr alias i32* @glob1
@aliased5 = weak_odr alias i32* @glob1
;Parameter Attribute Test
; CHECK: declare void @ParamAttr1(i8 zeroext)
declare void @ParamAttr1(i8 zeroext)
; CHECK: declare void @ParamAttr2(i8* nest)
declare void @ParamAttr2(i8* nest)
; CHECK: declare void @ParamAttr3(i8* sret)
declare void @ParamAttr3(i8* sret)
; CHECK: declare void @ParamAttr4(i8 signext)
declare void @ParamAttr4(i8 signext)
; CHECK: declare void @ParamAttr5(i8* inreg)
declare void @ParamAttr5(i8* inreg)
; CHECK: declare void @ParamAttr6(i8* byval)
declare void @ParamAttr6(i8* byval)
; CHECK: declare void @ParamAttr7(i8* noalias)
declare void @ParamAttr7(i8* noalias)
; CHECK: declare void @ParamAttr8(i8* nocapture)
declare void @ParamAttr8(i8* nocapture)
; CHECK: declare void @ParamAttr9{{[(i8* nest noalias nocapture) | (i8* noalias nocapture nest)]}}
declare void @ParamAttr9(i8* nest noalias nocapture)
; CHECK: declare void @ParamAttr10{{[(i8* sret noalias nocapture) | (i8* noalias nocapture sret)]}}
declare void @ParamAttr10(i8* sret noalias nocapture)
;CHECK: declare void @ParamAttr11{{[(i8* byval noalias nocapture) | (i8* noalias nocapture byval)]}}
declare void @ParamAttr11(i8* byval noalias nocapture)
;CHECK: declare void @ParamAttr12{{[(i8* inreg noalias nocapture) | (i8* noalias nocapture inreg)]}}
declare void @ParamAttr12(i8* inreg noalias nocapture)
; NamedTypesTest
define void @NamedTypes() {
entry:
; CHECK: %res = alloca %mytype
%res = alloca %mytype
ret void
}
; Garbage Collector Name Test
; CHECK: define void @gcTest() gc "gc"
define void @gcTest() gc "gc" {
entry:
ret void
}
; Named metadata Test
; CHECK: !name = !{!0, !1, !2}
!name = !{!0, !1, !2}
; CHECK: !0 = metadata !{metadata !"zero"}
!0 = metadata !{metadata !"zero"}
; CHECK: !1 = metadata !{metadata !"one"}
!1 = metadata !{metadata !"one"}
; CHECK: !2 = metadata !{metadata !"two"}
!2 = metadata !{metadata !"two"}

Binary file not shown.

View File

@ -1,48 +1,107 @@
; RUN: llvm-dis < %s.bc| FileCheck %s
; RUN: verify-uselistorder < %s.bc
; RUN: llvm-dis < %s.bc| FileCheck %s
; miscInstructions.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
; The test checks that LLVM does not misread miscellaneous instructions of
; older bitcode files.
@X = global i8 1
@_ZTIi = global i8* @X
@_ZTId = global i8* @X
define i32 @__gxx_personality_v0(...){
entry:
ret i32 0
}
define void @landingpadInstr1(i1 %cond1, <2 x i1> %cond2, <2 x i8> %x1, <2 x i8> %x2){
entry:
; CHECK: %res = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
%res = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
; CHECK: catch i8** @_ZTIi
catch i8** @_ZTIi
ret void
}
define void @landingpadInstr2(i1 %cond1, <2 x i1> %cond2, <2 x i8> %x1, <2 x i8> %x2){
entry:
; CHECK: %res = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
%res = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
; CHECK: cleanup
cleanup
ret void
}
define void @landingpadInstr3(i1 %cond1, <2 x i1> %cond2, <2 x i8> %x1, <2 x i8> %x2){
entry:
; CHECK: %res = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
%res = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
; CHECK: catch i8** @_ZTIi
catch i8** @_ZTIi
; CHECK: filter [1 x i8**] [i8** @_ZTId]
filter [1 x i8**] [i8** @_ZTId]
ret void
}
define void @phiInstr(){
LoopHeader:
%x = add i32 0, 0
br label %Loop
Loop:
; CHECK: %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
%indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
%nextindvar = add i32 %indvar, 1
br label %Loop
ret void
}
define void @selectInstr(i1 %cond1, <2 x i1> %cond2, <2 x i8> %x1, <2 x i8> %x2){
entry:
; CHECK: %res1 = select i1 %cond1, i8 1, i8 0
%res1 = select i1 %cond1, i8 1, i8 0
; CHECK-NEXT: %res2 = select <2 x i1> %cond2, <2 x i8> %x1, <2 x i8> %x2
%res2 = select <2 x i1> %cond2, <2 x i8> %x1, <2 x i8> %x2
ret void
}
define void @icmp(i32 %x1, i32 %x2, i32* %ptr1, i32* %ptr2, <2 x i32> %vec1, <2 x i32> %vec2){
entry:
; CHECK: %res1 = icmp eq i32 %x1, %x2
%res1 = icmp eq i32 %x1, %x2
; CHECK-NEXT: %res2 = icmp ne i32 %x1, %x2
%res2 = icmp ne i32 %x1, %x2
; CHECK-NEXT: %res3 = icmp ugt i32 %x1, %x2
%res3 = icmp ugt i32 %x1, %x2
; CHECK-NEXT: %res4 = icmp uge i32 %x1, %x2
%res4 = icmp uge i32 %x1, %x2
; CHECK-NEXT: %res5 = icmp ult i32 %x1, %x2
%res5 = icmp ult i32 %x1, %x2
; CHECK-NEXT: %res6 = icmp ule i32 %x1, %x2
%res6 = icmp ule i32 %x1, %x2
; CHECK-NEXT: %res7 = icmp sgt i32 %x1, %x2
%res7 = icmp sgt i32 %x1, %x2
; CHECK-NEXT: %res8 = icmp sge i32 %x1, %x2
%res8 = icmp sge i32 %x1, %x2
; CHECK-NEXT: %res9 = icmp slt i32 %x1, %x2
%res9 = icmp slt i32 %x1, %x2
; CHECK-NEXT: %res10 = icmp sle i32 %x1, %x2
%res10 = icmp sle i32 %x1, %x2
; CHECK-NEXT: %res11 = icmp eq i32* %ptr1, %ptr2
%res11 = icmp eq i32* %ptr1, %ptr2
; CHECK-NEXT: %res12 = icmp eq <2 x i32> %vec1, %vec2
%res12 = icmp eq <2 x i32> %vec1, %vec2
ret void
}
@ -51,55 +110,55 @@ define void @fcmp(float %x1, float %x2, <2 x float> %vec1, <2 x float> %vec2){
entry:
; CHECK: %res1 = fcmp oeq float %x1, %x2
%res1 = fcmp oeq float %x1, %x2
; CHECK-NEXT: %res2 = fcmp one float %x1, %x2
%res2 = fcmp one float %x1, %x2
; CHECK-NEXT: %res3 = fcmp ugt float %x1, %x2
%res3 = fcmp ugt float %x1, %x2
; CHECK-NEXT: %res4 = fcmp uge float %x1, %x2
%res4 = fcmp uge float %x1, %x2
; CHECK-NEXT: %res5 = fcmp ult float %x1, %x2
%res5 = fcmp ult float %x1, %x2
; CHECK-NEXT: %res6 = fcmp ule float %x1, %x2
%res6 = fcmp ule float %x1, %x2
; CHECK-NEXT: %res7 = fcmp ogt float %x1, %x2
%res7 = fcmp ogt float %x1, %x2
; CHECK-NEXT: %res8 = fcmp oge float %x1, %x2
%res8 = fcmp oge float %x1, %x2
; CHECK-NEXT: %res9 = fcmp olt float %x1, %x2
%res9 = fcmp olt float %x1, %x2
; CHECK-NEXT: %res10 = fcmp ole float %x1, %x2
%res10 = fcmp ole float %x1, %x2
; CHECK-NEXT: %res11 = fcmp ord float %x1, %x2
%res11 = fcmp ord float %x1, %x2
; CHECK-NEXT: %res12 = fcmp ueq float %x1, %x2
%res12 = fcmp ueq float %x1, %x2
; CHECK-NEXT: %res13 = fcmp une float %x1, %x2
%res13 = fcmp une float %x1, %x2
; CHECK-NEXT: %res14 = fcmp uno float %x1, %x2
%res14 = fcmp uno float %x1, %x2
; CHECK-NEXT: %res15 = fcmp true float %x1, %x2
%res15 = fcmp true float %x1, %x2
; CHECK-NEXT: %res16 = fcmp false float %x1, %x2
%res16 = fcmp false float %x1, %x2
; CHECK-NEXT: %res17 = fcmp oeq <2 x float> %vec1, %vec2
%res17 = fcmp oeq <2 x float> %vec1, %vec2
ret void
}
@ -110,13 +169,13 @@ entry:
; CHECK: %res1 = call i32 @test(i32 %x)
%res1 = call i32 @test(i32 %x)
; CHECK-NEXT: %res2 = tail call i32 @test(i32 %x)
%res2 = tail call i32 @test(i32 %x)
; CHECK-NEXT: %res3 = call i32 (i8*, ...)* @printf(i8* %msg, i32 12, i8 42)
%res3 = call i32 (i8*, ...)* @printf(i8* %msg, i32 12, i8 42)
ret void
}

View File

@ -0,0 +1,16 @@
; RUN: llvm-dis < %s.bc| FileCheck %s
; standardCIntrinsic.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
; The test checks that LLVM does not misread standard C library intrinsic functions
; of older bitcode files.
define void @memcpyintrinsic(i8* %dest, i8* %src, i32 %len) {
entry:
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 1, i1 true)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 1, i1 true)
ret void
}
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 %align, i1 %isvolatile)

Binary file not shown.

View File

@ -1,5 +1,4 @@
; RUN: llvm-dis < %s.bc| FileCheck %s
; RUN: verify-uselistorder < %s.bc
; RUN: llvm-dis < %s.bc| FileCheck %s
; TerminatorOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
; The test checks that LLVM does not misread terminator instructions from
@ -9,10 +8,10 @@ define i32 @condbr(i1 %cond){
entry:
; CHECK: br i1 %cond, label %TrueLabel, label %FalseLabel
br i1 %cond, label %TrueLabel, label %FalseLabel
TrueLabel:
ret i32 1
FalseLabel:
ret i32 0
}
@ -21,7 +20,7 @@ define i32 @uncondbr(){
entry:
; CHECK: br label %uncondLabel
br label %uncondLabel
uncondLabel:
ret i32 1
}
@ -30,10 +29,10 @@ define i32 @indirectbr(i8* %Addr){
entry:
; CHECK: indirectbr i8* %Addr, [label %bb1, label %bb2]
indirectbr i8* %Addr, [ label %bb1, label %bb2 ]
bb1:
ret i32 1
bb2:
ret i32 0
}
@ -42,7 +41,36 @@ define void @unreachable(){
entry:
; CHECK: unreachable
unreachable
ret void
}
define i32 @retInstr(){
entry:
; CHECK: ret i32 1
ret i32 1
}
define void @retInstr2(){
entry:
; CHECK: ret void
ret void
}
define i32 @switchInstr(i32 %x){
entry:
; CHECK: switch i32 %x, label %label3 [
switch i32 %x, label %label3 [
; CHECK-NEXT: i32 1, label %label1
i32 1, label %label1
; CHECK-NEXT: i32 2, label %label2
i32 2, label %label2
]
label1:
ret i32 1
label2:
ret i32 2
label3:
ret i32 0
}