[all-commits] [llvm/llvm-project] 83c309: [CUDA][HIP] capture possible ODR-used var (#136645)

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Wed Apr 23 09:50:50 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 83c309b90550aa768ff9aa11b70898ee2c56b71e
      https://github.com/llvm/llvm-project/commit/83c309b90550aa768ff9aa11b70898ee2c56b71e
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2025-04-23 (Wed, 23 Apr 2025)

  Changed paths:
    M clang/include/clang/Sema/ScopeInfo.h
    M clang/include/clang/Sema/SemaCUDA.h
    M clang/lib/Sema/SemaCUDA.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaOverload.cpp
    A clang/test/CodeGenCUDA/lambda-constexpr-capture.cu

  Log Message:
  -----------
  [CUDA][HIP] capture possible ODR-used var (#136645)

In a lambda function, a call of a function may
resolve to host and device functions with different
signatures. Especially, a constexpr local variable may
be passed by value by the device function and
passed by reference by the host function, which
will cause the constexpr variable captured by
the lambda function in host compilation but
not in the device compilation. The discrepancy
in the lambda captures will violate ODR and
causes UB for kernels using these lambdas.

This PR fixes the issue by identifying
discrepancy of ODR/non-ODR usages of constexpr
local variables passed to host/device functions
and conservatively capture them.

Fixes: https://github.com/llvm/llvm-project/issues/132068



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list