IRForTarget.h revision 82b74c85f719be67b78f9284a6a1341d47f7ac9c
1//===-- IRForTarget.h ---------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_IRForTarget_h_ 11#define liblldb_IRForTarget_h_ 12 13#include "llvm/Pass.h" 14 15namespace llvm { 16 class BasicBlock; 17 class CallInst; 18 class Constant; 19 class Function; 20 class Instruction; 21 class Module; 22 class TargetData; 23 class Value; 24} 25 26namespace lldb_private { 27 class ClangExpressionDeclMap; 28} 29 30class IRForTarget : public llvm::ModulePass 31{ 32public: 33 IRForTarget(const void *pid, 34 lldb_private::ClangExpressionDeclMap *decl_map, 35 const llvm::TargetData *target_data); 36 ~IRForTarget(); 37 bool runOnModule(llvm::Module &M); 38 void assignPassManager(llvm::PMStack &PMS, 39 llvm::PassManagerType T = llvm::PMT_ModulePassManager); 40 llvm::PassManagerType getPotentialPassManagerType() const; 41private: 42 // pass to find the result variable created in the result synthesizer and 43 // make a result variable out of it (or a void variable if there is no 44 // result) 45 bool createResultVariable(llvm::Module &M, 46 llvm::Function &F); 47 48 // pass to rewrite Objective-C method calls to use the runtime function 49 // sel_registerName 50 bool RewriteObjCSelector(llvm::Instruction* selector_load, 51 llvm::Module &M); 52 bool rewriteObjCSelectors(llvm::Module &M, 53 llvm::BasicBlock &BB); 54 55 // pass to find declarations of, and references to, persistent variables and 56 // register them for (de)materialization 57 bool RewritePersistentAlloc(llvm::Instruction *persistent_alloc, 58 llvm::Module &M); 59 bool rewritePersistentAllocs(llvm::Module &M, 60 llvm::BasicBlock &BB); 61 62 // pass to register referenced variables and redirect functions at their 63 // targets in the debugged process 64 bool MaybeHandleVariable(llvm::Module &M, 65 llvm::Value *V, 66 bool Store); 67 bool MaybeHandleCall(llvm::Module &M, 68 llvm::CallInst *C); 69 bool resolveExternals(llvm::Module &M, 70 llvm::BasicBlock &BB); 71 72 // pass to find references to guard variables and excise them 73 bool removeGuards(llvm::Module &M, 74 llvm::BasicBlock &BB); 75 76 // pass to replace all identified variables with references to members of 77 // the argument struct 78 bool replaceVariables(llvm::Module &M, 79 llvm::Function &F); 80 81 lldb_private::ClangExpressionDeclMap *m_decl_map; 82 const llvm::TargetData *m_target_data; 83 84 llvm::Constant *m_sel_registerName; 85}; 86 87#endif 88