Skip to content

[llvm] format and terminate namespaces with closing comment #94917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/CallGraphSCCPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using namespace llvm;
namespace llvm {
cl::opt<unsigned> MaxDevirtIterations("max-devirt-iterations", cl::ReallyHidden,
cl::init(4));
}
} // namespace llvm

STATISTIC(MaxSCCIterations, "Maximum CGSCCPassMgr iterations on one SCC");

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Analysis/CallPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace llvm;

namespace llvm {
template <class GraphType> struct GraphTraits;
}
} // namespace llvm

// This option shows static (relative) call counts.
// FIXME:
Expand Down Expand Up @@ -215,7 +215,7 @@ struct DOTGraphTraits<CallGraphDOTInfo *> : public DefaultDOTGraphTraits {
}
};

} // end llvm namespace
} // namespace llvm

namespace {
void doCallGraphDOTPrinting(
Expand Down
184 changes: 92 additions & 92 deletions llvm/lib/Analysis/CaptureTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,127 +72,127 @@ bool CaptureTracker::isDereferenceableOrNull(Value *O, const DataLayout &DL) {
}

namespace {
struct SimpleCaptureTracker : public CaptureTracker {
explicit SimpleCaptureTracker(bool ReturnCaptures)
: ReturnCaptures(ReturnCaptures) {}
struct SimpleCaptureTracker : public CaptureTracker {
explicit SimpleCaptureTracker(bool ReturnCaptures)
: ReturnCaptures(ReturnCaptures) {}

void tooManyUses() override {
LLVM_DEBUG(dbgs() << "Captured due to too many uses\n");
Captured = true;
}
void tooManyUses() override {
LLVM_DEBUG(dbgs() << "Captured due to too many uses\n");
Captured = true;
}

bool captured(const Use *U) override {
if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
return false;
bool captured(const Use *U) override {
if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
return false;

LLVM_DEBUG(dbgs() << "Captured by: " << *U->getUser() << "\n");
LLVM_DEBUG(dbgs() << "Captured by: " << *U->getUser() << "\n");

Captured = true;
return true;
}
Captured = true;
return true;
}

bool ReturnCaptures;
bool ReturnCaptures;

bool Captured = false;
};
bool Captured = false;
};

/// Only find pointer captures which happen before the given instruction. Uses
/// the dominator tree to determine whether one instruction is before another.
/// Only support the case where the Value is defined in the same basic block
/// as the given instruction and the use.
struct CapturesBefore : public CaptureTracker {
/// Only find pointer captures which happen before the given instruction. Uses
/// the dominator tree to determine whether one instruction is before another.
/// Only support the case where the Value is defined in the same basic block
/// as the given instruction and the use.
struct CapturesBefore : public CaptureTracker {

CapturesBefore(bool ReturnCaptures, const Instruction *I,
const DominatorTree *DT, bool IncludeI, const LoopInfo *LI)
: BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures),
IncludeI(IncludeI), LI(LI) {}
CapturesBefore(bool ReturnCaptures, const Instruction *I,
const DominatorTree *DT, bool IncludeI, const LoopInfo *LI)
: BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures),
IncludeI(IncludeI), LI(LI) {}

void tooManyUses() override { Captured = true; }
void tooManyUses() override { Captured = true; }

bool isSafeToPrune(Instruction *I) {
if (BeforeHere == I)
return !IncludeI;
bool isSafeToPrune(Instruction *I) {
if (BeforeHere == I)
return !IncludeI;

// We explore this usage only if the usage can reach "BeforeHere".
// If use is not reachable from entry, there is no need to explore.
if (!DT->isReachableFromEntry(I->getParent()))
return true;
// We explore this usage only if the usage can reach "BeforeHere".
// If use is not reachable from entry, there is no need to explore.
if (!DT->isReachableFromEntry(I->getParent()))
return true;

// Check whether there is a path from I to BeforeHere.
return !isPotentiallyReachable(I, BeforeHere, nullptr, DT, LI);
}
// Check whether there is a path from I to BeforeHere.
return !isPotentiallyReachable(I, BeforeHere, nullptr, DT, LI);
}

bool captured(const Use *U) override {
Instruction *I = cast<Instruction>(U->getUser());
if (isa<ReturnInst>(I) && !ReturnCaptures)
return false;
bool captured(const Use *U) override {
Instruction *I = cast<Instruction>(U->getUser());
if (isa<ReturnInst>(I) && !ReturnCaptures)
return false;

// Check isSafeToPrune() here rather than in shouldExplore() to avoid
// an expensive reachability query for every instruction we look at.
// Instead we only do one for actual capturing candidates.
if (isSafeToPrune(I))
return false;
// Check isSafeToPrune() here rather than in shouldExplore() to avoid
// an expensive reachability query for every instruction we look at.
// Instead we only do one for actual capturing candidates.
if (isSafeToPrune(I))
return false;

Captured = true;
return true;
}
Captured = true;
return true;
}

const Instruction *BeforeHere;
const DominatorTree *DT;
const Instruction *BeforeHere;
const DominatorTree *DT;

bool ReturnCaptures;
bool IncludeI;
bool ReturnCaptures;
bool IncludeI;

bool Captured = false;
bool Captured = false;

const LoopInfo *LI;
};
const LoopInfo *LI;
};

/// Find the 'earliest' instruction before which the pointer is known not to
/// be captured. Here an instruction A is considered earlier than instruction
/// B, if A dominates B. If 2 escapes do not dominate each other, the
/// terminator of the common dominator is chosen. If not all uses cannot be
/// analyzed, the earliest escape is set to the first instruction in the
/// function entry block.
// NOTE: Users have to make sure instructions compared against the earliest
// escape are not in a cycle.
struct EarliestCaptures : public CaptureTracker {

EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT)
: DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}

void tooManyUses() override {
Captured = true;
EarliestCapture = &*F.getEntryBlock().begin();
}
/// Find the 'earliest' instruction before which the pointer is known not to
/// be captured. Here an instruction A is considered earlier than instruction
/// B, if A dominates B. If 2 escapes do not dominate each other, the
/// terminator of the common dominator is chosen. If not all uses cannot be
/// analyzed, the earliest escape is set to the first instruction in the
/// function entry block.
// NOTE: Users have to make sure instructions compared against the earliest
// escape are not in a cycle.
struct EarliestCaptures : public CaptureTracker {

bool captured(const Use *U) override {
Instruction *I = cast<Instruction>(U->getUser());
if (isa<ReturnInst>(I) && !ReturnCaptures)
return false;
EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT)
: DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}

if (!EarliestCapture)
EarliestCapture = I;
else
EarliestCapture = DT.findNearestCommonDominator(EarliestCapture, I);
Captured = true;
void tooManyUses() override {
Captured = true;
EarliestCapture = &*F.getEntryBlock().begin();
}

// Return false to continue analysis; we need to see all potential
// captures.
bool captured(const Use *U) override {
Instruction *I = cast<Instruction>(U->getUser());
if (isa<ReturnInst>(I) && !ReturnCaptures)
return false;
}

Instruction *EarliestCapture = nullptr;
if (!EarliestCapture)
EarliestCapture = I;
else
EarliestCapture = DT.findNearestCommonDominator(EarliestCapture, I);
Captured = true;

const DominatorTree &DT;
// Return false to continue analysis; we need to see all potential
// captures.
return false;
}

bool ReturnCaptures;
Instruction *EarliestCapture = nullptr;

bool Captured = false;
const DominatorTree &DT;

Function &F;
};
}
bool ReturnCaptures;

bool Captured = false;

Function &F;
};
} // namespace

/// PointerMayBeCaptured - Return true if this pointer value may be captured
/// by the enclosing function (which is required to exist). This routine can
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/CycleAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace llvm;

namespace llvm {
class Module;
}
} // namespace llvm

CycleInfo CycleAnalysis::run(Function &F, FunctionAnalysisManager &) {
CycleInfo CI;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cl::opt<unsigned> MediumBasicBlockInstructionThreshold(
"medium-basic-block-instruction-threshold", cl::Hidden, cl::init(15),
cl::desc("The minimum number of instructions a basic block should contain "
"before being considered medium-sized."));
}
} // namespace llvm

static cl::opt<unsigned> CallWithManyArgumentsThreshold(
"call-with-many-arguments-threshold", cl::Hidden, cl::init(4),
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ImportedFunctionsInliningStatistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cl::opt<InlinerFunctionImportStatsOpts> InlinerFunctionImportStats(
clEnumValN(InlinerFunctionImportStatsOpts::Verbose, "verbose",
"printing of statistics for each inlined function")),
cl::Hidden, cl::desc("Enable inliner stats for imported functions"));
}
} // namespace llvm

ImportedFunctionsInliningStatistics::InlineGraphNode &
ImportedFunctionsInliningStatistics::createInlineGraphNode(const Function &F) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/InlineAdvisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static cl::opt<bool>

namespace llvm {
extern cl::opt<InlinerFunctionImportStatsOpts> InlinerFunctionImportStats;
}
} // namespace llvm

namespace {
using namespace llvm::ore;
Expand Down
Loading
Loading