使用 LLVM 3.4,我创建了一个具有属性的函数:attributes #0 = { nounwind uwtable }
.看起来还不错,但是 clang++ 在同一个函数中写入了更多信息:attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "ssp-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
如何将此信息添加到属性中? llc -march=cpp
没有给出答案。
一些谷歌搜索将我带到 llvm::TargetOptions
,但是如何处理这个类,它并没有告诉。多可惜。
LLVM 3.4,Ubuntu 13.04 x64
最佳答案
这些是依赖于目标的属性。您可以以与创建与目标无关的方法非常相似的方式创建它们,例如通过 Attribute::get(context, "less-precise-fpmad", "false")
.完整的图片是这样的:
LLVMContext c = ...
Function* f = ...
Attribute attr = Attribute::get(c, "less-precise-fpmad", "false");
f.addAttributes(0, AttributeSet::get(c, AttributeSet::FunctionIndex, attr));
关于ubuntu - LLVM。添加函数属性信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17809974/