This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Change initialization of __kmp_global
ClosedPublic

Authored by Hahnfeld on Aug 15 2019, 7:13 AM.

Details

Summary

There's no need to initialize variables with static storage duration
because they're implicitly initialized to zero. See
https://en.cppreference.com/w/c/language/initialization#Implicit_initialization

I think that's already relied upon because the supplied 0 only sets
'kmp_time_global_t g_time;' in 'struct kmp_base_global'. The other fields
are not set in the code, but implicitly initialized by the compiler.

Diff Detail

Repository
rL LLVM

Event Timeline

Hahnfeld created this revision.Aug 15 2019, 7:13 AM
Herald added a project: Restricted Project. · View Herald Transcript
Hahnfeld marked an inline comment as done.Aug 15 2019, 7:15 AM
Hahnfeld added inline comments.
openmp/runtime/src/kmp_global.cpp
434 ↗(On Diff #215391)

The other solution would be explicitly initializing all struct variables, not sure if that is preferred. Putting __kmp_global into the .bss section seems ok, it's initialized to zero by the loader.

This revision is now accepted and ready to land.Sep 4 2019, 6:42 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 4 2019, 10:46 AM