diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1588,9 +1588,12 @@ // a return. auto *C1 = dyn_cast(I1); auto *C2 = dyn_cast(I2); - if (C1 && C2) + if (C1 && C2) { if (C1->isMustTailCall() != C2->isMustTailCall()) return Changed; + if (C1->getMetadata(LLVMContext::MD_prof) || C2->getMetadata(LLVMContext::MD_prof)) + return Changed; + } if (!TTI.isProfitableToHoist(I1) || !TTI.isProfitableToHoist(I2)) return Changed; @@ -1798,9 +1801,12 @@ // and merging inline-asm instructions can potentially create arguments // that cannot satisfy the inline-asm constraints. // If the instruction has nomerge or convergent attribute, return false. - if (const auto *C = dyn_cast(I)) + if (const auto *C = dyn_cast(I)) { if (C->isInlineAsm() || C->cannotMerge() || C->isConvergent()) return false; + if (C->getMetadata(LLVMContext::MD_prof)) + return false; + } // Each instruction must have zero or one use. if (HasUse && !I->hasOneUse())