[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 1 01:55:10 PDT 2018

Hahnfeld added a comment.

In https://reviews.llvm.org/D47849#1183150, @hfinkel wrote:

> Hrmm. Doesn't that make it so that whatever functions are implemented using that inline assembly will not be callable from target code (or, perhaps worse, will crash the backend if called)?

You are right :-(

However I'm getting worried about a more general case, not all inline assembly is guarded by `#ifdef`s that we could hope to get right. For example take `sys/io.h` which currently throws 18 errors when compiling with offloading to GPUs, even with `-O0`. The inline assembly is only guarded by `#if defined __GNUC__ && __GNUC__ >= 2` which should be defined by any modern compiler claiming compatibility with GCC. I'm not sure this particular header will ever end up in an OpenMP application, but others with inline assembly will. From a quick grep it looks like some headers dealing with atomic operations have inline assembly and even `eigen3/Eigen/src/Core/util/Memory.h` for finding the cpuid.

Coming back to the original problem: Maybe we need to undefine optimization macros as in your patch to get as many correct inline functions as possible AND ignore errors from inline assembly as in my patch to not break when including weird headers?

  rC Clang


More information about the cfe-commits mailing list