mirror of
				https://github.com/intel/intel-graphics-compiler.git
				synced 2025-10-30 08:18:26 +08:00 
			
		
		
		
	Adding hasVLA attribute
If a function contains dynamic alloca then ModuleAllocaAnalysis pass adds 'hasVLA' attribute.
This commit is contained in:
		 Rybalov, Viacheslav G
					Rybalov, Viacheslav G
				
			
				
					committed by
					
						 igcbot
						igcbot
					
				
			
			
				
	
			
			
			 igcbot
						igcbot
					
				
			
						parent
						
							a9cd884f4c
						
					
				
				
					commit
					0120924892
				
			| @ -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; | ||||
|  | ||||
							
								
								
									
										28
									
								
								IGC/Compiler/tests/ModuleAllocaAnalysis/dynamic_alloca.ll
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								IGC/Compiler/tests/ModuleAllocaAnalysis/dynamic_alloca.ll
									
									
									
									
									
										Normal 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 = !{} | ||||
		Reference in New Issue
	
	Block a user