This is an archive of the discontinued LLVM Phabricator instance.

clang: Improve errors for DiagnosticInfoResourceLimit
ClosedPublic

Authored by arsenm on Oct 28 2022, 8:45 AM.

Details

Summary

Print source location info and demangle the name, compared
to the default behavior.

Several observations:

  1. 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?

  1. 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.

  1. 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.
  1. Backend errors are not observed with -save-temps and -fno-gpu-rdc or -flto,

and the compile incorrectly succeeds.

  1. The backend version prints error: <location info>; clang prints <location info>: error:
  1. -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.

Diff Detail

Event Timeline

arsenm created this revision.Oct 28 2022, 8:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2022, 8:45 AM
arsenm requested review of this revision.Oct 28 2022, 8:45 AM

see https://reviews.llvm.org/D110665 for how we get line/col from a function. basically, we have a map from function name hashes to source location available in clang

if we don't have clang source information for functions available, there's not much more we can do other than rely on debug info, which is what the default LLVM handlers use when possible. that's why lld doesn't have its own handler

Backend errors are not observed with -save-temps and -fno-gpu-rdc or -flto, and the compile incorrectly succeeds.

not sure why this would be happening

clang/include/clang/Basic/DiagnosticFrontendKinds.td
42

ultra nit: extra blank line

aeubanks accepted this revision.Oct 28 2022, 1:10 PM
This revision is now accepted and ready to land.Oct 28 2022, 1:10 PM