[llvm] r318189 - AMDGPU: Error on stack size overflow
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 12:33:14 PST 2017
Author: arsenm
Date: Tue Nov 14 12:33:14 2017
New Revision: 318189
URL: http://llvm.org/viewvc/llvm-project?rev=318189&view=rev
Log:
AMDGPU: Error on stack size overflow
Added:
llvm/trunk/test/CodeGen/AMDGPU/stack-size-overflow.ll
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp?rev=318189&r1=318188&r2=318189&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp Tue Nov 14 12:33:14 2017
@@ -262,7 +262,7 @@ void AMDGPUAsmPrinter::readPALMetadata(M
void AMDGPUAsmPrinter::emitCommonFunctionComments(
uint32_t NumVGPR,
uint32_t NumSGPR,
- uint32_t ScratchSize,
+ uint64_t ScratchSize,
uint64_t CodeSize) {
OutStreamer->emitRawComment(" codeLenInByte = " + Twine(CodeSize), false);
OutStreamer->emitRawComment(" NumSgprs: " + Twine(NumSGPR), false);
@@ -600,7 +600,7 @@ AMDGPUAsmPrinter::SIFunctionResourceInfo
int32_t MaxVGPR = -1;
int32_t MaxSGPR = -1;
- uint32_t CalleeFrameSize = 0;
+ uint64_t CalleeFrameSize = 0;
for (const MachineBasicBlock &MBB : MF) {
for (const MachineInstr &MI : MBB) {
@@ -718,7 +718,7 @@ AMDGPUAsmPrinter::SIFunctionResourceInfo
MaxSGPR = std::max(MaxSGPR, MaxSGPRGuess);
MaxVGPR = std::max(MaxVGPR, 23);
- CalleeFrameSize = std::max(CalleeFrameSize, 16384u);
+ CalleeFrameSize = std::max(CalleeFrameSize, UINT64_C(16384));
Info.UsesVCC = true;
Info.UsesFlatScratch = ST.hasFlatAddressSpace();
Info.HasDynamicallySizedStack = true;
@@ -763,6 +763,12 @@ void AMDGPUAsmPrinter::getSIProgramInfo(
ProgInfo.FlatUsed = Info.UsesFlatScratch;
ProgInfo.DynamicCallStack = Info.HasDynamicallySizedStack || Info.HasRecursion;
+ if (!isUInt<32>(ProgInfo.ScratchSize)) {
+ DiagnosticInfoStackSize DiagStackSize(*MF.getFunction(),
+ ProgInfo.ScratchSize, DS_Error);
+ MF.getFunction()->getContext().diagnose(DiagStackSize);
+ }
+
const SISubtarget &STM = MF.getSubtarget<SISubtarget>();
const SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
const SIInstrInfo *TII = STM.getInstrInfo();
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h?rev=318189&r1=318188&r2=318189&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h Tue Nov 14 12:33:14 2017
@@ -41,7 +41,7 @@ private:
// the end are tracked separately.
int32_t NumVGPR = 0;
int32_t NumExplicitSGPR = 0;
- uint32_t PrivateSegmentSize = 0;
+ uint64_t PrivateSegmentSize = 0;
bool UsesVCC = false;
bool UsesFlatScratch = false;
bool HasDynamicallySizedStack = false;
@@ -61,7 +61,7 @@ private:
uint32_t DX10Clamp = 0;
uint32_t DebugMode = 0;
uint32_t IEEEMode = 0;
- uint32_t ScratchSize = 0;
+ uint64_t ScratchSize = 0;
uint64_t ComputePGMRSrc1 = 0;
@@ -144,7 +144,7 @@ private:
const SIProgramInfo &KernelInfo);
void emitCommonFunctionComments(uint32_t NumVGPR,
uint32_t NumSGPR,
- uint32_t ScratchSize,
+ uint64_t ScratchSize,
uint64_t CodeSize);
public:
Added: llvm/trunk/test/CodeGen/AMDGPU/stack-size-overflow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/stack-size-overflow.ll?rev=318189&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/stack-size-overflow.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/stack-size-overflow.ll Tue Nov 14 12:33:14 2017
@@ -0,0 +1,14 @@
+; RUN: not llc -march=amdgcn < %s 2>&1 | FileCheck -check-prefix=ERROR %s
+; RUN: not llc -march=amdgcn < %s | FileCheck -check-prefix=GCN %s
+
+declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) #1
+
+; ERROR: error: stack size limit exceeded (4294967296) in stack_size_limit
+; GCN: ; ScratchSize: 4294967296
+define amdgpu_kernel void @stack_size_limit() #0 {
+entry:
+ %alloca = alloca [1073741823 x i32], align 4
+ %bc = bitcast [1073741823 x i32]* %alloca to i8*
+ call void @llvm.memset.p0i8.i32(i8* %bc, i8 9, i32 1073741823, i32 1, i1 true)
+ ret void
+}
More information about the llvm-commits
mailing list