[llvm] [InstCombine] Preserve metadata from orig load in select fold. (PR #115605)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 03:46:23 PST 2025
================
@@ -1065,6 +1065,25 @@ Instruction *InstCombinerImpl::visitLoadInst(LoadInst &LI) {
V1->setAtomic(LI.getOrdering(), LI.getSyncScopeID());
V2->setAlignment(Alignment);
V2->setAtomic(LI.getOrdering(), LI.getSyncScopeID());
+ // Can copy any metadata that cannot trigger UB. In particular do not
+ // copy !noundef or !invariant.load.
+ unsigned SafeMDKinds[] = {LLVMContext::MD_dbg,
+ LLVMContext::MD_tbaa,
+ LLVMContext::MD_prof,
+ LLVMContext::MD_fpmath,
+ LLVMContext::MD_tbaa_struct,
+ LLVMContext::MD_alias_scope,
+ LLVMContext::MD_noalias,
+ LLVMContext::MD_nontemporal,
+ LLVMContext::MD_mem_parallel_loop_access,
+ LLVMContext::MD_access_group,
----------------
fhahn wrote:
Finally updated this to use poison-generating kinds. As preparation, I put up https://github.com/llvm/llvm-project/pull/123188 to introduce an array holding the Metadata IDs that may generate poison.
https://github.com/llvm/llvm-project/pull/115605
More information about the llvm-commits
mailing list