[LLVMdev] Set up ExecutionEngine according to actual machine capabilities
Benjamin Kramer
benny.kra at gmail.com
Mon May 11 02:23:38 PDT 2015
On Mon, May 11, 2015 at 10:59 AM, Mueller-Roemer, Johannes Sebastian
<Johannes.Sebastian.Mueller-Roemer at igd.fraunhofer.de> wrote:
> I am currently setting up my Module with
>
>
>
> module->setTargetTriple(llvm::sys::getProcessTriple()
>
> #ifdef _WIN32
>
> + "-elf"
>
> #endif
>
> );
>
>
>
> And my ExecutionEngine with
>
>
>
> llvm::EngineBuilder(std::move(module))
>
> .setErrorStr(&err)
>
>
> .setMCPU(llvm::sys::getHostCPUName())
>
> .create()
>
>
>
> This works fine on most machines, however on some virtualized machines this
> fails because the host CPU name implies AVX, however AVX is in fact
> disabled, leading to an illegal instruction when running JIT-compiled
> functions.
>
>
>
> Is there a better way to set up the executionengine so that such failure do
> not occur (but all available features are used)?
The proper way to do this in LLVM trunk is to use
sys::getHostCPUFeatures instead of the name and set the individual
feature bits via setMAttrs. getHostCPUName used to be aware of
AVX-disabled environments but that was a bit of a hack and was removed
recently.
- Ben
More information about the llvm-dev
mailing list