[PATCH] D147954: [SimplifyCFG]Prevent premature simplification of callsites with profile data
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 11:11:45 PDT 2023
mingmingl created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mingmingl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
- Before MD_prof metadata is used, two different callsites with MD_prof shouldn't be simplified to one.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147954
Files:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1588,9 +1588,12 @@
// a return.
auto *C1 = dyn_cast<CallInst>(I1);
auto *C2 = dyn_cast<CallInst>(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<CallBase>(I))
+ if (const auto *C = dyn_cast<CallBase>(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())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147954.512200.patch
Type: text/x-patch
Size: 1289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230410/772fd4a8/attachment.bin>
More information about the llvm-commits
mailing list