oToToT created this revision.
oToToT added reviewers: sammccall, kadircet.
oToToT added a project: clang.
oToToT requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.

D97493 <https://reviews.llvm.org/D97493> separate target creation out to a 
single function `CompilerInstance::createTarget`. However, it would overwrite 
AuxTarget even if it has been set.
As @kadircet recommended in D98128 <https://reviews.llvm.org/D98128>, this 
patch check the existence of AuxTarget and not overwrite it when it has been 
set.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100024

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===================================================================
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -104,8 +104,10 @@
   if (!hasTarget())
     return false;
 
-  // Create TargetInfo for the other side of CUDA/OpenMP/SYCL compilation.
-  if ((getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  // Check whether AuxTarget exists, if not, then create TargetInfo for the
+  // other side of CUDA/OpenMP/SYCL compilation.
+  if (!hasAuxTarget() &&
+      (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
        getLangOpts().SYCLIsDevice) &&
       !getFrontendOpts().AuxTriple.empty()) {
     auto TO = std::make_shared<TargetOptions>();
Index: clang/include/clang/Frontend/CompilerInstance.h
===================================================================
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -377,6 +377,8 @@
   /// @name AuxTarget Info
   /// {
 
+  bool hasAuxTarget() const { return AuxTarget != nullptr; }
+
   TargetInfo *getAuxTarget() const { return AuxTarget.get(); }
 
   /// Replace the current AuxTarget.


Index: clang/lib/Frontend/CompilerInstance.cpp
===================================================================
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -104,8 +104,10 @@
   if (!hasTarget())
     return false;
 
-  // Create TargetInfo for the other side of CUDA/OpenMP/SYCL compilation.
-  if ((getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  // Check whether AuxTarget exists, if not, then create TargetInfo for the
+  // other side of CUDA/OpenMP/SYCL compilation.
+  if (!hasAuxTarget() &&
+      (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
        getLangOpts().SYCLIsDevice) &&
       !getFrontendOpts().AuxTriple.empty()) {
     auto TO = std::make_shared<TargetOptions>();
Index: clang/include/clang/Frontend/CompilerInstance.h
===================================================================
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -377,6 +377,8 @@
   /// @name AuxTarget Info
   /// {
 
+  bool hasAuxTarget() const { return AuxTarget != nullptr; }
+
   TargetInfo *getAuxTarget() const { return AuxTarget.get(); }
 
   /// Replace the current AuxTarget.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to