Skip to content

Commit

Permalink
[CodeGen][NFCI] Avoid calls to setTargetAttributes on definitions
Browse files Browse the repository at this point in the history
Avoid duplicate calls to setTargetAttributes on global variable definitions.

Differential: https://reviews.llvm.org/D153903
  • Loading branch information
Alex Gatea authored and cebowler committed Jul 12, 2023
1 parent 3c30179 commit fb9a741
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fb9a741

Please sign in to comment.