From: Andreas Beckmann Date: Tue, 15 Mar 2022 14:59:08 +0000 (+0100) Subject: [PATCH 1017/1017] support overriding the runtime cpu detection with POCL_LLVM_CPU_NAME X-Git-Tag: archive/raspbian/3.1-2+rpi1^2~9 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b1ab4590217b45908f686f71f329280c9d64fb64;p=pocl.git [PATCH 1017/1017] support overriding the runtime cpu detection with POCL_LLVM_CPU_NAME Gbp-Pq: Name 1017-support-overriding-the-runtime-cpu-detection-with-PO.patch --- diff --git a/lib/CL/pocl_llvm_utils.cc b/lib/CL/pocl_llvm_utils.cc index 56abfb0..d69c27e 100644 --- a/lib/CL/pocl_llvm_utils.cc +++ b/lib/CL/pocl_llvm_utils.cc @@ -126,7 +126,8 @@ static int getModuleTriple(const char *input_stream, size_t size, } char *pocl_get_llvm_cpu_name() { - StringRef r = llvm::sys::getHostCPUName(); + const char *custom = pocl_get_string_option("POCL_LLVM_CPU_NAME", NULL); + StringRef r = custom ? StringRef(custom) : llvm::sys::getHostCPUName(); // LLVM may return an empty string -- treat as generic if (r.empty()) @@ -136,7 +137,7 @@ char *pocl_get_llvm_cpu_name() { if (r.str() == "generic" && strlen(OCL_KERNEL_TARGET_CPU)) { POCL_MSG_WARN("LLVM does not recognize your cpu, trying to use " OCL_KERNEL_TARGET_CPU " for -target-cpu\n"); - r = llvm::StringRef(OCL_KERNEL_TARGET_CPU); + r = StringRef(OCL_KERNEL_TARGET_CPU); } #endif