Fix isGuaranteedLoopInvariant() check for invariance. The checks for alloca and alloc-like instructions was not valid when the 'KillingDef' was outside of the loop, while the 'CurrentDef' was inside the loop. In that case, the 'KillingDef' only overwrites the definition from the last iteration of the loop, and not the ones of all iterations, therefor it does not make the 'CurrentDef' to be dead.
Fixing issue : https://github.com/llvm/llvm-project/issues/52774
The code structure in this function no longer makes sense. Please rewrite the whole function to first strip offsets / GEP and then do a single entry block check.