Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableGen: References are not resolved at the top level #102447

Closed
optimisan opened this issue Aug 8, 2024 · 0 comments · Fixed by #104578
Closed

TableGen: References are not resolved at the top level #102447

optimisan opened this issue Aug 8, 2024 · 0 comments · Fixed by #104578
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] tablegen

Comments

@optimisan
Copy link
Contributor

llvm-tblgen crashes if "lookup" operators are used on the top level when the looked-up record does not exist.

I define "lookup" operators as !exists<type>(str) and !cast<type>(expr).

td file to reproduce this issue: (run llvm-tblgen file.td)

class Test{}
dump !cast<Test>("non-existent record");

Assertion failure:

llvm-tblgen: ~/llvm-project/llvm/lib/TableGen/Error.cpp:176: void llvm::dumpMessage(llvm::SMLoc, llvm::Init*): Assertion `MessageInit && "no debug message to print"' failed.

This is happening because references to records are only resolved once the Record parsing is finished. But at the top level there is no Record and so the resolution never happens.

I don't see a fix without adding a new mechanism to resolve top level references. The existing resolveReferences() method only works on a Record, which does not exist here. I can think of two approaches: 1. Create a dummy record for the top level and this single statement (RecordVal), or, 2. Create new methods to handle top level resolutions without the enclosing record.

@optimisan optimisan self-assigned this Aug 8, 2024
@EugeneZelenko EugeneZelenko added crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Aug 8, 2024
optimisan added a commit to optimisan/llvm-project that referenced this issue Aug 16, 2024
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.

Fixes llvm#102447
optimisan added a commit to optimisan/llvm-project that referenced this issue Aug 16, 2024
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.

Fixes llvm#102447
optimisan added a commit to optimisan/llvm-project that referenced this issue Aug 19, 2024
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.

Fixes llvm#102447
optimisan added a commit to optimisan/llvm-project that referenced this issue Aug 19, 2024
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.

Fixes llvm#102447
optimisan added a commit that referenced this issue Aug 19, 2024
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.

Fixes #102447

Co-authored-by: Akshat Oke <Akshat.Oke@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] tablegen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants