This is an archive of the discontinued LLVM Phabricator instance.

DiagnosticInfo: Report function location for resource limits
ClosedPublic

Authored by arsenm on Oct 28 2022, 7:52 AM.

Details

Summary

We have some odd redundancy where clang specially handles
the stack size case. If clang prints it, the source location is first
followed by "warning". The backend diagnostic, as printed by other tools
puts "warning" first.

Diff Detail

Event Timeline

arsenm created this revision.Oct 28 2022, 7:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2022, 7:52 AM
arsenm requested review of this revision.Oct 28 2022, 7:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2022, 7:52 AM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm updated this revision to Diff 471563.Oct 28 2022, 8:27 AM

Update clang test

paulkirth accepted this revision.Oct 28 2022, 11:25 AM

This is basically LGTM from my perspective. I'd suggest getting some feedback from someone who works more on this part of Clang before landing, but I think it fixes the inconsistency nicely.

clang/test/Misc/backend-resource-limit-diagnostics.hip
1

Does this need // REQUIRES: amdgpu-registered-target, like the test in backend-resourse-limit-diagnostics.cl?

2

Is this planned for this patch? or for future refactoring in multiple tests?

This revision is now accepted and ready to land.Oct 28 2022, 11:25 AM
arsenm added inline comments.Oct 28 2022, 11:27 AM
clang/test/Misc/backend-resource-limit-diagnostics.hip
2

I'm not sure. I currently cannot comprehend why this flag exists. It's only used in a handful of tests, and its effect seems to be to just create an edge case to crash codegen when there's no target streamer

arsenm added inline comments.Oct 28 2022, 11:40 AM
clang/test/Misc/backend-resource-limit-diagnostics.hip
2

A little more digging suggests this is a feature that is only properly implemented for 5/24 targets. Still don't really see the point

the reason clang tries to handle diagnostics is to be able to actually print the source code as context which is nice. but of course we can't do that without clang so there's a default handler

If clang prints it, the source location is first followed by "warning". The backend diagnostic, as printed by other tools puts "warning" first.

It looks like the backend diagnostic doesn't even print the location?

llvm/include/llvm/IR/DiagnosticInfo.h
356

any reason for moving this code? it makes it hard to see the diff

llvm/lib/IR/DiagnosticInfo.cpp
76

we should guard this with isLocationAvailable(), the <unknown>:0:0 isn't very useful

I think you may also need to rebase, both the X86/warn-stack.ll and ARM/warn-stack.ll were recently updated to reflect changes in the backend diagnostics.

clang/test/Misc/backend-resource-limit-diagnostics.hip
2

I think it's ideal for testing diagnostics in the backend, where you need codegen to occur but the actual output is unnecessary. IIUC this flag allows you to avoid using a non-portable way to throw away the output instead of redirecting to /dev/null.

arsenm added inline comments.Oct 28 2022, 1:22 PM
llvm/include/llvm/IR/DiagnosticInfo.h
356

Moving after DiagnosticInfoWithLocationBase since it's now the base class

llvm/lib/IR/DiagnosticInfo.cpp
76

Everywhere else here prints the unknown. I'd rather keep it consistent and remove them all together later

If clang prints it, the source location is first followed by "warning". The backend diagnostic, as printed by other tools puts "warning" first.

It looks like the backend diagnostic doesn't even print the location?

That's the point of this patch, to fix it for this case. There are still other remarks which don't

MaskRay added inline comments.Oct 28 2022, 1:35 PM
clang/test/Misc/backend-resource-limit-diagnostics.hip
2

FIXME: looks like an unused check prefix. Drop :

13

[[@LINE-5]] uses deprecated syntax. Use [[#@LINE-5]]

MaskRay added inline comments.Oct 28 2022, 1:37 PM
clang/test/Misc/backend-resource-limit-diagnostics.hip
1

-emit-codegen-only is preferred to -S -o /dev/null

MaskRay accepted this revision.Oct 28 2022, 2:03 PM

LGTM.

clang/test/Misc/backend-resource-limit-diagnostics.hip
1

Ignore me. I assume that the object MC backend isn't available. -S -o /dev/null looks fine.

9

2-space indentation is more common

14

Unintended indentation

arsenm added inline comments.Oct 28 2022, 2:07 PM
clang/test/Misc/backend-resource-limit-diagnostics.hip
1

Fixed this in D136983, The null streamer is broken in 19/24 in tree targets

aeubanks accepted this revision.Oct 28 2022, 2:11 PM