Closed mewmew closed 3 years ago
From llir/llvm
directory, run:
go test -v ./...
Search for mismatch
in test case output:
asm_test.go:531: module "../testdata/llvm/test/Transforms/InstCombine/vec_demanded_elts.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Transforms/InstSimplify/compare.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Transforms/Attributor/nonnull.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Feature/OperandBundles/adce.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Feature/OperandBundles/early-cse.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Feature/optnone-opt.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Assembler/2008-01-11-VarargAttrs.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Assembler/ConstantExprNoFold.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/Assembler/disubprogram.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/CodeGen/X86/extractps.ll.golden" mismatch (-want +got):
asm_test.go:531: module "../testdata/llvm/test/DebugInfo/X86/safestack-byval.ll.golden" mismatch (-want +got):
Search for syntax error at line
in test case output:
asm_test.go:516: unable to parse "../testdata/llvm/test/Bitcode/compatibility.ll" into AST; syntax error at line 46
asm_test.go:516: unable to parse "../testdata/llvm/test/DebugInfo/ARM/selectiondag-deadcode.ll" into AST; syntax error at line 4
asm_test.go:516: unable to parse "../testdata/llvm/test/Feature/callingconventions.ll" into AST; syntax error at line 14
asm_test.go:516: unable to parse "../testdata/llvm/test/Assembler/dimodule.ll" into AST; syntax error at line 21
Notes on how the golden test cases were updated in commit https://github.com/mewpull/testdata/commit/3ccdb27b7a0d087823e29b1a9a19bd1aa6273e67
test/Transforms/InstCombine/vec_demanded_elts.ll
git diff HEAD^1 -- test/Transforms/InstCombine/vec_demanded_elts.ll | grep -v "^[+-];" | grep "^[+]"
+++ b/llvm/test/Transforms/InstCombine/vec_demanded_elts.ll
+
+define <4 x float> @ins_of_ext(<4 x float> %x, float %y) {
+ %e0 = extractelement <4 x float> %x, i32 0
+ %i0 = insertelement <4 x float> undef, float %e0, i32 0
+ %i1 = insertelement <4 x float> %i0, float %y, i32 1
+ %i2 = insertelement <4 x float> %i1, float %y, i32 2
+ %i3 = insertelement <4 x float> %i2, float %y, i32 3
+ ret <4 x float> %i3
+}
+
+define <4 x float> @ins_of_ext_twice(<4 x float> %x, float %y) {
+ %e0 = extractelement <4 x float> %x, i32 0
+ %i0 = insertelement <4 x float> undef, float %e0, i32 0
+ %e1 = extractelement <4 x float> %x, i32 1
+ %i1 = insertelement <4 x float> %i0, float %e1, i32 1
+ %i2 = insertelement <4 x float> %i1, float %y, i32 2
+ %i3 = insertelement <4 x float> %i2, float %y, i32 3
+ ret <4 x float> %i3
+}
+
+
+define <4 x float> @ins_of_ext_wrong_demand(<4 x float> %x, float %y) {
+ %e0 = extractelement <4 x float> %x, i32 0
+ %i0 = insertelement <4 x float> undef, float %e0, i32 0
+ %i1 = insertelement <4 x float> %i0, float %y, i32 1
+ %i2 = insertelement <4 x float> %i1, float %y, i32 2
+ ret <4 x float> %i2
+}
+
+
+define <4 x float> @ins_of_ext_wrong_type(<5 x float> %x, float %y) {
+ %e0 = extractelement <5 x float> %x, i32 0
+ %i0 = insertelement <4 x float> undef, float %e0, i32 0
+ %i1 = insertelement <4 x float> %i0, float %y, i32 1
+ %i2 = insertelement <4 x float> %i1, float %y, i32 2
+ %i3 = insertelement <4 x float> %i2, float %y, i32 3
+ ret <4 x float> %i3
+}
+
+
+define <4 x i4> @ins_of_ext_undef_elts_propagation(<4 x i4> %v, <4 x i4> %v2, i4 %x) {
+ %v0 = extractelement <4 x i4> %v, i32 0
+ %t0 = insertelement <4 x i4> undef, i4 %v0, i32 0
+ %t2 = insertelement <4 x i4> %t0, i4 %x, i32 2
+ %r = shufflevector <4 x i4> %t2, <4 x i4> %v2, <4 x i32> <i32 0, i32 6, i32 2, i32 7>
+ ret <4 x i4> %r
+}
+
+
+define <8 x i4> @ins_of_ext_undef_elts_propagation2(<8 x i4> %v, <8 x i4> %v2, i4 %x) {
+ %i15 = extractelement <8 x i4> %v, i32 0
+ %i16 = insertelement <8 x i4> undef, i4 %i15, i32 0
+ %i17 = extractelement <8 x i4> %v, i32 1
+ %i18 = insertelement <8 x i4> %i16, i4 %i17, i32 1
+ %i19 = insertelement <8 x i4> %i18, i4 %x, i32 2
+ %i20 = shufflevector <8 x i4> %i19, <8 x i4> %v2, <8 x i32> <i32 0, i32 1, i32 2, i32 11, i32 10, i32 9, i32 8, i32 undef>
+ %i21 = shufflevector <8 x i4> %i20, <8 x i4> %v, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 15>
+ ret <8 x i4> %i21
+}
From the git diff
output we see that several new function definitions have been added. Copy these from vec_demanded_elts.ll
to vec_demanded_elts.ll.golden
and add each function to their corresponding source code position. Update formatting (e.g. using tags instead of spaces for indentation) and remove line comments for the *.ll.golden
file.
test/Transforms/Attributor/nonnull.ll
git diff HEAD^1 -- test/Transforms/Attributor/nonnull.ll | grep -v "^[+-];" | grep "^[+]"
+++ b/llvm/test/Transforms/Attributor/nonnull.ll
+declare i8 @use1safecall(i8* %x) readonly nounwind willreturn ; nounwind+willreturn guarantees that execution continues to successor
+declare i8* @strrchr(i8* %0, i32 %1) nofree nounwind readonly willreturn
+define i8* @nonnull_function_ptr_1() {
+ %bc = bitcast i8*()* @nonnull_function_ptr_1 to i8*
+ ret i8* %bc
+}
+
+declare i8* @function_decl()
+define i8* @nonnull_function_ptr_2() {
+ %bc = bitcast i8*()* @function_decl to i8*
+ ret i8* %bc
+}
+
+define void @nonnull_caller(i8* %p) {
+ call void @nonnull_callee(i8* %p)
+ ret void
+}
+
+declare void @nonnull_callee(i8* nonnull %p)
+
A few new function definitions and declaration have been added. Follow the same steps for nonnull.ll
as we did for vec_demanded_elts.ll
to update the golden test case file nonnull.ll.golden
.
test/Feature/OperandBundles/adce.ll
git diff HEAD^1 -- test/Feature/OperandBundles/adce.ll | grep -v "^[+-];" | grep "^[+]"
+++ b/llvm/test/Feature/OperandBundles/adce.ll
+declare void @readonly_function() readonly nounwind willreturn
+declare void @readnone_function() readnone nounwind willreturn
Only two new function declarations have been updated (the function attribute willreturn
was added).
Search for them in test/Feature/OperandBundles/adce.ll
and add them to test/Feature/OperandBundles/adce.ll.golden
at the corresponding place in the source file.
test/Feature/OperandBundles/early-cse.ll
git diff HEAD^1 -- test/Feature/OperandBundles/early-cse.ll | grep -v "^[+-];" | grep "^[+]"
+++ b/llvm/test/Feature/OperandBundles/early-cse.ll
+declare void @readonly_function() readonly nounwind willreturn
+declare void @readnone_function() readnone nounwind willreturn
Same procedure as adce.ll
test/Feature/optnone-opt.ll
git diff HEAD^1 -- test/Feature/optnone-opt.ll | grep -v "^[+-];"
--- a/llvm/test/Feature/optnone-opt.ll
+++ b/llvm/test/Feature/optnone-opt.ll
@@ -11,7 +18,7 @@
; optimizations on optnone functions.
; Function Attrs: noinline optnone
-define i32 @_Z3fooi(i32 %x) #0 {
+define i32 @foo(i32 %x) #0 {
entry:
%x.addr = alloca i32, align 4
store i32 %x, i32* %x.addr, align 4
@@ -28,38 +35,67 @@ while.body: ; preds = %while.cond
br label %while.cond
while.end: ; preds = %while.cond
- ret i32 0
+ ret i32 %dec
}
Update function name from @_Z3fooi
(C++ name mangled) to @foo
and update return argument from i32 0
to i32 %dec
.
test/Assembler/2008-01-11-VarargAttrs.ll
git diff HEAD^1 -- test/Assembler/2008-01-11-VarargAttrs.ll
--- a/llvm/test/Assembler/2008-01-11-VarargAttrs.ll
+++ b/llvm/test/Assembler/2008-01-11-VarargAttrs.ll
@@ -6,6 +6,6 @@
declare void @foo(...)
define void @bar() {
- call void (...) @foo(%struct* byval null )
+ call void (...) @foo(%struct* byval(%struct) null )
ret void
}
The parameter attribute (byval
) syntax has been updated. Update the golden test case file 2008-01-11-VarargAttrs.ll.golden
accordingly.
test/Assembler/ConstantExprNoFold.ll
git diff HEAD^1 -- test/Assembler/ConstantExprNoFold.ll
--- a/llvm/test/Assembler/ConstantExprNoFold.ll
+++ b/llvm/test/Assembler/ConstantExprNoFold.ll
@@ -42,6 +42,12 @@ target datalayout = "p:32:32"
@empty.2 = external global [0 x i8], align 1
@empty.cmp = global i1 icmp eq ([0 x i8]* @empty.1, [0 x i8]* @empty.2)
+; Two unnamed_addr globals can share an address
+; CHECK: @unnamed.cmp = global i1 icmp eq ([5 x i8]* @unnamed.1, [5 x i8]* @unnamed.2)
+@unnamed.1 = unnamed_addr constant [5 x i8] c"asdf\00"
+@unnamed.2 = unnamed_addr constant [5 x i8] c"asdf\00"
+@unnamed.cmp = global i1 icmp eq ([5 x i8]* @unnamed.1, [5 x i8]* @unnamed.2)
+
@addrspace3 = internal addrspace(3) global i32 undef
; CHECK: @no.fold.addrspace.icmp.eq.gv.null = global i1 icmp eq (i32 addrspace(3)* @addrspace3, i32 addrspace(3)* null)
Three new global variable definition have been added to ConstantExprNoFold.ll
. Copy them to the golden test case file ConstantExprNoFold.ll.golden
.
test/Assembler/disubprogram.ll
git diff HEAD^1 -- test/Assembler/disubprogram.ll
--- a/llvm/test/Assembler/disubprogram.ll
+++ b/llvm/test/Assembler/disubprogram.ll
@@ -25,8 +25,8 @@ define void @_Z3foov() !dbg !9 {
isOptimized: true, flags: "-O2",
splitDebugFilename: "abc.debug", emissionKind: 2)
-; CHECK: !9 = !DISubprogram(scope: null, spFlags: 0)
-!9 = !DISubprogram(isDefinition: false)
+; CHECK: !9 = distinct !DISubprogram(scope: null, spFlags: 0)
+!9 = distinct !DISubprogram(isDefinition: false)
; CHECK: !10 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1, file: !2, line: 7, type: !3, scopeLine: 8, containingType: !4, virtualIndex: 10, thisAdjustment: 3, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagPureVirtual | DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !5, declaration: !9, retainedNodes: !6)
!10 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
The specialized metadata field !DISubprogram
has been made distinct. Update the golden test case file disubprogram.ll.golden
accordingly.
test/CodeGen/X86/extractps.ll
git diff HEAD^1 -- test/CodeGen/X86/extractps.ll
--- a/llvm/test/CodeGen/X86/extractps.ll
+++ b/llvm/test/CodeGen/X86/extractps.ll
@@ -2,7 +2,7 @@
; RUN: llc < %s -mtriple=i686-- -mcpu=penryn | FileCheck %s
; PR2647
-@0 = external global float, align 16 ; <float*>:0 [#uses=2]
+@0 = external dso_local global float, align 16 ; <float*>:0 [#uses=2]
define internal void @a() nounwind {
; CHECK-LABEL: a:
The global variable declaration @0
has been made dso_local
in extractps.ll
. Update the golden test case file extractps.ll.golden
accordingly.
test/DebugInfo/X86/safestack-byval.ll
git diff HEAD^1 -- test/DebugInfo/X86/safestack-byval.ll
--- a/llvm/test/DebugInfo/X86/safestack-byval.ll
+++ b/llvm/test/DebugInfo/X86/safestack-byval.ll
@@ -21,7 +21,7 @@
@__safestack_unsafe_stack_ptr = external thread_local(initialexec) global i8*
; Function Attrs: norecurse nounwind readonly safestack uwtable
-define i32 @_Z1f1Sm(%struct.S* byval nocapture readonly align 8 %zzz, i64 %len) #0 !dbg !12 {
+define i32 @_Z1f1Sm(%struct.S* byval(%struct.S) nocapture readonly align 8 %zzz, i64 %len) #0 !dbg !12 {
entry:
%unsafe_stack_ptr = load i8*, i8** @__safestack_unsafe_stack_ptr, !dbg !22
%unsafe_stack_static_top = getelementptr i8, i8* %unsafe_stack_ptr, i32 -400, !dbg !22
The parameter attribute (byval
) syntax has been updated. Update the golden test case file safestack-byval.ll.golden
accordingly.
test/Transforms/InstSimplify/compare.ll.golden
git diff HEAD^1 -- test/Transforms/InstSimplify/compare.ll
The compare.ll
has had a lot of new function definitions added. Copy them over from compare.ll
to the golden test case file compare.ll.golden
and add each function to their corresponding source code position. Update formatting (e.g. using tags instead of spaces for indentation) and remove line comments for the *.ll.golden
file.
The following test case files require updates to the LLVM IR grammar (for inspiration, see #101 for updating the grammar to LLVM 9.0).
For errors like asm_test.go:516: unable to parse "../testdata/llvm/test/Bitcode/compatibility.ll" into AST; syntax error at line 46
:
testdata/llvm/test/Bitcode/compatibility.ll
(line 46)
poison
Fixed by PR https://github.com/llir/testdata/pull/9.
Similar steps taken to those detailed in #132.
Update of llir/testdata/llvm/Makefile:
Update
*.ll
test cases of LLVM