3
我正在里面http://llvm.org/demo下面的代码片段:LLVM属性::非展开
class X { public: ~X() __attribute((nothrow)); };
void a(X* p);
void nothr() throw();
void b() { try { X x; a(&x); } catch (X* foo) { nothr(); } }
我看到了一些电话,(例如,以func_llvm_eh_typeid_for)有属性::非展开集:
CallInst* int32_71 = CallInst::Create(func_llvm_eh_typeid_for, const_ptr_43, "", label_49);
int32_71->setCallingConv(CallingConv::C);
int32_71->setTailCall(false);
AttrListPtr int32_71_PAL;
{
SmallVector<AttributeWithIndex, 4> Attrs;
AttributeWithIndex PAWI;
PAWI.Index = 4294967295U; PAWI.Attrs = 0 | Attribute::NoUnwind;
Attrs.push_back(PAWI);
int32_71_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
}
int32_71->setAttributes(int32_71_PAL);
由于这个调用是用CallInst而不是InvokeInst创建的,我认为调用本身不能抛出,所以它让我想知道在这种情况下Unwind属性的目的是什么?
CallInst而不是InvokeInst并不意味着该调用不能放松。 InvokeInst意味着该函数或由其动态调用的函数可以执行'unwind'指令并分支到'invoke'指定的其中一个标签。一个异常仍然可以通过'CallInst'解决整个调用的堆栈问题(例如,C++函数可能会抛出一个C++异常并通过LLVM函数展开堆栈以降低帧数,其他语言也可能会抛出与安腾ABI兼容的异常) 。 –
hi Johannes;仍然不确定将名词wind属性设置为一个调用点有什么好处 – lurscher