[LLVMdev] LLVM-GCC generating too much code from inline assembly

Fred / Kettch mjr.kettch at gmail.com
Tue Mar 16 00:30:43 PDT 2010


Hi,

I recently switched to LLVM-GCC 4.2 on OS X, to go around a bug caused by
gcc with optimized code. Unfortunately, I ran into another weird problem on
LLVM-GCC. In my code, there's a file with a bunch of inline assembly blocks,
that worked fine with GCC 4.2. Now, when compiling with LLVM-GCC 4.2, weird
things happen.

Here's an example: (the blocks are larger than that, but a single line will
do to show you what's happening)
__asm {
   mov ebx, iObject
}

When compiling in release, everything goes fine, and the produced assembly
looks like this :
## InlineAsm Start
.file "... my filename"
## InlineAsm End
## InlineAsm Start
.line 1454
## InlineAsm End
## InlineAsm Start
movl -20(%ebp), $ebx
## InlineAsm End

The problem occurs in debug, and the code looks like this :
## InlineAsm Start
.file "... my filename"
## InlineAsm End
## InlineAsm Start
.line 1454
## InlineAsm End
## InlineAsm Start
movl -20(%ebp), $ebx
## InlineAsm End
movl %ebx, %eax
movl %eax, -52(%ebp)

Only the last two lines are added, but since I'm using the eax register for
other things in the block, the code keeps writing over it, and end up
crashing when I try to really use whatever I did put in eax.
>From the looks of it, those lines must be here for a reason, but I'm
wondering how to avoid generating them, as it's causing some major problems
in my code (at least in this specific file). Is there some way to disable
that ?

Thanks,
Fred
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100316/3e525a54/attachment.html>


More information about the llvm-dev mailing list