diff options
author | Sean Callanan <scallanan@apple.com> | 2013-06-28 21:44:15 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2013-06-28 21:44:15 +0000 |
commit | 4a20587f56a05955ea94f650cb39245a092b0c69 (patch) | |
tree | bf9184fc0571b4c31a79da5d234c4fdf8713cbdb /include | |
parent | 2f3daef19e4653c075ffcf16a2eb2e64d0380001 (diff) | |
download | lldb-4a20587f56a05955ea94f650cb39245a092b0c69.tar.gz |
Hitherto the IRForTarget infrastructure has mainly
been suitable for preparing a single IR function
for operation in the target. However, using blocks
and lambdas creates other IR functions that also
need to be processed.
I have audited IRForTarget to make it process
multiple functions. Where IRForTarget would add
new instructions at the beginning of the main
expression function, it now adds them on-demand
in the function where they are needed. This is
enabled by a system of FunctionValueCaches, which
invoke a lambda to create or derive the values as
needed, or report the result of that lambda if it
has already been called for the given function.
<rdar://problem/14180236>
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@185224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/lldb/Expression/IRForTarget.h | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/include/lldb/Expression/IRForTarget.h b/include/lldb/Expression/IRForTarget.h index a182069b0..151bf2ab4 100644 --- a/include/lldb/Expression/IRForTarget.h +++ b/include/lldb/Expression/IRForTarget.h @@ -18,6 +18,8 @@ #include "lldb/Symbol/TaggedASTType.h" #include "llvm/Pass.h" +#include <map> + namespace llvm { class BasicBlock; class CallInst; @@ -235,8 +237,7 @@ private: /// be determined); false otherwise. //------------------------------------------------------------------ bool - ResolveFunctionPointers (llvm::Module &llvm_module, - llvm::Function &llvm_function); + ResolveFunctionPointers (llvm::Module &llvm_module); //------------------------------------------------------------------ /// A function-level pass to take the generated global value @@ -307,7 +308,7 @@ private: CreateResultVariable (llvm::Function &llvm_function); //------------------------------------------------------------------ - /// A function-level pass to find Objective-C constant strings and + /// A module-level pass to find Objective-C constant strings and /// transform them to calls to CFStringCreateWithBytes. //------------------------------------------------------------------ @@ -321,32 +322,21 @@ private: /// The constant C string inside the NSString. This will be /// passed as the bytes argument to CFStringCreateWithBytes. /// - /// @param[in] FirstEntryInstruction - /// An instruction early in the execution of the function. - /// When this function synthesizes a call to - /// CFStringCreateWithBytes, it places the call before this - /// instruction. The instruction should come before all - /// uses of the NSString. - /// /// @return /// True on success; false otherwise //------------------------------------------------------------------ bool RewriteObjCConstString (llvm::GlobalVariable *NSStr, - llvm::GlobalVariable *CStr, - llvm::Instruction *FirstEntryInstruction); + llvm::GlobalVariable *CStr); //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_function - /// The function currently being processed. - /// /// @return /// True on success; false otherwise //------------------------------------------------------------------ bool - RewriteObjCConstStrings (llvm::Function &llvm_function); + RewriteObjCConstStrings (); //------------------------------------------------------------------ /// A basic block-level pass to find all Objective-C method calls and @@ -686,10 +676,26 @@ private: /// @return /// True on success; false otherwise //------------------------------------------------------------------ - static bool + + class FunctionValueCache { + public: + typedef std::function <llvm::Value *(llvm::Function *)> Maker; + + FunctionValueCache (Maker const &maker); + ~FunctionValueCache (); + llvm::Value *GetValue (llvm::Function *function); + private: + Maker const m_maker; + typedef std::map<llvm::Function *, llvm::Value *> FunctionValueMap; + FunctionValueMap m_values; + }; + + FunctionValueCache m_entry_instruction_finder; + + static bool UnfoldConstant (llvm::Constant *old_constant, - llvm::Value *new_constant, - llvm::Instruction *first_entry_inst); + FunctionValueCache &value_maker, + FunctionValueCache &entry_instruction_finder); //------------------------------------------------------------------ /// Construct a reference to m_reloc_placeholder with a given type |