LLVM: lib/IR/DroppedVariableStatsIR.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

19

20using namespace llvm;

21

22template

23const IRUnitT *DroppedVariableStatsIR::unwrapIR(Any IR) {

25 return IRPtr ? *IRPtr : nullptr;

26}

27

30 if (const auto *M = unwrapIR(IR))

31 return this->runOnModule(P, M, true);

32 if (const auto *F = unwrapIR(IR))

33 return this->runOnFunction(P, F, true);

34}

35

37 if (const auto *M = unwrapIR(IR))

38 runAfterPassModule(P, M);

39 else if (const auto *F = unwrapIR(IR))

40 runAfterPassFunction(P, F);

42}

43

44void DroppedVariableStatsIR::runAfterPassFunction(StringRef PassID,

47 calculateDroppedVarStatsOnFunction(F, PassID, F->getName().str(), "Function");

48}

49

50void DroppedVariableStatsIR::runAfterPassModule(StringRef PassID,

52 runOnModule(PassID, M, false);

53 calculateDroppedVarStatsOnModule(M, PassID, M->getName().str(), "Module");

54}

55

56void DroppedVariableStatsIR::runOnFunction(StringRef PassID, const Function *F,

57 bool Before) {

59 auto FuncName = F->getName();

60 Func = F;

62}

63

64void DroppedVariableStatsIR::calculateDroppedVarStatsOnFunction(

67 Func = F;

68 StringRef FuncName = F->getName();

71 PassLevel, Func);

72}

73

74void DroppedVariableStatsIR::runOnModule(StringRef PassID, const Module *M,

75 bool Before) {

76 for (auto &F : *M) {

77 runOnFunction(PassID, &F, Before);

78 }

79}

80

81void DroppedVariableStatsIR::calculateDroppedVarStatsOnModule(

84 for (auto &F : *M) {

85 calculateDroppedVarStatsOnFunction(&F, PassID, FuncOrModName, PassLevel);

86 }

87}

88

92 return;

93

94 PIC.registerBeforeNonSkippedPassCallback(

96 PIC.registerAfterPassCallback(

99 });

100 PIC.registerAfterPassInvalidatedCallback(

102}

103

104void DroppedVariableStatsIR::visitEveryInstruction(

107 const DIScope *DbgValScope = std::get<0>(Var);

109 auto *DbgLoc = I.getDebugLoc().get();

110 if (!DbgLoc)

111 continue;

113 InlinedAtsMap, Var, DroppedCount))

114 break;

115 }

116}

117

118void DroppedVariableStatsIR::visitEveryDebugRecord(

121 StringRef FuncName, bool Before) {

123 for (DbgRecord &DR : I.getDbgRecordRange()) {

125 auto *DbgVar = Dbg->getVariable();

126 auto DbgLoc = DR.getDebugLoc();

128 FuncName, Before);

129 }

130 }

131 }

132}

Expand Atomic instructions

===- DroppedVariableStatsIR.h - Opt Diagnostics -*- C++ -*-----------—===//

static bool runOnFunction(Function &F, bool PostInlining)

Module.h This file contains the declarations for the Module class.

Legalize the Machine IR a function s Machine IR

PassInstrumentationCallbacks PIC

This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...

Base class for scope-like contexts.

Implements a dense probed hash-table based set.

void registerCallbacks(PassInstrumentationCallbacks &PIC)

Definition DroppedVariableStatsIR.cpp:89

void runAfterPass(StringRef P, Any IR)

Definition DroppedVariableStatsIR.cpp:36

void runBeforePass(StringRef P, Any IR)

Definition DroppedVariableStatsIR.cpp:28

LLVM_ABI void calculateDroppedStatsAndPrint(DebugVariables &DbgVariables, StringRef FuncName, StringRef PassID, StringRef FuncOrModName, StringRef PassLevel, const Function *Func)

Calculate the number of dropped variables in an llvm::Function or llvm::MachineFunction and print the...

LLVM_ABI bool updateDroppedCount(DILocation *DbgLoc, const DIScope *Scope, const DIScope *DbgValScope, DenseMap< VarID, DILocation * > &InlinedAtsMap, VarID Var, unsigned &DroppedCount)

Check if a Var has been dropped or is a false positive.

bool DroppedVariableStatsEnabled

LLVM_ABI void populateVarIDSetAndInlinedMap(const DILocalVariable *DbgVar, DebugLoc DbgLoc, DenseSet< VarID > &VarIDSet, DenseMap< StringRef, DenseMap< VarID, DILocation * > > &InlinedAtsMap, StringRef FuncName, bool Before)

Populate the VarIDSet and InlinedAtMap with the relevant information needed for before and after pass...

SmallVector< DenseMap< const Function *, DebugVariables > > DebugVariablesStack

A stack of a DenseMap, that maps DebugVariables for every pass to an llvm::Function.

LLVM_ABI void run(DebugVariables &DbgVariables, StringRef FuncName, bool Before)

Run code to populate relevant data structures over an llvm::Function or llvm::MachineFunction.

A Module instance is used to store all the information related to an LLVM module.

This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...

A set of analyses that are preserved following a run of a transformation pass.

StringRef - Represent a constant reference to a string, i.e.

This is an optimization pass for GlobalISel generic memory operations.

std::tuple< const DIScope *, const DIScope *, const DILocalVariable * > VarID

A unique key that represents a debug variable.

T any_cast(const Any &Value)

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.