Repository navigation
[NativeAOT/ARM] Prevent misoptimization by clang - #97811
Conversation
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsOptimized builds by printf("%x %x %x\r\n", (uintptr_t)&RhpAssignRefAVLocation, (uintptr_t)&RhpAssignRefAVLocation & ~1, faultingIP);
// prints "4b9539 4b9539 4b9538"Avoid using non-aligned labels in the first place. Contributes to #97729
|
|
Isn't the root cause of the problem that these code labels are declared as void* alignment on any architecture supported by native AOT. There is still opportunity for mis-optimization. We have seen cases where clang/llvm is very creative in using the alignment guarantees for optimizations. Should these code labels be declared as byte variables instead to tell the compiler that there are no alignment guarantees?
|
|
Generally, we should unify on either using Taking an address of a I'm leaning slightly in the direction of |
+1. The unification does not need to be done in this PR. We should agree on direction.
The difference between these two mechanisms is in number of indirections.
|
Any suggestion for a name? |
|
The AV labels are named |
|
I’ll update the PR later today. |
| EXTERN_C void* RhpInterfaceDispatchAVLocation16; | ||
| EXTERN_C void* RhpInterfaceDispatchAVLocation32; | ||
| EXTERN_C void* RhpInterfaceDispatchAVLocation64; | ||
| EXTERN_C CODE_LOCATION RhpInitialInterfaceDispatch; |
There was a problem hiding this comment.
Side-node: This is broken on ARM. Firstly, it is function entrypoint and not AV location. Secondly, we don't do the access in the assembly that would cause the AV.
I'll probably submit the fix separately since I cannot test it on device now.
Optimized builds by
clangassume that variable addresses are already aligned and ignore the& ~1masking:Avoid using non-aligned labels in the first place.
Contributes to #97729