Skip to content

Commit 283941e

Browse files
author
Chris Cummins
authored
Merge pull request #515 from ChrisCummins/bitcode-writer
[llvm] Fix invalid use of BitcodeWriter API.
2 parents a056c6c + 085e79c commit 283941e

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

compiler_gym/envs/llvm/service/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ cc_binary(
308308
genrule(
309309
name = "strip-optnone-bin",
310310
srcs = [":strip-optnone-attribute-prelinked"],
311-
outs = ["strip-optnone"],
311+
outs = ["strip-optnone-attribute"],
312312
cmd = select({
313313
"@llvm//:darwin": (
314314
"cp $(location :strip-optnone-attribute-prelinked) $@"

compiler_gym/envs/llvm/service/Benchmark.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ namespace {
3434

3535
BenchmarkHash getModuleHash(const llvm::Module& module) {
3636
BenchmarkHash hash;
37-
llvm::SmallVector<char, 256> buffer;
37+
Bitcode bitcode;
38+
3839
// Writing the entire bitcode to a buffer that is then discarded is
3940
// inefficient.
40-
llvm::BitcodeWriter writer(buffer);
41-
writer.writeModule(module, /*ShouldPreserveUseListOrder=*/false,
42-
/*Index=*/nullptr, /*GenerateHash=*/true, &hash);
41+
llvm::raw_svector_ostream ostream(bitcode);
42+
llvm::WriteBitcodeToFile(module, ostream,
43+
/*ShouldPreserveUseListOrder=*/false,
44+
/*Index=*/nullptr, /*GenerateHash=*/true, &hash);
45+
4346
return hash;
4447
}
4548

compiler_gym/envs/llvm/service/StripOptNoneAttribute.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <iostream>
1010

1111
#include "compiler_gym/envs/llvm/service/BenchmarkFactory.h"
12-
#include "compiler_gym/envs/llvm/service/Observation.h"
13-
#include "compiler_gym/envs/llvm/service/ObservationSpaces.h"
1412
#include "compiler_gym/service/proto/compiler_gym_service.pb.h"
1513
#include "compiler_gym/util/GrpcStatusMacros.h"
1614
#include "llvm/IR/Module.h"

0 commit comments

Comments
 (0)