Subzero: Fixes for Hello World and bisection debugging.

Add the llvm2ice -sandbox option (false by default) to select between
native and sandboxed code generation.  Currently, it controls whether
the llvm.nacl.read.tp intrinsic is lowered to gs:[0x0] or a call to
__nacl_read_tp.

Change the asm output slightly for -ffunction-sections so that objdump
is more willing to provide a disassembly.

BUG= none
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/504963002
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 0423e39..930836b 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -18,6 +18,7 @@
 #include "IceDefs.h"
 #include "IceCfg.h"
 #include "IceCfgNode.h"
+#include "IceClFlags.h"
 #include "IceInstX8632.h"
 #include "IceOperand.h"
 #include "IceTargetLoweringX8632.def"
@@ -3052,13 +3053,19 @@
     return;
   }
   case Intrinsics::NaClReadTP: {
-    Constant *Zero = Ctx->getConstantZero(IceType_i32);
-    Operand *Src = OperandX8632Mem::create(Func, IceType_i32, NULL, Zero, NULL,
-                                           0, OperandX8632Mem::SegReg_GS);
-    Variable *Dest = Instr->getDest();
-    Variable *T = NULL;
-    _mov(T, Src);
-    _mov(Dest, T);
+    if (Ctx->getFlags().UseSandboxing) {
+      Constant *Zero = Ctx->getConstantZero(IceType_i32);
+      Operand *Src =
+        OperandX8632Mem::create(Func, IceType_i32, NULL, Zero, NULL,
+                                0, OperandX8632Mem::SegReg_GS);
+      Variable *Dest = Instr->getDest();
+      Variable *T = NULL;
+      _mov(T, Src);
+      _mov(Dest, T);
+    } else {
+      InstCall *Call = makeHelperCall("__nacl_read_tp", Instr->getDest(), 0);
+      lowerCall(Call);
+    }
     return;
   }
   case Intrinsics::Setjmp: {