LLVM: include/llvm-c/lto.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef LLVM_C_LTO_H

17#define LLVM_C_LTO_H

18

20

21#ifdef __cplusplus

22#include

23#else

24#include <stddef.h>

25#endif

26#include <sys/types.h>

27

28#ifndef __cplusplus

29#if !defined(_MSC_VER)

30#include <stdbool.h>

32#else

33

34

35

37#endif

38#else

40#endif

41

42

43

44

45

46

47

48

49#define LTO_API_VERSION 30

50

51

52

53

75

76

77

78

83

84

85

86

93

94

96

97

99

100

102

104

105

106

107

108

109

110extern const char*

112

113

114

115

116

117

118extern const char*

120

121

122

123

124

125

128

129

130

131

132

133

136 const char* target_triple_prefix);

137

138

139

140

141

142

143

146

147

148

149

150

151

153 size_t length);

154

155

156

157

158

159

162 const char* target_triple_prefix);

163

164

165

166

167

168

169

172

173

174

175

176

177

178

181

182

183

184

185

186

187

190 const char *path);

191

192

193

194

195

196

197

198

199

200

201

202

205 const char *path);

206

207

208

209

210

211

212

213

214

215

216

220

221

222

223

224

225

226

229

230

231

232

233

234

235

238 size_t map_size, off_t offset);

239

240

241

242

243

244

245

246extern void

248

249

250

251

252

253

254extern const char*

256

257

258

259

260

261

262extern void

264

265

266

267

268

269

270extern unsigned int

272

273

274

275

276

277

278extern const char*

280

281

282

283

284

285

288

289

290

291

292

293

295

296

297

298

299

300

302 unsigned int index);

303

304

305

306

307

308

309

310

311

312extern const char*

314

315

316

317

318

319

320

321

322

323

324

325

327 unsigned int *out_cputype,

328 unsigned int *out_cpusubtype);

329

330

331

332

333

334

335

336

337

338

340

341

342

343

344

351

352

353

354

355

356

357

358

359

360

363

364

365

366

367

368

369

370

373 void *);

374

375

376

377

378

379

380

381

382

383

386

387

388

389

390

391

392

393

394

395

398

399

400

401

402

403

404

405extern void

407

408

409

410

411

412

413

414

415

416

417

420

421

422

423

424

425

426

427

428

429extern void

431

432

433

434

435

436

437

440

441

442

443

444

445

446

449

450

451

452

453

454

455extern void

457

458

459

460

461

462

463

464extern void

466

467

468

469

470

471

472extern void

474 int nargs);

475

476

477

478

479

480

481

482

483extern void

485

486

487

488

489

490

491

492

495

496

497

498

499

500

501

502

503

504

505

506

507

508extern const void*

510

511

512

513

514

515

516

517

518

519

522

523

524

525

526

527

530

531

532

533

534

535

536

537

538

539

540

541

542

543extern const void*

545

546

547

548

549

550

551extern unsigned int

553

554

555

556

557

558

559

560

561

562

563

564

565

567

568

569

570

571

572

573

574

575

576

577

578

579extern void

581

582

583

584

585

586

587

589 const char *const *, int number);

590

591

592

593

594

595

596

597extern void

599

600

601

602

603

604

605

606extern void

609

610

611

612

613

614

615

616

617

618extern void

621

622

624

625

626

627

628

629

630

631

632

634 size_t buffer_size,

635 const char *path);

636

637

638

639

640

641

642

644

645

646

647

648

649

650

652

653

654

655

656

657

658

659

661 size_t index,

662 size_t *size);

663

664

665

666

667

668

669

671

672

673

674

675

676

677

678

679

680

681

682

683

684

689

690

691

692

693

694

695

696

697

698

699

700

701

703

704

705

706

707

708

709

711

712

713

714

715

716

717

718

719

720

721

722

724 const char *identifier, const char *data,

725 int length);

726

727

728

729

730

731

732

734

735

736

737

738

739

740

741

742

743

745

746

747

748

749

750

751

752

753

754

756 unsigned int index);

757

758

759

760

761

762

763

764

765

766

768

769

770

771

772

773

774

775

776

777

779 unsigned int index);

780

781

782

783

784

785

786

789

790

791

792

793

794

795

796

798 const char *save_temps_dir);

799

800

801

802

803

804

805

806

807

809 const char *save_temps_dir);

810

811

812

813

814

815

817

818

819

820

821

822

823

826

827

828

829

830

831

834

835

836

837

838

839

841

842

843

844

845

846

848

849

850

851

852

853

854

855

856

858 const char *name,

859 int length);

860

861

862

863

864

865

866

867

868

870 const char *name,

871 int length);

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

901 const char *cache_dir);

902

903

904

905

906

907

908

909

911 int interval);

912

913

914

915

916

917

918

919

920

921

922

923

924

925

928

929

930

931

932

933

934

936 unsigned expiration);

937

938

939

940

941

942

943

944

945

947 unsigned max_size_bytes);

948

949

950

951

952

953

954

955extern void

957 unsigned max_size_megabytes);

958

959

960

961

962

963

964

966 unsigned max_size_files);

967

968

969

970

971

973

974#endif

static constexpr std::size_t number(BlockVerifier::State S)

#define LLVM_C_EXTERN_C_BEGIN

#define LLVM_C_EXTERN_C_END

void lto_input_dispose(lto_input_t input)

Frees all memory internally allocated by the LTO input file.

lto_module_t lto_module_create_in_codegen_context(const void *mem, size_t length, const char *path, lto_code_gen_t cg)

Loads an object file in the codegen context.

void lto_codegen_debug_options(lto_code_gen_t cg, const char *)

Sets options to help debug codegen bugs.

lto_code_gen_t lto_codegen_create_in_local_context(void)

Instantiate a code generator in its own context.

lto_bool_t lto_module_get_macho_cputype(lto_module_t mod, unsigned int *out_cputype, unsigned int *out_cpusubtype)

If targeting mach-o on darwin, this function gets the CPU type and subtype that will end up being enc...

lto_module_t lto_module_create_in_local_context(const void *mem, size_t length, const char *path)

Loads an object file in its own context.

void lto_set_debug_options(const char *const *options, int number)

Parses options immediately, making them available as early as possible.

void lto_codegen_set_should_embed_uselists(lto_code_gen_t cg, lto_bool_t ShouldEmbedUselists)

Set whether to embed uselists in bitcode.

const void * lto_codegen_compile(lto_code_gen_t cg, size_t *length)

Generates code for all added modules into one native object file.

const char *const * lto_runtime_lib_symbols_list(size_t *size)

Returns the list of libcall symbols that can be generated by LTO that might not be visible from the s...

void lto_codegen_dispose(lto_code_gen_t)

Frees all code generator and all memory it internally allocated.

unsigned lto_input_get_num_dependent_libraries(lto_input_t input)

Returns the number of dependent library specifiers for the given LTO input file.

void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, int nargs)

Sets extra arguments that libLTO should pass to the assembler.

lto_module_t lto_module_create(const char *path)

Loads an object file from disk.

lto_code_gen_t lto_codegen_create(void)

Instantiates a code generator.

const char * lto_module_get_target_triple(lto_module_t mod)

Returns triple string which the object module was compiled under.

void lto_module_set_target_triple(lto_module_t mod, const char *triple)

Sets triple string with which the object will be codegened.

struct LLVMOpaqueLTOModule * lto_module_t

opaque reference to a loaded object module

Definition lto.h:95

lto_bool_t lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path)

Writes a new object file at the specified path that contains the merged contents of all modules added...

lto_debug_model

Definition lto.h:79

lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t file_size)

Loads an object file from disk.

unsigned int lto_module_get_num_symbols(lto_module_t mod)

Returns the number of symbols in the object module.

lto_bool_t lto_module_has_ctor_dtor(lto_module_t mod)

This function can be used by the linker to check if a given module has any constructor or destructor ...

const char * lto_module_get_linkeropts(lto_module_t mod)

Returns the module's linker options.

lto_module_t lto_module_create_from_memory(const void *mem, size_t length)

Loads an object file from memory.

struct LLVMOpaqueLTOCodeGenerator * lto_code_gen_t

opaque reference to a code generator

Definition lto.h:98

lto_bool_t lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model)

Sets which PIC code model to generated.

void lto_codegen_set_should_internalize(lto_code_gen_t cg, lto_bool_t ShouldInternalize)

Sets if we should run internalize pass during optimization and code generation.

lto_codegen_diagnostic_severity_t

Diagnostic severity.

Definition lto.h:345

lto_bool_t lto_module_has_objc_category(const void *mem, size_t length)

Return true if Buffer contains a bitcode file with ObjC code (category or class) in it.

unsigned int lto_api_version(void)

Returns the runtime API version.

lto_symbol_attributes

Definition lto.h:54

lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index)

Returns the attributes of the ith symbol in the object module.

void lto_codegen_set_module(lto_code_gen_t cg, lto_module_t mod)

Sets the object module for code generation.

const char * lto_module_get_asm_undef_symbol_name(lto_module_t mod, unsigned int index)

Returns the name of the ith asm undefined symbol in the object module.

const char * lto_module_get_symbol_name(lto_module_t mod, unsigned int index)

Returns the name of the ith symbol in the object module.

lto_module_t lto_module_create_from_memory_with_path(const void *mem, size_t length, const char *path)

Loads an object file from memory with an extra path argument.

void lto_codegen_set_diagnostic_handler(lto_code_gen_t, lto_diagnostic_handler_t, void *)

Set a diagnostic handler and the related context (void *).

lto_bool_t lto_module_is_object_file_in_memory_for_target(const void *mem, size_t length, const char *target_triple_prefix)

Checks if a buffer is a loadable object compiled for requested target.

struct LLVMOpaqueLTOInput * lto_input_t

Opaque reference to an LTO input file.

Definition lto.h:623

struct LLVMOpaqueThinLTOCodeGenerator * thinlto_code_gen_t

opaque reference to a thin code generator

Definition lto.h:101

lto_bool_t lto_codegen_optimize(lto_code_gen_t cg)

Runs optimization for the merged module.

lto_bool_t lto_module_is_object_file_for_target(const char *path, const char *target_triple_prefix)

Checks if a file is a loadable object compiled for requested target.

LLVM_C_EXTERN_C_BEGIN const char * lto_get_version(void)

Returns a printable string.

void lto_initialize_disassembler(void)

Initializes LLVM disassemblers.

void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char *symbol)

Adds to a list of all global symbols that must exist in the final generated code.

unsigned int lto_module_get_num_asm_undef_symbols(lto_module_t mod)

Returns the number of asm undefined symbols in the object module.

lto_bool_t lto_module_is_object_file_in_memory(const void *mem, size_t length)

Checks if a buffer is a loadable object file.

lto_bool_t lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod)

Add an object module to the set of modules for which code will be generated.

void(* lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt)

Diagnostic handler type.

Definition lto.h:361

const void * lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length)

Generates code for the optimized merged module into one native object file.

lto_codegen_model

Definition lto.h:87

lto_input_t lto_input_create(const void *buffer, size_t buffer_size, const char *path)

Creates an LTO input file from a buffer.

lto_bool_t lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model)

Sets if debug info should be generated.

lto_bool_t lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name)

Generates code for all added modules into one native object file.

lto_bool_t lto_module_is_object_file(const char *path)

Checks if a file is a loadable object file.

const char * lto_get_error_message(void)

Returns the last error string or NULL if last operation was successful.

void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu)

Sets the cpu to generate code for.

lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path, size_t file_size, size_t map_size, off_t offset)

Loads an object file from disk.

const char * lto_input_get_dependent_library(lto_input_t input, size_t index, size_t *size)

Returns the ith dependent library specifier for the given LTO input file.

void lto_codegen_debug_options_array(lto_code_gen_t cg, const char *const *, int number)

Same as the previous function, but takes every option separately through an array.

void lto_module_dispose(lto_module_t mod)

Frees all memory internally allocated by the module.

void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path)

Sets the location of the assembler tool to run.

@ LTO_DEBUG_MODEL_DWARF

Definition lto.h:81

@ LTO_DEBUG_MODEL_NONE

Definition lto.h:80

@ LTO_DS_REMARK

Definition lto.h:348

@ LTO_DS_WARNING

Definition lto.h:347

@ LTO_DS_NOTE

Definition lto.h:349

@ LTO_DS_ERROR

Definition lto.h:346

@ LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN

Definition lto.h:71

@ LTO_SYMBOL_PERMISSIONS_CODE

Definition lto.h:57

@ LTO_SYMBOL_DEFINITION_REGULAR

Definition lto.h:61

@ LTO_SYMBOL_SCOPE_DEFAULT

Definition lto.h:70

@ LTO_SYMBOL_SCOPE_INTERNAL

Definition lto.h:67

@ LTO_SYMBOL_ALIAS

Definition lto.h:73

@ LTO_SYMBOL_ALIGNMENT_MASK

Definition lto.h:55

@ LTO_SYMBOL_SCOPE_HIDDEN

Definition lto.h:68

@ LTO_SYMBOL_DEFINITION_TENTATIVE

Definition lto.h:62

@ LTO_SYMBOL_PERMISSIONS_DATA

Definition lto.h:58

@ LTO_SYMBOL_SCOPE_PROTECTED

Definition lto.h:69

@ LTO_SYMBOL_PERMISSIONS_RODATA

Definition lto.h:59

@ LTO_SYMBOL_SCOPE_MASK

Definition lto.h:66

@ LTO_SYMBOL_COMDAT

Definition lto.h:72

@ LTO_SYMBOL_DEFINITION_WEAKUNDEF

Definition lto.h:65

@ LTO_SYMBOL_DEFINITION_UNDEFINED

Definition lto.h:64

@ LTO_SYMBOL_DEFINITION_WEAK

Definition lto.h:63

@ LTO_SYMBOL_PERMISSIONS_MASK

Definition lto.h:56

@ LTO_SYMBOL_DEFINITION_MASK

Definition lto.h:60

@ LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC

Definition lto.h:90

@ LTO_CODEGEN_PIC_MODEL_DYNAMIC

Definition lto.h:89

@ LTO_CODEGEN_PIC_MODEL_DEFAULT

Definition lto.h:91

@ LTO_CODEGEN_PIC_MODEL_STATIC

Definition lto.h:88

void thinlto_codegen_set_cache_size_megabytes(thinlto_code_gen_t cg, unsigned max_size_megabytes)

Same as thinlto_codegen_set_cache_size_bytes, except the maximum size is in megabytes (2^20 bytes).

void thinlto_codegen_set_final_cache_size_relative_to_available_space(thinlto_code_gen_t cg, unsigned percentage)

Sets the maximum cache size that can be persistent across build, in terms of percentage of the availa...

void thinlto_codegen_set_cache_size_files(thinlto_code_gen_t cg, unsigned max_size_files)

Sets the maximum number of files in the cache directory.

void thinlto_codegen_set_cache_dir(thinlto_code_gen_t cg, const char *cache_dir)

Sets the path to a directory to use as a cache storage for incremental build.

void thinlto_codegen_set_cache_size_bytes(thinlto_code_gen_t cg, unsigned max_size_bytes)

Sets the maximum size of the cache directory (in bytes).

void thinlto_codegen_set_cache_pruning_interval(thinlto_code_gen_t cg, int interval)

Sets the cache pruning interval (in seconds).

void thinlto_codegen_set_cache_entry_expiration(thinlto_code_gen_t cg, unsigned expiration)

Sets the expiration (in seconds) for an entry in the cache.

void thinlto_codegen_add_cross_referenced_symbol(thinlto_code_gen_t cg, const char *name, int length)

Adds a symbol to the list of global symbols that are cross-referenced between ThinLTO files.

lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg, lto_codegen_model)

Sets which PIC code model to generate.

void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg, lto_bool_t disable)

Disable CodeGen, only run the stages till codegen and stop.

void thinlto_debug_options(const char *const *options, int number)

Parse -mllvm style debug options.

void thinlto_codegen_set_savetemps_dir(thinlto_code_gen_t cg, const char *save_temps_dir)

Sets the path to a directory to use as a storage for temporary bitcode files.

unsigned int thinlto_module_get_num_objects(thinlto_code_gen_t cg)

Returns the number of object files produced by the ThinLTO CodeGenerator.

LTOObjectBuffer thinlto_module_get_object(thinlto_code_gen_t cg, unsigned int index)

Returns a reference to the ith object file produced by the ThinLTO CodeGenerator.

const char * thinlto_module_get_object_file(thinlto_code_gen_t cg, unsigned int index)

Returns the path to the ith object file produced by the ThinLTO CodeGenerator.

void thinlto_set_generated_objects_dir(thinlto_code_gen_t cg, const char *save_temps_dir)

Set the path to a directory where to save generated object files.

void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const char *cpu)

Sets the cpu to generate code for.

thinlto_code_gen_t thinlto_create_codegen(void)

Instantiates a ThinLTO code generator.

void thinlto_codegen_add_module(thinlto_code_gen_t cg, const char *identifier, const char *data, int length)

Add a module to a ThinLTO code generator.

void thinlto_codegen_add_must_preserve_symbol(thinlto_code_gen_t cg, const char *name, int length)

Adds a symbol to the list of global symbols that must exist in the final generated code.

unsigned int thinlto_module_get_num_object_files(thinlto_code_gen_t cg)

Returns the number of object files produced by the ThinLTO CodeGenerator.

lto_bool_t lto_module_is_thinlto(lto_module_t mod)

Test if a module has support for ThinLTO linking.

void thinlto_codegen_process(thinlto_code_gen_t cg)

Optimize and codegen all the modules added to the codegenerator using ThinLTO.

void thinlto_codegen_set_codegen_only(thinlto_code_gen_t cg, lto_bool_t codegen_only)

Perform CodeGen only: disable all other stages.

void thinlto_codegen_dispose(thinlto_code_gen_t cg)

Frees the generator and all memory it internally allocated.

bool lto_bool_t

Definition lto.h:31

Type to wrap a single object returned by ThinLTO.

Definition lto.h:685

const char * Buffer

Definition lto.h:686

size_t Size

Definition lto.h:687