[Local] Only intersect tbaa metadata if instr moves. (#116682)
commit0bb1b683302e41bb1bdbcec1cbe724f54add0fa3
authorFlorian Hahn <flo@fhahn.com>
Wed, 20 Nov 2024 19:31:16 +0000 (20 19:31 +0000)
committerGitHub <noreply@github.com>
Wed, 20 Nov 2024 19:31:16 +0000 (20 19:31 +0000)
tree1d4e414972d0b17cf5abf0442bbd9e0a6e586344
parentc0efcc08e67325dc813d9acb7cc3560fd444fc8f
[Local] Only intersect tbaa metadata if instr moves. (#116682)

Preserve tbaa metadata on the replacement instruction, if it does not
move. In that case, the program would be UB, if the aliasing property
encoded in the metadata does not hold.

This makes use of the clarification re tbaa metadata implying UB if the
property does not hold: https://github.com/llvm/llvm-project/pull/116220

Same as https://github.com/llvm/llvm-project/pull/115868, but for !tbaa

PR: https://github.com/llvm/llvm-project/pull/116682
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/GVN/tbaa.ll [copied from llvm/test/Transforms/NewGVN/tbaa.ll with 88% similarity]
llvm/test/Transforms/InstCombine/loadstore-metadata.ll
llvm/test/Transforms/JumpThreading/thread-loads.ll
llvm/test/Transforms/NewGVN/tbaa.ll
llvm/test/Transforms/PhaseOrdering/X86/preserve-access-group.ll