From 202d308427a79fd8ac1e1ca6e4e092c576764392 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Fri, 16 Aug 2019 13:02:45 -0700 Subject: [PATCH] Prepare kernel calls lowering for upstream Change-Id: Ie01c49ac04575b9ce5b74d0169ed5ad9b3450acb --- lib/Target/AMDGPU/AMDGPULowerKernelCalls.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Target/AMDGPU/AMDGPULowerKernelCalls.cpp b/lib/Target/AMDGPU/AMDGPULowerKernelCalls.cpp index 061f6bb24d8e..73b7e9e7eaf2 100644 --- a/lib/Target/AMDGPU/AMDGPULowerKernelCalls.cpp +++ b/lib/Target/AMDGPU/AMDGPULowerKernelCalls.cpp @@ -1,15 +1,19 @@ -//===-- AMDGPULowerKernelCalls.cpp - Fix kernel-calling-kernel in HSAIL ------===// +//===-- AMDGPULowerKernelCalls.cpp - Fix kernel calls ---------------------===// // +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// // \file // // \brief replace calls to OpenCL kernels with equivalent non-kernel // functions // -// In OpenCL, a kernel may call another kernel as if it was a -// non-kernel function. But in HSAIL, such a call is not allowed. To -// fix this, we copy the body of kernel A into a new non-kernel -// function fA, if we encounter a call to A. All calls to A are then -// transferred to fA. +// In OpenCL, a kernel may call another kernel as if it was a non-kernel +// function. However, kernels and functions have different ABI. To fix this, +// we copy the body of kernel A into a new non-kernel function fA, if we +// encounter a call to A. All calls to A are then transferred to fA. // //===----------------------------------------------------------------------===// #include "AMDGPU.h" @@ -60,10 +64,6 @@ AMDGPULowerKernelCalls::AMDGPULowerKernelCalls() : ModulePass(ID) { static void setNameForBody(Function *FBody, const Function &FKernel) { StringRef Name = FKernel.getName(); - if (Name.startswith("__OpenCL_")) { - assert(Name.endswith("_kernel")); - Name = Name.slice(strlen("__OpenCL_"), Name.size() - strlen("_kernel")); - } SmallString<128> NewName("__amdgpu_"); NewName += Name; NewName += "_kernel_body";