This is an archive of the discontinued LLVM Phabricator instance.

[C API] Add LLVMWriteThinLTOBitcodeToMemoryBuffer to C API
Needs ReviewPublic

Authored by aykevl on Feb 10 2022, 5:19 AM.

Details

Summary

A similar function already exists in Rust as LLVMRustThinLTOBufferCreate. I needed it in the C API for my own project so I wrote this patch to add it.

I tried using the new pass manager, but somehow that didn't work: no module summary was created.

This didn't work:

std::string Data;
raw_string_ostream OS(Data);
ModulePassManager MPM;
ModuleAnalysisManager MAM;
MPM.addPass(ThinLTOBitcodeWriterPass(OS, nullptr));
MPM.run(*unwrap(M), MAM);
return wrap(MemoryBuffer::getMemBufferCopy(OS.str()).release());

Diff Detail

Event Timeline

aykevl created this revision.Feb 10 2022, 5:19 AM
aykevl requested review of this revision.Feb 10 2022, 5:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2022, 5:19 AM
aykevl updated this revision to Diff 407493.Feb 10 2022, 5:20 AM
  • add Go API
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 6:49 AM

Hi @aykevl . I unfortunately am not familiar with thin LTO, so it is very difficult for me to review this. Maybe @mehdi_amini could help? I know he worked on this at some point, and if he cannot, he'll know who can.