[cfe-dev] Question about compiling exit and clang assert

Peter Lawrence via cfe-dev cfe-dev at lists.llvm.org
Sun Jul 23 11:43:11 PDT 2017


Ooops, my apologies for that question. my target, like MSP430 has 16-bit ints,
but unlike MSP430, does not support 32-bit ints at all, so the actual crash
is in the call to __builtin_frame_address(0) which expects i32, but is being
passed i16 because that’s all my target supports.

If I change clang so that __builtin_frame_address / __builtin_return_address
take “native” size ints rather than being hard wired to i32
is that the sort of thing that a patch would be accepted for ?


TIA,
Peter Lawrence.

> On Jul 23, 2017, at 11:04 AM, Peter Lawrence <peterl95124 at sbcglobal.net> wrote:
> 
> I have a simulator for a target machine that I wrote an llvm port for
> The simulator detects a return to address zero as returning from “main"
> and that ends the simulation, with main's return value then being printed out
> (and finally returned from the simulator to the shell).
> 
> I tried to implement “exit” in C rather than in assembly with the following
> 
> 
> void * __builtin_frame_address (unsigned int level);
> 
> int exit (int X)
> {
> 	((int*)__builtin_frame_address(0))[1] = 0; // simulator termination magic
> 	return X; // put result code in R0, as though returning X from main
> }
> 
> 
> After some warnings about redeclaration and about noreturn
> clang crashes with an assert,
> 
> So my question is, isn’t the clang assertion too conservative ?
> Why crash after warnings, why not let it go through ?
> 
> 
> TIA,
> Peter Lawrence.
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170723/f9b7b32c/attachment.html>


More information about the cfe-dev mailing list