aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2024-11-20 19:31:16 +0000
committerGitHub <noreply@github.com>2024-11-20 19:31:16 +0000
commit0bb1b683302e41bb1bdbcec1cbe724f54add0fa3 (patch)
tree1d4e414972d0b17cf5abf0442bbd9e0a6e586344 /llvm/lib
parentc0efcc08e67325dc813d9acb7cc3560fd444fc8f (diff)
downloadllvm-0bb1b683302e41bb1bdbcec1cbe724f54add0fa3.zip
llvm-0bb1b683302e41bb1bdbcec1cbe724f54add0fa3.tar.gz
llvm-0bb1b683302e41bb1bdbcec1cbe724f54add0fa3.tar.bz2
[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
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 6cbfa12..42c258a 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3326,7 +3326,8 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J,
K->mergeDIAssignID(J);
break;
case LLVMContext::MD_tbaa:
- K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
+ if (DoesKMove)
+ K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
break;
case LLVMContext::MD_alias_scope:
K->setMetadata(Kind, MDNode::getMostGenericAliasScope(JMD, KMD));