xref: /llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll (revision 0dd9fdcf83cd00f51669b32c96937a97ef4b339e)
1; RUN: opt -passes='print<structural-hash>' -disable-output %s 2>&1 | FileCheck %s
2; RUN: opt -passes='print<structural-hash><detailed>' -disable-output %s 2>&1 | FileCheck %s -check-prefix=DETAILED-HASH
3; RUN: opt -passes='print<structural-hash><call-target-ignored>' -disable-output %s 2>&1 | FileCheck %s -check-prefix=CALLTARGETIGNORED-HASH
4
5; Add a declaration so that we can test we skip it.
6declare i64 @d1(i64)
7declare i64 @e1(i64)
8
9define i64 @f1(i64 %a) {
10	%b = add i64 %a, 1
11	%c = call i64 @d1(i64 %b)
12	ret i64 %c
13}
14
15define i64 @f2(i64 %a) {
16	%b = add i64 %a, 1
17	%c = call i64 @e1(i64 %b)
18	ret i64 %c
19}
20
21; CHECK: Module Hash: {{([a-f0-9]{16,})}}
22; CHECK-NEXT: Function f1 Hash: [[F1H:([a-f0-9]{16,})]]
23; CHECK-NEXT: Function f2 Hash: [[F1H]]
24
25; DETAILED-HASH: Module Hash: {{([a-f0-9]{16,})}}
26; DETAILED-HASH-NEXT: Function f1 Hash: [[DF1H:([a-f0-9]{16,})]]
27; DETAILED-HASH-NOT: [[DF1H]]
28; DETAILED-HASH-NEXT: Function f2 Hash: {{([a-f0-9]{16,})}}
29
30; When ignoring the call target, check if `f1` and `f2` produce the same function hash.
31; The index for the call instruction is 1, and the index of the call target operand is 1.
32; The ignored operand hashes for different call targets should be different.
33; CALLTARGETIGNORED-HASH: Module Hash: {{([a-f0-9]{16,})}}
34; CALLTARGETIGNORED-HASH-NEXT: Function f1 Hash: [[IF1H:([a-f0-9]{16,})]]
35; CALLTARGETIGNORED-HASH-NEXT:   Ignored Operand Hash: [[IO1H:([a-f0-9]{16,})]] at (1,1)
36; CALLTARGETIGNORED-HASH-NEXT: Function f2 Hash: [[IF1H]]
37; CALLTARGETIGNORED-HASH-NOT: [[IO1H]]
38; CALLTARGETIGNORED-HASH-NEXT:   Ignored Operand Hash: {{([a-f0-9]{16,})}} at (1,1)
39