[RISCV][compiler-rt] Small fixes for __riscv_feature_bits (#100158)
commit73ac9536268f21149e29601da31e3415725b0a17
authorPiyou Chen <piyou.chen@sifive.com>
Tue, 23 Jul 2024 23:52:08 +0000 (24 07:52 +0800)
committerGitHub <noreply@github.com>
Tue, 23 Jul 2024 23:52:08 +0000 (24 07:52 +0800)
tree65dccd30b31c5fc0c86215ecc898e958d5394973
parentef8de68faebee0226b4836e66574f225f724e768
[RISCV][compiler-rt] Small fixes for __riscv_feature_bits (#100158)

Changes included:

- Adding CONSTRUCTOR_ATTRIBUTE so that the static data is setup early on
in process lifetime. This is required by gcc docs for
__builtin_cpu_supports which we hope to implement in terms of this.
- Move the length initialization outside of the #if defined(linux) block
so that the length field always reflects the size of the structures even
if non of the feature bits are non-zero.
- Change the __riscv_vendor_feature_bits.length field to match the
length of the actual structure.

Note: Copy from https://github.com/llvm/llvm-project/pull/99958

---------

Co-authored-by: Philip Reames <preames@rivosinc.com>
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/cpu_model/riscv.c [moved from compiler-rt/lib/builtins/riscv/feature_bits.c with 94% similarity]