[PATCH] D10476: Additional fix for PR14269: Clang crashes when a bit field is used as inline assembler input / output with memory constraint

hfinkel at anl.gov hfinkel at anl.gov
Fri Jul 10 07:57:30 PDT 2015


hfinkel added a subscriber: hfinkel.
hfinkel added a comment.

> The problem here is that LLVM IR represents vectors with a specific vector type; you can't get address of a random element inside vector. Specific instructions should be used to get individual vector elements ("extractelement" and "insertelement"), but then again -- they don't provide addresses of elements. GCC simply treats a vector as an array of elements and computes desired address. In theory, this can be done in LLVM IR as well, but I don't think this is the right approach -- we generally can't make any assumptions on how vectors are represented by a target CPU.

> 

> Do you agree?


I agree; we don't want to tie frontend functionality to a specific representation of the vectors.

We could support this, but we'd need to do it by:

1. Creating a local stack variable (alloca)
2. Extracting the requested vector element and storing it in that stack-allocated memory
3. Providing the address of the local stack variable to the inline asm
4. After the inline asm, loading the value from the local stack variable and inserting it back into the vector

I have no opinion on whether or not this is worth implementing.


http://reviews.llvm.org/D10476







More information about the cfe-commits mailing list