Insert random noops to increase security against ROP attacks (llvm)
[oota-llvm.git] / test / CodeGen / PowerPC / noop-insert.ll
1 ; RUN: llc < %s -march=ppc32 -noop-insertion | FileCheck %s
2 ; RUN: llc < %s -march=ppc32 -noop-insertion -rng-seed=1 | FileCheck %s --check-prefix=SEED1
3 ; RUN: llc < %s -march=ppc32 -noop-insertion -noop-insertion-percentage=100 | FileCheck %s --check-prefix=100PERCENT
4
5 ; This test case checks that NOOPs are inserted correctly for PowerPC.
6
7 ; It just happens that with a default percentage of 25% and seed=0,
8 ; no NOOPs are inserted.
9 ; CHECK: mullw
10 ; CHECK-NEXT: add
11 ; CHECK-NEXT: blr
12
13 ; SEED1: nop
14 ; SEED1-NEXT: mullw
15 ; SEED1-NEXT: add
16 ; SEED1-NEXT: nop
17 ; SEED1-NEXT: blr
18
19 ; 100PERCENT: nop
20 ; 100PERCENT-NEXT: mullw
21 ; 100PERCENT-NEXT: nop
22 ; 100PERCENT-NEXT: add
23 ; 100PERCENT-NEXT: nop
24 ; 100PERCENT-NEXT: blr
25
26 define i32 @test1(i32 %x, i32 %y, i32 %z) {
27 entry:
28     %tmp = mul i32 %x, %y
29     %tmp2 = add i32 %tmp, %z
30     ret i32 %tmp2
31 }