[clang] [CUDA][HIP] capture possible ODR-used var (PR #136645)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 22 12:54:40 PDT 2025
================
@@ -1100,3 +1101,49 @@ std::string SemaCUDA::getConfigureFuncName() const {
// Legacy CUDA kernel configuration call
return "cudaConfigureCall";
}
+
+// Record any local constexpr variables that are passed one way on the host
+// and another on the device.
+void SemaCUDA::recordPotentialODRUsedVariable(
+ MultiExprArg Arguments, OverloadCandidateSet &Candidates) {
+ sema::LambdaScopeInfo *LambdaInfo = SemaRef.getCurLambda();
+ if (!LambdaInfo)
+ return;
+
+ for (unsigned I = 0; I < Arguments.size(); ++I) {
+ auto *DeclRef = dyn_cast<DeclRefExpr>(Arguments[I]);
+ if (!DeclRef)
+ continue;
+ auto *Variable = dyn_cast<VarDecl>(DeclRef->getDecl());
+ if (!Variable || !Variable->isLocalVarDecl() || !Variable->isConstexpr())
+ continue;
+
+ bool HostByValue = false, HostByRef = false;
+ bool DeviceByValue = false, DeviceByRef = false;
----------------
Artem-B wrote:
I'd move them do to where we use them.
https://github.com/llvm/llvm-project/pull/136645
More information about the cfe-commits
mailing list