Author: Fangrui Song Date: 2021-06-22T09:55:20-07:00 New Revision: f53d791520d85c5404381ff3ad92cb918256029d
URL: https://github.com/llvm/llvm-project/commit/f53d791520d85c5404381ff3ad92cb918256029d DIFF: https://github.com/llvm/llvm-project/commit/f53d791520d85c5404381ff3ad92cb918256029d.diff LOG: 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 Added: Modified: clang/test/Misc/backend-resource-limit-diagnostics.cl clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp llvm/include/llvm/IR/DiagnosticInfo.h llvm/lib/CodeGen/PrologEpilogInserter.cpp llvm/lib/IR/DiagnosticInfo.cpp llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll llvm/test/CodeGen/ARM/warn-stack.ll llvm/test/CodeGen/X86/warn-stack.ll Removed: ################################################################################ diff --git a/clang/test/Misc/backend-resource-limit-diagnostics.cl b/clang/test/Misc/backend-resource-limit-diagnostics.cl index 6e7619babe83b..d80f44f691867 100644 --- a/clang/test/Misc/backend-resource-limit-diagnostics.cl +++ b/clang/test/Misc/backend-resource-limit-diagnostics.cl @@ -1,7 +1,7 @@ // REQUIRES: amdgpu-registered-target // RUN: not %clang_cc1 -emit-codegen-only -triple=amdgcn-- %s 2>&1 | FileCheck %s -// CHECK: error: local memory limit exceeded (480000) in use_huge_lds +// CHECK: error: local memory (480000) exceeds limit in function 'use_huge_lds' kernel void use_huge_lds() { volatile local int huge[120000]; diff --git a/clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp b/clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp index 01b9ff598d86a..d28d54b0e8a2d 100644 --- a/clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp +++ b/clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp @@ -13,7 +13,7 @@ namespace frameSizeThunkWarning { }; // CHECK: warning: stack frame size of {{[0-9]+}} bytes in function 'frameSizeThunkWarning::B::f' - // CHECK: warning: stack size limit exceeded ({{[0-9]+}}) in {{[^ ]+}} + // CHECK: warning: stack frame size ([[#]]) exceeds limit in function '_ZTv0_n12_N21frameSizeThunkWarning1B1fEv' void B::f() { volatile int x = 0; // Ensure there is stack usage. } diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index 89c3f1ba9761e..9134ca12600b2 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -220,7 +220,7 @@ class DiagnosticInfoStackSize : public DiagnosticInfoResourceLimit { DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize, DiagnosticSeverity Severity = DS_Warning, uint64_t StackLimit = 0) - : DiagnosticInfoResourceLimit(Fn, "stack size", StackSize, Severity, + : DiagnosticInfoResourceLimit(Fn, "stack frame size", StackSize, Severity, DK_StackSize, StackLimit) {} uint64_t getStackSize() const { return getResourceSize(); } diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index e745f561a8961..2f65a450fb02a 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -285,7 +285,7 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) { (void)Failed; } if (StackSize > Threshold) { - DiagnosticInfoStackSize DiagStackSize(F, StackSize); + DiagnosticInfoStackSize DiagStackSize(F, StackSize, DS_Warning, Threshold); F.getContext().diagnose(DiagStackSize); } ORE->emit([&]() { diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index 59541704ef52c..f921382748018 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -70,12 +70,10 @@ void DiagnosticInfoInlineAsm::print(DiagnosticPrinter &DP) const { } void DiagnosticInfoResourceLimit::print(DiagnosticPrinter &DP) const { - DP << getResourceName() << " limit"; - + DP << getResourceName() << " (" << getResourceSize() << ") exceeds limit"; if (getResourceLimit() != 0) - DP << " of " << getResourceLimit(); - - DP << " exceeded (" << getResourceSize() << ") in " << getFunction(); + DP << " (" << getResourceLimit() << ')'; + DP << " in function '" << getFunction() << '\''; } void DiagnosticInfoDebugMetadataVersion::print(DiagnosticPrinter &DP) const { diff --git a/llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll b/llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll index 13aafc24895df..ad2c6debda7e9 100644 --- a/llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll +++ b/llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll @@ -1,6 +1,6 @@ ; 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 { call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[8:15]}" () @@ -19,7 +19,7 @@ define amdgpu_kernel void @use_too_many_sgprs_tahiti() #0 { 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 { call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[8:15]}" () @@ -38,7 +38,7 @@ define amdgpu_kernel void @use_too_many_sgprs_bonaire() #1 { 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 { call void asm sideeffect "", "~{s[0:7]}" () 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 } -; 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 { call void asm sideeffect "", "~{vcc}" () call void asm sideeffect "", "~{s[0:7]}" () @@ -76,7 +76,7 @@ define amdgpu_kernel void @use_too_many_sgprs_iceland() #2 { 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 { call void asm sideeffect "", "~{s[0:7]}" () call void asm sideeffect "", "~{s[8:15]}" () diff --git a/llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll b/llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll index 8550b7b1ed484..6977f0c4e4742 100644 --- a/llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll +++ b/llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll @@ -3,7 +3,7 @@ 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 define amdgpu_kernel void @stack_size_limit_wave64() #0 { entry: @@ -13,7 +13,7 @@ entry: 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 define amdgpu_kernel void @stack_size_limit_wave32() #1 { entry: diff --git a/llvm/test/CodeGen/ARM/warn-stack.ll b/llvm/test/CodeGen/ARM/warn-stack.ll index 751590059d0dd..fbea89d8b81d0 100644 --- a/llvm/test/CodeGen/ARM/warn-stack.ll +++ b/llvm/test/CodeGen/ARM/warn-stack.ll @@ -1,5 +1,5 @@ ; 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. ; <rdar://13987214> @@ -12,7 +12,7 @@ entry: 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" { entry: %buffer = alloca [80 x i8], align 1 diff --git a/llvm/test/CodeGen/X86/warn-stack.ll b/llvm/test/CodeGen/X86/warn-stack.ll index b0c51f22ebe0e..fc59c6edbee70 100644 --- a/llvm/test/CodeGen/X86/warn-stack.ll +++ b/llvm/test/CodeGen/X86/warn-stack.ll @@ -1,5 +1,5 @@ ; 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. ; <rdar://13987214> @@ -12,7 +12,7 @@ entry: 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" { entry: %buffer = alloca [80 x i8], align 1 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits