1 ; This is a smoke test of constant blinding and constant pooling. 2 3 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 \ 4 ; RUN: -sz-seed=1 -randomize-pool-immediates=randomize \ 5 ; RUN: -randomize-pool-threshold=0x1 \ 6 ; RUN: | FileCheck %s --check-prefix=BLINDINGO2 7 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 \ 8 ; RUN: -sz-seed=1 -randomize-pool-immediates=randomize \ 9 ; RUN: -randomize-pool-threshold=0x1 \ 10 ; RUN: | FileCheck %s --check-prefix=BLINDINGOM1 11 12 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 \ 13 ; RUN: -sz-seed=1 -randomize-pool-immediates=pool \ 14 ; RUN: -randomize-pool-threshold=0x1 \ 15 ; RUN: | FileCheck %s --check-prefix=POOLING 16 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 \ 17 ; RUN: -sz-seed=1 -randomize-pool-immediates=pool \ 18 ; RUN: -randomize-pool-threshold=0x1 \ 19 ; RUN: | FileCheck %s --check-prefix=POOLING 20 21 22 define internal i32 @add_arg_plus_200000(i32 %arg) { 23 entry: 24 %res = add i32 200000, %arg 25 ret i32 %res 26 27 ; BLINDINGO2-LABEL: add_arg_plus_200000 28 ; BLINDINGO2: mov [[REG:e[a-z]*]],0x669f4eea 29 ; BLINDINGO2-NEXT: lea [[REG]],{{[[]}}[[REG]]-0x669c41aa{{[]]}} 30 31 ; BLINDINGOM1-LABEL: add_arg_plus_200000 32 ; BLINDINGOM1: mov [[REG:e[a-z]*]],0x669f4eea 33 ; BLINDINGOM1-NEXT: lea [[REG]],{{[[]}}[[REG]]-0x669c41aa{{[]]}} 34 35 ; POOLING-LABEL: add_arg_plus_200000 36 ; POOLING: mov e{{[a-z]*}},{{(DWORD PTR )?}}ds:0x0 {{[0-9a-f]*}}: R_386_32 .L$i32$00030d40 37 } 38 39 define internal float @load_arg_plus_200000(float* %arg) { 40 entry: 41 %arg.int = ptrtoint float* %arg to i32 42 %addr.int = add i32 %arg.int, 200000 43 %addr.ptr = inttoptr i32 %addr.int to float* 44 %addr.load = load float, float* %addr.ptr, align 4 45 ret float %addr.load 46 ; BLINDINGO2-LABEL: load_arg_plus_200000 47 ; BLINDINGO2: lea [[REG:e[a-z]*]],{{[[]}}{{e[a-z]*}}+0x69ed4ee7{{[]]}} 48 49 ; BLINDINGOM1-LABEL: load_arg_plus_200000 50 ; BLINDINGOM1: lea [[REG:e[a-z]*]],{{[[]}}{{e[a-z]*}}-0x69ea41a7{{[]]}} 51 52 ; POOLING-LABEL: load_arg_plus_200000 53 ; POOLING: mov e{{[a-z]*}},{{(DWORD PTR )?}}ds:0x0 {{[0-9a-f]*}}: R_386_32 .L$i32$00030d40 54 } 55 56 define internal i64 @add_arg_plus_64bits(i32 %arg) { 57 entry: 58 %0 = sext i32 %arg to i64 59 %res = add i64 90000000000, %0 60 ret i64 %res 61 62 ; BLINDINGO2-LABEL: add_arg_plus_64bits 63 ; BLINDINGO2: sar [[RHI:e[a-z]*]],0x1f 64 ; BLINDINGO2: mov [[RLO:e[a-z]*]],0x61a345a8 65 ; BLINDINGO2-NEXT: lea [[RLO]],{{[[]}}[[RLO]]-0x6d3841a8{{[]]}} 66 67 ; BLINDINGOM1-LABEL: add_arg_plus_64bits 68 ; BLINDINGOM1: sar [[RHI:e[a-z]*]],0x1f 69 ; BLINDINGOM1: mov [[RLO:e[a-z]*]],0x61a345a8 70 ; BLINDINGOM1-NEXT: lea [[RLO]],{{[[]}}[[RLO]]-0x6d3841a8{{[]]}} 71 72 ; POOLING-LABEL: add_arg_plus_64bits 73 ; POOLING: mov e{{[a-z]*}},{{(DWORD PTR )?}}ds:0x0 {{[0-9a-f]*}}: R_386_32 .L$i32$f46b0400 74 } 75 76 define internal i64 @load_arg_plus_64bits(i64* %arg) { 77 entry: 78 %arg.int = ptrtoint i64* %arg to i32 79 %arg.new = add i32 %arg.int, 90000 80 %arg.ptr = inttoptr i32 %arg.new to i64* 81 %arg.load = load i64, i64* %arg.ptr, align 1 82 ret i64 %arg.load 83 84 ; BLINDINGO2-LABEL: load_arg_plus_64bits 85 ; BLINDINGO2: lea e{{[a-z]*}},{{[[]}}e{{[a-z]*}}+0x7087a139{{[]]}} 86 ; BLINDINGO2: mov e{{[a-z]*}},DWORD PTR {{[[]}}e{{[a-z]*}}-0x708641a9{{[]]}} 87 88 ; BLINDINGOM1-LABEL: load_arg_plus_64bits 89 ; BLINDINGOM1: mov e{{[a-z]*}},0x7087a139 90 ; BLINDINGOM1-NEXT: lea e{{[a-z]*}},{{[[]}}e{{[a-z]*}}-0x708641a9{{[]]}} 91 92 ; POOLING-LABEL: load_arg_plus_64bits 93 ; POOLING: mov e{{[a-z]x}},{{(DWORD PTR )?}}ds:0x0 {{[0-9a-f]*}}: R_386_32 .L$i32$00000004 94 } 95 96 define internal i32 @add_const_8bits(i32 %a) { 97 entry: 98 %a_8 = trunc i32 %a to i8 99 %add = add i8 %a_8, 123 100 %ret = zext i8 %add to i32 101 ret i32 %ret 102 103 ; BLINDINGO2-LABEL: add_const_8bits 104 ; BLINDINGO2: mov e{{[a-z]*}},0x73d44225 105 ; BLINDINGO2-NEXT: e{{[a-z]*}},{{[[]}}e{{[a-z]*}}-0x73d441aa{{[]]}} 106 107 ; BLINDINGOM1-LABEL: add_const_8bits 108 ; BLINDINGOM1: mov e{{[a-z]*}},0x73d44225 109 ; BLINDINGOM1-NEXT: e{{[a-z]*}},{{[[]}}e{{[a-z]*}}-0x73d441aa{{[]]}} 110 111 ; POOLING-LABEL: add_const_8bits 112 ; POOLING: mov {{[a-z]l}},{{(BYTE PTR )?}}ds:0x0 {{[0-9a-f]*}}: R_386_32 .L$i8$0000007b 113 } 114 115 define internal i32 @add_const_16bits(i32 %a) { 116 entry: 117 %a_16 = trunc i32 %a to i16 118 %add = add i16 %a_16, 32766 119 %ret = zext i16 %add to i32 120 ret i32 %ret 121 122 ; BLINDINGO2-LABEL: add_const_16bits 123 ; BLINDINGO2: mov e{{[a-z]*}},0x7722c1a5 124 ; BLINDINGO2-NEXT: e{{[a-z]*}},{{[[]}}e{{[a-z]*}}-0x772241a7{{[]]}} 125 126 ; BLINDINGOM1-LABEL: add_const_16bits 127 ; BLINDINGOM1: mov e{{[a-z]*}},0x7722c1a5 128 ; BLINDINGOM1-NEXT: e{{[a-z]*}},{{[[]}}e{{[a-z]*}}-0x772241a7{{[]]}} 129 130 ; POOLING-LABEL: add_const_16bits 131 ; POOLING: mov {{[a-z]x}},{{(WORD PTR )?}}ds:0x0 {{[0-9a-f]*}}: R_386_32 .L$i16$00007ffe 132 133 } 134