Class LLVMLTO


  • public class LLVMLTO
    extends java.lang.Object
    • Method Detail

      • nlto_get_version

        public static long nlto_get_version()
        Unsafe version of: get_version
      • lto_get_version

        public static java.lang.String lto_get_version()
        Returns a printable string.
      • nlto_get_error_message

        public static long nlto_get_error_message()
        Unsafe version of: get_error_message
      • lto_get_error_message

        @Nullable
        public static java.lang.String lto_get_error_message()
        Returns the last error string or NULL if last operation was successful.
      • nlto_module_is_object_file

        public static boolean nlto_module_is_object_file​(long path)
        Unsafe version of: module_is_object_file
      • lto_module_is_object_file

        public static boolean lto_module_is_object_file​(java.nio.ByteBuffer path)
        
        public static boolean lto_module_is_object_file​(java.lang.CharSequence path)
        
        Checks if a file is a loadable object file.
      • nlto_module_is_object_file_for_target

        public static boolean nlto_module_is_object_file_for_target​(long path,
                                                                    long target_triple_prefix)
      • lto_module_is_object_file_for_target

        public static boolean lto_module_is_object_file_for_target​(java.nio.ByteBuffer path,
                                                                   java.nio.ByteBuffer target_triple_prefix)
        
        public static boolean lto_module_is_object_file_for_target​(java.lang.CharSequence path,
                                                                   java.lang.CharSequence target_triple_prefix)
        
        Checks if a file is a loadable object compiled for requested target.
      • nlto_module_has_objc_category

        public static boolean nlto_module_has_objc_category​(long mem,
                                                            long length)
        Unsafe version of: module_has_objc_category
      • lto_module_has_objc_category

        public static boolean lto_module_has_objc_category​(java.nio.ByteBuffer mem)
        Return true if Buffer contains a bitcode file with ObjC code (category or class) in it.
      • nlto_module_is_object_file_in_memory

        public static boolean nlto_module_is_object_file_in_memory​(long mem,
                                                                   long length)
      • lto_module_is_object_file_in_memory

        public static boolean lto_module_is_object_file_in_memory​(java.nio.ByteBuffer mem)
        Checks if a buffer is a loadable object file.
      • nlto_module_is_object_file_in_memory_for_target

        public static boolean nlto_module_is_object_file_in_memory_for_target​(long mem,
                                                                              long length,
                                                                              long target_triple_prefix)
      • lto_module_is_object_file_in_memory_for_target

        public static boolean lto_module_is_object_file_in_memory_for_target​(java.nio.ByteBuffer mem,
                                                                             java.nio.ByteBuffer target_triple_prefix)
        
        public static boolean lto_module_is_object_file_in_memory_for_target​(java.nio.ByteBuffer mem,
                                                                             java.lang.CharSequence target_triple_prefix)
        
        Checks if a buffer is a loadable object compiled for requested target.
      • nlto_module_create

        public static long nlto_module_create​(long path)
        Unsafe version of: module_create
      • lto_module_create

        public static long lto_module_create​(java.nio.ByteBuffer path)
        
        public static long lto_module_create​(java.lang.CharSequence path)
        
        Loads an object file from disk. Returns NULL on error (check get_error_message for details).
      • nlto_module_create_from_memory

        public static long nlto_module_create_from_memory​(long mem,
                                                          long length)
        Unsafe version of: module_create_from_memory
      • lto_module_create_from_memory

        public static long lto_module_create_from_memory​(java.nio.ByteBuffer mem)
        Loads an object file from memory. Returns NULL on error (check get_error_message for details).
      • nlto_module_create_from_memory_with_path

        public static long nlto_module_create_from_memory_with_path​(long mem,
                                                                    long length,
                                                                    long path)
      • lto_module_create_from_memory_with_path

        public static long lto_module_create_from_memory_with_path​(java.nio.ByteBuffer mem,
                                                                   java.nio.ByteBuffer path)
        
        public static long lto_module_create_from_memory_with_path​(java.nio.ByteBuffer mem,
                                                                   java.lang.CharSequence path)
        
        Loads an object file from memory with an extra path argument. Returns NULL on error (check get_error_message for details).
      • nlto_module_create_in_local_context

        public static long nlto_module_create_in_local_context​(long mem,
                                                               long length,
                                                               long path)
      • lto_module_create_in_local_context

        public static long lto_module_create_in_local_context​(java.nio.ByteBuffer mem,
                                                              java.nio.ByteBuffer path)
        
        public static long lto_module_create_in_local_context​(java.nio.ByteBuffer mem,
                                                              java.lang.CharSequence path)
        
        Loads an object file in its own context.

        Loads an object file in its own LLVMContext. This function call is thread-safe. However, modules created this way should not be merged into an lto_code_gen_t using codegen_add_module.

        Returns NULL on error (check get_error_message for details).

      • nlto_module_create_in_codegen_context

        public static long nlto_module_create_in_codegen_context​(long mem,
                                                                 long length,
                                                                 long path,
                                                                 long cg)
      • lto_module_create_in_codegen_context

        public static long lto_module_create_in_codegen_context​(java.nio.ByteBuffer mem,
                                                                java.nio.ByteBuffer path,
                                                                long cg)
        
        public static long lto_module_create_in_codegen_context​(java.nio.ByteBuffer mem,
                                                                java.lang.CharSequence path,
                                                                long cg)
        
        Loads an object file in the codegen context.

        Loads an object file into the same context as cg. The module is safe to add using codegen_add_module.

        Returns NULL on error (check get_error_message for details).

      • nlto_module_create_from_fd

        public static long nlto_module_create_from_fd​(int fd,
                                                      long path,
                                                      long file_size)
        Unsafe version of: module_create_from_fd
      • lto_module_create_from_fd

        public static long lto_module_create_from_fd​(int fd,
                                                     java.nio.ByteBuffer path,
                                                     long file_size)
        
        public static long lto_module_create_from_fd​(int fd,
                                                     java.lang.CharSequence path,
                                                     long file_size)
        
        Loads an object file from disk. The seek point of fd is not preserved. Returns NULL on error (check get_error_message for details).
      • nlto_module_create_from_fd_at_offset

        public static long nlto_module_create_from_fd_at_offset​(int fd,
                                                                long path,
                                                                long file_size,
                                                                long map_size,
                                                                long offset)
      • lto_module_create_from_fd_at_offset

        public static long lto_module_create_from_fd_at_offset​(int fd,
                                                               java.nio.ByteBuffer path,
                                                               long file_size,
                                                               long map_size,
                                                               long offset)
        
        public static long lto_module_create_from_fd_at_offset​(int fd,
                                                               java.lang.CharSequence path,
                                                               long file_size,
                                                               long map_size,
                                                               long offset)
        
        Loads an object file from disk. The seek point of fd is not preserved. Returns NULL on error (check get_error_message for details).
      • lto_module_dispose

        public static void lto_module_dispose​(long mod)
        Frees all memory internally allocated by the module. Upon return the lto_module_t is no longer valid.
      • nlto_module_get_target_triple

        public static long nlto_module_get_target_triple​(long mod)
        Unsafe version of: module_get_target_triple
      • lto_module_get_target_triple

        @Nullable
        public static java.lang.String lto_module_get_target_triple​(long mod)
        Returns triple string which the object module was compiled under.
      • nlto_module_set_target_triple

        public static void nlto_module_set_target_triple​(long mod,
                                                         long triple)
        Unsafe version of: module_set_target_triple
      • lto_module_set_target_triple

        public static void lto_module_set_target_triple​(long mod,
                                                        java.nio.ByteBuffer triple)
        
        public static void lto_module_set_target_triple​(long mod,
                                                        java.lang.CharSequence triple)
        
        Sets triple string with which the object will be codegened.
      • lto_module_get_num_symbols

        public static int lto_module_get_num_symbols​(long mod)
        Returns the number of symbols in the object module.
      • nlto_module_get_symbol_name

        public static long nlto_module_get_symbol_name​(long mod,
                                                       int index)
        Unsafe version of: module_get_symbol_name
      • lto_module_get_symbol_name

        @Nullable
        public static java.lang.String lto_module_get_symbol_name​(long mod,
                                                                  int index)
        Returns the name of the ith symbol in the object module.
      • lto_module_get_symbol_attribute

        public static int lto_module_get_symbol_attribute​(long mod,
                                                          int index)
        Returns the attributes of the ith symbol in the object module.
      • nlto_module_get_linkeropts

        public static long nlto_module_get_linkeropts​(long mod)
        Unsafe version of: module_get_linkeropts
      • lto_module_get_linkeropts

        @Nullable
        public static java.lang.String lto_module_get_linkeropts​(long mod)
        Returns the module's linker options.

        The linker options may consist of multiple flags. It is the linker's responsibility to split the flags using a platform-specific mechanism.

      • nlto_codegen_set_diagnostic_handler

        public static void nlto_codegen_set_diagnostic_handler​(long cg,
                                                               long handler,
                                                               long ctxt)
      • lto_codegen_set_diagnostic_handler

        public static void lto_codegen_set_diagnostic_handler​(long cg,
                                                              LTODiagnosticHandlerI handler,
                                                              long ctxt)
        Set a diagnostic handler and the related context (void *). This is more general than get_error_message, as the diagnostic handler can be called at anytime within lto.
      • lto_codegen_create

        public static long lto_codegen_create()
        Instantiates a code generator. Returns NULL on error (check get_error_message for details).

        All modules added using codegen_add_module must have been created in the same context as the codegen.

      • lto_codegen_create_in_local_context

        public static long lto_codegen_create_in_local_context()
        Instantiate a code generator in its own context.

        Instantiates a code generator in its own context. Modules added via codegen_add_module must have all been created in the same context, using module_create_in_codegen_context.

      • lto_codegen_dispose

        public static void lto_codegen_dispose​(long cg)
        Frees all code generator and all memory it internally allocated. Upon return the lto_code_gen_t is no longer valid.
      • lto_codegen_set_module

        public static void lto_codegen_set_module​(long cg,
                                                  long mod)
        Sets the object module for code generation. This will transfer the ownership of the module to the code generator.

        cg and mod must both be in the same context.

      • lto_codegen_set_debug_model

        public static boolean lto_codegen_set_debug_model​(long cg,
                                                          int model)
        Sets if debug info should be generated. Returns true on error (check get_error_message for details).
      • lto_codegen_set_pic_model

        public static boolean lto_codegen_set_pic_model​(long cg,
                                                        int model)
        Sets which PIC code model to generated. Returns true on error (check get_error_message for details).
      • nlto_codegen_set_cpu

        public static void nlto_codegen_set_cpu​(long cg,
                                                long cpu)
        Unsafe version of: codegen_set_cpu
      • lto_codegen_set_cpu

        public static void lto_codegen_set_cpu​(long cg,
                                               java.nio.ByteBuffer cpu)
        
        public static void lto_codegen_set_cpu​(long cg,
                                               java.lang.CharSequence cpu)
        
        Sets the cpu to generate code for.
      • nlto_codegen_set_assembler_path

        public static void nlto_codegen_set_assembler_path​(long cg,
                                                           long path)
        Unsafe version of: codegen_set_assembler_path
      • lto_codegen_set_assembler_path

        public static void lto_codegen_set_assembler_path​(long cg,
                                                          java.nio.ByteBuffer path)
        
        public static void lto_codegen_set_assembler_path​(long cg,
                                                          java.lang.CharSequence path)
        
        Sets the location of the assembler tool to run. If not set, libLTO will use gcc to invoke the assembler.
      • nlto_codegen_set_assembler_args

        public static void nlto_codegen_set_assembler_args​(long cg,
                                                           long args,
                                                           int nargs)
        Unsafe version of: codegen_set_assembler_args
      • lto_codegen_set_assembler_args

        public static void lto_codegen_set_assembler_args​(long cg,
                                                          PointerBuffer args)
        Sets extra arguments that libLTO should pass to the assembler.
      • nlto_codegen_add_must_preserve_symbol

        public static void nlto_codegen_add_must_preserve_symbol​(long cg,
                                                                 long symbol)
      • lto_codegen_add_must_preserve_symbol

        public static void lto_codegen_add_must_preserve_symbol​(long cg,
                                                                java.nio.ByteBuffer symbol)
        
        public static void lto_codegen_add_must_preserve_symbol​(long cg,
                                                                java.lang.CharSequence symbol)
        
        Adds to a list of all global symbols that must exist in the final generated code. If a function is not listed there, it might be inlined into every usage and optimized away.
      • nlto_codegen_write_merged_modules

        public static boolean nlto_codegen_write_merged_modules​(long cg,
                                                                long path)
        Unsafe version of: codegen_write_merged_modules
      • lto_codegen_write_merged_modules

        public static boolean lto_codegen_write_merged_modules​(long cg,
                                                               java.nio.ByteBuffer path)
        
        public static boolean lto_codegen_write_merged_modules​(long cg,
                                                               java.lang.CharSequence path)
        
        Writes a new object file at the specified path that contains the merged contents of all modules added so far. Returns true on error (check get_error_message for details).
      • nlto_codegen_compile

        public static long nlto_codegen_compile​(long cg,
                                                long length)
        Unsafe version of: codegen_compile
      • lto_codegen_compile

        @Nullable
        public static java.nio.ByteBuffer lto_codegen_compile​(long cg)
        Generates code for all added modules into one native object file. This calls codegen_optimize then codegen_compile_optimized.

        On success returns a pointer to a generated mach-o/ELF buffer and length set to the buffer size. The buffer is owned by the lto_code_gen_t and will be freed when codegen_dispose is called, or lto_codegen_compile() is called again. On failure, returns NULL (check get_error_message for details).

      • nlto_codegen_compile_to_file

        public static boolean nlto_codegen_compile_to_file​(long cg,
                                                           long name)
        Unsafe version of: codegen_compile_to_file
      • lto_codegen_compile_to_file

        public static boolean lto_codegen_compile_to_file​(long cg,
                                                          PointerBuffer name)
        Generates code for all added modules into one native object file. This calls codegen_optimize then codegen_compile_optimized (instead of returning a generated mach-o/ELF buffer, it writes to a file).

        The name of the file is written to name. Returns true on error.

      • lto_codegen_optimize

        public static boolean lto_codegen_optimize​(long cg)
        Runs optimization for the merged module. Returns true on error.
      • nlto_codegen_compile_optimized

        public static long nlto_codegen_compile_optimized​(long cg,
                                                          long length)
        Unsafe version of: codegen_compile_optimized
      • lto_codegen_compile_optimized

        @Nullable
        public static java.nio.ByteBuffer lto_codegen_compile_optimized​(long cg)
        Generates code for the optimized merged module into one native object file. It will not run any IR optimizations on the merged module.

        On success returns a pointer to a generated mach-o/ELF buffer and length set to the buffer size. The buffer is owned by the lto_code_gen_t and will be freed when codegen_dispose is called, or lto_codegen_compile_optimized() is called again. On failure, returns NULL (check get_error_message for details).

      • lto_api_version

        public static int lto_api_version()
        Returns the runtime API version.
      • nlto_codegen_debug_options

        public static void nlto_codegen_debug_options​(long cg,
                                                      long options)
        Unsafe version of: codegen_debug_options
      • lto_codegen_debug_options

        public static void lto_codegen_debug_options​(long cg,
                                                     java.nio.ByteBuffer options)
        
        public static void lto_codegen_debug_options​(long cg,
                                                     java.lang.CharSequence options)
        
        Sets options to help debug codegen bugs.
      • lto_initialize_disassembler

        public static void lto_initialize_disassembler()
        Initializes LLVM disassemblers.
      • lto_codegen_set_should_internalize

        public static void lto_codegen_set_should_internalize​(long cg,
                                                              boolean ShouldInternalize)
        Sets if we should run internalize pass during optimization and code generation.
      • lto_codegen_set_should_embed_uselists

        public static void lto_codegen_set_should_embed_uselists​(long cg,
                                                                 boolean ShouldEmbedUselists)
        Set whether to embed uselists in bitcode.

        Sets whether codegen_write_merged_modules should embed uselists in output bitcode. This should be turned on for all -save-temps output.

      • thinlto_create_codegen

        public static long thinlto_create_codegen()
        Instantiates a ThinLTO code generator. Returns NULL on error (check lto_get_error_message() for details).

        The ThinLTOCodeGenerator is not intended to be reuse for multiple compilation: the model is that the client adds modules to the generator and ask to perform the ThinLTO optimizations / codegen, and finally destroys the codegenerator.

      • thinlto_codegen_dispose

        public static void thinlto_codegen_dispose​(long cg)
        Frees the generator and all memory it internally allocated. Upon return the thinlto_code_gen_t is no longer valid.
      • thinlto_codegen_add_module

        public static void thinlto_codegen_add_module​(long cg,
                                                      java.nio.ByteBuffer identifier,
                                                      java.nio.ByteBuffer data)
        
        public static void thinlto_codegen_add_module​(long cg,
                                                      java.lang.CharSequence identifier,
                                                      java.nio.ByteBuffer data)
        
        Add a module to a ThinLTO code generator. Identifier has to be unique among all the modules in a code generator. The data buffer stays owned by the client, and is expected to be available for the entire lifetime of the thinlto_code_gen_t it is added to.

        On failure, returns NULL (check get_error_message for details).

      • thinlto_module_get_num_objects

        public static int thinlto_module_get_num_objects​(long cg)
        Returns the number of object files produced by the ThinLTO CodeGenerator.

        It usually matches the number of input files, but this is not a guarantee of the API and may change in future implementation, so the client should not assume it.

      • thinlto_module_get_num_object_files

        public static int thinlto_module_get_num_object_files​(long cg)
        Returns the number of object files produced by the ThinLTO CodeGenerator.

        It usually matches the number of input files, but this is not a guarantee of the API and may change in future implementation, so the client should not assume it.

      • thinlto_module_get_object_file

        @Nullable
        public static java.lang.String thinlto_module_get_object_file​(long cg,
                                                                      int index)
        Returns the path to the ith object file produced by the ThinLTO CodeGenerator.

        Client should use thinlto_module_get_num_object_files(long) to get the number of available objects.

      • thinlto_codegen_set_pic_model

        public static boolean thinlto_codegen_set_pic_model​(long cg,
                                                            int model)
        Sets which PIC code model to generate. Returns true on error (check get_error_message for details).
      • thinlto_codegen_set_savetemps_dir

        public static void thinlto_codegen_set_savetemps_dir​(long cg,
                                                             java.nio.ByteBuffer save_temps_dir)
        
        public static void thinlto_codegen_set_savetemps_dir​(long cg,
                                                             java.lang.CharSequence save_temps_dir)
        
        Sets the path to a directory to use as a storage for temporary bitcode files. The intention is to make the bitcode files available for debugging at various stage of the pipeline.
      • thinlto_set_generated_objects_dir

        public static void thinlto_set_generated_objects_dir​(long cg,
                                                             java.nio.ByteBuffer save_temps_dir)
        
        public static void thinlto_set_generated_objects_dir​(long cg,
                                                             java.lang.CharSequence save_temps_dir)
        
        Set the path to a directory where to save generated object files. This path can be used by a linker to request on-disk files instead of in-memory buffers. When set, results are available through thinlto_module_get_object_file(long, int) instead of thinlto_module_get_object(long, int, org.lwjgl.llvm.LTOObjectBuffer).
      • thinlto_codegen_set_cpu

        public static void thinlto_codegen_set_cpu​(long cg,
                                                   java.nio.ByteBuffer cpu)
        
        public static void thinlto_codegen_set_cpu​(long cg,
                                                   java.lang.CharSequence cpu)
        
        Sets the cpu to generate code for.
      • thinlto_codegen_disable_codegen

        public static void thinlto_codegen_disable_codegen​(long cg,
                                                           boolean disable)
        Disable CodeGen, only run the stages till codegen and stop. The output will be bitcode.
      • thinlto_codegen_set_codegen_only

        public static void thinlto_codegen_set_codegen_only​(long cg,
                                                            boolean codegen_only)
        Perform CodeGen only: disable all other stages.
      • thinlto_debug_options

        public static void thinlto_debug_options​(PointerBuffer options)
        Parse -mllvm style debug options.
      • lto_module_is_thinlto

        public static boolean lto_module_is_thinlto​(long mod)
        Test if a module has support for ThinLTO linking.
      • thinlto_codegen_add_must_preserve_symbol

        public static void thinlto_codegen_add_must_preserve_symbol​(long cg,
                                                                    java.nio.ByteBuffer name)
        
        public static void thinlto_codegen_add_must_preserve_symbol​(long cg,
                                                                    java.lang.CharSequence name)
        
        Adds a symbol to the list of global symbols that must exist in the final generated code. If a function is not listed there, it might be inlined into every usage and optimized away. For every single module, the functions referenced from code outside of the ThinLTO modules need to be added here.
      • thinlto_codegen_add_cross_referenced_symbol

        public static void thinlto_codegen_add_cross_referenced_symbol​(long cg,
                                                                       java.nio.ByteBuffer name)
        
        public static void thinlto_codegen_add_cross_referenced_symbol​(long cg,
                                                                       java.lang.CharSequence name)
        
        Adds a symbol to the list of global symbols that are cross-referenced between ThinLTO files. If the ThinLTO CodeGenerator can ensure that every references from a ThinLTO module to this symbol is optimized away, then the symbol can be discarded.
      • thinlto_codegen_set_cache_dir

        public static void thinlto_codegen_set_cache_dir​(long cg,
                                                         java.nio.ByteBuffer cache_dir)
        
        public static void thinlto_codegen_set_cache_dir​(long cg,
                                                         java.lang.CharSequence cache_dir)
        
        Sets the path to a directory to use as a cache storage for incremental build. Setting this activates caching.
      • thinlto_codegen_set_cache_pruning_interval

        public static void thinlto_codegen_set_cache_pruning_interval​(long cg,
                                                                      int interval)
        Sets the cache pruning interval (in seconds). A negative value disables the pruning. An unspecified default value will be applied, and a value of 0 will force prunning to occur.
      • thinlto_codegen_set_final_cache_size_relative_to_available_space

        public static void thinlto_codegen_set_final_cache_size_relative_to_available_space​(long cg,
                                                                                            int percentage)
        Sets the maximum cache size that can be persistent across build, in terms of percentage of the available space on the disk. Set to 100 to indicate no limit, 50 to indicate that the cache size will not be left over half the available space. A value over 100 will be reduced to 100, a value of 0 will be ignored. An unspecified default value will be applied.

        The formula looks like: AvailableSpace = FreeSpace + ExistingCacheSize NewCacheSize = AvailableSpace * P/100

      • thinlto_codegen_set_cache_entry_expiration

        public static void thinlto_codegen_set_cache_entry_expiration​(long cg,
                                                                      int expiration)
        Sets the expiration (in seconds) for an entry in the cache. An unspecified default value will be applied. A value of 0 will be ignored.
      • thinlto_codegen_set_cache_size_bytes

        public static void thinlto_codegen_set_cache_size_bytes​(long cg,
                                                                int max_size_bytes)
        Sets the maximum size of the cache directory (in bytes). A value over the amount of available space on the disk will be reduced to the amount of available space. An unspecified default value will be applied. A value of 0 will be ignored.
      • thinlto_codegen_set_cache_size_megabytes

        public static void thinlto_codegen_set_cache_size_megabytes​(long cg,
                                                                    int max_size_megabytes)
        Same as thinlto_codegen_set_cache_size_bytes(long, int), except the maximum size is in megabytes (220 bytes).
      • thinlto_codegen_set_cache_size_files

        public static void thinlto_codegen_set_cache_size_files​(long cg,
                                                                int max_size_files)
        Sets the maximum number of files in the cache directory. An unspecified default value will be applied. A value of 0 will be ignored.