-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[mono][llvm] Support nested EH clauses #54176
Comments
The changes we'll need for exception filters (#54185) will be closely related to the changes needed to make nested EH clauses work (e.g. use of Moving this to 7.0. |
A few notes on playing around with The LLVM EH documentation claims that these instructions can be used to model C++ Itanium-style exception handling. This is true in theory but as of today LLVM makes several assumptions about the EH "personality" function and about the target's calling convention when these IR instructions are encountered while targeting arm64:
I didn't encounter any of this on amd64, even when targeting Linux, so maybe this would be easy to fix. Also EDIT: This won't matter to us for a while, but GlobalISel doesn't support these new EH instructions SEH filters are associated with individual catchpad instructions like so: define dso_local i32 @testguy() #1 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
; ...
%7 = catchpad within %5 [i8* bitcast (i32 (i8*, i8*)* @"?filt$0@0@testguy@@" to i8*)]
catchret from %7 to label %8
; ...
}
define internal i32 @"?filt$0@0@testguy@@"(i8* nocapture readnone %0, i8* %1) #3 {
%3 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @testguy to i8*), i8* %1)
%4 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @testguy to i8*), i8* %3, i32 0)
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %5, align 4
%7 = add nsw i32 %6, 2
store i32 %7, i32* %5, align 4
ret i32 15
} This constant function pointer is associated with a |
Bringing back the support for nested EH clauses would also mean fixing the original flow control bug. The original repro can be simplified to the following: [MethodImpl(MethodImplOptions.NoInlining)]
public static void CatchDivideByZeroException() => Console.WriteLine("***FAIL*** Caught DivideByZeroException");
[MethodImpl(MethodImplOptions.NoInlining)]
public static void FinallyInner() => Console.WriteLine("Finally inner");
[MethodImpl(MethodImplOptions.NoInlining)]
public static void CatchException() => Console.WriteLine("***FAIL*** Caught Exception");
[MethodImpl(MethodImplOptions.NoInlining)]
public static void FinallyOuter() => Console.WriteLine("Finally outer");
public static void Demo()
{
try
{
try
{
throw new Exception();
}
catch(DivideByZeroException)
{
CatchDivideByZeroException();
}
finally
{
FinallyInner();
throw new Exception();
}
}
catch(ArgumentException)
{
CatchException();
}
finally
{
FinallyOuter();
}
} Both The inside of the inner-most EH_CLAUSE0_BB3: ; preds = %NOEX_BB5, %BB2
%17 = landingpad { i8*, i32 }
catch i32* @type_info_0, !dbg !45
...
%ex_selector = extractvalue { i8*, i32 } %17, 1, !dbg !45
switch i32 %ex_selector, label %BB3_CALL_HANDLER_TARGET [
i32 3, label %BB7_CALL_HANDLER_TARGET
i32 2, label %BB6_CALL_HANDLER_TARGET
i32 1, label %BB4_CALL_HANDLER_TARGET
], !dbg !45 The label |
Simulations show that the performance and binary size benefits would be minimal. Closing. |
StoreNonTemporal_r.dll bails out of LLVM compilation of
IntelHardwareIntrinsicTest:Main
because of this:runtime/src/mono/mono/mini/mini-llvm.c
Lines 10910 to 10929 in d95bfea
The archived referenced bug is: https://bugzilla.xamarin.com/37/37273/bug.html
Some EH info from compiling this test:
Also enable JIT/HardwareIntrinsics/X86/Sse2.X64/StoreNonTemporal_{r,ro} with the fix
The text was updated successfully, but these errors were encountered: