OLD | NEW |
(Empty) | |
| 1 ; RUN: opt < %s -rewrite-pnacl-library-calls -S | FileCheck %s |
| 2 ; Check how the pass behaves in the presence of library functions with wrong |
| 3 ; signatures. |
| 4 |
| 5 declare i8 @longjmp(i64) |
| 6 |
| 7 @flongjmp = global i8 (i64)* @longjmp |
| 8 ; CHECK: @flongjmp = global i8 (i64)* bitcast (void (i64*, i32)* @longjmp to i8
(i64)*) |
| 9 |
| 10 ; CHECK: define internal void @longjmp(i64* %env, i32 %val) |
| 11 |
| 12 declare i8* @memcpy(i32) |
| 13 |
| 14 define i8* @call_bad_memcpy(i32 %arg) { |
| 15 %result = call i8* @memcpy(i32 %arg) |
| 16 ret i8* %result |
| 17 } |
| 18 |
| 19 ; CHECK: define i8* @call_bad_memcpy(i32 %arg) { |
| 20 ; CHECK: %result = call i8* bitcast (i8* (i8*, i8*, i32)* @memcpy to i8* (i32)
*)(i32 %arg) |
| 21 |
| 22 declare i8 @setjmp() |
| 23 |
| 24 ; This simulates a case where the original C file had a correct setjmp |
| 25 ; call but due to linking order a wrong declaration made it into the |
| 26 ; IR. In this case, the correct call is bitcasted to the correct type. |
| 27 ; The pass should treat this properly by creating a direct intrinsic |
| 28 ; call instead of going through the wrapper. |
| 29 define i32 @call_valid_setjmp(i64* %buf) { |
| 30 %result = call i32 bitcast (i8 ()* @setjmp to i32 (i64*)*)(i64* %buf) |
| 31 ret i32 %result |
| 32 } |
| 33 |
| 34 ; CHECK: define i32 @call_valid_setjmp(i64* %buf) { |
| 35 ; CHECK-NEXT: %jmp_buf_i8 = bitcast i64* %buf to i8* |
| 36 ; CHECK-NEXT: %result = call i32 @llvm.nacl.setjmp(i8* %jmp_buf_i8) |
| 37 ; CHECK-NEXT: ret i32 %result |
| 38 ; CHECK-NEXT: } |
OLD | NEW |