在代码生成期间如何将快速数学标志添加到 LLVM C++ API 中?

How are fast-math flags added int the LLVM C++ API during code generation?

我有一个构建操作的构建器:

return BuilderBinop.CreateFMul(L, R, "multmp");

这会生成

%multmp23 = fmul float %d22, %e21

现在我想为此添加快速数学标记。具体来说,我想添加 fast 标志。我该怎么做?

FastMathFlags fmf;
fmf.setFast(true);
BuilderBinop.setFastMathFlags(fmf);

FastMathFlags class 具有设置标志的辅助方法。由于这里的兴趣是将 fast 标志设置为 true,因此 .setFast() 派上用场。

要清除标志,可以使用 .clear()