llvm / llvm/circt

[HW] Inner symbols dropped by InlineModules

Open
#6,967 3 comments 0 reactions 0 assignees View on GitHub
bug HW
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

InlineModules pass currently strips inner symbols so it could break design.
```mlir
$ cat test.mlir
hw.hierpath @hier [@Foo::@bar, @Bar::@a]
hw.module private @Bar(in %a : i1 {hw.exportPort = #hw}, out b : i1) {
hw.output %a : i1
}
hw.module @Foo(in %a : i1, out b : i1) {
%bar.b = hw.instance "bar" sym @bar @Bar(a: %a: i1) -> (b: i1)
hw.output %bar.b : i1
}

$ circt-opt test.mlir -hw-flatten-modules -hw-verify-irn
test.mlir:1:3: error: 'hw.hierpath' op module: "Foo" does not contain any instance with symbol: "bar"
hw.hierpath @hier [@Foo::@bar, @Bar::@a]
^
test.mlir:1:3: note: see current operation: "hw.hierpath"() {namepath = [#hw.innerNameRef<@Foo::@bar>, #hw.innerN
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the InlineModules pass and reproduce the failure using the test.mlir example and the circt-opt -hw-flatten-modules -hw-verify-irn command. Trace how the @Bar::@a inner symbol and @Foo::@bar hierpath are handled; done means the inner symbols are preserved and the reproducer passes verification.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.