Skip to content

Commit a610b70

Browse files
committed
Add flag for profcheck studies
1 parent 6acdd6c commit a610b70

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static cl::opt<bool> SpecializeLiteralConstant(
8989
"Enable specialization of functions that take a literal constant as an "
9090
"argument"));
9191

92+
extern cl::opt<bool> ProfcheckDisableMetadataFixes;
93+
9294
bool InstCostVisitor::canEliminateSuccessor(BasicBlock *BB,
9395
BasicBlock *Succ) const {
9496
unsigned I = 0;
@@ -789,8 +791,9 @@ bool FunctionSpecializer::run() {
789791
<< " to call " << Clone->getName() << "\n");
790792
Call->setCalledFunction(S.Clone);
791793
auto &BFI = GetBFI(*Call->getFunction());
792-
if (std::optional<uint64_t> Count =
793-
BFI.getBlockProfileCount(Call->getParent())) {
794+
std::optional<uint64_t> Count =
795+
BFI.getBlockProfileCount(Call->getParent());
796+
if (Count && !ProfcheckDisableMetadataFixes) {
794797
std::optional<llvm::Function::ProfileCount> MaybeCloneCount =
795798
Clone->getEntryCount();
796799
assert(MaybeCloneCount && "Clone entry count was not set!");
@@ -1064,7 +1067,7 @@ Function *FunctionSpecializer::createSpecialization(Function *F,
10641067
// clone must.
10651068
Clone->setLinkage(GlobalValue::InternalLinkage);
10661069

1067-
if (F->getEntryCount())
1070+
if (F->getEntryCount() && !ProfcheckDisableMetadataFixes)
10681071
Clone->setEntryCount(0);
10691072

10701073
// Initialize the lattice state of the arguments of the function clone,

0 commit comments

Comments
 (0)