[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
Tue Jun 7 19:06:04 PDT 2022


rprichard created this revision.
Herald added subscribers: jsji, kosarev, mattd, gchakrabarti, asavonic, kerbowa, pengfei, jvesely.
Herald added a project: All.
rprichard requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, jholewinski.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Previously, NVPTXTargetInfo constructed a TargetInfo using the
TargetOptions::HostTriple field, but did not initialize the target CPU
or CPU features, which resulted in an inaccurate value for
MaxAtomicInlineWidth on x86_32. MaxAtomicInlineWidth is 64 if the host
TargetInfo is initialized with the +cx8 feature (e.g. 586 and up) but
is 32 otherwise.

Instead, add a setAuxTarget override and defer copying from the host
TargetInfo until CompilerInstance::createTarget calls it.

Change setAuxTarget to pass IntrusiveRefCntPtr<TargetInfo> instead of
a const TargetInfo*. NVPTXTargetInfo needs to retain the host
TargetInfo so that it can check calling conventions.

NVPTXTargetInfo was the only user of the TargetOptions::HostTriple
field, so remove the field.

Also see D29542 <https://reviews.llvm.org/D29542> and D56318 <https://reviews.llvm.org/D56318>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127267

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TargetOptions.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127267.435023.patch
Type: text/x-patch
Size: 6898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220608/11a2b27e/attachment.bin>


More information about the cfe-commits mailing list