1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Improve the diagnostic of DiagnosticInfoResourceLimit (and warn-stack-size in particular)

Before: `warning: stack size limit exceeded (888) in main`
After: `warning: stack frame size (888) exceeds limit (100) in function 'main'` (the -Wframe-larger-than limit will be mentioned)

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D104667
This commit is contained in:
Fangrui Song 2021-06-22 09:55:20 -07:00
parent afac7e2fd3
commit 61ffec433f
7 changed files with 16 additions and 18 deletions

View File

@ -220,7 +220,7 @@ public:
DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize, DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize,
DiagnosticSeverity Severity = DS_Warning, DiagnosticSeverity Severity = DS_Warning,
uint64_t StackLimit = 0) uint64_t StackLimit = 0)
: DiagnosticInfoResourceLimit(Fn, "stack size", StackSize, Severity, : DiagnosticInfoResourceLimit(Fn, "stack frame size", StackSize, Severity,
DK_StackSize, StackLimit) {} DK_StackSize, StackLimit) {}
uint64_t getStackSize() const { return getResourceSize(); } uint64_t getStackSize() const { return getResourceSize(); }

View File

@ -285,7 +285,7 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
(void)Failed; (void)Failed;
} }
if (StackSize > Threshold) { if (StackSize > Threshold) {
DiagnosticInfoStackSize DiagStackSize(F, StackSize); DiagnosticInfoStackSize DiagStackSize(F, StackSize, DS_Warning, Threshold);
F.getContext().diagnose(DiagStackSize); F.getContext().diagnose(DiagStackSize);
} }
ORE->emit([&]() { ORE->emit([&]() {

View File

@ -70,12 +70,10 @@ void DiagnosticInfoInlineAsm::print(DiagnosticPrinter &DP) const {
} }
void DiagnosticInfoResourceLimit::print(DiagnosticPrinter &DP) const { void DiagnosticInfoResourceLimit::print(DiagnosticPrinter &DP) const {
DP << getResourceName() << " limit"; DP << getResourceName() << " (" << getResourceSize() << ") exceeds limit";
if (getResourceLimit() != 0) if (getResourceLimit() != 0)
DP << " of " << getResourceLimit(); DP << " (" << getResourceLimit() << ')';
DP << " in function '" << getFunction() << '\'';
DP << " exceeded (" << getResourceSize() << ") in " << getFunction();
} }
void DiagnosticInfoDebugMetadataVersion::print(DiagnosticPrinter &DP) const { void DiagnosticInfoDebugMetadataVersion::print(DiagnosticPrinter &DP) const {

View File

@ -1,6 +1,6 @@
; RUN: not llc -march=amdgcn -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=ERROR %s ; RUN: not llc -march=amdgcn -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=ERROR %s
; ERROR: error: scalar registers limit of 104 exceeded (106) in use_too_many_sgprs_tahiti ; ERROR: error: scalar registers (106) exceeds limit (104) in function 'use_too_many_sgprs_tahiti'
define amdgpu_kernel void @use_too_many_sgprs_tahiti() #0 { define amdgpu_kernel void @use_too_many_sgprs_tahiti() #0 {
call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[0:7]}" ()
call void asm sideeffect "", "~{s[8:15]}" () call void asm sideeffect "", "~{s[8:15]}" ()
@ -19,7 +19,7 @@ define amdgpu_kernel void @use_too_many_sgprs_tahiti() #0 {
ret void ret void
} }
; ERROR: error: scalar registers limit of 104 exceeded (106) in use_too_many_sgprs_bonaire ; ERROR: error: scalar registers (106) exceeds limit (104) in function 'use_too_many_sgprs_bonaire'
define amdgpu_kernel void @use_too_many_sgprs_bonaire() #1 { define amdgpu_kernel void @use_too_many_sgprs_bonaire() #1 {
call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[0:7]}" ()
call void asm sideeffect "", "~{s[8:15]}" () call void asm sideeffect "", "~{s[8:15]}" ()
@ -38,7 +38,7 @@ define amdgpu_kernel void @use_too_many_sgprs_bonaire() #1 {
ret void ret void
} }
; ERROR: error: scalar registers limit of 104 exceeded (108) in use_too_many_sgprs_bonaire_flat_scr ; ERROR: error: scalar registers (108) exceeds limit (104) in function 'use_too_many_sgprs_bonaire_flat_scr'
define amdgpu_kernel void @use_too_many_sgprs_bonaire_flat_scr() #1 { define amdgpu_kernel void @use_too_many_sgprs_bonaire_flat_scr() #1 {
call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[0:7]}" ()
call void asm sideeffect "", "~{s[8:15]}" () call void asm sideeffect "", "~{s[8:15]}" ()
@ -58,7 +58,7 @@ define amdgpu_kernel void @use_too_many_sgprs_bonaire_flat_scr() #1 {
ret void ret void
} }
; ERROR: error: scalar registers limit of 96 exceeded (98) in use_too_many_sgprs_iceland ; ERROR: error: scalar registers (98) exceeds limit (96) in function 'use_too_many_sgprs_iceland'
define amdgpu_kernel void @use_too_many_sgprs_iceland() #2 { define amdgpu_kernel void @use_too_many_sgprs_iceland() #2 {
call void asm sideeffect "", "~{vcc}" () call void asm sideeffect "", "~{vcc}" ()
call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[0:7]}" ()
@ -76,7 +76,7 @@ define amdgpu_kernel void @use_too_many_sgprs_iceland() #2 {
ret void ret void
} }
; ERROR: error: addressable scalar registers limit of 102 exceeded (103) in use_too_many_sgprs_fiji ; ERROR: error: addressable scalar registers (103) exceeds limit (102) in function 'use_too_many_sgprs_fiji'
define amdgpu_kernel void @use_too_many_sgprs_fiji() #3 { define amdgpu_kernel void @use_too_many_sgprs_fiji() #3 {
call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[0:7]}" ()
call void asm sideeffect "", "~{s[8:15]}" () call void asm sideeffect "", "~{s[8:15]}" ()

View File

@ -3,7 +3,7 @@
declare void @llvm.memset.p5i8.i32(i8 addrspace(5)* nocapture, i8, i32, i32, i1) #1 declare void @llvm.memset.p5i8.i32(i8 addrspace(5)* nocapture, i8, i32, i32, i1) #1
; ERROR: error: stack size limit exceeded (131061) in stack_size_limit_wave64 ; ERROR: error: stack frame size (131061) exceeds limit in function 'stack_size_limit_wave64'
; GCN: ; ScratchSize: 131061 ; GCN: ; ScratchSize: 131061
define amdgpu_kernel void @stack_size_limit_wave64() #0 { define amdgpu_kernel void @stack_size_limit_wave64() #0 {
entry: entry:
@ -13,7 +13,7 @@ entry:
ret void ret void
} }
; ERROR: error: stack size limit exceeded (262117) in stack_size_limit_wave32 ; ERROR: error: stack frame size (262117) exceeds limit in function 'stack_size_limit_wave32'
; GCN: ; ScratchSize: 262117 ; GCN: ; ScratchSize: 262117
define amdgpu_kernel void @stack_size_limit_wave32() #1 { define amdgpu_kernel void @stack_size_limit_wave32() #1 {
entry: entry:

View File

@ -1,5 +1,5 @@
; RUN: llc -mtriple thumbv7-apple-ios3.0.0 < %s 2>&1 >/dev/null | FileCheck %s ; RUN: llc -mtriple thumbv7-apple-ios3.0.0 < %s 2>&1 >/dev/null | FileCheck %s
; Check the internal option that warns when the stack size exceeds the ; Check the internal option that warns when the stack frame size exceeds the
; given amount. ; given amount.
; <rdar://13987214> ; <rdar://13987214>
@ -12,7 +12,7 @@ entry:
ret void ret void
} }
; CHECK: warning: stack size limit exceeded (92) in warn ; CHECK: warning: stack frame size (92) exceeds limit (80) in function 'warn'
define void @warn() nounwind ssp "frame-pointer"="all" "warn-stack-size"="80" { define void @warn() nounwind ssp "frame-pointer"="all" "warn-stack-size"="80" {
entry: entry:
%buffer = alloca [80 x i8], align 1 %buffer = alloca [80 x i8], align 1

View File

@ -1,5 +1,5 @@
; RUN: llc -mtriple x86_64-apple-macosx10.8.0 < %s 2>&1 >/dev/null | FileCheck %s ; RUN: llc -mtriple x86_64-apple-macosx10.8.0 < %s 2>&1 >/dev/null | FileCheck %s
; Check the internal option that warns when the stack size exceeds the ; Check the internal option that warns when the stack frame size exceeds the
; given amount. ; given amount.
; <rdar://13987214> ; <rdar://13987214>
@ -12,7 +12,7 @@ entry:
ret void ret void
} }
; CHECK: warning: stack size limit exceeded (88) in warn ; CHECK: warning: stack frame size (88) exceeds limit (80) in function 'warn'
define void @warn() nounwind ssp "warn-stack-size"="80" { define void @warn() nounwind ssp "warn-stack-size"="80" {
entry: entry:
%buffer = alloca [80 x i8], align 1 %buffer = alloca [80 x i8], align 1