From: Andreas Beckmann Date: Tue, 15 Mar 2022 14:59:08 +0000 (+0100) Subject: [PATCH 40/42] support overriding the runtime cpu detection with POCL_LLVM_CPU_NAME X-Git-Tag: archive/raspbian/4.0-3+rpi1^2~10 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=21c9eba46ae39dcedadb7151eb64252604deabd2;p=pocl.git [PATCH 40/42] support overriding the runtime cpu detection with POCL_LLVM_CPU_NAME Gbp-Pq: Name 0040-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 df79e27..61cd41e 100644 --- a/lib/CL/pocl_llvm_utils.cc +++ b/lib/CL/pocl_llvm_utils.cc @@ -136,7 +136,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()) @@ -146,7 +147,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