Skip to content

Commit 22ac844

Browse files
authored
Merge pull request #554 from ChrisCummins/feature/strip-opts
[llvm] Enable the strip-optnone-attribute binary to take a list of paths
2 parents 67ff153 + 97cb9cb commit 22ac844

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

compiler_gym/envs/llvm/service/StripOptNoneAttribute.cc

+15-11
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@ namespace fs = boost::filesystem;
2121
using namespace compiler_gym;
2222
using namespace compiler_gym::llvm_service;
2323

24-
int main(int argc, char** argv) {
25-
google::InitGoogleLogging(argv[0]);
26-
27-
CHECK(argc == 2) << "Usage: compute_observation <bitcode-path>";
28-
29-
const fs::path workingDirectory{"."};
30-
24+
void stripOptNoneAttributesOrDie(const fs::path& path, BenchmarkFactory& benchmarkFactory) {
3125
compiler_gym::Benchmark request;
3226
request.set_uri("user");
33-
request.mutable_program()->set_uri(fmt::format("file:///{}", argv[1]));
27+
request.mutable_program()->set_uri(fmt::format("file:///{}", path.string()));
3428

35-
auto& benchmarkFactory = BenchmarkFactory::getSingleton(workingDirectory);
3629
std::unique_ptr<::llvm_service::Benchmark> benchmark;
3730
{
3831
const auto status = benchmarkFactory.getBenchmark(request, &benchmark);
@@ -58,9 +51,20 @@ int main(int argc, char** argv) {
5851
}
5952
}
6053

61-
ASSERT_OK(benchmark->writeBitcodeToFile(argv[1]));
62-
std::cerr << "Stripped " << removedOptNoneCount << " optnone attributes from " << argv[1]
54+
ASSERT_OK(benchmark->writeBitcodeToFile(path.string()));
55+
std::cerr << "Stripped " << removedOptNoneCount << " optnone attributes from " << path.string()
6356
<< std::endl;
57+
}
58+
59+
int main(int argc, char** argv) {
60+
google::InitGoogleLogging(argv[0]);
61+
62+
const fs::path workingDirectory{"."};
63+
auto& benchmarkFactory = BenchmarkFactory::getSingleton(workingDirectory);
64+
65+
for (int i = 1; i < argc; ++i) {
66+
stripOptNoneAttributesOrDie(argv[i], benchmarkFactory);
67+
}
6468

6569
return 0;
6670
}

0 commit comments

Comments
 (0)