LLVM exception throwing

♀尐吖头ヾ 提交于 2019-12-03 11:40:23

问题


I have read this blog post, this documentation page and this example, but I still don't understand how to throw a basic exception using the LLVM's IRBuilder for a non-C++ oriented language.

From my understanding, I have to :

  • Create a llvm::Value containing the throwed value.
  • Call "a function", passing it the throwed value. This function will not return.

The example is using a system rewinding function (_Unwind_RaiseException) in order to throw a C++ exception, and I don't really understand how to use my own raising function instead (since I only need to throw an object pointer). What am I missing ?


回答1:


Short answer is that _Unwind_RaiseException is not a C++-specific function. It comes from the libunwind library, and allows to throw any type of exception.

More details can be found on these blog posts.




回答2:


As you don't want to use existing C++ exception handling infrastructure, you'll need to replicate parts of it for your language.

You can use the implementation of C unwinder in compiler-rt (or significantly more complex one in libstdc++), and invocation of an unwinder in libstdc++ to start with.



来源:https://stackoverflow.com/questions/14824906/llvm-exception-throwing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!