This program is for testing features that rely on multi-module bitcode files.
It takes a multi-module bitcode file, extracts one of the modules and writes
it to the output file.
Details
Diff Detail
- Build Status
Buildable 1685 Build 1685: arc lint + arc unit
Event Timeline
Could we have a cheap way to extract modules without parsing the IR?
(I assume we need D26179 to get in before we can have a test with multiple modules)
Could we have a cheap way to extract modules without parsing the IR?
Most likely, but it would probably require a change to the bitcode format because we represent the VST offset as an offset from the start of the file rather than the start of the module.
(I assume we need D26179 to get in before we can have a test with multiple modules)
Right.
LGTM.
Right I think any relative offset should begin with the module block! I'm fine keeping this as future work.
This is just a drive-by comment, but you might be able to get away with less boilerplate by just teaching llvm-extract to do this. I don't feels strongly about this suggestion so do whatever you find best.
Having a llvm-bcutils tool is a good idea, but that a larger refactoring. We should think about it, but not block committing this patch either.
Actually this is a problem and I think we should address it now.
The issue is that if we go with the current solution, we'll have to support "forever" the fact that a bitcode file with multiple module can have offset from the beginning of the file.
It seems to me that we have to first update the bitcode to make sure each offset start from the beginning of the module.
llvm/tools/llvm-modextract/llvm-modextract.cpp | ||
---|---|---|
54 | For symmetry with llvm-cat, can we have the same -b option: std::error_code EC; std::unique_ptr<tool_output_file> Out( new tool_output_file(OutputFilename, EC, sys::fs::F_None)); ExitOnErr(errorCodeToError(EC)); if (BinaryExtract) { // Write header ... //Dump Ms[ModuleIndex].getBuffer() in Out->os() ... return 0; } std::unique_ptr<Module> M = ExitOnErr(Ms[ModuleIndex].parseModule(Context)); WriteBitcodeToFile(M.get(), Out->os()); |
For symmetry with llvm-cat, can we have the same -b option: