Skip to content

Commit 4a139c8

Browse files
stefan-iligcbot
authored andcommitted
Fix MergeAllocas pass not respecting optnone attribute
MergeAllocas pass now correctly skips functions with optnone attribute.
1 parent a6ae559 commit 4a139c8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

IGC/AdaptorCommon/RayTracing/MergeAllocas.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ void MergeAllocas::getAnalysisUsage(llvm::AnalysisUsage& AU) const
332332

333333
bool MergeAllocas::runOnFunction(Function& F)
334334
{
335+
if (F.hasOptNone()){
336+
return false;
337+
}
338+
335339
auto ABLA = getAnalysis<AllocationBasedLivenessAnalysis>().getLivenessInfo();
336340

337341
// we group the allocations by type, then sort them into buckets with nonoverlapping liveranges
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2025 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
; RUN: igc_opt --igc-merge-allocas -S %s --platformpvc | FileCheck %s
9+
; ------------------------------------------------
10+
; MergeAllocas
11+
; ------------------------------------------------
12+
13+
; Check that allocas are not merged if optnone attribute is set
14+
; Function Attrs: noinline optnone
15+
define spir_kernel void @_ZTS43Kernel_NoReusePrivMem_SameFunc_AlwaysInline() #0 {
16+
; CHECK-LABEL: _ZTS43Kernel_NoReusePrivMem_SameFunc_AlwaysInline
17+
; CHECK-NEXT: alloca [128 x float], i32 0, align 4
18+
; CHECK-NEXT: alloca [128 x float], i32 0, align 4
19+
%1 = alloca [128 x float], i32 0, align 4
20+
%2 = alloca [128 x float], i32 0, align 4
21+
ret void
22+
}
23+
24+
attributes #0 = { noinline optnone }

0 commit comments

Comments
 (0)