paritytech / paritytech/revive

`!dbg` attachment on the wrong subprogram

Open
#587 0 comments 0 reactions 1 assignee View on GitHub

@xermicus is already working on this.

Since Aug 10, 2026.

Dominant language
Rust
Stars
102
Forks
26
Avg merge
1d 13h
Merged PRs (30d)
6

Description

A Yul function definition and an msize() in the same inline-assembly block make the stock pipeline attach a debug location scoped to the user function to an instruction in the enclosing function. LLVM's verifier rejects the module and compilation fails.

The --newyork pipeline is unaffected.

MRE

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
contract DbgScope {
  function run() external {
    assembly {
      function f() { }
      let q := msize()
    }
  }
}

--disable-solc-optimizer is required, because solc refuses msize while its own Yul optimizer is on.

Execution results

$ resolc --disable-solc-optimizer -O3 --bin DbgScope.sol
Error: The contract `DbgScope.sol:DbgScope` unoptimized LLVM IR verification error:
!dbg attachment points at wrong subprogram for function
  !199 = distinct !DISubprogram(name: "fun_run_8_runtime__14", ...)
  ptr @fun_run_8_runtime__14
  br label %return, !dbg !246
  !246 = !DILocation(line: 77, column: 22, scope: !247)
  !247 = distinct !DISubprogram(name: "usr$f1_runtime__15", ...)

The branch belongs to fun_run_8_runtime__14, the entry function, but carries a location scoped to usr$f1_runtime__15, the Yul function.

With --newyork the same contract compiles at every level.

Git commit: d1c00c21471e94bc7a7c94a608c2e56dca1c237e; LLVM 22.1.5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.