[LLVMdev] SIGFPE generation

Dan Gohman gohman at apple.com
Fri Apr 9 15:44:52 PDT 2010


On Apr 9, 2010, at 2:52 PM, Sarah Thompson wrote:

> Just a quick question...
> 
> I've been attempting to trap floating point badness by setting up a  
> SIGFPE handler. However, I'm not seeing it trigger, even for simple  
> test code that forces division by zero. I'm generating bitcode with  
> llvm-gcc and then executing it with a (modified) version of the  
> jitter, for reference.
> 
> Is there any arcane magic necessary to turn on SIGFPE generation?


Most platforms default to "non-stop" mode, where floating-point
exceptions do not trap. The interfaces defined in <fenv.h> can be
used to query floating-point exceptions. Trapping on exceptions
can usually be enabled, though it requires platform-specific code.
See your platform's documentation for details.

Note that enabling traps can cause degraded performance, and it
can cause incompatibilities with library code that doesn't expect
it.

Dan




More information about the llvm-dev mailing list