LLVM: lib/Target/WebAssembly/WebAssemblyMCLowerPrePass.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
25using namespace llvm;
26
27#define DEBUG_TYPE "wasm-mclower-prepass"
28
29namespace {
30class WebAssemblyMCLowerPrePass final : public ModulePass {
31 StringRef getPassName() const override {
32 return "WebAssembly MC Lower Pre Pass";
33 }
34
35 void getAnalysisUsage(AnalysisUsage &AU) const override {
38 }
39
40 bool runOnModule(Module &M) override;
41
42public:
43 static char ID;
44 WebAssemblyMCLowerPrePass() : ModulePass(ID) {}
45};
46}
47
48char WebAssemblyMCLowerPrePass::ID = 0;
50 WebAssemblyMCLowerPrePass, DEBUG_TYPE,
51 "Collects information ahead of time for MC lowering",
52 false, false)
53
55 return new WebAssemblyMCLowerPrePass();
56}
57
58
59
60
61
62
63
64
65bool WebAssemblyMCLowerPrePass::runOnModule(Module &M) {
66 auto *MMIWP = getAnalysisIfAvailable();
67 if (!MMIWP)
68 return true;
69
70 MachineModuleInfo &MMI = MMIWP->getMMI();
71 MachineModuleInfoWasm &MMIW = MMI.getObjFileInfo();
72
73 for (Function &F : M) {
75 if (!MF)
76 continue;
77
78 LLVM_DEBUG(dbgs() << "********** MC Lower Pre Pass **********\n"
79 "********** Function: "
80 << MF->getName() << '\n');
81
82 for (MachineBasicBlock &MBB : *MF) {
84
85 if (MI.isDebugInstr() || MI.isInlineAsm())
86 continue;
87 for (MachineOperand &MO : MI.uses()) {
88 if (MO.isSymbol()) {
90 }
91 }
92 }
93 }
94 }
95 return true;
96}
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file contains the declaration of the WebAssembly-specific utility functions.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
SetVector< StringRef > MachineSymbolsUsed
Ty & getObjFileInfo()
Keep track of various per-module pieces of information for backends that would like to do so.
LLVM_ABI MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ModulePass * createWebAssemblyMCLowerPrePass()