[llvm-branch-commits] [llvm] [ir] MD_prof is not UB-implying (PR #152420)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 11 07:49:07 PDT 2025


================
@@ -1678,6 +1680,8 @@ void Instruction::dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs) {
 
   // A DIAssignID attachment is debug metadata, don't drop it.
   KnownSet.insert(LLVMContext::MD_DIAssignID);
+  if (!ProfcheckDisableMetadataFixes)
+    KnownSet.insert(LLVMContext::MD_prof);
----------------
nikic wrote:

In this function we don't really know anything about what transform we're performing, so we can't say whether preserving the metadata is correct or not.

In dropUBImplyingAttrsAndMetadata() we know (roughly) that we are doing a transform that unconditionally executes a previously conditionally executed instruction.

Whether preserving !prof in that case is correct or not is of course also debatable. The metadata may only be correct under the condition it was previously executed, and the value distribution might be completely different if speculated. But I'd guess that the distribution would stay the same more often than not...

https://github.com/llvm/llvm-project/pull/152420


More information about the llvm-branch-commits mailing list