mirror of
				https://github.com/intel/intel-graphics-compiler.git
				synced 2025-10-30 08:18:26 +08:00 
			
		
		
		
	handle bitcasted opaque ptrs instead of skipping them in SOALayoutChecker
When the `SOALayoutChecker::visitBitCastInst()` encountered a ptr bitcast on opaque pointers, we just used to skip it. With this change, we checks users of the bitcast, like it's done on typed pointers (just without ptr type checks). Such bitcasted ptr `%p` would be skipped without properly handling it. ```llvm %arr = alloca [32 x float], align 4 %p = bitcast ptr %arr to ptr ``` ---------------------------
This commit is contained in:
		 Zwolak, Karol Marcin
					Zwolak, Karol Marcin
				
			
				
					committed by
					
						 igcbot
						igcbot
					
				
			
			
				
	
			
			
			 igcbot
						igcbot
					
				
			
						parent
						
							6da778b285
						
					
				
				
					commit
					7308ad7501
				
			| @ -517,10 +517,13 @@ bool SOALayoutChecker::checkUsers(Instruction &I) { | ||||
| } | ||||
|  | ||||
| bool SOALayoutChecker::visitBitCastInst(BitCastInst &BI) { | ||||
|   // no sense in comparing pointer base types on opaque pointers | ||||
|   if (BI.use_empty() || IsBitCastForLifetimeMark(&BI) || AreOpaquePointersEnabled()) { | ||||
|   if (BI.use_empty() || IsBitCastForLifetimeMark(&BI)) { | ||||
|     return true; | ||||
|   } | ||||
|   // no sense in comparing pointer base types on opaque pointers, just check users | ||||
|   if (AreOpaquePointersEnabled()) { | ||||
|     return checkUsers(BI); | ||||
|   } | ||||
|   // FIXME: remove this once we only support opaque pointers | ||||
|   Type *baseT = GetBaseType(IGCLLVM::getNonOpaquePtrEltTy(BI.getType()), true); | ||||
|   Type *sourceType = GetBaseType(IGCLLVM::getNonOpaquePtrEltTy(BI.getOperand(0)->getType()), true); | ||||
|  | ||||
| @ -0,0 +1,27 @@ | ||||
| ;=========================== begin_copyright_notice ============================ | ||||
| ; | ||||
| ; Copyright (C) 2025 Intel Corporation | ||||
| ; | ||||
| ; SPDX-License-Identifier: MIT | ||||
| ; | ||||
| ;============================ end_copyright_notice ============================= | ||||
| ; | ||||
| ; REQUIRES: regkeys,llvm-16-plus | ||||
| ; RUN: igc_opt --opaque-pointers -igc-priv-mem-to-reg --regkey EnableOpaquePointersBackend=1 -S %s 2>&1 | ||||
|  | ||||
| ; Make sure we correctly handle the ptr bitcast on opaque pointers and the compilation suceedees. | ||||
|  | ||||
| define spir_kernel void @test() { | ||||
|   %arr = alloca [32 x float], align 4 | ||||
|   %p = bitcast ptr %arr to ptr | ||||
|   call spir_func void @foo(ptr %p) | ||||
|   ret void | ||||
| } | ||||
|  | ||||
| declare spir_func void @foo(ptr) | ||||
|  | ||||
| !igc.functions = !{!0} | ||||
|  | ||||
| !0 = !{ptr @test, !1} | ||||
| !1 = !{!2} | ||||
| !2 = !{!"function_type", i32 0} | ||||
		Reference in New Issue
	
	Block a user