forked from OSchip/llvm-project
Make DiagnosticInfoResourceLimit's limit param required
And always print it. This makes some LLVM diagnostics match up better with Clang's diagnostics. Updated some AMDGPU uses of DiagnosticInfoResourceLimit and now we print better diagnostics for those. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D110204
This commit is contained in:
parent
2649999579
commit
e42234383e
|
@ -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 (480000) exceeds limit in function 'use_huge_lds'
|
||||
// CHECK: error: local memory (480000) exceeds limit (32768) in function 'use_huge_lds'
|
||||
kernel void use_huge_lds()
|
||||
{
|
||||
volatile local int huge[120000];
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace frameSizeThunkWarning {
|
|||
};
|
||||
|
||||
// CHECK: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in function 'frameSizeThunkWarning::B::f'
|
||||
// CHECK: warning: stack frame size ([[#]]) exceeds limit in function '_ZTv0_n12_N21frameSizeThunkWarning1B1fEv'
|
||||
// CHECK: warning: stack frame size ([[#]]) exceeds limit ([[#]]) in function '_ZTv0_n12_N21frameSizeThunkWarning1B1fEv'
|
||||
void B::f() {
|
||||
volatile int x = 0; // Ensure there is stack usage.
|
||||
}
|
||||
|
|
|
@ -195,10 +195,9 @@ public:
|
|||
/// \p The function that is concerned by this stack size diagnostic.
|
||||
/// \p The computed stack size.
|
||||
DiagnosticInfoResourceLimit(const Function &Fn, const char *ResourceName,
|
||||
uint64_t ResourceSize,
|
||||
uint64_t ResourceSize, uint64_t ResourceLimit,
|
||||
DiagnosticSeverity Severity = DS_Warning,
|
||||
DiagnosticKind Kind = DK_ResourceLimit,
|
||||
uint64_t ResourceLimit = 0)
|
||||
DiagnosticKind Kind = DK_ResourceLimit)
|
||||
: DiagnosticInfo(Kind, Severity), Fn(Fn), ResourceName(ResourceName),
|
||||
ResourceSize(ResourceSize), ResourceLimit(ResourceLimit) {}
|
||||
|
||||
|
@ -219,10 +218,10 @@ class DiagnosticInfoStackSize : public DiagnosticInfoResourceLimit {
|
|||
void anchor() override;
|
||||
public:
|
||||
DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize,
|
||||
DiagnosticSeverity Severity = DS_Warning,
|
||||
uint64_t StackLimit = 0)
|
||||
: DiagnosticInfoResourceLimit(Fn, "stack frame size", StackSize, Severity,
|
||||
DK_StackSize, StackLimit) {}
|
||||
uint64_t StackLimit,
|
||||
DiagnosticSeverity Severity = DS_Warning)
|
||||
: DiagnosticInfoResourceLimit(Fn, "stack frame size", StackSize,
|
||||
StackLimit, Severity, DK_StackSize) {}
|
||||
|
||||
uint64_t getStackSize() const { return getResourceSize(); }
|
||||
uint64_t getStackLimit() const { return getResourceLimit(); }
|
||||
|
|
|
@ -285,7 +285,7 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
|
|||
(void)Failed;
|
||||
}
|
||||
if (StackSize > Threshold) {
|
||||
DiagnosticInfoStackSize DiagStackSize(F, StackSize, DS_Warning, Threshold);
|
||||
DiagnosticInfoStackSize DiagStackSize(F, StackSize, Threshold, DS_Warning);
|
||||
F.getContext().diagnose(DiagStackSize);
|
||||
}
|
||||
ORE->emit([&]() {
|
||||
|
|
|
@ -70,10 +70,8 @@ void DiagnosticInfoInlineAsm::print(DiagnosticPrinter &DP) const {
|
|||
}
|
||||
|
||||
void DiagnosticInfoResourceLimit::print(DiagnosticPrinter &DP) const {
|
||||
DP << getResourceName() << " (" << getResourceSize() << ") exceeds limit";
|
||||
if (getResourceLimit() != 0)
|
||||
DP << " (" << getResourceLimit() << ')';
|
||||
DP << " in function '" << getFunction() << '\'';
|
||||
DP << getResourceName() << " (" << getResourceSize() << ") exceeds limit ("
|
||||
<< getResourceLimit() << ") in function '" << getFunction() << '\'';
|
||||
}
|
||||
|
||||
void DiagnosticInfoDebugMetadataVersion::print(DiagnosticPrinter &DP) const {
|
||||
|
|
|
@ -678,7 +678,8 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
|
|||
GCNSubtarget::MaxWaveScratchSize / STM.getWavefrontSize();
|
||||
if (ProgInfo.ScratchSize > MaxScratchPerWorkitem) {
|
||||
DiagnosticInfoStackSize DiagStackSize(MF.getFunction(),
|
||||
ProgInfo.ScratchSize, DS_Error);
|
||||
ProgInfo.ScratchSize,
|
||||
MaxScratchPerWorkitem, DS_Error);
|
||||
MF.getFunction().getContext().diagnose(DiagStackSize);
|
||||
}
|
||||
|
||||
|
@ -697,11 +698,9 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
|
|||
if (ProgInfo.NumSGPR > MaxAddressableNumSGPRs) {
|
||||
// This can happen due to a compiler bug or when using inline asm.
|
||||
LLVMContext &Ctx = MF.getFunction().getContext();
|
||||
DiagnosticInfoResourceLimit Diag(MF.getFunction(),
|
||||
"addressable scalar registers",
|
||||
ProgInfo.NumSGPR, DS_Error,
|
||||
DK_ResourceLimit,
|
||||
MaxAddressableNumSGPRs);
|
||||
DiagnosticInfoResourceLimit Diag(
|
||||
MF.getFunction(), "addressable scalar registers", ProgInfo.NumSGPR,
|
||||
MaxAddressableNumSGPRs, DS_Error, DK_ResourceLimit);
|
||||
Ctx.diagnose(Diag);
|
||||
ProgInfo.NumSGPR = MaxAddressableNumSGPRs - 1;
|
||||
}
|
||||
|
@ -745,11 +744,9 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
|
|||
// This can happen due to a compiler bug or when using inline asm to use
|
||||
// the registers which are usually reserved for vcc etc.
|
||||
LLVMContext &Ctx = MF.getFunction().getContext();
|
||||
DiagnosticInfoResourceLimit Diag(MF.getFunction(),
|
||||
"scalar registers",
|
||||
ProgInfo.NumSGPR, DS_Error,
|
||||
DK_ResourceLimit,
|
||||
MaxAddressableNumSGPRs);
|
||||
DiagnosticInfoResourceLimit Diag(MF.getFunction(), "scalar registers",
|
||||
ProgInfo.NumSGPR, MaxAddressableNumSGPRs,
|
||||
DS_Error, DK_ResourceLimit);
|
||||
Ctx.diagnose(Diag);
|
||||
ProgInfo.NumSGPR = MaxAddressableNumSGPRs;
|
||||
ProgInfo.NumSGPRsForWavesPerEU = MaxAddressableNumSGPRs;
|
||||
|
@ -766,14 +763,16 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
|
|||
if (MFI->getNumUserSGPRs() > STM.getMaxNumUserSGPRs()) {
|
||||
LLVMContext &Ctx = MF.getFunction().getContext();
|
||||
DiagnosticInfoResourceLimit Diag(MF.getFunction(), "user SGPRs",
|
||||
MFI->getNumUserSGPRs(), DS_Error);
|
||||
MFI->getNumUserSGPRs(),
|
||||
STM.getMaxNumUserSGPRs(), DS_Error);
|
||||
Ctx.diagnose(Diag);
|
||||
}
|
||||
|
||||
if (MFI->getLDSSize() > static_cast<unsigned>(STM.getLocalMemorySize())) {
|
||||
LLVMContext &Ctx = MF.getFunction().getContext();
|
||||
DiagnosticInfoResourceLimit Diag(MF.getFunction(), "local memory",
|
||||
MFI->getLDSSize(), DS_Error);
|
||||
MFI->getLDSSize(),
|
||||
STM.getLocalMemorySize(), DS_Error);
|
||||
Ctx.diagnose(Diag);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
declare void @llvm.memset.p5i8.i32(i8 addrspace(5)* nocapture, i8, i32, i32, i1) #1
|
||||
|
||||
; ERROR: error: stack frame size (131061) exceeds limit in function 'stack_size_limit_wave64'
|
||||
; ERROR: error: stack frame size (131061) exceeds limit (131056) 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 frame size (262117) exceeds limit in function 'stack_size_limit_wave32'
|
||||
; ERROR: error: stack frame size (262117) exceeds limit (262112) in function 'stack_size_limit_wave32'
|
||||
; GCN: ; ScratchSize: 262117
|
||||
define amdgpu_kernel void @stack_size_limit_wave32() #1 {
|
||||
entry:
|
||||
|
|
Loading…
Reference in New Issue