1; Verify that calls to known stdio library functions declared with 2; incompatible signatures are handled gracefully and without aborting. 3; 4; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 5; RUN: opt < %s -passes=instcombine -S | FileCheck %s 6 7declare i32 @fwrite(ptr, i64, i64, ptr) 8declare i8 @fputc(ptr, ptr) 9 10declare void @printf(ptr) 11declare i8 @fprintf(ptr, ptr) 12declare i8 @sprintf(ptr, ptr) 13 14 15@ca1 = constant [1 x i8] c"1" 16@pcnt_s = constant [3 x i8] c"%s\00" 17 18 19; Verify that a call to fwrite isn't transformed into one to fputc when 20; the latter is declared with an incompatible signature (which might 21; trigger an abort). 22 23define void @call_fwrite(ptr %fp) { 24 call i32 @fwrite(ptr @ca1, i64 1, i64 1, ptr %fp) 25 ret void 26} 27 28 29; Verify that a call to an incompatible void printf(char*) with just "%s" 30; isn't transformed. 31 32define void @call_printf(ptr %s) { 33; CHECK-LABEL: @call_printf( 34; 35 call i32 @printf(ptr @pcnt_s) 36 ret void 37} 38 39; Verify that a call to an incompatible int fprintf(FILE*, char*) isn't 40; transformed. 41 42define i8 @call_fprintf(ptr %fp, ptr %p) { 43; CHECK-LABEL: @call_fprintf( 44; 45 %call = call i8 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @pcnt_s, ptr %p) 46 ret i8 %call 47} 48 49; Verify that a call to an incompatible int sprintf(FILE*, char*) isn't 50; transformed. 51 52define i8 @call_sprintf(ptr %p, ptr %q) { 53; CHECK-LABEL: @call_sprintf( 54; 55 %call = call i8 (ptr, ptr, ...) @sprintf(ptr %p, ptr @pcnt_s, ptr %q) 56 ret i8 %call 57} 58 59