diff --git a/clang/include/clang/Basic/BuiltinsRISCV.def b/clang/include/clang/Basic/BuiltinsRISCV.def index 18a10444b6b8..35042db78043 100644 --- a/clang/include/clang/Basic/BuiltinsRISCV.def +++ b/clang/include/clang/Basic/BuiltinsRISCV.def @@ -20,7 +20,7 @@ //===----------------------------------------------------------------------===// // Barrier function builtins -TARGET_BUILTIN(barrier, "vi", "n", "32bit") +TARGET_BUILTIN(barrier, "vi.", "n", "32bit") TARGET_BUILTIN(work_group_barrier, "vi.", "n", "32bit") // WORKAROUND: Disabled for now. /* diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 4760c5dcdba8..d9595d8e7ca6 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19491,8 +19491,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID, // Ventus GPGPU workitem case RISCV::BIbarrier: - ID = Intrinsic::riscv_ventus_barrier; - break; case RISCV::BIwork_group_barrier: { unsigned NumArgs = E->getNumArgs(); switch (NumArgs) { diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h index 288bb18bc654..a84b36b1cb38 100644 --- a/clang/lib/Headers/opencl-c.h +++ b/clang/lib/Headers/opencl-c.h @@ -12397,6 +12397,7 @@ void __ovld vstorea_half16_rtn(double16, size_t, __private half *); */ void __ovld __conv barrier(cl_mem_fence_flags); +void __ovld __conv barrier(cl_mem_fence_flags, memory_scope); #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) void __ovld __conv work_group_barrier(cl_mem_fence_flags, memory_scope); diff --git a/clang/test/CodeGenOpenCL/barrier.cl b/clang/test/CodeGenOpenCL/barrier.cl new file mode 100644 index 000000000000..b7584551902b --- /dev/null +++ b/clang/test/CodeGenOpenCL/barrier.cl @@ -0,0 +1,12 @@ +// RUN: clang -no-opaque-pointers -triple riscv32-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s + +void test() { + // CHECK: call void @llvm.riscv.ventus.barrier(i32 1) + // CHECK-NEXT: call void @llvm.riscv.ventus.barrier.with.scope(i32 1, i32 2) + // CHECK-NEXT: call void @llvm.riscv.ventus.barrier(i32 1) + // CHECK-NEXT: call void @llvm.riscv.ventus.barrier.with.scope(i32 1, i32 2) + barrier(1); + barrier(1, 2); + work_group_barrier(1); + work_group_barrier(1, 2); +} \ No newline at end of file