[llvm] 70b5a22 - [hwasan] Don't crash on vscale allocas (#90932)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 3 00:17:00 PDT 2024
Author: Vitaly Buka
Date: 2024-05-03T00:16:57-07:00
New Revision: 70b5a22678cf38982086762b0b2ec02eb8f9dbc2
URL: https://github.com/llvm/llvm-project/commit/70b5a22678cf38982086762b0b2ec02eb8f9dbc2
DIFF: https://github.com/llvm/llvm-project/commit/70b5a22678cf38982086762b0b2ec02eb8f9dbc2.diff
LOG: [hwasan] Don't crash on vscale allocas (#90932)
getAllocaSizeInBytes will crash casting size to
constant.
Added:
Modified:
llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
index 0464ba5e181178..77b2c50b4413a4 100644
--- a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
+++ b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
@@ -180,6 +180,8 @@ void StackInfoBuilder::visit(Instruction &Inst) {
bool StackInfoBuilder::isInterestingAlloca(const AllocaInst &AI) {
return (AI.getAllocatedType()->isSized() &&
+ // FIXME: support vscale.
+ !AI.getAllocatedType()->isScalableTy() &&
// FIXME: instrument dynamic allocas, too
AI.isStaticAlloca() &&
// alloca() may be called with 0 size, ignore it.
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll b/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
index b671571992eee0..9b64c06ddd5556 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
@@ -110,6 +110,24 @@ entry:
ret void, !dbg !24
}
+define void @test_vscale_alloca() sanitize_hwaddress {
+; DYNAMIC-SHADOW-LABEL: define void @test_vscale_alloca(
+; DYNAMIC-SHADOW-SAME: ) #[[ATTR0]] {
+; DYNAMIC-SHADOW-NEXT: [[X:%.*]] = alloca <vscale x 4 x i64>, align 32
+; DYNAMIC-SHADOW-NEXT: call void @use32(ptr nonnull [[X]])
+; DYNAMIC-SHADOW-NEXT: ret void
+;
+; ZERO-BASED-SHADOW-LABEL: define void @test_vscale_alloca(
+; ZERO-BASED-SHADOW-SAME: ) #[[ATTR0]] {
+; ZERO-BASED-SHADOW-NEXT: [[X:%.*]] = alloca <vscale x 4 x i64>, align 32
+; ZERO-BASED-SHADOW-NEXT: call void @use32(ptr nonnull [[X]])
+; ZERO-BASED-SHADOW-NEXT: ret void
+;
+ %x = alloca <vscale x 4 x i64>
+ call void @use32(ptr nonnull %x)
+ ret void
+}
+
declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.dbg.cu = !{!0}
More information about the llvm-commits
mailing list