Skip to content
  1. Feb 19, 2014
  2. Feb 18, 2014
    • Rafael Espindola's avatar
      Fix PR18743. · 09dcc6a5
      Rafael Espindola authored
      The IR
      @foo = private constant i32 42
      
      is valid, but before this patch we would produce an invalid MachO from it. It
      was invalid because it would use an L label in a section where the liker needs
      the labels in order to atomize it.
      
      One way of fixing it would be to just reject this IR in the backend, but that
      would not be very front end friendly.
      
      What this patch does is use an 'l' prefix in sections that we know the linker
      requires symbols for atomizing them. This allows frontends to just use
      private and not worry about which sections they go to or how the linker handles
      them.
      
      One small issue with this strategy is that now a symbol name depends on the
      section, which is not available before codegen. This is not a problem in
      practice. The reason is that it only happens with private linkage, which will
      be ignored by the non codegen users (llvm-nm and llvm-ar).
      
      llvm-svn: 201608
      09dcc6a5
  3. Jan 23, 2014
    • Juergen Ributzka's avatar
      Add target analysis passes to the codegen pipeline for MCJIT. · 5fe955cb
      Juergen Ributzka authored
      This patch adds the target analysis passes (usually TargetTransformInfo) to the
      codgen pipeline. We also expose now the AddAnalysisPasses method through the C
      API, because the optimizer passes would also benefit from better target-specific
      cost models.
      
      Reviewed by Andrew Kaylor
      
      llvm-svn: 199926
      5fe955cb
  4. Jan 15, 2014
    • Quentin Colombet's avatar
      [LTO] Add a hook to map LLVM diagnostics into the clients of LTO. · 5fa1f6f5
      Quentin Colombet authored
      Add a hook in the C API of LTO so that clients of the code generator can set
      their own handler for the LLVM diagnostics.
      The handler is defined like this:
      typedef void (*lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t
      severity, const char *diag, void *ctxt)
      - severity says how bad this is.
      - diag is a string that contains the diagnostic message.
      - ctxt is the registered context for this handler.
      
      This hook is more general than the lto_get_error_message, since this function
      keeps only the latest message and can only be queried when something went wrong
      (no warning for instance).
      
      <rdar://problem/15517596>
      
      llvm-svn: 199338
      5fa1f6f5
  5. Jan 14, 2014
    • Duncan P. N. Exon Smith's avatar
      Reapply "LTO: add API to set strategy for -internalize" · 93be7c4f
      Duncan P. N. Exon Smith authored
      Reapply r199191, reverted in r199197 because it carelessly broke
      Other/link-opts.ll.  The problem was that calling
      createInternalizePass("main") would select
      createInternalizePass(bool("main")) instead of
      createInternalizePass(ArrayRef<const char *>("main")).  This commit
      fixes the bug.
      
      The original commit message follows.
      
      Add API to LTOCodeGenerator to specify a strategy for the -internalize
      pass.
      
      This is a new attempt at Bill's change in r185882, which he reverted in
      r188029 due to problems with the gold linker.  This puts the onus on the
      linker to decide whether (and what) to internalize.
      
      In particular, running internalize before outputting an object file may
      change a 'weak' symbol into an internal one, even though that symbol
      could be needed by an external object file --- e.g., with arclite.
      
      This patch enables three strategies:
      
      - LTO_INTERNALIZE_FULL: the default (and the old behaviour).
      - LTO_INTERNALIZE_NONE: skip -internalize.
      - LTO_INTERNALIZE_HIDDEN: only -internalize symbols with hidden
        visibility.
      
      LTO_INTERNALIZE_FULL should be used when linking an executable.
      
      Outputting an object file (e.g., via ld -r) is more complicated, and
      depends on whether hidden symbols should be internalized.  E.g., for
      ld -r, LTO_INTERNALIZE_NONE can be used when -keep_private_externs, and
      LTO_INTERNALIZE_HIDDEN can be used otherwise.  However,
      LTO_INTERNALIZE_FULL is inappropriate, since the output object file will
      eventually need to link with others.
      
      lto_codegen_set_internalize_strategy() sets the strategy for subsequent
      calls to lto_codegen_write_merged_modules() and lto_codegen_compile*().
      
      <rdar://problem/14334895>
      
      llvm-svn: 199244
      93be7c4f
    • NAKAMURA Takumi's avatar
      Revert r199191, "LTO: add API to set strategy for -internalize" · 23c0ab53
      NAKAMURA Takumi authored
      Please update also Other/link-opts.ll, in next time.
      
      llvm-svn: 199197
      23c0ab53
    • Duncan P. N. Exon Smith's avatar
      LTO: add API to set strategy for -internalize · 43ea3478
      Duncan P. N. Exon Smith authored
      Add API to LTOCodeGenerator to specify a strategy for the -internalize
      pass.
      
      This is a new attempt at Bill's change in r185882, which he reverted in
      r188029 due to problems with the gold linker.  This puts the onus on the
      linker to decide whether (and what) to internalize.
      
      In particular, running internalize before outputting an object file may
      change a 'weak' symbol into an internal one, even though that symbol
      could be needed by an external object file --- e.g., with arclite.
      
      This patch enables three strategies:
      
      - LTO_INTERNALIZE_FULL: the default (and the old behaviour).
      - LTO_INTERNALIZE_NONE: skip -internalize.
      - LTO_INTERNALIZE_HIDDEN: only -internalize symbols with hidden
        visibility.
      
      LTO_INTERNALIZE_FULL should be used when linking an executable.
      
      Outputting an object file (e.g., via ld -r) is more complicated, and
      depends on whether hidden symbols should be internalized.  E.g., for
      ld -r, LTO_INTERNALIZE_NONE can be used when -keep_private_externs, and
      LTO_INTERNALIZE_HIDDEN can be used otherwise.  However,
      LTO_INTERNALIZE_FULL is inappropriate, since the output object file will
      eventually need to link with others.
      
      lto_codegen_set_internalize_strategy() sets the strategy for subsequent
      calls to lto_codegen_write_merged_modules() and lto_codegen_compile*().
      
      <rdar://problem/14334895>
      
      llvm-svn: 199191
      43ea3478
  6. Jan 13, 2014
    • Chandler Carruth's avatar
      [cleanup] Move the Dominators.h and Verifier.h headers into the IR · 5ad5f15c
      Chandler Carruth authored
      directory. These passes are already defined in the IR library, and it
      doesn't make any sense to have the headers in Analysis.
      
      Long term, I think there is going to be a much better way to divide
      these matters. The dominators code should be fully separated into the
      abstract graph algorithm and have that put in Support where it becomes
      obvious that evn Clang's CFGBlock's can use it. Then the verifier can
      manually construct dominance information from the Support-driven
      interface while the Analysis library can provide a pass which both
      caches, reconstructs, and supports a nice update API.
      
      But those are very long term, and so I don't want to leave the really
      confusing structure until that day arrives.
      
      llvm-svn: 199082
      5ad5f15c
  7. Jan 10, 2014
  8. Jan 07, 2014
  9. Jan 03, 2014
    • Rafael Espindola's avatar
      Make the llvm mangler depend only on DataLayout. · 58873566
      Rafael Espindola authored
      Before this patch any program that wanted to know the final symbol name of a
      GlobalValue had to link with Target.
      
      This patch implements a compromise solution where the mangler uses DataLayout.
      This way, any tool that already links with Target (llc, clang) gets the exact
      behavior as before and new IR files can be mangled without linking with Target.
      
      With this patch the mangler is constructed with just a DataLayout and DataLayout
      is extended to include the information the Mangler needs.
      
      llvm-svn: 198438
      58873566
  10. Dec 12, 2013
  11. Dec 05, 2013
    • Rafael Espindola's avatar
      Remove the isImplicitlyPrivate argument of getNameWithPrefix. · 117b20c4
      Rafael Espindola authored
      getSymbolWithGlobalValueBase use is to create a name of a new symbol based
      on the name of an existing GV. Assert that and then remove the last call
      to pass true to isImplicitlyPrivate.
      
      This gives the mangler API a 1:1 mapping from GV to names, which is what we
      need to drop the mangler dependency on the target (and use an extended
      datalayout instead).
      
      llvm-svn: 196472
      117b20c4
  12. Nov 16, 2013
  13. Nov 12, 2013
    • Justin Bogner's avatar
      Protect user-supplied runtime library functions in LTO · b10a520c
      Justin Bogner authored
      Add user-supplied C runtime and compiler-rt library functions to
      llvm.compiler.used to protect them from premature optimization by
      passes like -globalopt and -ipsccp.  Calls to (seemingly unused)
      runtime library functions can be added by -instcombine and instruction
      lowering.
      
      Patch by Duncan Exon Smith, thanks!
      
      Fixes <rdar://problem/14740087>
      
      llvm-svn: 194514
      b10a520c
  14. Oct 31, 2013
    • Rafael Espindola's avatar
      Use LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN instead of the "dso list". · 282a4703
      Rafael Espindola authored
      There are two ways one could implement hiding of linkonce_odr symbols in LTO:
      * LLVM tells the linker which symbols can be hidden if not used from native
        files.
      * The linker tells LLVM which symbols are not used from other object files,
        but will be put in the dso symbol table if present.
      
      GOLD's API is the second option. It was implemented almost 1:1 in llvm by
      passing the list down to internalize.
      
      LLVM already had partial support for the first option. It is also very similar
      to how ld64 handles hiding these symbols when *not* doing LTO.
      
      This patch then
      * removes the APIs for the DSO list.
      * marks LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN all linkonce_odr unnamed_addr
        global values and other linkonce_odr whose address is not used.
      * makes the gold plugin responsible for handling the API mismatch.
      
      llvm-svn: 193800
      282a4703
  15. Oct 29, 2013
  16. Oct 16, 2013
  17. Oct 03, 2013
    • Rafael Espindola's avatar
      Optimize linkonce_odr unnamed_addr functions during LTO. · cda2911c
      Rafael Espindola authored
      Generalize the API so we can distinguish symbols that are needed just for a DSO
      symbol table from those that are used from some native .o.
      
      The symbols that are only wanted for the dso symbol table can be dropped if
      llvm can prove every other dso has a copy (linkonce_odr) and the address is not
      important (unnamed_addr).
      
      llvm-svn: 191922
      cda2911c
  18. Oct 02, 2013
  19. Sep 30, 2013
  20. Sep 25, 2013
  21. Sep 04, 2013
  22. Aug 27, 2013
    • Shuxin Yang's avatar
      Revert 189297, the original commit message is following. · 388b52c0
      Shuxin Yang authored
      ----
        Add new API lto_codegen_compile_parallel().
      
        This API is proposed by Nick Kledzik. The semantic is:
      
        --------------------------------------------------------------------------
         Generate code for merged module into an array of native object files. On 
         success returns a pointer to an array of NativeObjectFile.  The count 
         parameter returns the number of elements in the array.  Each element is 
         a pointer/length for a generated mach-o/ELF buffer.  The buffer is owned
         by the lto_code_gen_t and will be freed when lto_codegen_dispose() is called, 
         or lto_codegen_compile() is called again. On failure, returns NULL 
         (check lto_get_error_message() for details).
      
         extern const struct  NativeObjectFile*
         lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count);
        ---------------------------------------------------------------------------
      
        This API is currently only called on OSX platform. Linux or other Unixes
      using GNU gold are not supposed to call this function, because on these systems, 
      object files are fed back to linker via disk file instead of memory buffer.
      
        In this commit, lto_codegen_compile_parallel() simply calls
      lto_codegen_compile() to return a single object file. In the near future,
      this function is the entry point for compilation with partition. Linker can
      blindly call this function even if partition is turned off; in this case,
      compiler will return only one object file.
      
      llvm-svn: 189386
      388b52c0
    • Shuxin Yang's avatar
      Add new API lto_codegen_compile_parallel(). · a44362e4
      Shuxin Yang authored
        This API is proposed by Nick Kledzik. The semantic is:
      
        --------------------------------------------------------------------------
         Generate code for merged module into an array of native object files. On 
         success returns a pointer to an array of NativeObjectFile.  The count 
         parameter returns the number of elements in the array.  Each element is 
         a pointer/length for a generated mach-o/ELF buffer.  The buffer is owned
         by the lto_code_gen_t and will be freed when lto_codegen_dispose() is called, 
         or lto_codegen_compile() is called again. On failure, returns NULL 
         (check lto_get_error_message() for details).
      
         extern const struct  NativeObjectFile*
         lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count);
        ---------------------------------------------------------------------------
      
        This API is currently only called on OSX platform. Linux or other Unixes
      using GNU gold are not supposed to call this function, because on these systems, 
      object files are fed back to linker via disk file instead of memory buffer.
      
        In this commit, lto_codegen_compile_parallel() simply calls
      lto_codegen_compile() to return a single object file. In the near future,
      this function is the entry point for compilation with partition. Linker can
      blindly call this function even if partition is turned off; in this case,
      compiler will return only one object file.
      
      llvm-svn: 189297
      a44362e4
  23. Aug 12, 2013
    • Shuxin Yang's avatar
      Revert r188188 and r188200. · 1826ae23
      Shuxin Yang authored
      In order to appease people (in Apple) who accuse me for committing "huge change" (?) without proper review. 
      
      Thank Eric for fixing a compile-warning. 
      
      llvm-svn: 188204
      1826ae23
    • Shuxin Yang's avatar
      Misc enhancements to LTO: · 76d082b5
      Shuxin Yang authored
        1. Add some helper classes for partitions. They are designed in a
           way such that the top-level LTO driver will not see much difference 
           with or without partitioning.
      
        2. Introduce work-dir. Now all intermediate files generated during 
           LTO phases will be saved under work-dir. User can specify the workdir
           via -lto-workdir=/path/to/dir. By default the work-dir will be 
           erased before linker exit. To keep the workdir, do -lto-keep, or -lto-keep=1.
      
          TODO: Erase the workdir, if the linker exit prematurely.  
            We are currently not able to remove directory on signal. The support 
            routines simply ignore directory.
      
        3. Add one new API lto_codegen_get_files_need_remove().
           Linker and LTO plugin will communicate via this API about which files
          (including directories) need to removed before linker exit.
      
      llvm-svn: 188188
      76d082b5
  24. Aug 09, 2013
  25. Aug 07, 2013
  26. Aug 06, 2013
  27. Jul 27, 2013
  28. Jul 23, 2013
  29. Jul 22, 2013
    • Shuxin Yang's avatar
      Initialize/Register LTO passes to enable flags like -print-after=<lto-pass> · 1e6d80e2
      Shuxin Yang authored
      There already have two "dead" functions, initialize{IPO|IPA}, defined for 
      similar purpose. I decide not to call these two functions for two reasons:
        o. they don't cover all LTO passes (which will soon be separated into IPO 
           and post-IPO passes)
        o. We have not yet figured out the right passes and the ordering for IPO 
           and post-IPO stages, meaning this change is only for the time being.
      
      Since LTO passes are registered, we are now able to print IR before and 
      after particular point.
      
      For OSX users:
      --------------
        "...-Wl,-mllvm -Wl,-print-after=<pass-name>" will print IR after the
        specified pass.
      
      For Other UNIX with GNU gold linker:
      ------------------------------------
        "-Wl,-plugin-opt=-print-after=<pass-name>" should work.
        (NOTE: no need for "-Wl,-mllvm")
      
        Strip "-Wl," if flags are fed directly to linker instead of clang/clang++.
      
      llvm-svn: 186853
      1e6d80e2
  30. Jul 16, 2013
    • Rafael Espindola's avatar
      Add a wrapper for open. · 6d35481c
      Rafael Espindola authored
      This centralizes the handling of O_BINARY and opens the way for hiding more
      differences (like how open behaves with directories).
      
      llvm-svn: 186447
      6d35481c
  31. Jul 09, 2013
  32. Jul 05, 2013
  33. Jun 18, 2013
Loading