[PATCH] D127267: [NVPTX] Add setAuxTarget override rather than make a new TargetInfo

Ryan Prichard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 14:40:53 PDT 2022


rprichard added a comment.

In D127267#3570269 <https://reviews.llvm.org/D127267#3570269>, @yaxunl wrote:

> This patch is to fix an issue, right? At least we need a test to prevent that issue from happening again.

Yes, this patch is necessary to keep the clang/test/Preprocessor/cuda-types.cu test passing after applying D28213 <https://reviews.llvm.org/D28213>. That test is verifying that `__GCC_ATOMIC_LLONG_LOCK_FREE` is the same for `--cuda-device-only` and `--cuda-host-only`.

D28213 <https://reviews.llvm.org/D28213> fixes the value of `__GCC_ATOMIC_LLONG_LOCK_FREE` to be `2` when targeting 586 and up, which has the cx8 feature (cmpxchg8b). Without this NVPTX patch, the value of `__GCC_ATOMIC_LLONG_LOCK_FREE` is `2` for `--cuda-host-only`, but `1` for `--cuda-device-only`, because when NVPTXTargetInfo creates the host TargetInfo, it only uses the host triple, and doesn't set the target CPU nor initialize CPU features. (Specifically, NVPTXTargetInfo calls AllocateTarget but skips all the other work that TargetInfo::CreateTargetInfo does, like calling initFeatureMap, handleTargetFeatures, and setMaxAtomicWidth.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127267/new/

https://reviews.llvm.org/D127267



More information about the cfe-commits mailing list