[clang] fb9a741 - [CodeGen][NFCI] Avoid calls to setTargetAttributes on definitions
    Chris Bowler via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Wed Jul 12 06:29:27 PDT 2023
    
    
  
Author: Alex Gatea
Date: 2023-07-12T09:29:11-04:00
New Revision: fb9a74122ef7730ae9839c63c4b7e9a78549d8e6
URL: https://github.com/llvm/llvm-project/commit/fb9a74122ef7730ae9839c63c4b7e9a78549d8e6
DIFF: https://github.com/llvm/llvm-project/commit/fb9a74122ef7730ae9839c63c4b7e9a78549d8e6.diff
LOG: [CodeGen][NFCI] Avoid calls to setTargetAttributes on definitions
Avoid duplicate calls to setTargetAttributes on global variable definitions.
Differential: https://reviews.llvm.org/D153903
Added: 
    
Modified: 
    clang/lib/CodeGen/CodeGenModule.cpp
Removed: 
    
################################################################################
diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 13b49eb577a703..d8a45e4dcb3064 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4765,7 +4765,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty,
     }
   }
 
-  if (GV->isDeclaration()) {
+  if (D &&
+      D->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly) {
     getTargetCodeGenInfo().setTargetAttributes(D, GV, *this);
     // External HIP managed variables needed to be recorded for transformation
     // in both device and host compilations.
        
    
    
More information about the cfe-commits
mailing list