Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ExceptionDemo] Transition example from MCJIT to ORC and fix compiling errors #92504

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

epitavy
Copy link
Contributor

@epitavy epitavy commented May 17, 2024

This is a follow up on PR #69485 . I squashed all the previous commit of the PR.
In addition, this fixes an error in the log of the execution. The caught exception type was computed based on a pointer offset, which was in bytes instead of ptr size .
Fixes #63702

@epitavy
Copy link
Contributor Author

epitavy commented May 17, 2024

From the comments in the file we can read

// Demo program which implements an example LLVM exception implementation, and
// shows several test cases including the handling of foreign exceptions.
// It is run with type info types arguments to throw. A test will
// be run for each given type info type. While type info types with the value
// of -1 will trigger a foreign C++ exception to be thrown; type info types
// <= 6 and >= 1 will cause the associated generated exceptions to be thrown
// and caught by generated test functions; and type info types > 6
// will result in exceptions which pass through to the test harness. All other
// type info types are not supported and could cause a crash. In all cases,
// the "finally" blocks of every generated test functions will executed
// regardless of whether or not that test function ignores or catches the
// thrown exception.
//
// examples:
//
// ExceptionDemo
//
// causes a usage to be printed to stderr
//
// ExceptionDemo 2 3 7 -1
//
// results in the following cases:
// - Value 2 causes an exception with a type info type of 2 to be
// thrown and caught by an inner generated test function.
// - Value 3 causes an exception with a type info type of 3 to be
// thrown and caught by an outer generated test function.
// - Value 7 causes an exception with a type info type of 7 to be
// thrown and NOT be caught by any generated function.
// - Value -1 causes a foreign C++ exception to be thrown and not be
// caught by any generated function
//
// Cases -1 and 7 are caught by a C++ test harness where the validity of
// of a C++ catch(...) clause catching a generated exception with a
// type info type of 7 is explained by: example in rules 1.6.4 in
// http://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html (v1.22)

Here the result of the execution, which I think is correct.

./bin/ExceptionDemo 2 3 7 -1

Begin Test:

Gen: About to throw exception type <2> in throwFunct.
Gen: Exception type <2> received (stack unwound)  in innerCatchFunct.
Gen: Executing catch block typeInfo2 in innerCatchFunct
Gen: Executing finally block finally in innerCatchFunct
Gen: In end block: exiting in innerCatchFunct.
Gen: No exception in outerCatchFunct!
Gen: Executing finally block finally in outerCatchFunct
Gen: In end block: exiting in outerCatchFunct.

Gen: About to throw exception type <3> in throwFunct.
Gen: Exception type <3> received (stack unwound)  in innerCatchFunct.
Gen: Executing finally block finally in innerCatchFunct
Gen: Exception type <3> received (stack unwound)  in outerCatchFunct.
Gen: Executing catch block typeInfo3 in outerCatchFunct
Gen: Executing finally block finally in outerCatchFunct
Gen: In end block: exiting in outerCatchFunct.

Gen: About to throw exception type <7> in throwFunct.
Gen: Exception type <7> received (stack unwound)  in innerCatchFunct.
Gen: Executing finally block finally in innerCatchFunct
Gen: Exception type <7> received (stack unwound)  in outerCatchFunct.
Gen: Executing finally block finally in outerCatchFunct

runExceptionThrow(...):In C++ catch all.

Gen: About to throw exception type <-1> in throwFunct.
Gen: Foreign exception received.
Gen: Executing finally block finally in innerCatchFunct
Gen: Foreign exception received.
Gen: Executing finally block finally in outerCatchFunct

runExceptionThrow(...):In C++ catch OurCppRunException with reason: thrown by throwCppException(...).

End Test:

@dtcxzyw dtcxzyw requested a review from lhames May 17, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLVM Build fails if exception enabled
1 participant