[cfe-commits] r122643 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGStmt.cpp test/CodeGen/asm-variable.c
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Jan 3 14:56:25 PST 2011
On Jan 3, 2011, at 2:48 PM, dalej wrote:
> I was on vacation during this this thread, sorry. I'm the one who has been (sporadically) fixing this in llvm-gcc. As of 119392 I believe local asm variables are correct there.
>
> On Jan 1, 2011, at 12:15 PM, Jakob Stoklund Olesen wrote:
>> On Dec 31, 2010, at 7:05 PM, Chris Lattner wrote:
>>> On Dec 31, 2010, at 12:43 PM, Jakob Stoklund Olesen wrote:
>>>> 1. Pinned local variables are treated no differently than normal local variables except when they are used as operands for inline asm. This is what Rafael's patch implements. I suppose you could warn if such a variable is never used for inline asm.
>>> […]
>
> Also, the register is not pinned to the variable. It is available for normal allocation except around asm statements.
>
>>>> 2. Global variables pinned to a reserved register. This is just an odd way of accessing a register, and it is fairly easy to support in the front end by emitting empty inline asm instead of reads and writes to the global.
>>>
>>> Right, llvm-gcc does this. This is vaguely bogus but it is (obviously) used and useful to support.
>>>
>>>> 3. Global variables pinned to an allocatable register. For this to work, the backend must treat the pinned register as reserved, effectively changing the calling convention of all functions in the compilation unit. Other compilation units would have to be built with -ffixed-reg. I really don't want to support this if it can at all be avoided.
>>>
>>> […]
>
> Currently, the IR doesn't support a way of representing this. It doesn't work in llvm-gcc, and I agree it would be good to avoid doing it.
>
> I haven't looked at the patches, but clang should generate the same thing llvm-gcc generates for the same constructs. If you do that it will work; if you do anything else you'll probably hit subtle bugs.
Rafael's patch only works for local variable, and it only tweaks the inline asm constraints where the variable is used as an operand. It does not insert inline asm around all uses like llvm-gcc does. As I am reading the GCC documentation, it doesn't have to.
The GCC documentation does not require that the variable be pinned to the register at all times, and we definitely don't want to guarantee that.
Dale, do you remember cases where it was necessary to insert empty inline asm around other uses, like llvm-gcc does?
/jakob
More information about the cfe-commits
mailing list