[PATCH] D106206: Lazy initialized the NotUnderValgrind flag
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 19 11:41:16 PDT 2021
dexonsmith added inline comments.
================
Comment at: llvm/lib/Support/Valgrind.cpp:27-38
+namespace {
+struct CreateNotUnderValgrind {
+ static void *call() { return new bool{!RUNNING_ON_VALGRIND}; }
+};
+} // namespace
+static const llvm::ManagedStatic<bool, CreateNotUnderValgrind> NotUnderValgrind;
----------------
dexonsmith wrote:
> Can `NotUnderValgrind` be merged into `RunningOnValgrind`, skipping the managed static?
>
> The only reason not to is if it `RUNNING_ON_VALGRIND` could return "true" on the first use, but "false" some time later in the same execution. I don't imagine that's possible...?
>
> ... but if it //is// possible, maybe switching to ManagedStatic isn't safe either, since there would be a reason to cache the value at load-time instead of at first use.
(Based on https://www.valgrind.org/docs/manual/manual-core-adv.html I strongly doubt load-time is special in any way...)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106206/new/
https://reviews.llvm.org/D106206
More information about the llvm-commits
mailing list