driver: support -fgo-debug-optimization option
Change-Id: I07ff4c845b3d7bd3bb9ddda5f870f229651c2190
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/176040
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/bridge/go-c.h b/bridge/go-c.h
index cd438ac..5b8b6e7 100644
--- a/bridge/go-c.h
+++ b/bridge/go-c.h
@@ -36,6 +36,7 @@
int debug_escape_level;
const char* debug_escape_hash;
int64_t nil_check_size_threshold;
+ bool debug_optimization;
};
// These are defined in gofrontend and called from the bridge.
diff --git a/driver/CompileGo.cpp b/driver/CompileGo.cpp
index e217fcb..d7cecd8 100644
--- a/driver/CompileGo.cpp
+++ b/driver/CompileGo.cpp
@@ -680,6 +680,10 @@
opt::Arg *hasharg =
args_.getLastArg(gollvm::options::OPT_fgo_debug_escape_hash_EQ);
args.debug_escape_hash = (hasharg != nullptr ? hasharg->getValue() : NULL);
+ args.debug_optimization =
+ driver_.reconcileOptionPair(gollvm::options::OPT_fgo_debug_optimization,
+ gollvm::options::OPT_fno_go_debug_optimization,
+ false);
args.nil_check_size_threshold = -1;
args.linemap = linemap_.get();
args.backend = bridge_.get();
diff --git a/driver/GollvmOptions.td b/driver/GollvmOptions.td
index ffa5380..7500652 100644
--- a/driver/GollvmOptions.td
+++ b/driver/GollvmOptions.td
@@ -466,6 +466,14 @@
" given suffix. Can be used to binary search across"
" functions to uncover escape analysis bugs.">;
+def fgo_debug_optimization : Flag<["-"], "fgo-debug-optimization">,
+ Group<f_Group>,
+ HelpText<"Emit gofrontend optimization diagnostics">;
+
+def fno_go_debug_optimization : Flag<["-"], "fno-go-debug-optimization">,
+ Group<f_Group>,
+ HelpText<"Do not emit gofrontend optimization diagnostics">;
+
def tracelevel_EQ : Joined<["-", "--"], "tracelevel=">, Group<Developer_Group>,
HelpText<"Set debug trace level (def: 0, no trace output)">;