Skip to content

[compiler-rt][RISCV] Initialize length only when __init_riscv_feature… #115449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler-rt/lib/builtins/cpu_model/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ void __init_riscv_feature_bits(void *PlatformArgs) {
if (FeaturesBitCached)
return;

__riscv_feature_bits.length = RISCV_FEATURE_BITS_LENGTH;
__riscv_vendor_feature_bits.length = RISCV_VENDOR_FEATURE_BITS_LENGTH;

#if defined(__linux__)
struct riscv_hwprobe Hwprobes[] = {
{RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0}, {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
Expand All @@ -369,6 +366,9 @@ void __init_riscv_feature_bits(void *PlatformArgs) {
return;

initRISCVFeature(Hwprobes);

__riscv_feature_bits.length = RISCV_FEATURE_BITS_LENGTH;
__riscv_vendor_feature_bits.length = RISCV_VENDOR_FEATURE_BITS_LENGTH;
Comment on lines +370 to +371
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would work, but it might be more obvious if this was moved into initRISCVFeature, maybe where the other fields in the structure are being set?

#endif // defined(__linux__)

FeaturesBitCached = 1;
Expand Down
Loading