OptimizerHacks.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 /// \ingroup PeoGroup
7 /// Workarounds for optimizer bugs
8 namespace optimizer_hacks {
9 /// \ingroup PeoGroup
10 /// Produce a situation where the value of `*variable` could have been
11 /// changed without the optimizer's knowledge, without actually
12 /// changing the variable.
13 void indicate_value_can_be_changed(void* variable) noexcept;
14 } // namespace optimizer_hacks
15 
16 #ifdef __clang__
17 #define VARIABLE_CAUSES_CLANG_FPE(var) \
18  ::optimizer_hacks::indicate_value_can_be_changed(&(var))
19 #else /* __clang__ */
20 /// \ingroup PeoGroup
21 /// Clang's optimizer has a known bug that sometimes produces spurious
22 /// FPEs. This indicates that the variable `var` can trigger that bug
23 /// and prevents some optimizations. (See [the LLVM bug
24 /// report](https://llvm.org/bugs/show_bug.cgi?id=18673), which is
25 /// effectively WONTFIX.)
26 #define VARIABLE_CAUSES_CLANG_FPE(var) ((void)(var))
27 #endif /* __clang__ */
void indicate_value_can_be_changed(void *) noexcept
Produce a situation where the value of *variable could have been changed without the optimizer's know...
Definition: OptimizerHacks.cpp:7
Workarounds for optimizer bugs.
Definition: OptimizerHacks.cpp:6