Adding hasVLA attribute

If a function contains dynamic alloca
then ModuleAllocaAnalysis pass adds 'hasVLA' attribute.
This commit is contained in:
Rybalov, Viacheslav G
2025-10-17 14:39:46 +00:00
committed by igcbot
parent a9cd884f4c
commit 0120924892
2 changed files with 29 additions and 0 deletions

View File

@ -507,6 +507,7 @@ void ModuleAllocaAnalysis::FunctionAllocaInfo::AssignAlloca(llvm::AllocaInst *AI
bool SupportsUniformPrivateMemory) {
// Dynamic allocas are handled by stack-related instructions
if (!isa<ConstantInt>(AI->getArraySize())) {
AI->getParent()->getParent()->addFnAttr("hasVLA");
return;
}
bool isUniform = AI->getMetadata("uniform") != nullptr;

View File

@ -0,0 +1,28 @@
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2025 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
; REQUIRES: llvm-14-plus
;
; RUN: igc_opt --opaque-pointers --igc-module-alloca-info -S < %s 2>&1 | FileCheck %s
; ------------------------------------------------
; ModuleAllocaAnalysis
; ------------------------------------------------
;
; CHECK: define void @test_dynamic_alloca(i64 %size, i64 %index) #0
; CHECK: attributes #0 = { "hasVLA" }
define void @test_dynamic_alloca(i64 %size, i64 %index) {
entry:
%alloc_var = alloca i32, i64 %size, align 4
%0 = getelementptr inbounds i32, ptr %alloc_var, i64 %index
%1 = load i32, ptr %0, align 4
call void @use.i32(i32 %1)
ret void
}
declare void @use.i32(i32)
!igc.functions = !{}