This patch replaces getCharWidth with getCharAlign where it is used incorrectly
Details
Diff Detail
Event Timeline
Currently getCharWidth and getCharAlign functions are hard coded to return 8 in clang with no way to change it for target.
This can be seen in TargetInfo.h file:
unsigned getCharWidth() const { return 8; } // FIXME unsigned getCharAlign() const { return 8; } // FIXME
It means that these functions can be used interchangeably and there will be no test failures because of this, until custom alignment will be supported.
Nevertheless, it will not be possible to support custom alignment until all incorrect usages of getCharWidth will be replaced with getCharAlign. This patch fixes some of them
Likewise, LLVM hardcodes that byte is 8 bits and does not want to change that
since there is no official LLVM target with that characteristics,
and thus it is impossible to test it, and it would quickly regress.
Which target will be affected by this patch?
I suspect the situation is the same here.
If there is no way to test this upstream...
Thank you for your comments, Roman.
Despite the fact, that there are no official LLVM targets that will be influenced by this patch, there are architectures which support only word addressing mode, for which the assumption of char align equals to 8 is not true.
The patch have been tested for a proprietary architecture, where there is a difference between align and width of char. As for the official targets, it's more like a style improvement.
Thank you for working on this!
So in other words this will sadly indeed not have any test coverage in LLVM proper, correct?
If so, i think you want to submit an RFC (mentioning this fact) to cfe-dev (maybe CC llvm-dev).
The patch have been tested for a proprietary architecture, where there is a difference between align and width of char.
The C standard requires that both alignof(char) and sizeof(char) must equal 1, and therefore must equal each other. Could you clarify the characteristics of your target?
Could you clarify the characteristics of your target?
Yeah, sure.
The target supports only word addressing when it comes to loading from memory or storing to memory, that's why types shorter than 4 bytes need to be aligned by at least 4.
In order to achieve this, getCharAlign and getShortAlign functions and some llvm passes have been modified to work with such kind of layout.
The C standard requires that both alignof(char) and sizeof(char) must equal 1, and therefore must equal each other
Currently we are targeting C99 language standard, which, as far as I know, says nothing about alignof keyword. Anyway, thanks for pointing that out.