Skip to content

Commit 7fb67c4

Browse files
committed
Restore change from llvm#134100 that was accidentally reverted in merge
1 parent d40605d commit 7fb67c4

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,28 +1661,19 @@ class CodeGenFunction : public CodeGenTypeCache {
16611661
UseSkipPath,
16621662
};
16631663

1664-
/// Increment the profiler's counter for the given statement by \p StepV.
1665-
/// If \p StepV is null, the default increment is 1.
1666-
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
1667-
incrementProfileCounter(UseExecPath, S, false, StepV);
1668-
}
1669-
16701664
/// Emit increment of Counter.
16711665
/// \param ExecSkip Use `Skipped` Counter if UseSkipPath is specified.
16721666
/// \param S The Stmt that Counter is associated.
16731667
/// \param UseBoth Mark both Exec/Skip as used. (for verification)
16741668
/// \param StepV The offset Value for adding to Counter.
16751669
void incrementProfileCounter(CounterForIncrement ExecSkip, const Stmt *S,
1676-
bool UseBoth = false,
1677-
llvm::Value *StepV = nullptr) {
1678-
if (CGM.getCodeGenOpts().hasProfileClangInstr() &&
1679-
!CurFn->hasFnAttribute(llvm::Attribute::NoProfile) &&
1680-
!CurFn->hasFnAttribute(llvm::Attribute::SkipProfile)) {
1681-
auto AL = ApplyDebugLocation::CreateArtificial(*this);
1682-
PGO.emitCounterSetOrIncrement(Builder, S, (ExecSkip == UseSkipPath),
1683-
UseBoth, StepV);
1684-
}
1685-
PGO.setCurrentStmt(S);
1670+
bool UseBoth = false,
1671+
llvm::Value *StepV = nullptr);
1672+
1673+
/// Increment the profiler's counter for the given statement by \p StepV.
1674+
/// If \p StepV is null, the default increment is 1.
1675+
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
1676+
incrementProfileCounter(UseExecPath, S, false, StepV);
16861677
}
16871678

16881679
bool isMCDCCoverageEnabled() const {

clang/lib/CodeGen/CodeGenPGO.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,13 +1447,15 @@ CodeGenFunction::createProfileWeightsForLoop(const Stmt *Cond,
14471447
std::max(*CondCount, LoopCount) - LoopCount);
14481448
}
14491449

1450-
void CodeGenFunction::incrementProfileCounter(const Stmt *S,
1451-
llvm::Value *StepV) {
1450+
void CodeGenFunction::incrementProfileCounter(
1451+
CodeGenFunction::CounterForIncrement ExecSkip, const Stmt *S,
1452+
bool UseBoth, llvm::Value *StepV) {
14521453
if (CGM.getCodeGenOpts().hasProfileClangInstr() &&
14531454
!CurFn->hasFnAttribute(llvm::Attribute::NoProfile) &&
14541455
!CurFn->hasFnAttribute(llvm::Attribute::SkipProfile)) {
14551456
auto AL = ApplyDebugLocation::CreateArtificial(*this);
1456-
PGO->emitCounterSetOrIncrement(Builder, S, StepV);
1457+
PGO->emitCounterSetOrIncrement(Builder, S, (ExecSkip == UseSkipPath),
1458+
UseBoth, StepV);
14571459
}
14581460
PGO->setCurrentStmt(S);
14591461
}

0 commit comments

Comments
 (0)