Previously, this unconditionally emitted text IR. I ran
into a bug that manifested in broken disassembly, so the
desired output was the bitcode format. If the input format
was binary bitcode, the requested output file ends in .bc,
or an explicit -output-bitcode option was used, emit bitcode.
Details
- Reviewers
aeubanks regehr lebedev.ri fhahn
Diff Detail
Unit Tests
Event Timeline
wdyt about replacing -output-bitcode with -output-type=autodetect|bitcode|text, defaulting to autodetect? that seems conceptually cleaner than this logic, which has a weird imbalance between preferring bitcode vs text
I thought about doing this. We have so little consistency throughout the tools for this. Most seem to use -S to switch to text, and I don't think any try to detect based on the file extension. Since it's a reduction tool, the most sensible thing would probably be to just consistently reuse the input type (this also applies to -write-tmp-files-as-bitcode. Most of the tools happen to accept .ll or .bc inputs, but you could be reducing something that specifically needs one or the other)
Drop file extension based guess. Just preserve the input format, or follow the existing flag
llvm/test/tools/llvm-reduce/Inputs/test-output-format.ll | ||
---|---|---|
2 | can you use llvm-as instead of checking in the .bc file? | |
llvm/tools/llvm-reduce/ReducerWorkItem.h | ||
47 | returning std::pair<std::unique_ptr<ReducerWorkItem>, bool> and using C++17 structured bindings seems nicer | |
llvm/tools/llvm-reduce/llvm-reduce.cpp | ||
161 | does auto [OutputFileName, OutputBitcode] = work? |
can you use llvm-as instead of checking in the .bc file?