I was trying to add .cfi_ annotations to assembly code in the FreeBSD
kernel and changed a macro that then resulted in incorrectly nested
directives. However, clang's diagnostics said the error was happening at
<unknown>:0. This addresses one of the TODOs added in D51695.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | ||
---|---|---|
245 ↗ | (On Diff #301927) | These can be simplified by switching to default arguments in the declarations. |
llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | ||
---|---|---|
245 ↗ | (On Diff #301927) | Yes. However, I chose to not add default arguments to ensure that all callers from the asmparser side are forced to pass the argument. I initially had default arguments but missed a lot of call sites before I removed the default. |
llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | ||
---|---|---|
245 ↗ | (On Diff #301927) | To simplify the cases where there is no Loc, we could do something like void emitCFIEndProc(MCSTREAMER_SMLOC(Loc)); The files that don't can't to pass a SMLoc could then do |
I've been thinking about this problem of missing SMLocs for a while, and I think the right direction is probably for MCStreamer to have a way to get the location of the beginning of the directive being processed. That would suffice for the majority of these .cfi_* directives. It would make it much easier to get error reporting right by default or to add in error reporting later.
How should MCStreamer get an access to the parser's SMLoc? The constructor of AsmParser has a non-const reference to MCStreamer. Add a SMLoc pointer in MCStreamer and make it aware of the parser's SMLoc in the constructor of AsmParser?
Sounds reasonable to me. Note, it's not the current parser location, it's the saved location of the start of the directive, but otherwise, that's the idea.
OK, D90511 for the idea.
(I confess I committed a symbol binding related SMLoc change abruptly yesterday.. Sorry)
LGTM. One last comment
llvm/test/MC/X86/cfi-scope-unclosed.s | ||
---|---|---|
0 | If cfi-scope-errors.s includes the coverage perhaps delete the file |
Perhaps EndLoc is clearer.