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