[llvm] Fix invalid use of BitcodeWriter API.
Use the WriteBitcodeToFile() function rather than
BitcodeWriter::writeMethod() method to prevent a debugging assertion.
Issue
@@ -34,12 +34,15 @@ namespace {
BenchmarkHash getModuleHash(const llvm::Module& module) {
BenchmarkHash hash;
- llvm::SmallVector<char, 256> buffer;
+ Bitcode bitcode;
+
// Writing the entire bitcode to a buffer that is then discarded is
// inefficient.
- llvm::BitcodeWriter writer(buffer);
- writer.writeModule(module, /*ShouldPreserveUseListOrder=*/false,
+ llvm::raw_svector_ostream ostream(bitcode);
+ llvm::WriteBitcodeToFile(module, ostream,
+ /*ShouldPreserveUseListOrder=*/false,
/*Index=*/nullptr, /*GenerateHash=*/true, &hash);
+
return hash;
}
