http://llvm.org/bugs/show_bug.cgi?id=9779
Summary: Code from C backend compiled with GCC crashes due to
calling functions through pointers to a different
function types
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Consider the following original code line:
fprintf(stdout, "this fprintf is involved into crash\n");
LLVM translates it to the following IR:
%6 = call i64 bitcast (i64 (i8*, i64, i64, %struct._IO_FILE*)* @fwrite to i64
(i8*, i64, i64, i8*)*)(i8* getelementptr inbounds ([37 x i8]* @.cst2, i64 0,
i64 0), i64 1, i64 36, i8* %5) nounwind
And C backend generates a similar line of C code:
llvm_cbe_tmp__5 = ((unsigned long long (*) (unsigned char *, unsigned long
long , unsigned long long , unsigned char
*))(void*)fwrite)(((&_OC_cst2.array[((signed long long )0ull)])), 1ull, 36ull,
(((unsigned char *)llvm_cbe_tmp__4)));
Now, compiled with gcc, we have:
warning: function called through a non-compatible type
note: if this code is reached, the program will abort
And resulting program will crash with SIGILL (Illegal instruction).
Although, the problem seems to be specific to gcc and specific to code
generation approach involving C backend instead of direct asm generation, it
would be better to make LLVM more accurate about functions typecasting.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs