From da9feae7355c15d489b916340ea2b62f9f8c0a7c Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Sat, 23 Jul 2022 08:45:55 +0300 Subject: [PATCH] gallivm: push LLVM version guard into assert The asserts that check the pointer element type can't be used on LLVM >= 15. Instead of using precompiler #if, use boolean shortcut in assert. Reviewed-by: Brian Paul Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_struct.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_struct.c b/src/gallium/auxiliary/gallivm/lp_bld_struct.c index 1007090..be579c4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_struct.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_struct.c @@ -51,11 +51,7 @@ lp_build_struct_get_ptr(struct gallivm_state *gallivm, LLVMValueRef indices[2]; LLVMValueRef member_ptr; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); - - /* Starting with LLVM 15, we're not supposed to look at pointer element type anymore. */ -#if LLVM_VERSION_MAJOR < 15 - assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); -#endif + assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); indices[0] = lp_build_const_int32(gallivm, 0); indices[1] = lp_build_const_int32(gallivm, member); @@ -73,9 +69,7 @@ lp_build_struct_get(struct gallivm_state *gallivm, LLVMValueRef member_ptr; LLVMValueRef res; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); -#if LLVM_VERSION_MAJOR < 15 - assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); -#endif + assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); member_ptr = lp_build_struct_get_ptr(gallivm, ptr, member, name); res = LLVMBuildLoad(gallivm->builder, member_ptr, ""); lp_build_name(res, "%s.%s", LLVMGetValueName(ptr), name); @@ -92,11 +86,7 @@ lp_build_struct_get_ptr2(struct gallivm_state *gallivm, LLVMValueRef indices[2]; LLVMValueRef member_ptr; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); - - /* Starting with LLVM 15, we're not supposed to look at pointer element type anymore. */ -#if LLVM_VERSION_MAJOR < 15 - assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); -#endif + assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); indices[0] = lp_build_const_int32(gallivm, 0); indices[1] = lp_build_const_int32(gallivm, member); @@ -115,9 +105,7 @@ lp_build_struct_get2(struct gallivm_state *gallivm, LLVMValueRef member_ptr; LLVMValueRef res; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); -#if LLVM_VERSION_MAJOR < 15 - assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); -#endif + assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); member_ptr = lp_build_struct_get_ptr2(gallivm, ptr_type, ptr, member, name); res = LLVMBuildLoad(gallivm->builder, member_ptr, ""); lp_build_name(res, "%s.%s", LLVMGetValueName(ptr), name); -- 2.7.4