If a .size directive which uses an expression to calculate the size has a typo
in a label reference or references a label from another section, it is invalid.
Emit an error instead of a fatal error, and if there's a way to hint at the
cause, emit relevant diagnostic notes.
Details
- Reviewers
MaskRay
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Is it overkill to add a spell corrector? .size is usually generated by the compiler, so this can only be useful for hand-written assembly. Though I wonder how many times this can be useful.
For whatever reason, many hexagon developers frequently use the .size directive to set the function size correctly when hand-writing assembly. There may be / may have been some developer scripts that expected/relied on this being set.
This particular patch is inspired by developer bug reports - including one that had a .size referencing a label incorrectly - with a single-character error: differing only in case.
If you think the "did you mean..." is overkill, I am happy to remove it.
Yeah, I kinda feel like we are not making good use of the 50 lines of code. .size is too minor a feature that I'd waste 50 lines, adding MCAssembler &Asm, in various places to make this work.
To make good use of the 50 lines, this should be something generic (think as a utility similar to evaluateAsRelocatable), so that every other directive which has similar usage to .size can benefit from this.
Hmm. Removing the spell check portion of NoteUndef only saves around ~9 lines. So it sounds like that's not sufficient? You prefer either not accepting any of this patch or expanding its scope to include other directives? I will explore the latter.
Yes, reusing this in more places can improve its value... I am also a bit unsure about did you mean to refer suggesting more than one symbol.
clang-format: please reformat the code