Skip to content

[hwasan] Don't crash on vscale allocas #90932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down