This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode
ClosedPublic

Authored by Topotuna on Jul 30 2021, 7:16 AM.

Details

Summary

Definition of __cpp_threadsafe_static_init macro is controlled by
language option Opts.ThreadsafeStatics. This patch sets language
option to false by default in OpenCL mode, resulting in macro
__cpp_threadsafe_static_init being undefined. Default value can be
overriden using command line option -fthreadsafe-statics.

Change is supposed to address portability because not all OpenCL
vendors support thread safe implementation of static initialization.

Fixes llvm.org/PR48012

Diff Detail

Event Timeline

Topotuna created this revision.Jul 30 2021, 7:16 AM
Topotuna requested review of this revision.Jul 30 2021, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 30 2021, 7:16 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Topotuna edited the summary of this revision. (Show Details)Jul 30 2021, 7:17 AM
Anastasia added inline comments.Jul 30 2021, 7:42 AM
clang/lib/Driver/ToolChains/Clang.cpp
6195–6196

I think this will work fine apart from if someone creates .cpp file but passes -cl-std=clc++. But it is not the conventional flow so I think we should not worry about it for now.

clang/test/Driver/threadsafe-statics.clcpp
3

Worth adding one more RUN line with -fthreadsafe-statics passed.

Topotuna marked an inline comment as done.Jul 30 2021, 7:49 AM
Topotuna added inline comments.
clang/test/Driver/threadsafe-statics.clcpp
3

Such RUN line is present on line 8. Should I move it up so that all RUN lines are close to one another?

Anastasia accepted this revision.Aug 2 2021, 2:54 AM

LGTM! Thanks!

This revision is now accepted and ready to land.Aug 2 2021, 2:54 AM
This revision was automatically updated to reflect the committed changes.
Topotuna marked an inline comment as done.