Subzero: Allow per-method controls.

Several aspects of compilation can now be controlled with fine per-function granularity:

- Focus -timing on individual functions
- Only translate certain functions
- Enable verbosity only for certain functions
- Force O2 translation for certain functions (with Om1 default)

In addition, -test-status limits the output of -verbose=status.  This is just used to enable lit testing of the RangeSpec class.

The main motivation here is to enable bisection debugging of a PNaCl application running in the browser.  The initial use is to control O2 versus Om1, and could be extended to control things like address mode inference and advanced phi lowering, possibly even controlling at the granularity of the instruction numbers.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4370
R=eholk@chromium.org, jpp@chromium.org

Review URL: https://codereview.chromium.org/1900543002 .
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 285b489..0ff94b4 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -197,20 +197,25 @@
 void Cfg::translate() {
   if (hasError())
     return;
+  // Cache the possibly-overridden optimization level once translation begins.
+  // It would be nicer to do this in the constructor, but we need to wait until
+  // after setFunctionName() has a chance to be called.
+  OptimizationLevel =
+      getFlags().matchForceO2(getFunctionName(), getSequenceNumber())
+          ? Opt_2
+          : getFlags().getOptLevel();
   if (BuildDefs::timers()) {
-    const std::string TimingFocusOn = getFlags().getTimingFocusOn();
-    if (!TimingFocusOn.empty()) {
-      const std::string Name = getFunctionName().toString();
-      if (TimingFocusOn == "*" || TimingFocusOn == Name) {
-        setFocusedTiming();
-        getContext()->resetTimer(GlobalContext::TSK_Default);
-      }
+    if (getFlags().matchTimingFocus(getFunctionName(), getSequenceNumber())) {
+      setFocusedTiming();
+      getContext()->resetTimer(GlobalContext::TSK_Default);
     }
   }
   if (BuildDefs::dump()) {
-    if (isVerbose(IceV_Status)) {
+    if (isVerbose(IceV_Status) &&
+        getFlags().matchTestStatus(getFunctionName(), getSequenceNumber())) {
       getContext()->getStrDump() << ">>>Translating "
-                                 << getFunctionNameAndSize() << "\n";
+                                 << getFunctionNameAndSize()
+                                 << " seq=" << getSequenceNumber() << "\n";
     }
   }
   TimerMarker T_func(getContext(), getFunctionName().toStringOrEmpty());
@@ -222,7 +227,7 @@
     profileBlocks();
     // TODO(jpp): this is fragile, at best. Figure out a better way of
     // detecting exit functions.
-    if (GlobalContext::matchSymbolName(getFunctionName(), "exit")) {
+    if (getFunctionName().toStringOrEmpty() == "exit") {
       addCallToProfileSummary();
     }
     dump("Profiled CFG");