On Thu, Mar 12, 2009 at 5:18 PM, Dan Gohman <gohman at apple.com> wrote:> This looks like an interesting idea. As written, the inline asms > aren't safe > though; they reference %eax, %edx, etc. without declaring such things in > constraints, so the compiler wouldn't know that it can't clobber those > registers. > > Dan >I don't know how to specify the constraint, since it should constrain gcc to not use the register before the asm block, while constraints can just say how to pass info to/from the asm block, and describe how the asm block modifies the environment. Actually, I don't think it is needed, though, since those asm blocks are put at the very beginning and the very end of the function (and declared volatile, i.e. they cannot be moved), so the compiler has no need for those registers: * they are not used by standard prologue/epilogue * the only thing that is done before is the allocation of the stack space, and since we use it both before and after a call, the compiler must use one (or more) callee saved registers for it, so it can't use any of the registers we need to save. Corrado
I've created a patch (attached to the bug): http://llvm.org/bugs/attachment.cgi?id=2744, that goes in a different direction, and solves the safety problems. The patch uses original asm, but removes the call through plt, and puts the invoked function in an anonymous namespace. This allows the static linker to always know the location of the jump, removing the need for PIC invocation setup. This is tested with g++ 4.2 . Corrado
It looks fine to me. Anton, does it look ok to you? Evan On Mar 20, 2009, at 2:33 PM, Corrado Zoccolo wrote:> I've created a patch (attached to the bug): > http://llvm.org/bugs/attachment.cgi?id=2744, that goes in a different > direction, and solves the safety problems. > The patch uses original asm, but removes the call through plt, and > puts the invoked function in an anonymous namespace. This allows the > static linker to always know the location of the jump, removing the > need for PIC invocation setup. > This is tested with g++ 4.2 . > > Corrado > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev