开发者

llvm Attribute::NoUnwind

i'm running inside http://llvm.org/demo the following snippet:

class X { public: ~X() __attribute((nothrow)); };
void a(X* p);
void nothr() throw();
void b() { try { X x; a(&x); } catch (X* foo) { nothr(); } }

I see that some of the calls, (for instance, to func_llvm_eh_typeid_for) have the Attribute::NoUnwind set:

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&g开发者_运维百科t; 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);

Since this calls are created with CallInst rather than InvokeInst, i presume the call themselves cannot throw, so it makes me wonder whats the purpose of the Unwind attribute in this context?


It means that you don't have to worry about generating exception handling code or optimizing as if an exception could propagate through that section of code since you've already said it doesn't. If one happens to come through there then it should propagate correctly through to the next stack frame in your program.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜