IRForTarget.h revision 06dc17f8eb821d7256fd42e56f85c2779a29f689
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 "lldb/lldb-public.h"
14#include "lldb/Core/ConstString.h"
15#include "lldb/Core/Error.h"
16#include "lldb/Core/Stream.h"
17#include "lldb/Symbol/TaggedASTType.h"
18#include "llvm/Pass.h"
19
20namespace llvm {
21    class BasicBlock;
22    class CallInst;
23    class Constant;
24    class ConstantInt;
25    class Function;
26    class GlobalValue;
27    class GlobalVariable;
28    class Instruction;
29    class Module;
30    class StoreInst;
31    class TargetData;
32    class Type;
33    class Value;
34}
35
36namespace lldb_private {
37    class ClangExpressionDeclMap;
38}
39
40//----------------------------------------------------------------------
41/// @class IRForTarget IRForTarget.h "lldb/Expression/IRForTarget.h"
42/// @brief Transforms the IR for a function to run in the target
43///
44/// Once an expression has been parsed and converted to IR, it can run
45/// in two contexts: interpreted by LLDB as a DWARF location expression,
46/// or compiled by the JIT and inserted into the target process for
47/// execution.
48///
49/// IRForTarget makes the second possible, by applying a series of
50/// transformations to the IR which make it relocatable.  These
51/// transformations are discussed in more detail next to their relevant
52/// functions.
53//----------------------------------------------------------------------
54class IRForTarget : public llvm::ModulePass
55{
56public:
57    class StaticDataAllocator {
58    public:
59        StaticDataAllocator();
60        virtual ~StaticDataAllocator();
61        virtual lldb_private::StreamString &GetStream() = 0;
62        virtual lldb::addr_t Allocate() = 0;
63    };
64
65    //------------------------------------------------------------------
66    /// Constructor
67    ///
68    /// @param[in] decl_map
69    ///     The list of externally-referenced variables for the expression,
70    ///     for use in looking up globals and allocating the argument
71    ///     struct.  See the documentation for ClangExpressionDeclMap.
72    ///
73    /// @param[in] resolve_vars
74    ///     True if the external variable references (including persistent
75    ///     variables) should be resolved.  If not, only external functions
76    ///     are resolved.
77    ///
78    /// @param[in] execution_policy
79    ///     Determines whether an IR interpreter can be used to statically
80    ///     evaluate the expression.
81    ///
82    /// @param[in] const_result
83    ///     This variable is populated with the statically-computed result
84    ///     of the function, if it has no side-effects and the result can
85    ///     be computed statically.
86    ///
87    /// @param[in] data_allocator
88    ///     If non-NULL, the static data allocator to use for literal strings.
89    ///
90    /// @param[in] error_stream
91    ///     If non-NULL, a stream on which errors can be printed.
92    ///
93    /// @param[in] func_name
94    ///     The name of the function to prepare for execution in the target.
95    //------------------------------------------------------------------
96    IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
97                bool resolve_vars,
98                lldb_private::ExecutionPolicy execution_policy,
99                lldb::ClangExpressionVariableSP &const_result,
100                StaticDataAllocator *data_allocator,
101                lldb_private::Stream *error_stream,
102                const char* func_name = "$__lldb_expr");
103
104    //------------------------------------------------------------------
105    /// Destructor
106    //------------------------------------------------------------------
107    virtual ~IRForTarget();
108
109    //------------------------------------------------------------------
110    /// Run this IR transformer on a single module
111    ///
112    /// Implementation of the llvm::ModulePass::runOnModule() function.
113    ///
114    /// @param[in] llvm_module
115    ///     The module to run on.  This module is searched for the function
116    ///     $__lldb_expr, and that function is passed to the passes one by
117    ///     one.
118    ///
119    /// @param[in] interpreter_error
120    ///     An error.  If the expression fails to be interpreted, this error
121    ///     is set to a reason why.
122    ///
123    /// @return
124    ///     True on success; false otherwise
125    //------------------------------------------------------------------
126    virtual bool
127    runOnModule (llvm::Module &llvm_module);
128
129    //------------------------------------------------------------------
130    /// Interface stub
131    ///
132    /// Implementation of the llvm::ModulePass::assignPassManager()
133    /// function.
134    //------------------------------------------------------------------
135    virtual void
136    assignPassManager (llvm::PMStack &pass_mgr_stack,
137                       llvm::PassManagerType pass_mgr_type = llvm::PMT_ModulePassManager);
138
139    //------------------------------------------------------------------
140    /// Returns PMT_ModulePassManager
141    ///
142    /// Implementation of the llvm::ModulePass::getPotentialPassManagerType()
143    /// function.
144    //------------------------------------------------------------------
145    virtual llvm::PassManagerType
146    getPotentialPassManagerType() const;
147
148    //------------------------------------------------------------------
149    /// Checks whether the IR interpreter successfully interpreted the
150    /// expression.
151    ///
152    /// Returns true if it did; false otherwise.
153    //------------------------------------------------------------------
154    lldb_private::Error &
155    getInterpreterError ()
156    {
157        return m_interpreter_error;
158    }
159
160private:
161    //------------------------------------------------------------------
162    /// Ensures that the current function's linkage is set to external.
163    /// Otherwise the JIT may not return an address for it.
164    ///
165    /// @param[in] llvm_function
166    ///     The function whose linkage is to be fixed.
167    ///
168    /// @return
169    ///     True on success; false otherwise.
170    //------------------------------------------------------------------
171    bool
172    FixFunctionLinkage (llvm::Function &llvm_function);
173
174    //------------------------------------------------------------------
175    /// A module-level pass to replace all function pointers with their
176    /// integer equivalents.
177    //------------------------------------------------------------------
178
179    //------------------------------------------------------------------
180    /// The top-level pass implementation
181    ///
182    /// @param[in] llvm_module
183    ///     The module currently being processed.
184    ///
185    /// @param[in] llvm_function
186    ///     The function currently being processed.
187    ///
188    /// @return
189    ///     True on success; false otherwise.
190    //------------------------------------------------------------------
191    bool
192    HasSideEffects (llvm::Function &llvm_function);
193
194    //------------------------------------------------------------------
195    /// A function-level pass to check whether the function has side
196    /// effects.
197    //------------------------------------------------------------------
198
199    //------------------------------------------------------------------
200    /// Get the address of a fuction, and a location to put the complete
201    /// Value of the function if one is available.
202    ///
203    /// @param[in] function
204    ///     The function to find the location of.
205    ///
206    /// @param[out] ptr
207    ///     The location of the function in the target.
208    ///
209    /// @param[out] name
210    ///     The resolved name of the function (matters for intrinsics).
211    ///
212    /// @param[out] value_ptr
213    ///     A variable to put the function's completed Value* in, or NULL
214    ///     if the Value* shouldn't be stored anywhere.
215    ///
216    /// @return
217    ///     The pointer.
218    //------------------------------------------------------------------
219    bool
220    GetFunctionAddress (llvm::Function *function,
221                        uint64_t &ptr,
222                        lldb_private::ConstString &name,
223                        llvm::Constant **&value_ptr);
224
225    //------------------------------------------------------------------
226    /// Build a function pointer given a type and a raw pointer.
227    ///
228    /// @param[in] type
229    ///     The type of the function pointer to be built.
230    ///
231    /// @param[in] ptr
232    ///     The value of the pointer.
233    ///
234    /// @return
235    ///     The pointer.
236    //------------------------------------------------------------------
237    llvm::Constant *
238    BuildFunctionPointer (llvm::Type *type,
239                          uint64_t ptr);
240
241    void
242    RegisterFunctionMetadata (llvm::LLVMContext &context,
243                              llvm::Value *function_ptr,
244                              const char *name);
245
246    //------------------------------------------------------------------
247    /// The top-level pass implementation
248    ///
249    /// @param[in] llvm_function
250    ///     The function currently being processed.
251    ///
252    /// @return
253    ///     True if the function has side effects (or if this cannot
254    ///     be determined); false otherwise.
255    //------------------------------------------------------------------
256    bool
257    ResolveFunctionPointers (llvm::Module &llvm_module,
258                             llvm::Function &llvm_function);
259
260    //------------------------------------------------------------------
261    /// A function-level pass to take the generated global value
262    /// $__lldb_expr_result and make it into a persistent variable.
263    /// Also see ASTResultSynthesizer.
264    //------------------------------------------------------------------
265
266    //------------------------------------------------------------------
267    /// Find the NamedDecl corresponding to a Value.  This interface is
268    /// exposed for the IR interpreter.
269    ///
270    /// @param[in] module
271    ///     The module containing metadata to search
272    ///
273    /// @param[in] global
274    ///     The global entity to search for
275    ///
276    /// @return
277    ///     The corresponding variable declaration
278    //------------------------------------------------------------------
279public:
280    static clang::NamedDecl *
281    DeclForGlobal (const llvm::GlobalValue *global_val, llvm::Module *module);
282private:
283    clang::NamedDecl *
284    DeclForGlobal (llvm::GlobalValue *global);
285
286    //------------------------------------------------------------------
287    /// Set the constant result variable m_const_result to the provided
288    /// constant, assuming it can be evaluated.  The result variable
289    /// will be reset to NULL later if the expression has side effects.
290    ///
291    /// @param[in] initializer
292    ///     The constant initializer for the variable.
293    ///
294    /// @param[in] name
295    ///     The name of the result variable.
296    ///
297    /// @param[in] type
298    ///     The Clang type of the result variable.
299    //------------------------------------------------------------------
300    void
301    MaybeSetConstantResult (llvm::Constant *initializer,
302                            const lldb_private::ConstString &name,
303                            lldb_private::TypeFromParser type);
304
305    //------------------------------------------------------------------
306    /// If the IR represents a cast of a variable, set m_const_result
307    /// to the result of the cast.  The result variable will be reset to
308    /// NULL latger if the expression has side effects.
309    ///
310    /// @param[in] type
311    ///     The Clang type of the result variable.
312    //------------------------------------------------------------------
313    void
314    MaybeSetCastResult (lldb_private::TypeFromParser type);
315
316    //------------------------------------------------------------------
317    /// The top-level pass implementation
318    ///
319    /// @param[in] llvm_function
320    ///     The function currently being processed.
321    ///
322    /// @return
323    ///     True on success; false otherwise
324    //------------------------------------------------------------------
325    bool
326    CreateResultVariable (llvm::Function &llvm_function);
327
328    //------------------------------------------------------------------
329    /// A function-level pass to find Objective-C constant strings and
330    /// transform them to calls to CFStringCreateWithBytes.
331    //------------------------------------------------------------------
332
333    //------------------------------------------------------------------
334    /// Rewrite a single Objective-C constant string.
335    ///
336    /// @param[in] NSStr
337    ///     The constant NSString to be transformed
338    ///
339    /// @param[in] CStr
340    ///     The constant C string inside the NSString.  This will be
341    ///     passed as the bytes argument to CFStringCreateWithBytes.
342    ///
343    /// @param[in] FirstEntryInstruction
344    ///     An instruction early in the execution of the function.
345    ///     When this function synthesizes a call to
346    ///     CFStringCreateWithBytes, it places the call before this
347    ///     instruction.  The instruction should come before all
348    ///     uses of the NSString.
349    ///
350    /// @return
351    ///     True on success; false otherwise
352    //------------------------------------------------------------------
353    bool
354    RewriteObjCConstString (llvm::GlobalVariable *NSStr,
355                            llvm::GlobalVariable *CStr,
356                            llvm::Instruction *FirstEntryInstruction);
357
358    //------------------------------------------------------------------
359    /// The top-level pass implementation
360    ///
361    /// @param[in] llvm_function
362    ///     The function currently being processed.
363    ///
364    /// @return
365    ///     True on success; false otherwise
366    //------------------------------------------------------------------
367    bool
368    RewriteObjCConstStrings (llvm::Function &llvm_function);
369
370    //------------------------------------------------------------------
371    /// A basic block-level pass to find all Objective-C method calls and
372    /// rewrite them to use sel_registerName instead of statically allocated
373    /// selectors.  The reason is that the selectors are created on the
374    /// assumption that the Objective-C runtime will scan the appropriate
375    /// section and prepare them.  This doesn't happen when code is copied
376    /// into the target, though, and there's no easy way to induce the
377    /// runtime to scan them.  So instead we get our selectors from
378    /// sel_registerName.
379    //------------------------------------------------------------------
380
381    //------------------------------------------------------------------
382    /// Replace a single selector reference
383    ///
384    /// @param[in] selector_load
385    ///     The load of the statically-allocated selector.
386    ///
387    /// @return
388    ///     True on success; false otherwise
389    //------------------------------------------------------------------
390    bool
391    RewriteObjCSelector (llvm::Instruction* selector_load);
392
393    //------------------------------------------------------------------
394    /// The top-level pass implementation
395    ///
396    /// @param[in] basic_block
397    ///     The basic block currently being processed.
398    ///
399    /// @return
400    ///     True on success; false otherwise
401    //------------------------------------------------------------------
402    bool
403    RewriteObjCSelectors (llvm::BasicBlock &basic_block);
404
405    //------------------------------------------------------------------
406    /// A basic block-level pass to find all newly-declared persistent
407    /// variables and register them with the ClangExprDeclMap.  This
408    /// allows them to be materialized and dematerialized like normal
409    /// external variables.  Before transformation, these persistent
410    /// variables look like normal locals, so they have an allocation.
411    /// This pass excises these allocations and makes references look
412    /// like external references where they will be resolved -- like all
413    /// other external references -- by ResolveExternals().
414    //------------------------------------------------------------------
415
416    //------------------------------------------------------------------
417    /// Handle a single allocation of a persistent variable
418    ///
419    /// @param[in] persistent_alloc
420    ///     The allocation of the persistent variable.
421    ///
422    /// @return
423    ///     True on success; false otherwise
424    //------------------------------------------------------------------
425    bool
426    RewritePersistentAlloc (llvm::Instruction *persistent_alloc);
427
428    //------------------------------------------------------------------
429    /// The top-level pass implementation
430    ///
431    /// @param[in] basic_block
432    ///     The basic block currently being processed.
433    //------------------------------------------------------------------
434    bool
435    RewritePersistentAllocs (llvm::BasicBlock &basic_block);
436
437    //------------------------------------------------------------------
438    /// A function-level pass to find all external variables and functions
439    /// used in the IR.  Each found external variable is added to the
440    /// struct, and each external function is resolved in place, its call
441    /// replaced with a call to a function pointer whose value is the
442    /// address of the function in the target process.
443    //------------------------------------------------------------------
444
445    //------------------------------------------------------------------
446    /// Write an initializer to a memory array of assumed sufficient
447    /// size.
448    ///
449    /// @param[in] data
450    ///     A pointer to the data to write to.
451    ///
452    /// @param[in] initializer
453    ///     The initializer itself.
454    ///
455    /// @return
456    ///     True on success; false otherwise
457    //------------------------------------------------------------------
458    bool
459    MaterializeInitializer (uint8_t *data, llvm::Constant *initializer);
460
461    //------------------------------------------------------------------
462    /// Move an internal variable into the static allocation section.
463    ///
464    /// @param[in] global_variable
465    ///     The variable.
466    ///
467    /// @return
468    ///     True on success; false otherwise
469    //------------------------------------------------------------------
470    bool
471    MaterializeInternalVariable (llvm::GlobalVariable *global_variable);
472
473    //------------------------------------------------------------------
474    /// Handle a single externally-defined variable
475    ///
476    /// @param[in] value
477    ///     The variable.
478    ///
479    /// @return
480    ///     True on success; false otherwise
481    //------------------------------------------------------------------
482    bool
483    MaybeHandleVariable (llvm::Value *value);
484
485    //------------------------------------------------------------------
486    /// Handle a single externally-defined symbol
487    ///
488    /// @param[in] symbol
489    ///     The symbol.
490    ///
491    /// @return
492    ///     True on success; false otherwise
493    //------------------------------------------------------------------
494    bool
495    HandleSymbol (llvm::Value *symbol);
496
497    //------------------------------------------------------------------
498    /// Handle a single externally-defined Objective-C class
499    ///
500    /// @param[in] classlist_reference
501    ///     The reference, usually "01L_OBJC_CLASSLIST_REFERENCES_$_n"
502    ///     where n (if present) is an index.
503    ///
504    /// @return
505    ///     True on success; false otherwise
506    //------------------------------------------------------------------
507    bool
508    HandleObjCClass(llvm::Value *classlist_reference);
509
510    //------------------------------------------------------------------
511    /// Handle all the arguments to a function call
512    ///
513    /// @param[in] C
514    ///     The call instruction.
515    ///
516    /// @return
517    ///     True on success; false otherwise
518    //------------------------------------------------------------------
519    bool
520    MaybeHandleCallArguments (llvm::CallInst *call_inst);
521
522    //------------------------------------------------------------------
523    /// Resolve variable references in calls to external functions
524    ///
525    /// @param[in] basic_block
526    ///     The basic block currently being processed.
527    ///
528    /// @return
529    ///     True on success; false otherwise
530    //------------------------------------------------------------------
531    bool
532    ResolveCalls (llvm::BasicBlock &basic_block);
533
534    //------------------------------------------------------------------
535    /// Remove calls to __cxa_atexit, which should never be generated by
536    /// expressions.
537    ///
538    /// @param[in] call_inst
539    ///     The call instruction.
540    ///
541    /// @return
542    ///     True if the scan was successful; false if some operation
543    ///     failed
544    //------------------------------------------------------------------
545    bool
546    RemoveCXAAtExit (llvm::BasicBlock &basic_block);
547
548    //------------------------------------------------------------------
549    /// The top-level pass implementation
550    ///
551    /// @param[in] basic_block
552    ///     The function currently being processed.
553    ///
554    /// @return
555    ///     True on success; false otherwise
556    //------------------------------------------------------------------
557    bool
558    ResolveExternals (llvm::Function &llvm_function);
559
560    //------------------------------------------------------------------
561    /// A basic block-level pass to excise guard variables from the code.
562    /// The result for the function is passed through Clang as a static
563    /// variable.  Static variables normally have guard variables to
564    /// ensure that they are only initialized once.
565    //------------------------------------------------------------------
566
567    //------------------------------------------------------------------
568    /// Rewrite a load to a guard variable to return constant 0.
569    ///
570    /// @param[in] guard_load
571    ///     The load instruction to zero out.
572    //------------------------------------------------------------------
573    void
574    TurnGuardLoadIntoZero(llvm::Instruction* guard_load);
575
576    //------------------------------------------------------------------
577    /// The top-level pass implementation
578    ///
579    /// @param[in] basic_block
580    ///     The basic block currently being processed.
581    ///
582    /// @return
583    ///     True on success; false otherwise
584    //------------------------------------------------------------------
585    bool
586    RemoveGuards (llvm::BasicBlock &basic_block);
587
588    //------------------------------------------------------------------
589    /// A module-level pass to allocate all string literals in a separate
590    /// allocation and redirect references to them.
591    //------------------------------------------------------------------
592
593    //------------------------------------------------------------------
594    /// The top-level pass implementation
595    ///
596    /// @return
597    ///     True on success; false otherwise
598    //------------------------------------------------------------------
599    bool
600    ReplaceStrings ();
601
602    //------------------------------------------------------------------
603    /// A basick block-level pass to find all literals that will be
604    /// allocated as statics by the JIT (in contrast to the Strings,
605    /// which already are statics) and synthesize loads for them.
606    //------------------------------------------------------------------
607
608    //------------------------------------------------------------------
609    /// The top-level pass implementation
610    ///
611    /// @param[in] basic_block
612    ///     The basic block currently being processed.
613    ///
614    /// @return
615    ///     True on success; false otherwise
616    //------------------------------------------------------------------
617    bool
618    ReplaceStaticLiterals (llvm::BasicBlock &basic_block);
619
620    //------------------------------------------------------------------
621    /// A function-level pass to make all external variable references
622    /// point at the correct offsets from the void* passed into the
623    /// function.  ClangExpressionDeclMap::DoStructLayout() must be called
624    /// beforehand, so that the offsets are valid.
625    //------------------------------------------------------------------
626
627    //------------------------------------------------------------------
628    /// The top-level pass implementation
629    ///
630    /// @param[in] llvm_function
631    ///     The function currently being processed.
632    ///
633    /// @return
634    ///     True on success; false otherwise
635    //------------------------------------------------------------------
636    bool
637    ReplaceVariables (llvm::Function &llvm_function);
638
639    //------------------------------------------------------------------
640    /// A module-level pass to remove all global variables from the
641    /// module since it no longer should export or import any symbols.
642    //------------------------------------------------------------------
643
644    //------------------------------------------------------------------
645    /// The top-level pass implementation
646    ///
647    /// @param[in] llvm_module
648    ///     The module currently being processed.
649    ///
650    /// @return
651    ///     True on success; false otherwise
652    //------------------------------------------------------------------
653    bool
654    StripAllGVs (llvm::Module &llvm_module);
655
656    /// Flags
657    bool                                    m_resolve_vars;             ///< True if external variable references and persistent variable references should be resolved
658    lldb_private::ExecutionPolicy           m_execution_policy;         ///< True if the interpreter should be used to attempt to get a static result
659    bool                                    m_interpret_success;        ///< True if the interpreter successfully handled the whole expression
660    std::string                             m_func_name;                ///< The name of the function to translate
661    lldb_private::ConstString               m_result_name;              ///< The name of the result variable ($0, $1, ...)
662    lldb_private::TypeFromParser            m_result_type;              ///< The type of the result variable.
663    llvm::Module                           *m_module;                   ///< The module being processed, or NULL if that has not been determined yet.
664    std::auto_ptr<llvm::TargetData>         m_target_data;              ///< The target data for the module being processed, or NULL if there is no module.
665    lldb_private::ClangExpressionDeclMap   *m_decl_map;                 ///< The DeclMap containing the Decls
666    StaticDataAllocator                    *m_data_allocator;           ///< If non-NULL, the allocator to use for constant strings
667    llvm::Constant                         *m_CFStringCreateWithBytes;  ///< The address of the function CFStringCreateWithBytes, cast to the appropriate function pointer type
668    llvm::Constant                         *m_sel_registerName;         ///< The address of the function sel_registerName, cast to the appropriate function pointer type
669    lldb::ClangExpressionVariableSP        &m_const_result;             ///< This value should be set to the return value of the expression if it is constant and the expression has no side effects
670    lldb_private::Stream                   *m_error_stream;             ///< If non-NULL, the stream on which errors should be printed
671    lldb_private::Error                     m_interpreter_error;        ///< The error result from the IR interpreter
672
673    bool                                    m_has_side_effects;         ///< True if the function's result cannot be simply determined statically
674    llvm::StoreInst                        *m_result_store;             ///< If non-NULL, the store instruction that writes to the result variable.  If m_has_side_effects is true, this is NULL.
675    bool                                    m_result_is_pointer;        ///< True if the function's result in the AST is a pointer (see comments in ASTResultSynthesizer::SynthesizeBodyResult)
676
677    llvm::GlobalVariable                   *m_reloc_placeholder;        ///< A placeholder that will be replaced by a pointer to the final location of the static allocation.
678
679    //------------------------------------------------------------------
680    /// UnfoldConstant operates on a constant [Old] which has just been
681    /// replaced with a value [New].  We assume that new_value has
682    /// been properly placed early in the function, in front of the
683    /// first instruction in the entry basic block
684    /// [FirstEntryInstruction].
685    ///
686    /// UnfoldConstant reads through the uses of Old and replaces Old
687    /// in those uses with New.  Where those uses are constants, the
688    /// function generates new instructions to compute the result of the
689    /// new, non-constant expression and places them before
690    /// FirstEntryInstruction.  These instructions replace the constant
691    /// uses, so UnfoldConstant calls itself recursively for those.
692    ///
693    /// @param[in] llvm_function
694    ///     The function currently being processed.
695    ///
696    /// @return
697    ///     True on success; false otherwise
698    //------------------------------------------------------------------
699    static bool
700    UnfoldConstant (llvm::Constant *old_constant,
701                    llvm::Value *new_constant,
702                    llvm::Instruction *first_entry_inst);
703
704    //------------------------------------------------------------------
705    /// Construct a reference to m_reloc_placeholder with a given type
706    /// and offset.  This typically happens after inserting data into
707    /// m_data_allocator.
708    ///
709    /// @param[in] type
710    ///     The type of the value being loaded.
711    ///
712    /// @param[in] offset
713    ///     The offset of the value from the base of m_data_allocator.
714    ///
715    /// @return
716    ///     The Constant for the reference, usually a ConstantExpr.
717    //------------------------------------------------------------------
718    llvm::Constant *
719    BuildRelocation(llvm::Type *type,
720                    uint64_t offset);
721
722    //------------------------------------------------------------------
723    /// Commit the allocation in m_data_allocator and use its final
724    /// location to replace m_reloc_placeholder.
725    ///
726    /// @param[in] module
727    ///     The module that m_data_allocator resides in
728    ///
729    /// @return
730    ///     True on success; false otherwise
731    //------------------------------------------------------------------
732    bool
733    CompleteDataAllocation ();
734
735};
736
737#endif
738