Weird the clang's codegen behavior?

Hey guys! Can anyone help me understand how the clang codegen works? I’ve implemented the address_space for the clang frontend. It realizes the qualificator as an attribute. After that I implemented the ASTContext stuff, Sema and Mangling stuff etc. I also added the address space size to the target by overriding GetPointerWidth method. As far as I can see, this attribute falls to the IR. But when the IR converts to the DAG, I can see that the size of my attribute is wrong. What I mean to say is that it should be i32, but when I do llc -debug, I get i64 instead of this. So, my question is: where exactly can I catch this conversion?

I recommend you take a look at the implementation of the __ptr32 and __ptr64 extensions in clang for x86_64. Those translate to address spaces in IR, and eventually translate to i32/i64 in the backend. There are some hooks in the x86 backend for handling this correctly. You can search it for address spaces to see what had to be done. example code, implementation patch

Unfortunately there are still a number of places using the default address space by accident. It sounds like you’re running into one of those. It sounds like there’s an errant getPointerTy call somewhere

Thank you, but when I developing my code, I relied on this patch)