Test source: git
Source: <stdin>
-- 1. ModuleToFunctionPassAdaptor
-- 1. PassManager<Function> : Skipping NOP
-- 2. MergeICmpsPass
----------------------------------------
declare void @foo(...)
define i1 @opeq1(ptr nocapture nowrite dereferenceable(16) %a, ptr nocapture nowrite dereferenceable(16) %b) nofree zeroext {
entry:
%#0 = load i32, ptr nocapture nowrite dereferenceable(16) %a, align 4
%#1 = load i32, ptr nocapture nowrite dereferenceable(16) %b, align 4
call void @foo() memory(inaccessiblemem: readwrite)
%cmp.i = icmp eq i32 %#0, %#1
br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit
land.rhs.i:
%second.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %a, 16 x i64 0, 1 x i64 4
%#2 = load i32, ptr %second.i, align 4
%second2.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %b, 16 x i64 0, 1 x i64 4
%#3 = load i32, ptr %second2.i, align 4
%cmp2.i = icmp eq i32 %#2, %#3
br i1 %cmp2.i, label %land.rhs.i.2, label %opeq1.exit
land.rhs.i.2:
%third.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %a, 16 x i64 0, 1 x i64 8
%#4 = load i32, ptr %third.i, align 4
%third2.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %b, 16 x i64 0, 1 x i64 8
%#5 = load i32, ptr %third2.i, align 4
%cmp3.i = icmp eq i32 %#4, %#5
br i1 %cmp3.i, label %land.rhs.i.3, label %opeq1.exit
land.rhs.i.3:
%fourth.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %a, 16 x i64 0, 1 x i64 12
%#6 = load i32, ptr %fourth.i, align 4
%fourth2.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %b, 16 x i64 0, 1 x i64 12
%#7 = load i32, ptr %fourth2.i, align 4
%cmp4.i = icmp eq i32 %#6, %#7
br label %opeq1.exit
opeq1.exit:
%#8 = phi i1 [ 0, %entry ], [ 0, %land.rhs.i ], [ 0, %land.rhs.i.2 ], [ %cmp4.i, %land.rhs.i.3 ]
ret i1 %#8
}
Transformation seems to be correct! (syntactically equal)
-- 3. MergeICmpsPass
----------------------------------------
declare void @foo(...)
define i1 @opeq1(ptr nocapture nowrite dereferenceable(16) %a, ptr nocapture nowrite dereferenceable(16) %b) nofree zeroext {
entry:
%#0 = load i32, ptr nocapture nowrite dereferenceable(16) %a, align 4
%#1 = load i32, ptr nocapture nowrite dereferenceable(16) %b, align 4
call void @foo() memory(inaccessiblemem: readwrite)
%cmp.i = icmp eq i32 %#0, %#1
br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit
land.rhs.i:
%second.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %a, 16 x i64 0, 1 x i64 4
%#2 = load i32, ptr %second.i, align 4
%second2.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %b, 16 x i64 0, 1 x i64 4
%#3 = load i32, ptr %second2.i, align 4
%cmp2.i = icmp eq i32 %#2, %#3
br i1 %cmp2.i, label %land.rhs.i.2, label %opeq1.exit
land.rhs.i.2:
%third.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %a, 16 x i64 0, 1 x i64 8
%#4 = load i32, ptr %third.i, align 4
%third2.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %b, 16 x i64 0, 1 x i64 8
%#5 = load i32, ptr %third2.i, align 4
%cmp3.i = icmp eq i32 %#4, %#5
br i1 %cmp3.i, label %land.rhs.i.3, label %opeq1.exit
land.rhs.i.3:
%fourth.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %a, 16 x i64 0, 1 x i64 12
%#6 = load i32, ptr %fourth.i, align 4
%fourth2.i = gep inbounds ptr nocapture nowrite dereferenceable(16) %b, 16 x i64 0, 1 x i64 12
%#7 = load i32, ptr %fourth2.i, align 4
%cmp4.i = icmp eq i32 %#6, %#7
br label %opeq1.exit
opeq1.exit:
%#8 = phi i1 [ 0, %entry ], [ 0, %land.rhs.i ], [ 0, %land.rhs.i.2 ], [ %cmp4.i, %land.rhs.i.3 ]
ret i1 %#8
}
=>
declare void @foo(...)
declare i32 @memcmp(nocapture ptr, nocapture ptr, i64) nofree willreturn memory(argmem: read)
define i1 @opeq1(ptr nocapture nowrite dereferenceable(16) %a, ptr nocapture nowrite dereferenceable(16) %b) nofree zeroext {
entry+land.rhs.i+land.rhs.i.2+land.rhs.i.3:
call void @foo() memory(inaccessiblemem: readwrite)
%memcmp = memcmp ptr nocapture nowrite dereferenceable(16) %a, ptr nocapture nowrite dereferenceable(16) %b, i64 16
%#0 = icmp eq i32 %memcmp, 0
br label %opeq1.exit
opeq1.exit:
ret i1 %#0
}
Transformation doesn't verify! (unsound)
ERROR: Source is more defined than target
Example:
ptr nocapture nowrite dereferenceable(16) %a = pointer(non-local, block_id=1, offset=4, attrs=3) / Address=#x0c
ptr nocapture nowrite dereferenceable(16) %b = pointer(non-local, block_id=1, offset=48, attrs=3) / Address=#x38
Source:
i32 %#0 = #x02010101 (33620225)
i32 %#1 = #x00000000 (0)
Function @foo returned
i1 %cmp.i = #x0 (0)
>> Jump to %opeq1.exit
i1 %#8 = #x0 (0)
SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 > size: 0 align: 1 alloc type: 0 alive: false address: 0
Block 1 > size: 128 align: 8 alloc type: 2 alive: false address: 8
Contents:
50: #x00
10: null, byte offset=0
52: #x01
48: #x00
54: #x02
9: #x01
15: #x00
14: #x00
51: #x00
4: #x01
57: null, byte offset=0
13: #x01
6: #x01
7: #x02
11: null, byte offset=0
55: #x20
59: #x00
49: #x00
8: null, byte offset=0
12: null, byte offset=0
53: null, byte offset=0
58: #x00
56: #x01
5: #x01
*: poison
Block 2 > size: 0 align: 1 alloc type: 0 alive: true address: 5
Contents:
48: #x01
50: #x01
52: #x00
55: #x00
54: #x00
59: #x01
49: #x01
51: #x02
53: #x00
58: #x01
57: #x00
56: #x00
*: poison
Block 3 > size: 0 align: 1 alloc type: 0 alive: true address: 4
Target:
Function @foo returned
i32 %memcmp = UB triggered!
Pass: MergeICmpsPass
Command line: '/home/nlopes/llvm/build/bin/opt' '-load=/home/nlopes/alive2/build/tv/tv.so' '-load-pass-plugin=/home/nlopes/alive2/build/tv/tv.so' '-tv-exit-on-error' '-passes=mergeicmps' '-verify-dom-info' '-mtriple=x86_64-unknown-unknown' '-S' '-tv-smt-to=20000' '-tv-report-dir=/home/nlopes/alive2/build/logs' '-tv-smt-stats'
Wrote bitcode to: "/home/nlopes/alive2/build/logs/in_NrABiuyG_I2Kh.bc"
------------------- SMT STATS -------------------
Num queries: 56
Num invalid: 0
Num skips: 0
Num trivial: 6 (9.7%)
Num timeout: 0 (0.0%)
Num errors: 0 (0.0%)
Num SAT: 42 (75.0%)
Num UNSAT: 14 (25.0%)
Alive2: Transform doesn't verify; aborting!
/home/nlopes/alive2/build/opt-alive.sh < /bitbucket/nlopes/llvm/llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll -passes=mergeicmps -verify-dom-info -mtriple=x86_64-unknown-unknown -S | /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll --check-prefix=X86 # RUN: at line 2 + /home/nlopes/alive2/build/opt-alive.sh -passes=mergeicmps -verify-dom-info -mtriple=x86_64-unknown-unknown -S + /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll --check-prefix=X86 FileCheck error: '<stdin>' is empty. FileCheck command line: /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll --check-prefix=X86