[all-commits] [llvm/llvm-project] 658d26: [clang] Define convergence in C++ languages such a...

Sameer Sahasrabuddhe via All-commits all-commits at lists.llvm.org
Thu Apr 17 05:55:40 PDT 2025


  Branch: refs/heads/users/ssahasra/clang-generate-tokens
  Home:   https://github.com/llvm/llvm-project
  Commit: 658d26ca2a2f172524714094d5f924db39b814a1
      https://github.com/llvm/llvm-project/commit/658d26ca2a2f172524714094d5f924db39b814a1
  Author: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
  Date:   2025-04-17 (Thu, 17 Apr 2025)

  Changed paths:
    A clang/docs/ThreadConvergence.rst
    M clang/docs/conf.py
    M clang/docs/index.rst
    M clang/include/clang/AST/ParentMap.h
    A clang/include/clang/Analysis/Analyses/ConvergenceCheck.h
    M clang/include/clang/Analysis/CFG.h
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/AST/ParentMap.cpp
    M clang/lib/Analysis/AnalysisDeclContext.cpp
    M clang/lib/Analysis/CMakeLists.txt
    A clang/lib/Analysis/ConvergenceCheck.cpp
    M clang/lib/Sema/AnalysisBasedWarnings.cpp
    A clang/test/SemaHIP/convergence-warnings.hip

  Log Message:
  -----------
  [clang] Define convergence in C++ languages such as HIP, CUDA, OpenCL

The proposed definition closely follows the existing definition of convergence
in LLVM IR, but using C++ terms to describe language constructs.

There is no undefined behaviour. For each situation, convergence is either fully
defined or implementation-defined.

Two important limitations where LLVM IR requires convergence control tokens to
correctly express the convergence specified here:

1. Some combinations of loops, continue and break statements have different
   convergence specified for the statements inside that region of code, but
   result in the same loops in LLVM IR, thus producing ambiguous convergence in
   LLVM IR.

2. When a divergent condition inside a loop contains a convergent call followed
   by a break statement, these statements are lexically inside the loop, but in
   LLVM IR, they are outside the corresponding CFG loop.


  Commit: ad07d9c25d3d1e17f3999487aa6be0094c667c5d
      https://github.com/llvm/llvm-project/commit/ad07d9c25d3d1e17f3999487aa6be0094c667c5d
  Author: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
  Date:   2025-04-17 (Thu, 17 Apr 2025)

  Changed paths:
    M clang/docs/ThreadConvergence.rst
    M clang/include/clang/Analysis/Analyses/ConvergenceCheck.h
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Basic/LangOptions.def
    M clang/include/clang/Driver/Options.td
    M clang/lib/Analysis/ConvergenceCheck.cpp
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/CGStmt.cpp
    M clang/lib/CodeGen/CodeGenFunction.cpp
    M clang/lib/CodeGen/CodeGenFunction.h
    M clang/lib/CodeGen/CodeGenModule.h
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Sema/AnalysisBasedWarnings.cpp
    A clang/test/CodeGenHIP/convergence-tokens.hip
    A clang/test/CodeGenHIP/noconvergent-statement.hip
    A clang/test/SemaHIP/noconvergent-errors/backwards_jump.hip
    A clang/test/SemaHIP/noconvergent-errors/jump-into-nest.hip
    A clang/test/SemaHIP/noconvergent-errors/no-errors.hip
    A clang/test/SemaHIP/noconvergent-errors/simple_jump.hip
    M llvm/include/llvm/IR/InstrTypes.h
    M llvm/include/llvm/IR/IntrinsicInst.h
    A llvm/include/llvm/Transforms/Utils/FixConvergenceControl.h
    M llvm/lib/IR/Instructions.cpp
    M llvm/lib/IR/IntrinsicInst.cpp
    M llvm/lib/Transforms/Utils/CMakeLists.txt
    A llvm/lib/Transforms/Utils/FixConvergenceControl.cpp

  Log Message:
  -----------
  [clang] Redefine `noconvergent` and generate convergence control tokens

This introduces the `-fconvergence-control` flag that emits convergence control
intrinsics which are then used as the `convergencectrl` operand bundle on
convergent calls.

This also redefines the `noconvergent` attribute in Clang. The existing simple
interpretation is that if a statement is marked `noconvergent`, then every asm
call is treated as a non-convergent operation in the emitted LLVM IR.

The new semantics introduces a more powerful notion that a `noconvergent`
statement may contain convergent operations, but the resulting convergence
constraints are limited to the scope of that statement. As a whole the statement
itself does not place any convergence constraints on the control flow reaching
it. When emitting convergence tokens, this attribute results in a call to the
`anchor` intrinsic that determines convergence within the statement.


Compare: https://github.com/llvm/llvm-project/compare/fb6a38e16a3f...ad07d9c25d3d

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