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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to