[LLVMdev] Thumb-2 code generation error in Apple LLVM at all optimization levels

Don Quixote de la Mancha quixote at dulcineatech.com
Sun Nov 13 02:19:54 PST 2011


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.

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.  If it is to be considered a
bug in GDB it would be really hard to fix.


-- 
Don Quixote de la Mancha
Dulcinea Technologies Corporation
Software of Elegance and Beauty
http://www.dulcineatech.com
quixote at dulcineatech.com



More information about the llvm-dev mailing list