[LLVMdev] Thumb-2 code generation error in Apple LLVM at all optimization levels
Jean-Daniel Dupas
devlists at shadowlab.org
Sun Nov 13 04:51:35 PST 2011
Le 13 nov. 2011 à 11:19, Don Quixote de la Mancha a écrit :
> I am thinking now that the Thumb-2 machine code generated by Apple's
> LLVM 3.0+svn compiler is correct, but that when a Release build is
> generated, the use of conditional machine instructions confuses GDB.
>
> I boiled my apparently erroneous source down to:
>
> - (void) mySleep: (int)sleepTime
> {
> if ( sleepTime >= 4000 ){
> usleep( sleepTime );
> }
>
> return;
> }
>
> If I set a breakpoint on the usleep call, the breakpoint will be hit
> but usleep() will not actually be called.
>
Debugging info in optimized build are not reliable.
The compiler reorder instructions, change the program flow, and do a lot of other transformation that alter them.
> I verified this by passing in 5000. When I do, I can step down into
> the shared libraries that lead to the actual system call.
>
> I have also tried calling a regular subroutine of my own instead of a
> system call. When sleepTime is zero, my subroutine is not called even
> though GDB shows my program stepping over the subroutine call.
>
> I would say that this is a bug in GDB's source code debugger, in that
> it ought to consider the basic block of the if only to be entered if
> the test succeeds. GDB's assembly code debugger does the right thing.
>
> In any case this is not a bug in LLVM.
Why not ? Generating valid debug info is the role of the compiler, not the debugger.
> If it is to be considered a bug in GDB it would be really hard to fix.
-- Jean-Daniel
More information about the llvm-dev
mailing list