mirror of
https://github.com/openbsd/src.git
synced 2026-06-17 23:03:29 +02:00
fir crashing with scalable TypeSizes
From 537f3d3a7588d226b86590f97c4401107585e1ce Mon Sep 17 00:00:00 2001 From: Jakob Koschel <jakobkoschel@google.com> Date: Thu, 5 Mar 2026 01:11:44 +0100 Subject: [PATCH] [SafeStack] Fix crashing with scalable TypeSizes (#180547) On e.g. aarch64 the TypeSize of scalar types can have a size that is not known at compile time. Currently when safestack occurs those it simply crashes as described in https://github.com/llvm/llvm-project/issues/175868.
This commit is contained in:
@@ -176,6 +176,8 @@ class SafeStack {
|
||||
|
||||
bool IsMemIntrinsicSafe(const MemIntrinsic *MI, const Use &U,
|
||||
const Value *AllocaPtr, uint64_t AllocaSize);
|
||||
bool IsAccessSafe(Value *Addr, TypeSize Size, const Value *AllocaPtr,
|
||||
uint64_t AllocaSize);
|
||||
bool IsAccessSafe(Value *Addr, uint64_t Size, const Value *AllocaPtr,
|
||||
uint64_t AllocaSize);
|
||||
|
||||
@@ -206,6 +208,16 @@ uint64_t SafeStack::getStaticAllocaAllocationSize(const AllocaInst* AI) {
|
||||
return Size;
|
||||
}
|
||||
|
||||
bool SafeStack::IsAccessSafe(Value *Addr, TypeSize AccessSize,
|
||||
const Value *AllocaPtr, uint64_t AllocaSize) {
|
||||
if (AccessSize.isScalable()) {
|
||||
// In case we don't know the size at compile time we cannot verify if the
|
||||
// access is safe.
|
||||
return false;
|
||||
}
|
||||
return IsAccessSafe(Addr, AccessSize.getFixedValue(), AllocaPtr, AllocaSize);
|
||||
}
|
||||
|
||||
bool SafeStack::IsAccessSafe(Value *Addr, uint64_t AccessSize,
|
||||
const Value *AllocaPtr, uint64_t AllocaSize) {
|
||||
const SCEV *AddrExpr = SE.getSCEV(Addr);
|
||||
|
||||
Reference in New Issue
Block a user