[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:55:50 PDT 2025


================
@@ -1699,8 +1699,12 @@ static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop,
       // The check on hasMetadataOtherThanDebugLoc is to prevent us from burning
       // time in isGuaranteedToExecute if we don't actually have anything to
       // drop.  It is a compile time optimization, not required for correctness.
-      !SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop))
-    I.dropUBImplyingAttrsAndMetadata();
+      !SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop)) {
+    if (ProfcheckDisableMetadataFixes)
+      I.dropUBImplyingAttrsAndMetadata();
+    else
+      I.dropUBImplyingAttrsAndMetadata({LLVMContext::MD_prof});
----------------
snehasish wrote:

Ah. Didn't realize it wasn't exposed already.

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


More information about the llvm-commits mailing list