Some function declarations like this:
void foo();
do not have a type declaration, for that you'd use:
void foo(void);
Clang internally bitcasts the variadic function declaration to a function pointer, but doesn't use the correct address space on AVR. This commit fixes that.
This fix is necessary to let Clang compile compiler-rt for AVR.
Two remarks on this diff:
- I wasn't sure whether there is a way to set the address space on a function. I at least couldn't seem to get it to work. If it is possible to set the address space, I think the fix is slightly wrong and should somehow get the address space from the function declaration instead of using getProgramAddressSpace (please let me know how or where to find this information).
- I hoped there was a test file already where I could include this test, but at least CodeGen/address-space.c seemed a bit too complex to also test with AVR (for example, int is 16-bit on AVR).
CalleePtr->getType()->getPointerAddressSpace() should be fine.