LLVM: lib/CodeGen/MachineModuleInfo.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

19#include

20

21using namespace llvm;

23

24

26

28 ObjFileMMI = nullptr;

29 NextFnNum = 0;

30}

31

34

35

36 delete ObjFileMMI;

37 ObjFileMMI = nullptr;

38}

39

42 Context(TM.getTargetTriple(), TM.getMCAsmInfo(), TM.getMCRegisterInfo(),

43 TM.getMCSubtargetInfo(), nullptr, &TM.Options.MCOptions, false),

44 MachineFunctions(std::move(MMI.MachineFunctions)) {

46 ObjFileMMI = MMI.ObjFileMMI;

47 ExternalContext = MMI.ExternalContext;

48 TheModule = MMI.TheModule;

49}

50

52 : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),

53 TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),

57}

58

61 : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),

62 TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),

64 ExternalContext(ExtContext) {

67}

68

70

73 auto I = MachineFunctions.find(&F);

74 return I != MachineFunctions.end() ? I->second.get() : nullptr;

75}

76

78

79

80 if (LastRequest == &F)

81 return *LastResult;

82

83 auto I = MachineFunctions.insert(

84 std::make_pair(&F, std::unique_ptr()));

86 if (I.second) {

87

91

92

94

95

96 I.first->second.reset(MF);

97 } else {

98 MF = I.first->second.get();

99 }

100

101 LastRequest = &F;

102 LastResult = MF;

103 return *MF;

104}

105

107 MachineFunctions.erase(&F);

108 LastRequest = nullptr;

109 LastResult = nullptr;

110}

111

113 std::unique_ptr &&MF) {

114 auto I = MachineFunctions.insert(std::make_pair(&F, std::move(MF)));

115 assert(I.second && "machine function already mapped");

116 (void)I;

117}

118

119namespace {

120

121

122class FreeMachineFunction : public FunctionPass {

123public:

124 static char ID;

125

127

128 void getAnalysisUsage(AnalysisUsage &AU) const override {

131 }

132

135 getAnalysis().getMMI();

137 return true;

138 }

139

140 StringRef getPassName() const override {

141 return "Free MachineFunction";

142 }

143};

144

145}

146

147char FreeMachineFunction::ID;

148

150 return new FreeMachineFunction();

151}

152

157}

158

163}

164

165

167 "Machine Module Information", false, false)

169

172

174 const MDNode *LocInfo = nullptr;

175 if (BufNum > 0 && BufNum <= LocInfos.size())

176 LocInfo = LocInfos[BufNum - 1];

177

178

179

181 if (LocInfo) {

182 unsigned ErrorLine = SMD.getLineNo() - 1;

184 ErrorLine = 0;

185

188 mdconst::dyn_extract(LocInfo->getOperand(ErrorLine)))

189 LocCookie = CI->getZExtValue();

190 }

191

192 return LocCookie;

193}

194

197 MMI.TheModule = &M;

200 [&Ctx, &M](const SMDiagnostic &SMD, bool IsInlineAsm,

202 std::vector<const MDNode *> &LocInfos) {

204 if (IsInlineAsm)

208 });

209 return false;

210}

211

214 return false;

215}

216

218

221 MMI.TheModule = &M;

224 [&Ctx, &M](const SMDiagnostic &SMD, bool IsInlineAsm,

226 std::vector<const MDNode *> &LocInfos) {

227 unsigned LocCookie = 0;

228 if (IsInlineAsm)

232 });

234}

This file contains the declarations for the subclasses of Constant, which represent the different fla...

static bool runOnFunction(Function &F, bool PostInlining)

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

static INITIALIZE_PASS(MachineModuleInfoWrapperPass, "machinemoduleinfo", "Machine Module Information", false, false) char MachineModuleInfoWrapperPass uint64_t getLocCookie(const SMDiagnostic &SMD, const SourceMgr &SrcMgr, std::vector< const MDNode * > &LocInfos)

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

A container for analyses that lazily runs them and caches their results.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

AnalysisUsage & addPreserved()

Add the specified Pass class to the set of analyses preserved by this pass.

This is the shared class of boolean and integer constants.

Diagnostic information for SMDiagnostic reporting.

FunctionPass class - This class is used to implement most global optimizations.

ImmutablePass class - This class is used to provide information that does not need to be run.

This is an important class for using LLVM in a threaded context.

void diagnose(const DiagnosticInfo &DI)

Report a message to the currently installed diagnostic handler.

Context object for machine code objects.

void setObjectFileInfo(const MCObjectFileInfo *Mofi)

void setDiagnosticHandler(DiagHandlerTy DiagHandler)

void reset()

reset - return object to right after construction state to prepare to process a new module

const MDOperand & getOperand(unsigned I) const

unsigned getNumOperands() const

Return number of MDNode operands.

void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI)

Initialize the target specific MachineFunctionInfo.

Result run(Module &M, ModuleAnalysisManager &)

Run the analysis pass and produce machine module information.

virtual ~MachineModuleInfoImpl()

bool doFinalization(Module &) override

doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...

MachineModuleInfoWrapperPass(const TargetMachine *TM=nullptr)

bool doInitialization(Module &) override

doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...

This class contains meta information specific to a module.

MachineModuleInfo(const TargetMachine *TM=nullptr)

void insertFunction(const Function &F, std::unique_ptr< MachineFunction > &&MF)

Add an externally created MachineFunction MF for F.

const MCContext & getContext() const

MachineFunction & getOrCreateMachineFunction(Function &F)

Returns the MachineFunction constructed for the IR function F.

MachineFunction * getMachineFunction(const Function &F) const

Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.

void deleteMachineFunctionFor(Function &F)

Delete the MachineFunction MF and reset the link in the IR Function to Machine Function map.

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

static PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...

This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.

unsigned FindBufferContainingLoc(SMLoc Loc) const

Return the ID of the buffer containing the specified location.

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

Primary interface to the complete machine description for the target machine.

virtual TargetLoweringObjectFile * getObjFileLowering() const

virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const

Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...

virtual void registerMachineRegisterInfoCallback(MachineFunction &MF) const

TargetSubtargetInfo - Generic base class for all target subtargets.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

Calculates the starting offsets for various sections within the .debug_names section.

This is an optimization pass for GlobalISel generic memory operations.

void initializeMachineModuleInfoWrapperPassPass(PassRegistry &)

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

FunctionPass * createFreeMachineFunctionPass()

This pass frees the memory occupied by the MachineFunction.

Implement std::hash so that hash_code can be used in STL containers.

A special type used by analysis passes to provide an address that identifies that particular analysis...