About Runtime Optimization

Hi all members,

I am new to LLVM. I am getting to know how the trace-based Runtime
Optimization feature of LLVM works and how I can use it.

From some old documents of LLVM, I've got a general idea that we instrument

a program with First & Second level Instrumentations (FLI & SLI), then link
it with runtime libraries that handle runtime generation of traces.

The FLI will detect hot loop regions, then it will invoke SLI to further
detect hot paths forming a trace inside the loop. Finally, The Runtime
Optimizer is invoked to do optimization on that trace...

Then I also did some search in this mailing list and on the Internet.
However, I have not found any documentation showing in detail how to do
this.

I wonder:

1) given a program written purely in C, can we apply this feature using the
tools & libraries provided by LLVM? and How (if yes)?

2) Is the design of FLI & SLI outdated? How is the state of runtime
optimization in LLVM dev at the moment?

3) If the design of FLI & SLI is still used for runtime optimization:
- Is 'opt
-insert-edge-profiling/-insert-optimal-edge-profiling/-insert-path-profiling'
the right way to insert FLI and/or SLI to the program binary?
- what are the exact libraries I should use for runtime generation of
traces?

Any reply/suggestion would be highly appreciated!

Best regards,