Proper way to do thinlto (from code)

I’m using llvm-c (but if needed can call c++ stuff too if nedeed); what’s the proper way to emit bitcode with thinlto info so the linker can parallelize ?

I’m currently using:

unwrap(PMB)->PrepareForThinLTO = b;

on the pass manager builder, but that doesn’t seem to be enough?

You need to make sure that your bitcode file has a module summary index. You can do that either by creating a WriteBitcodePass with EmitSummaryIndex set to true or by calling WriteBitcodeToFile with a module summary index that you created yourself. It doesn’t look like either of those options are hooked up to the c API, though.

Peter

Thanks!

I’ll create a wrapper for WriteBitcodePass. Do I still need the PrepareForThinTLO pass or is the writeBitCodePass enough?

I would leave prepare set to true, I don’t think it is absolutely necessary but it should help make the bitcode files smaller and easier to optimize.

Peter