LLVM如何将Attributes :: NoUnwind设置为Function? [英] LLVM how to set Attributes::NoUnwind to Function?

查看:89
本文介绍了LLVM如何将Attributes :: NoUnwind设置为Function?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是一个非常简单的问题,但我无法解决.很伤心 所以.

I think this is very simple question, but I can't resolve it. Very sad. So. When I do

llc.exe -march=cpp test.bc 

我通过这段代码得到有趣的test.cpp:

I get interesting test.cpp with this piece of code:

AttrListPtr func__Z2f1i_PAL;
{
 SmallVector<AttributeWithIndex, 4> Attrs;
 AttributeWithIndex PAWI;
 PAWI.Index = 4294967295U; PAWI.Attrs = Attribute::None  | Attribute::NoUnwind;
 Attrs.push_back(PAWI);
 func__Z2f1i_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
}

但是当我想写PAWI.Attrs = Attribute::None | Attribute::NoUnwind;

在我的项目中,出现错误IntelliSense: no operator "=" matches these operands operand types are: llvm::Attributes = int我需要做什么? 包括所有必要的标题. [OS-Windows 7 x64,LLVM-3.2]

in my project, I got error IntelliSense: no operator "=" matches these operands operand types are: llvm::Attributes = int What I need to do? All necessary headers included. [OS - Windows 7 x64, LLVM - 3.2]

推荐答案

我不知道为什么cpp后端会生成此代码.无论如何,属性处理在3.2中已更改(并将在3.3中再次更改).在3.2中获取属性的正确方法应该是:

I don't know why the cpp backend generates this code. In any case attribute handing was changed in 3.2 (and will change again in 3.3). The proper way to get an attribute in 3.2 should be:

Attributes::get(Context, Attributes::NoUnwind)

(您始终可以在此处传递任何ArrayRef作为第二个参数,以初始化具有多个值的属性集).

(you can always pass any ArrayRef here as the second argument, to initialize the attribute set with multiple values).

向函数添加属性的最简单方法是:

The simplest way to add an attribute to a function would be:

Function->addFnAttr(Attributes::NoUnwind)

如果需要AttributeWithIndex:

AttributeWithIndex::get(Context, ID, Attributes::NoUnwind)
// OR:
AttributeWithIndex::get(ID, Attributes::get(Context, Attributes::NoUnwind))

这篇关于LLVM如何将Attributes :: NoUnwind设置为Function?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆