[llvm] [Local] Make combineAAMetadata() more principled (PR #122091)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 03:33:17 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff bfa711a970d50c9101c8962609f9aad4f5395825 bc23709d3b026e3c5bdf7de026bed6d19682698b --extensions cpp,h -- llvm/include/llvm/Transforms/Utils/Local.h llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/lib/Transforms/Utils/Local.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 918b3a4225..8e4e96128a 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3320,98 +3320,97 @@ static void combineMetadata(Instruction *K, const Instruction *J,
MDNode *KMD = MD.second;
switch (Kind) {
- default:
- K->setMetadata(Kind, nullptr); // Remove unknown metadata
- break;
- case LLVMContext::MD_dbg:
- llvm_unreachable("getAllMetadataOtherThanDebugLoc returned a MD_dbg");
- case LLVMContext::MD_DIAssignID:
- if (!AAOnly)
- K->mergeDIAssignID(J);
- break;
- case LLVMContext::MD_tbaa:
- if (DoesKMove)
- K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
- break;
- case LLVMContext::MD_alias_scope:
- if (DoesKMove)
- K->setMetadata(Kind, MDNode::getMostGenericAliasScope(JMD, KMD));
- break;
- case LLVMContext::MD_noalias:
- case LLVMContext::MD_mem_parallel_loop_access:
- if (DoesKMove)
- K->setMetadata(Kind, MDNode::intersect(JMD, KMD));
- break;
- case LLVMContext::MD_access_group:
- if (DoesKMove)
- K->setMetadata(LLVMContext::MD_access_group,
- intersectAccessGroups(K, J));
- break;
- case LLVMContext::MD_range:
- if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
- K->setMetadata(Kind, MDNode::getMostGenericRange(JMD, KMD));
- break;
- case LLVMContext::MD_fpmath:
- if (!AAOnly)
- K->setMetadata(Kind, MDNode::getMostGenericFPMath(JMD, KMD));
- break;
- case LLVMContext::MD_invariant_load:
- // If K moves, only set the !invariant.load if it is present in both
- // instructions.
- if (DoesKMove)
- K->setMetadata(Kind, JMD);
- break;
- case LLVMContext::MD_nonnull:
- if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
- K->setMetadata(Kind, JMD);
- break;
- case LLVMContext::MD_invariant_group:
- // Preserve !invariant.group in K.
- break;
- case LLVMContext::MD_mmra:
- // Combine MMRAs
- break;
- case LLVMContext::MD_align:
- if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
- K->setMetadata(
- Kind, MDNode::getMostGenericAlignmentOrDereferenceable(JMD, KMD));
- break;
- case LLVMContext::MD_dereferenceable:
- case LLVMContext::MD_dereferenceable_or_null:
- if (!AAOnly && DoesKMove)
- K->setMetadata(Kind,
- MDNode::getMostGenericAlignmentOrDereferenceable(JMD, KMD));
- break;
- case LLVMContext::MD_memprof:
- if (!AAOnly)
- K->setMetadata(Kind, MDNode::getMergedMemProfMetadata(KMD, JMD));
- break;
- case LLVMContext::MD_callsite:
- if (!AAOnly)
- K->setMetadata(Kind, MDNode::getMergedCallsiteMetadata(KMD, JMD));
- break;
- case LLVMContext::MD_preserve_access_index:
- // Preserve !preserve.access.index in K.
- break;
- case LLVMContext::MD_noundef:
- // If K does move, keep noundef if it is present in both instructions.
- if (!AAOnly && DoesKMove)
- K->setMetadata(Kind, JMD);
- break;
- case LLVMContext::MD_nontemporal:
- // Preserve !nontemporal if it is present on both instructions.
- if (!AAOnly)
- K->setMetadata(Kind, JMD);
- break;
- case LLVMContext::MD_prof:
- if (!AAOnly && DoesKMove)
- K->setMetadata(Kind, MDNode::getMergedProfMetadata(KMD, JMD, K, J));
- break;
- case LLVMContext::MD_noalias_addrspace:
- if (DoesKMove)
- K->setMetadata(Kind,
- MDNode::getMostGenericNoaliasAddrspace(JMD, KMD));
- break;
+ default:
+ K->setMetadata(Kind, nullptr); // Remove unknown metadata
+ break;
+ case LLVMContext::MD_dbg:
+ llvm_unreachable("getAllMetadataOtherThanDebugLoc returned a MD_dbg");
+ case LLVMContext::MD_DIAssignID:
+ if (!AAOnly)
+ K->mergeDIAssignID(J);
+ break;
+ case LLVMContext::MD_tbaa:
+ if (DoesKMove)
+ K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
+ break;
+ case LLVMContext::MD_alias_scope:
+ if (DoesKMove)
+ K->setMetadata(Kind, MDNode::getMostGenericAliasScope(JMD, KMD));
+ break;
+ case LLVMContext::MD_noalias:
+ case LLVMContext::MD_mem_parallel_loop_access:
+ if (DoesKMove)
+ K->setMetadata(Kind, MDNode::intersect(JMD, KMD));
+ break;
+ case LLVMContext::MD_access_group:
+ if (DoesKMove)
+ K->setMetadata(LLVMContext::MD_access_group,
+ intersectAccessGroups(K, J));
+ break;
+ case LLVMContext::MD_range:
+ if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
+ K->setMetadata(Kind, MDNode::getMostGenericRange(JMD, KMD));
+ break;
+ case LLVMContext::MD_fpmath:
+ if (!AAOnly)
+ K->setMetadata(Kind, MDNode::getMostGenericFPMath(JMD, KMD));
+ break;
+ case LLVMContext::MD_invariant_load:
+ // If K moves, only set the !invariant.load if it is present in both
+ // instructions.
+ if (DoesKMove)
+ K->setMetadata(Kind, JMD);
+ break;
+ case LLVMContext::MD_nonnull:
+ if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
+ K->setMetadata(Kind, JMD);
+ break;
+ case LLVMContext::MD_invariant_group:
+ // Preserve !invariant.group in K.
+ break;
+ case LLVMContext::MD_mmra:
+ // Combine MMRAs
+ break;
+ case LLVMContext::MD_align:
+ if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
+ K->setMetadata(
+ Kind, MDNode::getMostGenericAlignmentOrDereferenceable(JMD, KMD));
+ break;
+ case LLVMContext::MD_dereferenceable:
+ case LLVMContext::MD_dereferenceable_or_null:
+ if (!AAOnly && DoesKMove)
+ K->setMetadata(
+ Kind, MDNode::getMostGenericAlignmentOrDereferenceable(JMD, KMD));
+ break;
+ case LLVMContext::MD_memprof:
+ if (!AAOnly)
+ K->setMetadata(Kind, MDNode::getMergedMemProfMetadata(KMD, JMD));
+ break;
+ case LLVMContext::MD_callsite:
+ if (!AAOnly)
+ K->setMetadata(Kind, MDNode::getMergedCallsiteMetadata(KMD, JMD));
+ break;
+ case LLVMContext::MD_preserve_access_index:
+ // Preserve !preserve.access.index in K.
+ break;
+ case LLVMContext::MD_noundef:
+ // If K does move, keep noundef if it is present in both instructions.
+ if (!AAOnly && DoesKMove)
+ K->setMetadata(Kind, JMD);
+ break;
+ case LLVMContext::MD_nontemporal:
+ // Preserve !nontemporal if it is present on both instructions.
+ if (!AAOnly)
+ K->setMetadata(Kind, JMD);
+ break;
+ case LLVMContext::MD_prof:
+ if (!AAOnly && DoesKMove)
+ K->setMetadata(Kind, MDNode::getMergedProfMetadata(KMD, JMD, K, J));
+ break;
+ case LLVMContext::MD_noalias_addrspace:
+ if (DoesKMove)
+ K->setMetadata(Kind, MDNode::getMostGenericNoaliasAddrspace(JMD, KMD));
+ break;
}
}
// Set !invariant.group from J if J has it. If both instructions have it
``````````
</details>
https://github.com/llvm/llvm-project/pull/122091
More information about the llvm-commits
mailing list