[clang] [clang] Improve diagnostics for constraints of inline asm (NFC) (PR #96363)

Evgenii Kudriashov via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 24 08:39:27 PDT 2024


e-kud wrote:

> It's really unfortunate to have to add all this asm handling to clang. Can't it rely on backend diagnostic remarks for this?

I've tried to do the similar thing in the backend: https://reviews.llvm.org/D152332. The problem I see is that `llc`'s error handler ignores errors and continues compilation until something further reports a fatal error. In other words we have to return something wrong intentionally to continue compilation. On the other hand, we can prepare all callers to have an error somewhere inside but there will be a lot of refactor because there is no common practice to emit target specific errors. `report_fatal_error` is more likable.

```
$ grep -R emitError lib/Target/X86/*
lib/Target/X86/X86FloatingPoint.cpp:      MI.emitError("fixed input regs must be last on the x87 stack");
lib/Target/X86/X86FloatingPoint.cpp:      MI.emitError("output regs must be last on the x87 stack");
lib/Target/X86/X86FloatingPoint.cpp:      MI.emitError("clobbers must be last on the x87 stack");
lib/Target/X86/X86FloatingPoint.cpp:      MI.emitError("implicitly popped regs must be last on the x87 stack");
lib/Target/X86/X86PreTileConfig.cpp:static void emitErrorMsg(MachineFunction &MF) {
lib/Target/X86/X86PreTileConfig.cpp:  Context.emitError(
lib/Target/X86/X86PreTileConfig.cpp:      emitErrorMsg(MF);
lib/Target/X86/X86PreTileConfig.cpp:      emitErrorMsg(MF);
$ grep -R emitError lib/Target/AArch64/*
lib/Target/AArch64/AArch64AsmPrinter.cpp:    BaseGV->getContext().emitError(
$ grep -R emitError lib/Target/RISCV/*
$
```
```
$ grep -R emitError lib/Target/* | wc -l
47
$ grep -R report_fatal_error lib/Target/* | wc -l
675
```
I'm not sure whether it is much better. 



https://github.com/llvm/llvm-project/pull/96363


More information about the cfe-commits mailing list