Repository navigation
Closed
Description
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
| /* | |
| * Nested clauses where one of the clauses is a finally clause is | |
| * not supported, because LLVM can't figure out the control flow, | |
| * probably because we resume exception handling by calling our | |
| * own function instead of using the 'resume' llvm instruction. | |
| */ | |
| for (i = 0; i < cfg->header->num_clauses; ++i) { | |
| for (j = 0; j < cfg->header->num_clauses; ++j) { | |
| MonoExceptionClause *clause1 = &cfg->header->clauses [i]; | |
| MonoExceptionClause *clause2 = &cfg->header->clauses [j]; | |
| // FIXME: Nested try clauses fail in some cases too, i.e. #37273 | |
| if (i != j && clause1->try_offset >= clause2->try_offset && clause1->handler_offset <= clause2->handler_offset) { | |
| //(clause1->flags == MONO_EXCEPTION_CLAUSE_FINALLY || clause2->flags == MONO_EXCEPTION_CLAUSE_FINALLY)) { | |
| cfg->exception_message = g_strdup ("nested clauses"); | |
| cfg->disable_llvm = TRUE; | |
| break; | |
| } | |
| } | |
| } |
The archived referenced bug is: https://bugzilla.xamarin.com/37/37273/bug.html
Some EH info from compiling this test:
Method int IntelHardwareIntrinsicTest.Program:Main (string[]) emitted at 0x41d516a0 to 0x41d51f1d (code length 2173)
IL clause: try 0x15e-0x194 handler 0x194-0x199 filter 0x0
looking for end of try [350, 54] -> 0x55d2206dde78 (code size 550)
IL clause: try 0x15e-0x194 handler 0x199-0x1bd filter 0x0
looking for end of try [350, 54] -> 0x55d2206dde78 (code size 550)
IL clause: try 0x1be-0x1f4 handler 0x1f4-0x1f9 filter 0x0
looking for end of try [446, 54] -> 0x55d2206de3b8 (code size 550)
IL clause: try 0x1be-0x1f4 handler 0x1f9-0x21d filter 0x0
looking for end of try [446, 54] -> 0x55d2206de3b8 (code size 550)
Also enable JIT/HardwareIntrinsics/X86/Sse2.X64/StoreNonTemporal_{r,ro} with the fix
Activity
imhameed commentedon Jun 28, 2021
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
catchswitch,catchret, etc.)Moving this to 7.0.
imhameed commentedon Oct 15, 2021
A few notes on playing around with
catchswitch,catchpad, andcatchret: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
landingpadallows the runtime EH unwinder to communicate values back to the generated object code via registers.catchpaddoes not.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:
This constant function pointer is associated with a
BasicBlockhere: https://github.com/dotnet/llvm-project/blob/release/11.x/llvm/lib/CodeGen/WinEHPrepare.cpp#L378-L383jandupej commentedon Oct 25, 2022
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:
Both
catchblocks are executed, while none should be.The inside of the inner-most
tryblock translates to LLVMinvokes with the exception path leading to this landing pad:The label
BB3_CALL_HANDLER_TARGETis the default branch and also the inside of thecatch(DivideByZeroException)block. So if an unexpected exception is raised, the incorrect block is executed. That default is set inmini-llvm.c:5504.jandupej commentedon Mar 21, 2023
Simulations show that the performance and binary size benefits would be minimal. Closing.