OLD | NEW |
(Empty) | |
| 1 ; RUN: opt %s -sandbox-memory-accesses -S | FileCheck %s |
| 2 |
| 3 |
| 4 ; CHECK: @__sfi_memory_base = external global i64 |
| 5 |
| 6 define void @func(i32* %ptr) { |
| 7 %val = load i32* %ptr |
| 8 ret void |
| 9 } |
| 10 ; CHECK: define void @func(i32* %ptr) { |
| 11 ; CHECK-NEXT: %mem_base = load i64* @__sfi_memory_base |
| 12 ; CHECK-NEXT: %1 = ptrtoint i32* %ptr to i32 |
| 13 ; CHECK-NEXT: %2 = zext i32 %1 to i64 |
| 14 ; CHECK-NEXT: %3 = add i64 %mem_base, %2 |
| 15 ; CHECK-NEXT: %4 = inttoptr i64 %3 to i32* |
| 16 ; CHECK-NEXT: %val = load i32* %4 |
| 17 |
| 18 define void @func2(i32* %ptr) { |
| 19 %val = load i32* %ptr |
| 20 store i32 %val, i32* %ptr |
| 21 ret void |
| 22 } |
| 23 ; TODO... |
| 24 |
| 25 define void @ptr_with_addend(i32 %ptr) { |
| 26 %add = add i32 %ptr, 1234 |
| 27 %add.p = inttoptr i32 %add to i32* |
| 28 %val = load i32* %add.p |
| 29 ret void |
| 30 } |
| 31 ; CHECK: define void @ptr_with_addend(i32 %ptr) { |
| 32 ; CHECK-NEXT: %mem_base = load i64* @__sfi_memory_base |
| 33 ; CHECK-NEXT: %add = add i32 %ptr, 1234 |
| 34 ; CHECK-NEXT: %add.p = inttoptr i32 %add to i32* |
| 35 ; CHECK-NEXT: %1 = zext i32 %ptr to i64 |
| 36 ; CHECK-NEXT: %2 = add i64 %mem_base, %1 |
| 37 ; CHECK-NEXT: %3 = add i64 %2, 1234 |
| 38 ; CHECK-NEXT: %4 = inttoptr i64 %3 to i32* |
| 39 ; CHECK-NEXT: %val = load i32* %4 |
OLD | NEW |