Skip to content

Commit

Permalink
[SOL] Error out when a function access an invalid offset
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Jul 9, 2024
1 parent 8bc30e8 commit 5528bc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/SBF/SBFRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL)
<< -MaxOffset << " by " << MaxOffset - Offset
<< " bytes, please minimize large stack variables. "
<< "Estimated function frame size: " << StackSize << " bytes.\n\n";
report_fatal_error("Exceeding the maximum stack offset may cause "
"undefined behavior, including the loss of funds.");
} else {
DiagnosticInfoUnsupported DiagStackSize(
MF.getFunction(),
Expand Down
5 changes: 3 additions & 2 deletions llvm/test/CodeGen/SBF/warn-stack.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llc -march=sbf < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not --crash llc -march=sbf < %s 2>&1 >/dev/null | FileCheck %s

define void @nowarn() local_unnamed_addr #0 !dbg !6 {
%1 = alloca [4096 x i8], align 1
Expand All @@ -22,7 +22,8 @@ declare void @doit(i8*) local_unnamed_addr #3
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1

; CHECK: Error: warn_stack.c
; CHECK: please minimize large stack variables
; CHECK: please minimize large stack variables
; CHECK: Exceeding the maximum stack offset may cause undefined behavior, including the loss of funds.
define void @warn() local_unnamed_addr #0 !dbg !20 {
%1 = alloca [512 x i8], align 1
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0, !dbg !26
Expand Down

0 comments on commit 5528bc2

Please sign in to comment.