Print source location info and demangle the name, compared
to the default behavior.
Several observations:
- Specially handling this seems to give source locations
without enabling debug info, and also gives columns compared
to the backend diagnostic. This seems like a bug?
- We're duplicating diagnostic effort in DiagnosticInfo
and clang. This feels wrong, but clang can demangle and I guess
have better debug info available? Should clang really have any of this
code? For the purposes of this diagnostic, the important piece
is just reading the source location out of the llvm::Function.
- lld is not duplicating the same effort as clang with LTO, and just
directly printing the DiagnosticInfo as-is. e.g.
$ clang -fgpu-rdc lld: error: local memory (480000) exceeds limit (65536) in function '_Z12use_huge_ldsIiEvv' lld: error: local memory (960000) exceeds limit (65536) in function '_Z12use_huge_ldsIdEvv' $ clang -fno-gpu-rdc backend-resource-limit-diagnostics.hip:8:17: error: local memory (480000) exceeds limit (65536) in 'void use_huge_lds<int>()' __global__ void use_huge_lds() { ^ backend-resource-limit-diagnostics.hip:8:17: error: local memory (960000) exceeds limit (65536) in 'void use_huge_lds<double>()' 2 errors generated when compiling for gfx90a.
- Backend errors are not observed with -save-temps and -fno-gpu-rdc or -flto,
and the compile incorrectly succeeds.
- The backend version prints error: <location info>; clang prints <location info>: error:
- -emit-codegen-only is totally broken for AMDGPU. MC
gets a null target streamer. I do not understand why this
is a thing. This just creates a horrible edge case.
Just work around this by emitting actual code instead of blocking
this patch.
ultra nit: extra blank line