Skip to content
Open
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
6 changes: 3 additions & 3 deletions llvm/include/llvm/IR/DroppedVariableStatsIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class LLVM_ABI DroppedVariableStatsIR : public DroppedVariableStats {
DroppedVariableStatsIR(bool DroppedVarStatsEnabled)
: llvm::DroppedVariableStats(DroppedVarStatsEnabled) {}

void runBeforePass(StringRef P, Any IR);
void runBeforePass(StringRef P, const Any &IR);

void runAfterPass(StringRef P, Any IR);
void runAfterPass(StringRef P, const Any &IR);

void registerCallbacks(PassInstrumentationCallbacks &PIC);

Expand Down Expand Up @@ -81,7 +81,7 @@ class LLVM_ABI DroppedVariableStatsIR : public DroppedVariableStats {
DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
StringRef FuncName, bool Before) override;

template <typename IRUnitT> static const IRUnitT *unwrapIR(Any IR);
template <typename IRUnitT> static const IRUnitT *unwrapIR(const Any &IR);
};

} // namespace llvm
Expand Down
14 changes: 7 additions & 7 deletions llvm/include/llvm/IR/PassInstrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ class PassInstrumentationCallbacks {
// already invalidated IRUnit is unsafe. There are ways to handle invalidated
// IRUnits in a safe way, and we might pursue that as soon as there is a
// useful instrumentation that needs it.
using BeforePassFunc = bool(StringRef, Any);
using BeforeSkippedPassFunc = void(StringRef, Any);
using BeforeNonSkippedPassFunc = void(StringRef, Any);
using AfterPassFunc = void(StringRef, Any, const PreservedAnalyses &);
using BeforePassFunc = bool(StringRef, const Any &);
using BeforeSkippedPassFunc = void(StringRef, const Any &);
using BeforeNonSkippedPassFunc = void(StringRef, const Any &);
using AfterPassFunc = void(StringRef, const Any &, const PreservedAnalyses &);
using AfterPassInvalidatedFunc = void(StringRef, const PreservedAnalyses &);
using BeforeAnalysisFunc = void(StringRef, Any);
using AfterAnalysisFunc = void(StringRef, Any);
using AnalysisInvalidatedFunc = void(StringRef, Any);
using BeforeAnalysisFunc = void(StringRef, const Any &);
using AfterAnalysisFunc = void(StringRef, const Any &);
using AnalysisInvalidatedFunc = void(StringRef, const Any &);
using AnalysesClearedFunc = void(StringRef);

public:
Expand Down
45 changes: 23 additions & 22 deletions llvm/include/llvm/Passes/StandardInstrumentations.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class PrintIRInstrumentation {
IRName{IRName}, PassID(PassID) {}
};

void printBeforePass(StringRef PassID, Any IR);
void printAfterPass(StringRef PassID, Any IR);
void printBeforePass(StringRef PassID, const Any &IR);
void printAfterPass(StringRef PassID, const Any &IR);
void printAfterPassInvalidated(StringRef PassID);

bool shouldPrintBeforePass(StringRef PassID);
Expand All @@ -78,7 +78,8 @@ class PrintIRInstrumentation {
bool shouldPrintBeforeSomePassNumber();
bool shouldPrintAfterSomePassNumber();

void pushPassRunDescriptor(StringRef PassID, Any IR, unsigned PassNumber);
void pushPassRunDescriptor(StringRef PassID, const Any &IR,
unsigned PassNumber);
PassRunDescriptor popPassRunDescriptor(StringRef PassID);

enum class IRDumpFileSuffixType {
Expand Down Expand Up @@ -109,15 +110,15 @@ class OptNoneInstrumentation {

private:
bool DebugLogging;
bool shouldRun(StringRef PassID, Any IR);
bool shouldRun(StringRef PassID, const Any &IR);
};

class OptPassGateInstrumentation {
LLVMContext &Context;
bool HasWrittenIR = false;
public:
OptPassGateInstrumentation(LLVMContext &Context) : Context(Context) {}
LLVM_ABI bool shouldRun(StringRef PassName, Any IR);
LLVM_ABI bool shouldRun(StringRef PassName, const Any &IR);
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC);
};

Expand Down Expand Up @@ -218,9 +219,9 @@ template <typename IRUnitT> class LLVM_ABI ChangeReporter {

// Determine if this pass/IR is interesting and if so, save the IR
// otherwise it is left on the stack without data.
void saveIRBeforePass(Any IR, StringRef PassID, StringRef PassName);
void saveIRBeforePass(const Any &IR, StringRef PassID, StringRef PassName);
// Compare the IR from before the pass after the pass.
void handleIRAfterPass(Any IR, StringRef PassID, StringRef PassName);
void handleIRAfterPass(const Any &IR, StringRef PassID, StringRef PassName);
// Handle the situation where a pass is invalidated.
void handleInvalidatedPass(StringRef PassID);

Expand All @@ -229,16 +230,16 @@ template <typename IRUnitT> class LLVM_ABI ChangeReporter {
void registerRequiredCallbacks(PassInstrumentationCallbacks &PIC);

// Called on the first IR processed.
virtual void handleInitialIR(Any IR) = 0;
virtual void handleInitialIR(const Any &IR) = 0;
// Called before and after a pass to get the representation of the IR.
virtual void generateIRRepresentation(Any IR, StringRef PassID,
virtual void generateIRRepresentation(const Any &IR, StringRef PassID,
IRUnitT &Output) = 0;
// Called when the pass is not iteresting.
virtual void omitAfter(StringRef PassID, std::string &Name) = 0;
// Called when an interesting IR has changed.
virtual void handleAfter(StringRef PassID, std::string &Name,
const IRUnitT &Before, const IRUnitT &After,
Any) = 0;
const Any &) = 0;
// Called when an interesting pass is invalidated.
virtual void handleInvalidated(StringRef PassID) = 0;
// Called when the IR or pass is not interesting.
Expand All @@ -263,7 +264,7 @@ class LLVM_ABI TextChangeReporter : public ChangeReporter<IRUnitT> {
TextChangeReporter(bool Verbose);

// Print a module dump of the first IR that is changed.
void handleInitialIR(Any IR) override;
void handleInitialIR(const Any &IR) override;
// Report that the IR was omitted because it did not change.
void omitAfter(StringRef PassID, std::string &Name) override;
// Report that the pass was invalidated.
Expand Down Expand Up @@ -291,12 +292,12 @@ class LLVM_ABI IRChangedPrinter : public TextChangeReporter<std::string> {

protected:
// Called before and after a pass to get the representation of the IR.
void generateIRRepresentation(Any IR, StringRef PassID,
void generateIRRepresentation(const Any &IR, StringRef PassID,
std::string &Output) override;
// Called when an interesting IR has changed.
void handleAfter(StringRef PassID, std::string &Name,
const std::string &Before, const std::string &After,
Any) override;
const Any &) override;
};

class LLVM_ABI IRChangedTester : public IRChangedPrinter {
Expand All @@ -309,7 +310,7 @@ class LLVM_ABI IRChangedTester : public IRChangedPrinter {
void handleIR(const std::string &IR, StringRef PassID);

// Check initial IR
void handleInitialIR(Any IR) override;
void handleInitialIR(const Any &IR) override;
// Do nothing.
void omitAfter(StringRef PassID, std::string &Name) override;
// Do nothing.
Expand All @@ -322,7 +323,7 @@ class LLVM_ABI IRChangedTester : public IRChangedPrinter {
// Call test as interesting IR has changed.
void handleAfter(StringRef PassID, std::string &Name,
const std::string &Before, const std::string &After,
Any) override;
const Any &) override;
};

// Information that needs to be saved for a basic block in order to compare
Expand Down Expand Up @@ -428,7 +429,7 @@ template <typename T> class IRComparer {
CompareFunc);

// Analyze \p IR and build the IR representation in \p Data.
static void analyzeIR(Any IR, IRDataT<T> &Data);
static void analyzeIR(const Any &IR, IRDataT<T> &Data);

protected:
// Generate the data for \p F into \p Data.
Expand Down Expand Up @@ -456,13 +457,13 @@ class LLVM_ABI InLineChangePrinter

protected:
// Create a representation of the IR.
void generateIRRepresentation(Any IR, StringRef PassID,
void generateIRRepresentation(const Any &IR, StringRef PassID,
IRDataT<EmptyData> &Output) override;

// Called when an interesting IR has changed.
void handleAfter(StringRef PassID, std::string &Name,
const IRDataT<EmptyData> &Before,
const IRDataT<EmptyData> &After, Any) override;
const IRDataT<EmptyData> &After, const Any &) override;

void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID,
StringRef Divider, bool InModule, unsigned Minor,
Expand Down Expand Up @@ -495,7 +496,7 @@ class TimeProfilingPassesHandler {

private:
// Implementation of pass instrumentation callbacks.
void runBeforePass(StringRef PassID, Any IR);
void runBeforePass(StringRef PassID, const Any &IR);
void runAfterPass();
};

Expand Down Expand Up @@ -544,16 +545,16 @@ class LLVM_ABI DotCfgChangeReporter : public ChangeReporter<IRDataT<DCData>> {
bool initializeHTML();

// Called on the first IR processed.
void handleInitialIR(Any IR) override;
void handleInitialIR(const Any &IR) override;
// Called before and after a pass to get the representation of the IR.
void generateIRRepresentation(Any IR, StringRef PassID,
void generateIRRepresentation(const Any &IR, StringRef PassID,
IRDataT<DCData> &Output) override;
// Called when the pass is not iteresting.
void omitAfter(StringRef PassID, std::string &Name) override;
// Called when an interesting IR has changed.
void handleAfter(StringRef PassID, std::string &Name,
const IRDataT<DCData> &Before, const IRDataT<DCData> &After,
Any) override;
const Any &) override;
// Called when an interesting pass is invalidated.
void handleInvalidated(StringRef PassID) override;
// Called when the IR or pass is not interesting.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PseudoProbeVerifier {
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC);

// Implementation of pass instrumentation callbacks for new pass manager.
LLVM_ABI void runAfterPass(StringRef PassID, Any IR);
LLVM_ABI void runAfterPass(StringRef PassID, const Any &IR);

private:
// Allow a little bias due the rounding to integral factors.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/TargetPassConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void llvm::registerCodeGenCallback(PassInstrumentationCallbacks &PIC,
TargetMachine &TM) {

// Register a callback for disabling passes.
PIC.registerShouldRunOptionalPassCallback([](StringRef P, Any) {
PIC.registerShouldRunOptionalPassCallback([](StringRef P, const Any &) {

#define DISABLE_PASS(Option, Name) \
if (Option && P.contains(#Name)) \
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/IR/DroppedVariableStatsIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
using namespace llvm;

template <typename IRUnitT>
const IRUnitT *DroppedVariableStatsIR::unwrapIR(Any IR) {
const IRUnitT **IRPtr = llvm::any_cast<const IRUnitT *>(&IR);
const IRUnitT *DroppedVariableStatsIR::unwrapIR(const Any &IR) {
const IRUnitT *const *IRPtr = llvm::any_cast<const IRUnitT *>(&IR);
return IRPtr ? *IRPtr : nullptr;
}

void DroppedVariableStatsIR::runBeforePass(StringRef P, Any IR) {
void DroppedVariableStatsIR::runBeforePass(StringRef P, const Any &IR) {
setup();
if (const auto *M = unwrapIR<Module>(IR))
return this->runOnModule(P, M, true);
if (const auto *F = unwrapIR<Function>(IR))
return this->runOnFunction(P, F, true);
}

void DroppedVariableStatsIR::runAfterPass(StringRef P, Any IR) {
void DroppedVariableStatsIR::runAfterPass(StringRef P, const Any &IR) {
if (const auto *M = unwrapIR<Module>(IR))
runAfterPassModule(P, M);
else if (const auto *F = unwrapIR<Function>(IR))
Expand Down Expand Up @@ -92,9 +92,9 @@ void DroppedVariableStatsIR::registerCallbacks(
return;

PIC.registerBeforeNonSkippedPassCallback(
[this](StringRef P, Any IR) { return runBeforePass(P, IR); });
[this](StringRef P, const Any &IR) { return runBeforePass(P, IR); });
PIC.registerAfterPassCallback(
[this](StringRef P, Any IR, const PreservedAnalyses &PA) {
[this](StringRef P, const Any &IR, const PreservedAnalyses &PA) {
return runAfterPass(P, IR);
});
PIC.registerAfterPassInvalidatedCallback(
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/IR/PassTimingInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,17 @@ void TimePassesHandler::registerCallbacks(PassInstrumentationCallbacks &PIC) {
return;

PIC.registerBeforeNonSkippedPassCallback(
[this](StringRef P, Any) { this->startPassTimer(P); });
[this](StringRef P, const Any &) { this->startPassTimer(P); });
PIC.registerAfterPassCallback(
[this](StringRef P, Any, const PreservedAnalyses &) {
[this](StringRef P, const Any &, const PreservedAnalyses &) {
this->stopPassTimer(P);
});
PIC.registerAfterPassInvalidatedCallback(
[this](StringRef P, const PreservedAnalyses &) {
this->stopPassTimer(P);
});
PIC.registerBeforeAnalysisCallback(
[this](StringRef P, Any) { this->startAnalysisTimer(P); });
[this](StringRef P, const Any &) { this->startAnalysisTimer(P); });
PIC.registerAfterAnalysisCallback(
[this](StringRef P, Any) { this->stopAnalysisTimer(P); });
[this](StringRef P, const Any &) { this->stopAnalysisTimer(P); });
}
Loading
Loading