koffie drinker via llvm-dev
2016-Jan-21 14:21 UTC
[llvm-dev] Propagation of foreign c++ exceptions (msvc, x64, llvm 3.7.1, MCJIT) through IR code
Hi all, I have the following code: [use llvm to generate ir_func() ] in side the ir_func() there's a call to a native cpp function that throws an exception. (Just imagine changing the fibonacci example and calling a native c++ func that throws inside the fibonacci body) I can't seem to catch "foreign" exception or any exception using the following pseudo code: try { // cast function ptr and execute ir_func(); } catch (const myEx&) { } catch (...) { } Looking at: *LLVM_ENABLE_EH:BOOL*Build LLVM with exception-handling support. This is necessary if you wish to link against LLVM libraries and make use of C++ exceptions in your own code that need to propagate through LLVM code. Defaults to OFF. It seems to be exactly what I require. I enabled LLVM_ENABLE_EH and LLVM_ENABLE_RTTI but it doesn't seems to work. I also tested it with /EHs /EHsc in msvc. It makes no difference I also looked at the ExceptionDemo.cpp, but it seems to be unsupported under windows. Do I need to try catch and retrhow in my ir_func() ? Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160121/ccc8473f/attachment.html>
Reid Kleckner via llvm-dev
2016-Jan-21 18:15 UTC
[llvm-dev] Propagation of foreign c++ exceptions (msvc, x64, llvm 3.7.1, MCJIT) through IR code
This sounds like https://llvm.org/bugs/show_bug.cgi?id=24233. On Thu, Jan 21, 2016 at 6:21 AM, koffie drinker via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi all, > > I have the following code: > > [use llvm to generate ir_func() ] > > in side the ir_func() there's a call to a native cpp function that throws > an exception. > (Just imagine changing the fibonacci example and calling a native c++ func > that throws inside the fibonacci body) > > I can't seem to catch "foreign" exception or any exception using the > following pseudo code: > > try { > // cast function ptr and execute > ir_func(); > } catch (const myEx&) { > } catch (...) { > } > > Looking at: > *LLVM_ENABLE_EH:BOOL*Build LLVM with exception-handling support. This is > necessary if you wish to link against LLVM libraries and make use of C++ > exceptions in your own code that need to propagate through LLVM code. > Defaults to OFF. > It seems to be exactly what I require. > > I enabled LLVM_ENABLE_EH and LLVM_ENABLE_RTTI but it doesn't seems to > work. > I also tested it with /EHs /EHsc in msvc. It makes no difference > > I also looked at the ExceptionDemo.cpp, but it seems to be unsupported > under windows. Do I need to try catch and retrhow in my ir_func() ? > > Regards, > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160121/c4710213/attachment.html>
koffie drinker via llvm-dev
2016-Jan-22 12:38 UTC
[llvm-dev] Propagation of foreign c++ exceptions (msvc, x64, llvm 3.7.1, MCJIT) through IR code
I remembered it working on an older prototype version that I used. I've checked the old version (it also uses mcjit, llvm 3.5 or 3.6, x64) and found the following: try { engine->runFunction(func, args); *// exception is caught * auto f = (double (*)())engine->getPointerToFunction(func); auto d = f(); *// exception is not caught* } catch (const MyEx& e) { std::cout << " eval exp handler " << std::endl; } catch (...) { std::cout << " unknown exp handler " << std::endl; } If you use the runFunction(), the exception does not get lost. If you cast it and run the func ptr, the exception gets thrown but the exception is not caught. For me I could make runFunction to work with my case, but whats the difference? On Thu, Jan 21, 2016 at 7:15 PM, Reid Kleckner <rnk at google.com> wrote:> This sounds like https://llvm.org/bugs/show_bug.cgi?id=24233. > > On Thu, Jan 21, 2016 at 6:21 AM, koffie drinker via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi all, >> >> I have the following code: >> >> [use llvm to generate ir_func() ] >> >> in side the ir_func() there's a call to a native cpp function that throws >> an exception. >> (Just imagine changing the fibonacci example and calling a native c++ >> func that throws inside the fibonacci body) >> >> I can't seem to catch "foreign" exception or any exception using the >> following pseudo code: >> >> try { >> // cast function ptr and execute >> ir_func(); >> } catch (const myEx&) { >> } catch (...) { >> } >> >> Looking at: >> *LLVM_ENABLE_EH:BOOL*Build LLVM with exception-handling support. This is >> necessary if you wish to link against LLVM libraries and make use of C++ >> exceptions in your own code that need to propagate through LLVM code. >> Defaults to OFF. >> It seems to be exactly what I require. >> >> I enabled LLVM_ENABLE_EH and LLVM_ENABLE_RTTI but it doesn't seems to >> work. >> I also tested it with /EHs /EHsc in msvc. It makes no difference >> >> I also looked at the ExceptionDemo.cpp, but it seems to be unsupported >> under windows. Do I need to try catch and retrhow in my ir_func() ? >> >> Regards, >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160122/f47d4c8e/attachment.html>