Re: JIT compiling with LLVM v11 - Mailing list pgsql-hackers

From Andres Freund
Subject Re: JIT compiling with LLVM v11
Date
Msg-id 20180308201209.miod2nwy5ivd4fxu@alap3.anarazel.de
Whole thread Raw
In response to Re: JIT compiling with LLVM v11  (Andres Freund <andres@anarazel.de>)
Responses Re: JIT compiling with LLVM v11  (Thomas Munro <thomas.munro@enterprisedb.com>)
List pgsql-hackers
On 2018-03-08 11:58:41 -0800, Andres Freund wrote:
> I think we can easily fix this by behaving like clang, which uses
> llvm::sys::getHostCPUFeatures(HostFeatures) to built the feature list:
> 
>   // If -march=native, autodetect the feature list.
>   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
>     if (StringRef(A->getValue()) == "native") {
>       llvm::StringMap<bool> HostFeatures;
>       if (llvm::sys::getHostCPUFeatures(HostFeatures))
>         for (auto &F : HostFeatures)
>           Features.push_back(
>               Args.MakeArgString((F.second ? "+" : "-") + F.first()));
>     }
>   }
> 
> which seems easy enough.

Or even in core LLVM, which has this nice comment:

  // If user asked for the 'native' CPU, we need to autodetect features.
  // This is necessary for x86 where the CPU might not support all the
  // features the autodetected CPU name lists in the target. For example,
  // not all Sandybridge processors support AVX.
  if (MCPU == "native") {

which pretty much describes the issue you're apparently hitting.

I've pushed an attempted fix (needs a comment, but works here).

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: JIT compiling with LLVM v11
Next
From: Andres Freund
Date:
Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE ofpartition key