I’ve come across this tool: GitHub - abokhalill/lshaz: Find the microarchitectural performance bugs hiding in your C++ code · GitHub
It claims to detect latency hazards at compile-time: struct layouts that span cache lines, atomics that trigger cross-core invalidation storms, heap allocations in hot loops, virtual dispatch that defeats branch prediction, etc.
Granted, it seems oriented towards x64, but it claims to also support arm64. In addition, it has GH workflow files to run this tool on PRs.