Skip to content

Commit

Permalink
Log a warning instead of throwing an exception when opt is not availa… (
Browse files Browse the repository at this point in the history
hernanponcedeleon#666)

Signed-off-by: Hernan Ponce de Leon <hernanl.leon@huawei.com>
Co-authored-by: Hernan Ponce de Leon <hernanl.leon@huawei.com>
  • Loading branch information
2 people authored and tonghaining committed May 24, 2024
1 parent d53866e commit 3f9745f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static File compileWithClang(File file, String cflags) throws Exception {
return new File(outputFileName);
}

public static File applyLlvmPasses(File file) throws Exception {
public static File applyLlvmPasses(File file) throws IOException {
final String outputFileName = getOutputName(file, "-opt.ll");
ArrayList<String> cmd = new ArrayList<>();
cmd.add("opt");
Expand All @@ -45,7 +45,12 @@ public static File applyLlvmPasses(File file) throws Exception {
cmd.add("-S");
cmd.add("-o");
cmd.add(outputFileName);
runCmd(cmd);
try {
runCmd(cmd);
} catch (Exception e) {
logger.warn("Failed to run opt (llvm optimizations). Continuing without optimizations.");
return file;
}
return new File(outputFileName);
}

Expand Down

0 comments on commit 3f9745f

Please sign in to comment.