Skip to content

Commit

Permalink
[ORC-RT] Silence warning when building with Clang ToT on Windows
Browse files Browse the repository at this point in the history
This fixes several of these:
```
[3524/7446] Building CXX object projects\compiler-rt\lib\orc\CMakeFiles\RTOrc.x86_64.dir\dlfcn_wrapper.cpp.obj
In file included from C:\git\llvm-project\compiler-rt\lib\orc\dlfcn_wrapper.cpp:15:
C:\git\llvm-project\compiler-rt\lib\orc\wrapper_function_utils.h(299,27): warning: address of '__orc_rt_jit_dispatch_ctx' will always evaluate to 'true' [-Wpointer-bool-conversion]
  299 |     if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch_ctx))
      |                         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~
C:\git\llvm-project\compiler-rt\lib\orc\compiler.h(60,55): note: expanded from macro 'ORC_RT_UNLIKELY'
   60 | #define ORC_RT_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
      |                                                       ^~~~
1 warning generated.
```
  • Loading branch information
aganea committed Jan 17, 2024
1 parent 6f8b633 commit 6736cc6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler-rt/lib/orc/wrapper_function_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,15 @@ class WrapperFunction<SPSRetTagT(SPSTagTs...)> {
// operation fails.
detail::ResultDeserializer<SPSRetTagT, RetT>::makeSafe(Result);

// Since the functions cannot be zero/unresolved on Windows, the following
// reference taking would always be non-zero, thus generating a compiler
// warning otherwise.
#if !defined(_WIN32)
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch_ctx))
return make_error<StringError>("__orc_rt_jit_dispatch_ctx not set");
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch))
return make_error<StringError>("__orc_rt_jit_dispatch not set");

#endif
auto ArgBuffer =
WrapperFunctionResult::fromSPSArgs<SPSArgList<SPSTagTs...>>(Args...);
if (const char *ErrMsg = ArgBuffer.getOutOfBandError())
Expand Down

0 comments on commit 6736cc6

Please sign in to comment.