[llvm] [licm] don't drop `MD_prof` when dropping other metadata (PR #152420)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 16:57:36 PDT 2025
================
@@ -552,14 +552,19 @@ void Instruction::dropUBImplyingAttrsAndUnknownMetadata(
CB->removeRetAttrs(UBImplyingAttributes);
}
-void Instruction::dropUBImplyingAttrsAndMetadata() {
+void Instruction::dropUBImplyingAttrsAndMetadata(ArrayRef<unsigned> Keep) {
// !annotation metadata does not impact semantics.
// !range, !nonnull and !align produce poison, so they are safe to speculate.
// !noundef and various AA metadata must be dropped, as it generally produces
// immediate undefined behavior.
- unsigned KnownIDs[] = {LLVMContext::MD_annotation, LLVMContext::MD_range,
- LLVMContext::MD_nonnull, LLVMContext::MD_align};
- dropUBImplyingAttrsAndUnknownMetadata(KnownIDs);
+ static const unsigned KnownIDs[] = {
+ LLVMContext::MD_annotation, LLVMContext::MD_range,
+ LLVMContext::MD_nonnull, LLVMContext::MD_align};
+ SmallVector<unsigned> KeepIDs;
+ KeepIDs.reserve(Keep.size() + std::size(KnownIDs));
----------------
snehasish wrote:
Is this useful in practice? SmallVector<unsigned> might already allocate enough inline storage to not require an allocation for the small number of metadata types we have.
https://github.com/llvm/llvm-project/pull/152420
More information about the llvm-commits
mailing list