llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangir Author: Arseniy Obolenskiy (aobolensk) <details> <summary>Changes</summary> Use an address space cast instead of a bitcast, which failed CIR verification --- Full diff: https://github.com/llvm/llvm-project/pull/233724.diff 2 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+3-2) - (modified) clang/test/CIR/CodeGenBuiltins/builtins.cpp (+14) ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp index a94139cff20ff..160578037066c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp @@ -2538,8 +2538,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, mlir::Value addr = cir::FrameAddrOp::create( builder, loc, allocaInt8PtrTy, builder.getConstAPInt(loc, builder.getUInt32Ty(), level)); - return RValue::get( - builder.createCast(loc, cir::CastKind::bitcast, addr, voidPtrTy)); + addr = builder.createBitcast( + addr, builder.getVoidPtrTy(getCIRAllocaAddressSpace())); + return RValue::get(performAddrSpaceCast(addr, convertType(e->getType()))); } case Builtin::BI__builtin_extract_return_addr: case Builtin::BI__builtin_frob_return_addr: diff --git a/clang/test/CIR/CodeGenBuiltins/builtins.cpp b/clang/test/CIR/CodeGenBuiltins/builtins.cpp index 920f0696dba2d..8e4be00faaba0 100644 --- a/clang/test/CIR/CodeGenBuiltins/builtins.cpp +++ b/clang/test/CIR/CodeGenBuiltins/builtins.cpp @@ -4,6 +4,10 @@ // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -Wno-unused-value -fclangir -emit-cir %s -o %t-amdgpu.cir +// RUN: FileCheck --input-file=%t-amdgpu.cir %s -check-prefix=CIR-AMDGPU +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -Wno-unused-value -fclangir -emit-llvm %s -o %t-amdgpu.ll +// RUN: FileCheck --input-file=%t-amdgpu.ll %s -check-prefix=LLVM-AMDGPU double fabs(double x) { return __builtin_fabs(x); @@ -35,4 +39,14 @@ extern "C" void *test_frame_address(void) { // LLVM-LABEL: @test_frame_address // LLVM: {{%.*}} = call ptr @llvm.frameaddress.p0(i32 1) + // CIR-AMDGPU-LABEL: test_frame_address + // CIR-AMDGPU: [[ARG:%.*]] = cir.const #cir.int<1> : !u32i + // CIR-AMDGPU: %[[ADDR:.*]] = cir.frame_address([[ARG]]) : !cir.ptr<!u8i, target_address_space(5)> + // CIR-AMDGPU: %[[CAST:.*]] = cir.cast bitcast %[[ADDR]] : !cir.ptr<!u8i, target_address_space(5)> -> !cir.ptr<!void, target_address_space(5)> + // CIR-AMDGPU: {{%.*}} = cir.cast address_space %[[CAST]] : !cir.ptr<!void, target_address_space(5)> -> !cir.ptr<!void> + + // LLVM-AMDGPU-LABEL: @test_frame_address + // LLVM-AMDGPU: %[[ADDR:.*]] = call ptr addrspace(5) @llvm.frameaddress.p5(i32 1) + // LLVM-AMDGPU: {{%.*}} = addrspacecast ptr addrspace(5) %[[ADDR]] to ptr + } `````````` </details> https://github.com/llvm/llvm-project/pull/233724 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
