Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Getting started LLVM 14 C API

License

NotificationsYou must be signed in to change notification settings

mo-xiaoming/getting-started-llvm-c-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Started from Pauladam Smith's bloghow to get started with llvm c api, then try to make it a comprehensive code guide about llvm c api

Build

Typical cmake project, make sure LLVM in cmake search path

MCJIT

  1. simple function --create_sum_fn: Adopted Paladam'ssum code to LLVM 14 and C++
  2. call function in libc --create_out_fn: Call functions from libc,puts
  3. recursive calls and TCE --create_factorial_fn: Recursive functionfactorial(n) withLLVMAddTailCallEliminationPass to eliminate recursive calls in IR
  4. more complicated recursive calls and TCE --create_fib_fn: Naive recursive implementation offib(n), clearly only the lastfib call infib(n-1) + fib(n-2) got TCE optimized
  5. if-the-else with PHI --create_is_odd_fn:if then else pattern
  6. while-do without PHI --create_factorial_loop_fn:while-do without PHI. For factorial, this version and the recursive one optimized down to the same IR code.
  7. array access with GEP --create_ap_sum_fn: Sum of an array of arithmetic progression numbers, I really hoped LLVM can do it in the way of(f + l) * n / 2, but sadly no, still loops
  8. Niubi LLVM optimization --create_ap_simple_sum_fn: Sum ofan array of a sequence of arithmetic progression numbers, still not using that formula, maybe because of some optimization are missing,unlike pure -O3, maybe it is being done during re-write

ORC V2 JIT

Inorcv2jit.cpp file

  1. Found memory leaks inllvm official example, filed abug report, fixed in4246269
  2. In the same bug report, I mentionedLLVMOrcIRTransformLayerSetTransform causesmemory leaks, fixed inbc062e0
  3. cal_fact_4: call to another function in a different module

[8]ページ先頭

©2009-2025 Movatter.jp