[PATCH] D104667: Improve the diagnostic of DiagnosticInfoResourceLimit (and warn-stack-size in particular)

2021-06-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf53d791520d8: Improve the diagnostic of 
DiagnosticInfoResourceLimit (and warn-stack-size in… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104667/new/

https://reviews.llvm.org/D104667

Files:
  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

Index: llvm/test/CodeGen/X86/warn-stack.ll
===
--- llvm/test/CodeGen/X86/warn-stack.ll
+++ 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.
 ; 
 
@@ -12,7 +12,7 @@
   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
Index: llvm/test/CodeGen/ARM/warn-stack.ll
===
--- llvm/test/CodeGen/ARM/warn-stack.ll
+++ 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.
 ; 
 
@@ -12,7 +12,7 @@
   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
Index: llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll
===
--- llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll
+++ 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 @@
   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:
Index: llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll
===
--- llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll
+++ 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 @@
   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 @@
   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 @@
   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 {
  

[PATCH] D104667: Improve the diagnostic of DiagnosticInfoResourceLimit (and warn-stack-size in particular)

2021-06-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 353510.
MaskRay added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104667/new/

https://reviews.llvm.org/D104667

Files:
  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

Index: llvm/test/CodeGen/X86/warn-stack.ll
===
--- llvm/test/CodeGen/X86/warn-stack.ll
+++ 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.
 ; 
 
@@ -12,7 +12,7 @@
   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
Index: llvm/test/CodeGen/ARM/warn-stack.ll
===
--- llvm/test/CodeGen/ARM/warn-stack.ll
+++ 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.
 ; 
 
@@ -12,7 +12,7 @@
   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
Index: llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll
===
--- llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll
+++ 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 @@
   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:
Index: llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll
===
--- llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll
+++ 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 @@
   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 @@
   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 @@
   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 @@
   ret void
 }
 
-; ERROR: error: addressable scalar registers limit of 102 

[PATCH] D104667: Improve the diagnostic of DiagnosticInfoResourceLimit (and warn-stack-size in particular)

2021-06-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Misc/backend-resource-limit-diagnostics.cl:4
 
-// CHECK: error: local memory limit exceeded (48) in use_huge_lds
+// CHECK: error: local memory (48) exceeds limit in function 'use_huge_lds'
 kernel void use_huge_lds()

nickdesaulniers wrote:
> The value of the limit is still not printed though.
> 
> Oh, we don't print `(0)` if the limit is `0`? Perhaps add a `--check-prefix` 
> and additional `RUN` line that exercises a non-zero limit from the frontend?
0 means the diagnostic does not convey the limit information. It needs more 
refactoring to make this happen... and probably should not be the job of this 
patch...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104667/new/

https://reviews.llvm.org/D104667

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104667: Improve the diagnostic of DiagnosticInfoResourceLimit (and warn-stack-size in particular)

2021-06-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 353497.
MaskRay added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

stack size -> stack frame size

The former is ambiguous (it could mean the full stack size).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104667/new/

https://reviews.llvm.org/D104667

Files:
  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

Index: llvm/test/CodeGen/X86/warn-stack.ll
===
--- llvm/test/CodeGen/X86/warn-stack.ll
+++ 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.
 ; 
 
@@ -12,7 +12,7 @@
   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 {
 entry:
   %buffer = alloca [80 x i8], align 1
Index: llvm/test/CodeGen/ARM/warn-stack.ll
===
--- llvm/test/CodeGen/ARM/warn-stack.ll
+++ 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.
 ; 
 
@@ -12,7 +12,7 @@
   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" {
 entry:
   %buffer = alloca [80 x i8], align 1
Index: llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll
===
--- llvm/test/CodeGen/AMDGPU/stack-size-overflow.ll
+++ 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 @@
   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:
Index: llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll
===
--- llvm/test/CodeGen/AMDGPU/exceed-max-sgprs.ll
+++ 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 @@
   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 @@
   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 @@
   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 "",