[all-commits] [llvm/llvm-project] 939860: [CIR] Fix inline asm operand-attr indexing (#202790)

adams381 via All-commits all-commits at lists.llvm.org
Wed Jun 10 09:53:04 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 939860e16212b40ae1f15cb5dc360eaf653cec2d
      https://github.com/llvm/llvm-project/commit/939860e16212b40ae1f15cb5dc360eaf653cec2d
  Author: adams381 <adams at nvidia.com>
  Date:   2026-06-10 (Wed, 10 Jun 2026)

  Changed paths:
    M clang/lib/CIR/CodeGen/CIRGenAsm.cpp
    M clang/test/CIR/CodeGen/inline-asm.c

  Log Message:
  -----------
  [CIR] Fix inline asm operand-attr indexing (#202790)

Inline asm with a register operand ordered before a memory operand, e.g. `asm("" :: "r"(i), "m"(g))`, crashes CIRGen at the `"pointer type expected"` / `"element type differs from pointee type"` assertions in `emitAsmStmt`.

The element-type-attribute loop walks `argElemTypes` with a counter that only advances on entries that have an element type, but uses that counter to index the parallel `args` array. The two arrays are the same length (every operand pushes to both, and `assert(args.size() == operandAttrs.size())` enforces it), so the matching value for `argElemTypes[k]` is `args[k]`. As soon as a register operand (null element type) precedes a memory operand (non-null), the counter desyncs and reads the wrong operand — a non-pointer, or a pointer with the wrong pointee.

The fix indexes `args` positionally with `llvm::enumerate`, matching classic CodeGen in `CGStmt.cpp`, which iterates `llvm::enumerate(ArgElemTypes)` and attaches the element-type attribute at `Pair.index()`. New `t35` in `inline-asm.c` covers the register-before-memory ordering and checks the lowered IR against classic codegen.



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