Skip to content

Commit

Permalink
improve: use herbie improve instead
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrantq committed May 16, 2024
1 parent dc7f495 commit efa1eac
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions enzyme/Enzyme/Herbie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <fstream>
#include <map>
#include <sstream>
#include <string>

#include "Herbie.h"
Expand All @@ -36,6 +37,7 @@ void runViaHerbie(const std::string &cmd) {
std::string tmpin = "/tmp/herbie_input";
std::string tmpout = "/tmp/herbie_output";

std::remove(tmpout.c_str());
std::ofstream input(tmpin);
if (!input) {
llvm::errs() << "Failed to open input file.\n";
Expand All @@ -45,21 +47,14 @@ void runViaHerbie(const std::string &cmd) {
input.close();

std::string Program = HERBIE_BINARY;

llvm::StringRef Args[] = {"", "shell"};
llvm::ArrayRef<llvm::Optional<llvm::StringRef>> Redirects = {
llvm::StringRef(tmpin), // stdin
llvm::StringRef(tmpout), // stdout
llvm::StringRef(tmpout) // stderr
};

llvm::StringRef Args[] = {Program, "improve", tmpin, tmpout};
std::string ErrMsg;
bool ExecutionFailed = false;

llvm::errs() << "Executing: " << Program << "\n";

llvm::sys::ExecuteAndWait(Program, Args, /*Env=*/llvm::None,
/*Redirects=*/Redirects,
/*Redirects=*/llvm::None,
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg,
&ExecutionFailed);

Expand All @@ -75,6 +70,7 @@ void runViaHerbie(const std::string &cmd) {
}

std::string line;
llvm::errs() << "Herbie output:\n";
while (std::getline(output, line)) {
llvm::errs() << line << "\n";
}
Expand Down

0 comments on commit efa1eac

Please sign in to comment.