Skip to content
  1. Sep 11, 2018
  2. Sep 06, 2018
    • Lang Hames's avatar
      [ORC] Make RuntimeDyldObjectLinkingLayer2 take memory managers by unique_ptr. · bf985258
      Lang Hames authored
      The existing memory manager API can not be shared between objects when linking
      concurrently (since there is no way to know which concurrent allocations were
      performed on behalf of which object, and hence which allocations would be safe
      to finalize when finalizeMemory is called). For now, we can work around this by
      requiring a new memory manager for each object.
      
      This change only affects the concurrent version of the ORC APIs.
      
      llvm-svn: 341579
      bf985258
    • Lang Hames's avatar
      [ORC] Remove the mapSectionAddress method from RuntimeDyldObjectLinkingLayer2. · a5f33c86
      Lang Hames authored
      Section address mappings can be applied using the RuntimeDyld instance passed to
      the RuntimeDyld::MemoryManager::notifyObjectLoaded method. Proving an alternate
      route via RuntimeDyldObjectLinkingLayer2 is redundant.
      
      llvm-svn: 341578
      a5f33c86
  3. Sep 02, 2018
  4. Aug 31, 2018
    • Lang Hames's avatar
      [ORC] Add utilities to RTDyldObjectLinkingLayer2 to simplify symbol flag · 6d32002e
      Lang Hames authored
      management and materialization responsibility registration.
      
      The setOverrideObjectFlagsWithResponsibilityFlags method instructs
      RTDyldObjectlinkingLayer2 to override the symbol flags produced by RuntimeDyld with
      the flags provided by the MaterializationResponsibility instance. This can be used
      to enable symbol visibility (hidden/exported) for COFF object files, which do not
      currently support the SF_Exported flag.
      
      The setAutoClaimResponsibilityForObjectSymbols method instructs
      RTDyldObjectLinkingLayer2 to claim responsibility for any symbols provided by a
      given object file that were not already in the MaterializationResponsibility
      instance. Setting this flag allows higher-level program representations (e.g.
      LLVM IR) to be added based on only a subset of the symbols they provide, without
      having to write intervening layers to scan and add the additional symbols. This
      trades diagnostic quality for convenience however: If all symbols are enumerated
      up-front then clashes can be detected and reported early. If this option is set,
      clashes for the additional symbols may not be detected until late, and detection
      may depend on the flow of control through JIT'd code.
      
      llvm-svn: 341154
      6d32002e
  5. Aug 28, 2018
    • Lang Hames's avatar
      [ORC] Replace lookupFlags in JITSymbolResolver with getResponsibilitySet. · 6cadc7c0
      Lang Hames authored
      The new method name/behavior more closely models the way it was being used.
      It also fixes an assertion that can occur when using the new ORC Core APIs,
      where flags alone don't necessarily provide enough context to decide whether
      the caller is responsible for materializing a given symbol (which was always
      the reason this API existed).
      
      The default implementation of getResponsibilitySet uses lookupFlags to determine
      responsibility as before, so existing JITSymbolResolvers should continue to
      work.
      
      llvm-svn: 340874
      6cadc7c0
    • Lang Hames's avatar
      [ORC] Add an addObjectFile method to LLJIT. · 37a66413
      Lang Hames authored
      The addObjectFile method adds the given object file to the JIT session, making
      its code available for execution.
      
      Support for the -extra-object flag is added to lli when operating in
      -jit-kind=orc-lazy mode to support testing of this feature.
      
      llvm-svn: 340870
      37a66413
  6. Aug 26, 2018
    • Lang Hames's avatar
      [ORC] Do not include non-global symbols in getObjectSymbolFlags. · 60511582
      Lang Hames authored
      Private symbols are not visible outside the object file, and so not defined by
      the object file from ORC's perspective.
      
      No test case yet. Ideally this would be a unit test parsing a checked-in binary,
      but I am not aware of any way to reference the LLVM source root from a unit
      test.
      
      llvm-svn: 340703
      60511582
  7. Aug 18, 2018
    • Lang Hames's avatar
      [RuntimeDyld] Fix a bug in RuntimeDyld::loadObjectImpl that was over-allocating · 8e296229
      Lang Hames authored
      space for common symbols.
      
      Patch by Dmitry Sidorov. Thanks Dmitry!
      
      Differential revision: https://reviews.llvm.org/D50240
      
      llvm-svn: 340125
      8e296229
    • Lang Hames's avatar
      [ORC] Rename 'finalize' to 'emit' to avoid potential confusion. · 76e21c97
      Lang Hames authored
      An emitted symbol has had its contents written and its memory protections
      applied, but it is not automatically ready to execute.
      
      Prior to ORC supporting concurrent compilation, the term "finalized" could be
      interpreted two different (but effectively equivalent) ways: (1) The finalized
      symbol's contents have been written and its memory protections applied, and (2)
      the symbol is ready to run. Now that ORC supports concurrent compilation, sense
      (1) no longer implies sense (2). We have already introduced a new term, 'ready',
      to capture sense (2), so rename sense (1) to 'emitted' to avoid any lingering
      confusion.
      
      llvm-svn: 340115
      76e21c97
  8. Aug 17, 2018
    • Lang Hames's avatar
      [ORC] Rename VSO to JITDylib. · d5f56c59
      Lang Hames authored
      VSO was a little close to VDSO (an acronym on Linux for Virtual Dynamic Shared
      Object) for comfort. It also risks giving the impression that instances of this
      class could be shared between ExecutionSessions, which they can not.
      
      JITDylib seems moderately less confusing, while still hinting at how this
      class is intended to be used, i.e. as a JIT-compiled stand-in for a dynamic
      library (code that would have been a dynamic library if you had wanted to
      compile it ahead of time).
      
      llvm-svn: 340084
      d5f56c59
  9. Aug 15, 2018
  10. Aug 06, 2018
  11. Aug 02, 2018
    • Lang Hames's avatar
      [ORC] Add a re-exports fallback definition generator. · be1066de
      Lang Hames authored
      An instance of ReexportsFallbackDefinitionGenerator can be attached to a VSO
      (via setFallbackDefinitionGenerator) to re-export symbols on demandy from a
      backing VSO.
      
      llvm-svn: 338764
      be1066de
    • Lang Hames's avatar
      [ORC] Add a 'Callable' flag to JITSymbolFlags. · bfea8cdc
      Lang Hames authored
      The callable flag can be used to indicate that a symbol is callable. If present,
      the symbol is callable. If absent, the symbol may or may not be callable (the
      client must determine this by context, for example by examining the program
      representation that will provide the symbol definition).
      
      This flag will be used in the near future to enable creation of lazy compilation
      stubs based on SymbolFlagsMap instances only (without having to provide
      additional information to determine which symbols need stubs).
      
      llvm-svn: 338649
      bfea8cdc
  12. Jul 30, 2018
  13. Jul 25, 2018
    • Andres Freund's avatar
      Move JIT listener C binding fallbackks to ExecutionEngineBindings.cpp. · ee10ce71
      Andres Freund authored
      Initially, in https://reviews.llvm.org/D44890, I had these defined as
      empty functions inside the header when the respective event listener
      was not built in. As done in that commit, that wasn't correct, because
      it was a ODR violation.  Krasimir hot-fixed that in r333265, but that
      wasn't quite right either, because it'd lead to the symbol not being
      available.
      
      Instead just move the fallbacksto ExecutionEngineBindings.cpp. Could
      define them as static inlines in the header too, but I don't think it
      matters.
      
      Reviewers: whitequark
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D49654
      
      llvm-svn: 337930
      ee10ce71
  14. Jul 24, 2018
    • Andres Freund's avatar
      Add PerfJITEventListener for perf profiling support. · 376a3d36
      Andres Freund authored
      This new JIT event listener supports generating profiling data for
      the linux 'perf' profiling tool, allowing it to generate function and
      instruction level profiles.
      
      Currently this functionality is not enabled by default, but must be
      enabled with LLVM_USE_PERF=yes.  Given that the listener has no
      dependencies, it might be sensible to enable by default once the
      initial issues have been shaken out.
      
      I followed existing precedent in registering the listener by default
      in lli. Should there be a decision to enable this by default on linux,
      that should probably be changed.
      
      Please note that until https://reviews.llvm.org/D47343 is resolved,
      using this functionality with mcjit rather than orcjit will not
      reliably work.
      
      Disregarding the previous comment, here's an example:
      
      $ cat /tmp/expensive_loop.c
      
      bool stupid_isprime(uint64_t num)
      {
              if (num == 2)
                      return true;
              if (num < 1 || num % 2 == 0)
                      return false;
              for(uint64_t i = 3; i < num / 2; i+= 2) {
                      if (num % i == 0)
                              return false;
              }
              return true;
      }
      
      int main(int argc, char **argv)
      {
              int numprimes = 0;
      
              for (uint64_t num = argc; num < 100000; num++)
              {
                      if (stupid_isprime(num))
                              numprimes++;
              }
      
              return numprimes;
      }
      
      $ clang -ggdb -S -c -emit-llvm /tmp/expensive_loop.c -o
      /tmp/expensive_loop.ll
      
      $ perf record -o perf.data -g -k 1 ./bin/lli -jit-kind=mcjit /tmp/expensive_loop.ll 1
      
      $ perf inject --jit -i perf.data -o perf.jit.data
      
      $ perf report -i perf.jit.data
      -   92.59%  lli      jitted-5881-2.so                   [.] stupid_isprime
           stupid_isprime
           main
           llvm::MCJIT::runFunction
           llvm::ExecutionEngine::runFunctionAsMain
           main
           __libc_start_main
           0x4bf6258d4c544155
      +    0.85%  lli      ld-2.27.so                         [.] do_lookup_x
      
      And line-level annotations also work:
             │              for(uint64_t i = 3; i < num / 2; i+= 2) {
             │1 30:   movq   $0x3,-0x18(%rbp)
        0.03 │1 38:   mov    -0x18(%rbp),%rax
        0.03 │        mov    -0x10(%rbp),%rcx
             │        shr    $0x1,%rcx
        3.63 │     ┌──cmp    %rcx,%rax
             │     ├──jae    6f
             │     │                if (num % i == 0)
        0.03 │     │  mov    -0x10(%rbp),%rax
             │     │  xor    %edx,%edx
       89.00 │     │  divq   -0x18(%rbp)
             │     │  cmp    $0x0,%rdx
        0.22 │     │↓ jne    5f
             │     │                        return false;
             │     │  movb   $0x0,-0x1(%rbp)
             │     │↓ jmp    73
             │     │        }
        3.22 │1 5f:│↓ jmp    61
             │     │        for(uint64_t i = 3; i < num / 2; i+= 2) {
      
      Subscribers: mgorny, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D44892
      
      llvm-svn: 337789
      376a3d36
  15. Jul 21, 2018
  16. Jul 20, 2018
    • Reid Kleckner's avatar
      Revert r337595 "[ORC] Add new symbol lookup methods to ExecutionSessionBase in preparation for" · 7ed83591
      Reid Kleckner authored
      Breaks the build with LLVM_ENABLE_THREADS=OFF.
      
      llvm-svn: 337608
      7ed83591
    • Lang Hames's avatar
      [ORC] Add new symbol lookup methods to ExecutionSessionBase in preparation for · 732d116a
      Lang Hames authored
      deprecating SymbolResolver and AsynchronousSymbolQuery.
      
      Both lookup overloads take a VSO search order to perform the lookup. The first
      overload is non-blocking and takes OnResolved and OnReady callbacks. The second
      is blocking, takes a boolean flag to indicate whether to wait until all symbols
      are ready, and returns a SymbolMap. Both overloads take a RegisterDependencies
      function to register symbol dependencies (if any) on the query.
      
      llvm-svn: 337595
      732d116a
    • Lang Hames's avatar
      [ORC] Simplify VSO::lookupFlags to return the flags map. · d4df0f17
      Lang Hames authored
      This discards the unresolved symbols set and returns the flags map directly
      (rather than mutating it via the first argument).
      
      The unresolved symbols result made it easy to chain lookupFlags calls, but such
      chaining should be rare to non-existant (especially now that symbol resolvers
      are being deprecated) so the simpler method signature is preferable.
      
      llvm-svn: 337594
      d4df0f17
    • Lang Hames's avatar
      [ORC] Replace SymbolResolvers in the new ORC layers with search orders on VSOs. · fd0c1e71
      Lang Hames authored
      A search order is a list of VSOs to be searched linearly to find symbols. Each
      VSO now has a search order that will be used when fixing up definitions in that
      VSO. Each VSO's search order defaults to just that VSO itself.
      
      This is a first step towards removing symbol resolvers from ORC altogether. In
      practice symbol resolvers tended to be used to implement a search order anyway,
      sometimes with additional programatic generation of symbols. Now that VSOs
      support programmatic generation of definitions via fallback generators, search
      orders provide a cleaner way to achieve the desired effect (while removing a lot
      of boilerplate).
      
      llvm-svn: 337593
      fd0c1e71
  17. Jul 12, 2018
  18. Jul 11, 2018
  19. Jul 09, 2018
    • Lang Hames's avatar
      [ORC] Rename MaterializationResponsibility::delegate to replace and add a new · f07dad3d
      Lang Hames authored
      delegate method (and unit test).
      
      The name 'replace' better captures what the old delegate method did: it
      returned materialization responsibility for a set of symbols to the VSO.
      
      The new delegate method delegates responsibility for a set of symbols to a new
      MaterializationResponsibility instance. This can be used to split responsibility
      between multiple threads, or multiple materialization methods.
      
      llvm-svn: 336603
      f07dad3d
  20. Jul 05, 2018
  21. Jul 03, 2018
  22. Jun 27, 2018
  23. Jun 26, 2018
    • Lang Hames's avatar
      [ORC] Add LLJIT and LLLazyJIT, and replace OrcLazyJIT in LLI with LLLazyJIT. · 6a94134b
      Lang Hames authored
      LLJIT is a prefabricated ORC based JIT class that is meant to be the go-to
      replacement for MCJIT. Unlike OrcMCJITReplacement (which will continue to be
      supported) it is not API or bug-for-bug compatible, but targets the same
      use cases: Simple, non-lazy compilation and execution of LLVM IR.
      
      LLLazyJIT extends LLJIT with support for function-at-a-time lazy compilation,
      similar to what was provided by LLVM's original (now long deprecated) JIT APIs.
      
      This commit also contains some simple utility classes (CtorDtorRunner2,
      LocalCXXRuntimeOverrides2, JITTargetMachineBuilder) to support LLJIT and
      LLLazyJIT.
      
      Both of these classes are works in progress. Feedback from JIT clients is very
      welcome!
      
      llvm-svn: 335670
      6a94134b
    • Lang Hames's avatar
      [ORC] Reset AsynchronousSymbolQuery's NotifySymbolsResolved callback on error. · 2795a0a0
      Lang Hames authored
      AsynchronousSymbolQuery::canStillFail checks the value of the callback to
      prevent sending it redundant error notifications, so we need to reset it after
      running it.
      
      llvm-svn: 335664
      2795a0a0
    • Lang Hames's avatar
      [ORC] Move the VSOList typedef out of VSO. · 831c5758
      Lang Hames authored
      llvm-svn: 335663
      831c5758
Loading