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.0-6+rpi1~1^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a8586d4b5d0705b9bd2a7c5dc5bb1061d4df256b;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 018bbb3..6ab5792 100644 --- a/lib/CL/pocl_llvm_utils.cc +++ b/lib/CL/pocl_llvm_utils.cc @@ -122,7 +122,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()) @@ -132,7 +133,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