Skip to content
  1. Sep 11, 2018
  2. Aug 28, 2018
    • 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
  3. 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
  4. 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
  5. Jul 03, 2018
  6. 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
  7. May 30, 2018
    • Lang Hames's avatar
      [ORC] Update JITCompileCallbackManager to support multi-threaded code. · bd0cb787
      Lang Hames authored
      Previously JITCompileCallbackManager only supported single threaded code. This
      patch embeds a VSO (see include/llvm/ExecutionEngine/Orc/Core.h) in the callback
      manager. The VSO ensures that the compile callback is only executed once and that
      the resulting address cached for use by subsequent re-entries.
      
      llvm-svn: 333490
      bd0cb787
  8. May 17, 2018
    • Lang Hames's avatar
      [ORC] Rewrite the VSO symbol table yet again. Update related utilities. · d261e125
      Lang Hames authored
      VSOs now track dependencies for materializing symbols. Each symbol must have its
      dependencies registered with the VSO prior to finalization. Usually this will
      involve registering the dependencies returned in
      AsynchronousSymbolQuery::ResolutionResults for queries made while linking the
      symbols being materialized.
      
      Queries against symbols are notified that a symbol is ready once it and all of
      its transitive dependencies are finalized, allowing compilation work to be
      broken up and moved between threads without queries returning until their
      symbols fully safe to access / execute.
      
      Related utilities (VSO, MaterializationUnit, MaterializationResponsibility) are
      updated to support dependence tracking and more explicitly track responsibility
      for symbols from the point of definition until they are finalized.
      
      llvm-svn: 332541
      d261e125
  9. May 14, 2018
    • Nicola Zaghen's avatar
      Rename DEBUG macro to LLVM_DEBUG. · d34e60ca
      Nicola Zaghen authored
          
      The DEBUG() macro is very generic so it might clash with other projects.
      The renaming was done as follows:
      - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
      - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM
      - Manual change to APInt
      - Manually chage DOCS as regex doesn't match it.
      
      In the transition period the DEBUG() macro is still present and aliased
      to the LLVM_DEBUG() one.
      
      Differential Revision: https://reviews.llvm.org/D43624
      
      llvm-svn: 332240
      d34e60ca
  10. Apr 30, 2018
    • Nico Weber's avatar
      IWYU for llvm-config.h in llvm, additions. · 432a3883
      Nico Weber authored
      See r331124 for how I made a list of files missing the include.
      I then ran this Python script:
      
          for f in open('filelist.txt'):
              f = f.strip()
              fl = open(f).readlines()
      
              found = False
              for i in xrange(len(fl)):
                  p = '#include "llvm/'
                  if not fl[i].startswith(p):
                      continue
                  if fl[i][len(p):] > 'Config':
                      fl.insert(i, '#include "llvm/Config/llvm-config.h"\n')
                      found = True
                      break
              if not found:
                  print 'not found', f
              else:
                  open(f, 'w').write(''.join(fl))
      
      and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p`
      and tried to fix include ordering and whatnot.
      
      No intended behavior change.
      
      llvm-svn: 331184
      432a3883
  11. Apr 22, 2018
  12. Apr 13, 2018
  13. Apr 11, 2018
    • David Blaikie's avatar
      Rename *CommandFlags.def to *CommandFlags.inc · 4333f970
      David Blaikie authored
      These aren't the .def style files used in LLVM that require a macro
      defined before their inclusion - they're just basic non-modular includes
      to stamp out command line flag variables.
      
      llvm-svn: 329840
      4333f970
  14. Apr 02, 2018
  15. Mar 15, 2018
  16. Mar 14, 2018
  17. Feb 14, 2018
  18. Feb 09, 2018
    • Lang Hames's avatar
      [ORC] Remove Layer handles from the layer concept. · 0976cee8
      Lang Hames authored
      Handles were returned by addModule and used as keys for removeModule,
      findSymbolIn, and emitAndFinalize. Their job is now subsumed by VModuleKeys,
      which simplify resource management by providing a consistent handle across all
      layers.
      
      llvm-svn: 324700
      0976cee8
  19. Feb 06, 2018
    • Lang Hames's avatar
      [ORC] Remove some unused lambda captures. · e33798f5
      Lang Hames authored
      llvm-svn: 324410
      e33798f5
    • Lang Hames's avatar
      [ORC] Start migrating ORC layers to use the new ORC Core.h APIs. · 4b546c91
      Lang Hames authored
      In particular this patch switches RTDyldObjectLinkingLayer to use
      orc::SymbolResolver and threads the requried changse (ExecutionSession
      references and VModuleKeys) through the existing layer APIs.
      
      The purpose of the new resolver interface is to improve query performance and
      better support parallelism, both in JIT'd code and within the compiler itself.
      
      The most visibile change is switch of the <Layer>::addModule signatures from:
      
      Expected<Handle> addModule(std::shared_ptr<ModuleType> Mod,
                                 std::shared_ptr<JITSymbolResolver> Resolver)
      
      to:
      
      Expected<Handle> addModule(VModuleKey K, std::shared_ptr<ModuleType> Mod);
      
      Typical usage of addModule will now look like:
      
      auto K = ES.allocateVModuleKey();
      Resolvers[K] = createSymbolResolver(...);
      Layer.addModule(K, std::move(Mod));
      
      See the BuildingAJIT tutorial code for example usage.
      
      llvm-svn: 324405
      4b546c91
  20. Jan 19, 2018
    • Lang Hames's avatar
      [ORC] Re-apply r322913 with a fix for a read-after-free error. · b72f4845
      Lang Hames authored
      ExternalSymbolMap now stores the string key (rather than using a StringRef),
      as the object file backing the key may be removed at any time.
      
      llvm-svn: 323001
      b72f4845
    • Lang Hames's avatar
      [ORC] Revert r322913 while I investigate an ASan failure. · 44efd042
      Lang Hames authored
      llvm-svn: 322914
      44efd042
    • Lang Hames's avatar
      [ORC] Redesign the JITSymbolResolver interface to support bulk queries. · 817df9fa
      Lang Hames authored
      Bulk queries reduce IPC/RPC overhead for cross-process JITing and expose
      opportunities for parallel compilation.
      
      The two new query methods are lookupFlags, which finds the flags for each of a
      set of symbols; and lookup, which finds the address and flags for each of a
      set of symbols. (See doxygen comments for more details.)
      
      The existing JITSymbolResolver class is renamed LegacyJITSymbolResolver, and
      modified to extend the new JITSymbolResolver class using the following scheme:
      
      - lookupFlags is implemented by calling findSymbolInLogicalDylib for each of the
      symbols, then returning the result of calling getFlags() on each of these
      symbols. (Importantly: lookupFlags does NOT call getAddress on the returned
      symbols, so lookupFlags will never trigger materialization, and lookupFlags will
      never call findSymbol, so only symbols that are part of the logical dylib will
      return results.)
      
      - lookup is implemented by calling findSymbolInLogicalDylib for each symbol and
      falling back to findSymbol if findSymbolInLogicalDylib returns a null result.
      Assuming a symbol is found its getAddress method is called to materialize it and
      the result (if getAddress succeeds) is stored in the result map, or the error
      (if getAddress fails) is returned immediately from lookup. If any symbol is not
      found then lookup returns immediately with an error.
      
      This change will break any out-of-tree derivatives of JITSymbolResolver. This
      can be fixed by updating those classes to derive from LegacyJITSymbolResolver
      instead.
      
      llvm-svn: 322913
      817df9fa
  21. Jan 09, 2018
    • Craig Topper's avatar
      [lli] Make lli support -mcpu=native for CPU autodetection · 243f20f1
      Craig Topper authored
      llc, opt, and clang can all autodetect the CPU and supported features. lli cannot as far as I could tell.
      
      This patch uses the getCPUStr() and introduces a new getCPUFeatureList() and uses those in lli in place of MCPU and MAttrs.
      
      Ideally, we would merge getCPUFeatureList and getCPUFeatureStr, but opt and llc need a string and lli wanted a list. Maybe we should just return the SubtargetFeature object and let the caller decide what it needs?
      
      Differential Revision: https://reviews.llvm.org/D41833
      
      llvm-svn: 322100
      243f20f1
  22. Nov 27, 2017
    • David Blaikie's avatar
      Rename CommandFlags.h -> CommandFlags.def · c14bfec4
      David Blaikie authored
      Since this isn't a real header - it includes static functions and had
      external linkage variables (though this change makes them static, since
      that's what they should be) so can't be included more than once in a
      program.
      
      llvm-svn: 319082
      c14bfec4
  23. Sep 04, 2017
    • Lang Hames's avatar
      [ORC] Refactor OrcRemoteTarget code to expose its RPC API, reduce · 9e68b734
      Lang Hames authored
      code duplication in the client, and improve error propagation.
      
      This patch moves the OrcRemoteTarget rpc::Function declarations from
      OrcRemoteTargetRPCAPI into their own namespaces under llvm::orc::remote so that
      they can be used in new contexts (in particular, a remote-object-file adapter
      layer that I will commit shortly).
      
      Code duplication in OrcRemoteTargetClient (especially in loops processing the
      code, rw-data and ro-data allocations) is removed by moving the loop bodies
      into their own functions.
      
      Error propagation is (slightly) improved by adding an ErrorReporter functor to
      the OrcRemoteTargetClient -- Errors that can't be returned (because they occur
      in destructors, or behind stable APIs that don't provide error returns) can be
      sent to the ErrorReporter instead. Some methods in the Client API are also
      changed to make better use of the Expected class: returning Expected<T>s rather
      than returning Errors and taking T&s to store the results.
      
      llvm-svn: 312500
      9e68b734
  24. Aug 28, 2017
  25. Aug 11, 2017
  26. Aug 03, 2017
    • Rafael Espindola's avatar
      Delete Default and JITDefault code models · 79e238af
      Rafael Espindola authored
      IMHO it is an antipattern to have a enum value that is Default.
      
      At any given piece of code it is not clear if we have to handle
      Default or if has already been mapped to a concrete value. In this
      case in particular, only the target can do the mapping and it is nice
      to make sure it is always done.
      
      This deletes the two default enum values of CodeModel and uses an
      explicit Optional<CodeModel> when it is possible that it is
      unspecified.
      
      llvm-svn: 309911
      79e238af
  27. Jul 11, 2017
  28. Jul 07, 2017
    • Lang Hames's avatar
      [ORC] Errorize the ORC APIs. · 4ce98662
      Lang Hames authored
      This patch updates the ORC layers and utilities to return and propagate
      llvm::Errors where appropriate. This is necessary to allow ORC to safely handle
      error cases in cross-process and remote JITing.
      
      llvm-svn: 307350
      4ce98662
  29. Jul 04, 2017
    • Lang Hames's avatar
      [Orc] Remove the memory manager argument to addModule, and de-templatize the · 5b518160
      Lang Hames authored
      symbol resolver argument.
      
      De-templatizing the symbol resolver is part of the ongoing simplification of
      ORC layer API.
      
      Removing the memory management argument (and delegating construction of memory
      managers for RTDyldObjectLinkingLayer to a functor passed in to the constructor)
      allows us to build JITs whose base object layers need not be compatible with
      RTDyldObjectLinkingLayer's memory mangement scheme. For example, a 'remote
      object layer' that sends fully relocatable objects directly to the remote does
      not need a memory management scheme at all (that will be handled by the remote).
      
      llvm-svn: 307058
      5b518160
  30. Jun 24, 2017
  31. Jun 23, 2017
  32. Jun 22, 2017
  33. Jun 20, 2017
Loading