[cfe-dev] static const structures declared as "external global %struct.S" instead of "external constant %struct.S"
richard at xmos.com
Fri Dec 6 13:18:52 PST 2013
Currently the XCore backend choses how to access the global based on whether it is declared as constant in the LLVM IR. If it is constant it is placed in the .cp.rodata section the accessed via the cp register, otherwise it is placed in the .dp.data section and it is accessed via the dp register.
In retrospect this is the wrong approach - it breaks when the constness of the global in LLVM IR differs across translation units and there is no way to avoid this with C++. I think the right fix is to move the decision of where to place the global (which is an ABI issue) to the frontend where the decision can be based on the high level type. In particular clang should explicitly specify the .cp.rodata section on globals that need to go in the cp according the XCore ABI. In the absence of an explicit section the XCore backend should place all globals in the .dp.data or .dp.rodata sections.
This is a problem on the XCore target as we handle constant and non-constant data in separate areas and hence will emit different assembler instructions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev