1. 23 Jun, 2015 4 commits
  2. 22 Jun, 2015 8 commits
    • Subzero: Use more "= default;" for ctors and dtors. · e587d949
      Jim Stichnoth authored
      Look for "() override {}" and "() final {}" patterns.
      
      Don't touch IceTargetLoweringX8632.* to spare a refactoring in
      progress.
      
      BUG= none
      R=jpp@chromium.org
      
      Review URL: https://codereview.chromium.org/1201023002
    • Fix llvm makefile to handle macro INPUT_IS_TEXTUAL_BITCODE. · cac05851
      Karl Schimpf authored
      BUG=None
      R=stichnot@chromium.org
      
      Review URL: https://codereview.chromium.org/1205463002
    • Allow pnacl-sz to be compiled to textual bitcode records. · 6f9ba115
      Karl Schimpf authored
      This has been added to allow fuzzing to be applied to textual bitcode
      records. When built with make option TEXTUAL_BITCODE=1, the
      corresponding generated pnacl-sz will preprocess the input file
      (containing the textual form of bitcode records) and generate
      a corresponding data stream with the binary form.
      
      Note that the texual form of bitcode records is not LLVM assembly
      (i.e. .ll files). Rather, it is sequences of texual integers
      corresponding to bitcode records.
      
      Dependent on: https://codereview.chromium.org/1191393004
      
      BUG= https://code.google.com/p/nativeclient/issues/detail?id=4169
      R=stichnot@chromium.org
      
      Review URL: https://codereview.chromium.org/1190413004
    • Subzero: Fix "make -f Makefile.standalone MINIMAL=1 check". · c8799688
      Jim Stichnoth authored
      Some recent ARM changes turned out to break the lit tests for the MINIMAL build.  Two main issues:
      
      1. ARM tests are currently asm-only, so allow_dump needs to be required.
      
      2. GlobalContext::emitFileHeader() needs to return gracefully instead of calling report_fatal_error(), to allow error tests to produce the right error output.
      
      BUG= none
      R=kschimpf@google.com
      
      Review URL: https://codereview.chromium.org/1202563002
    • Subzero. Fixes memory leaks. · 1bec8bcd
      John Porto authored
      Adds named constructors to initialzers. Removes destructor from Inst.
      
      BUG= None
      R=stichnot@chromium.org
      
      Review URL: https://codereview.chromium.org/1181013016.
    • Subzero: Apply commutativity to the RMW optimization. · 8525c329
      Jim Stichnoth authored
      The read-modify-write (RMW) optimization looks for patterns like this:
      
        a = Load addr
        b = <op> a, other
        Store b, addr
      
      and essentially transforms them into this:
      
        RMW <op>, addr, other
      
      This CL also applies the transformation when the middle instruction is
        b = <op> other, a
      and <op> is commutative.
      
      BUG= https://code.google.com/p/nativeclient/issues/detail?id=4095
      R=jpp@chromium.org
      
      Review URL: https://codereview.chromium.org/1193103005
    • Subzero: Use C++11 member initializers where practical. · eafb56cb
      Jim Stichnoth authored
      Also change the pattern "foo() {}" into "foo() = default;" for ctors and dtors.
      
      Generally avoids initializing unique_ptr<> members to nullptr in a .h file, because that requires knowing the definition of the underlying class which may not be available to all includers.
      
      BUG= none
      R=jpp@chromium.org
      
      Review URL: https://codereview.chromium.org/1197223002
    • Add constant blinding/pooling option for X8632 code translation. · 253dc8a8
      Qining Lu authored
      GOAL:
      The goal is to remove the ability of an attacker to control immediates emitted into the text section.
      
      OPTION:
      The option -randomize-pool-immediates is set to none by default (-randomize-pool-immediates=none). To turn on constant blinding, set -randomize-pool-immediates=randomize; to turn on constant pooling, use -randomize-pool-immediates=pool.
      
      Not all constant integers in the input pexe file will be randomized or pooled. The signed representation of a candidate constant integer must be between -randomizeOrPoolImmediatesThreshold/2 and +randomizeOrPoolImmediatesThreshold/2. This threshold value can be set with command line option: "-randomize-pool-threshold". By default this threshold is set to 0xffff.
      
      The constants introduced by instruction lowering (e.g. constants in shifting, masking) and argument lowering are not blinded in this way. The mask used for sandboxing is not affected either.
      
      APPROACH:
      We use GAS syntax in these examples.
      
      Constant blinding for immediates:
      Original:
          add 0x1234, eax
      After:
          mov 0x1234+cookie, temp_reg
          lea -cookie[temp_reg], temp_reg
          add temp_reg, eax
      
      Constant blinding for memory addressing offsets:
      Original:
        mov 0x1234(eax, esi, 1), ebx
      After:
        lea 0x1234+cookie(eax), temp_reg
        mov -cookie(temp_reg, esi, 1), ebx
      
      We use "lea" here because it won't affect flag register, so it is safer to transform immediate-involved instructions.
      
      Constant pooling for immediates:
      Original:
          add 0x1234, eax
      After:
          mov [memory label of 0x1234], temp_reg
          add temp_reg, eax
      
      Constant pooling for addressing offsets:
      Original:
        mov 0x1234, eax
      After:
        mov [memory label of 0x1234], temp_reg
        mov temp_reg, eax
      
      Note in both cases, temp_reg may be assigned with "eax" here, depends on the
      liveness analysis. So this approach may not require extra register.
      
      IMPLEMENTATION:
        Processing:
         TargetX8632::randomizeOrPoolImmediate(Constant *Immediate, int32_t RegNum);
         TargetX8632::randomizeOrPoolImmediate(OperandX8632Mem *Memoperand, int32_t RegNum);
      
        Checking eligibility:
          ConstantInteger32::shouldBeRandomizedOrPooled(const GlobalContext *Ctx);
      
      ISSUES:
      1. bool Ice::TargetX8632::RandomizationPoolingPaused is used to guard some translation phases to disable constant blinding/pooling temporally. Helper class BoolFlagSaver is added to latch the value of RandomizationPoolingPaused.
      
      Known phases that need to be guarded are: doLoadOpt() and advancedPhiLowering(). However, during advancedPhiLowering(), if the destination variable has a physical register allocated, constant blinding and pooling are allowed. Stopping blinding/pooling for doLoadOpt() won't hurt our randomization or pooling as the optimized addressing operands will be processed again in genCode() phase.
      
      2. i8 and i16 constants are collected with different constant pools now, instead of sharing a same constant pool with i32 constants. This requires emitting two more pools during constants lowering, hence create two more read-only data sections in the resulting ELF and ASM. No runtime issues have been observed so far.
      
      BUG=
      R=stichnot@chromium.org
      
      Review URL: https://codereview.chromium.org/1185703004.
  3. 18 Jun, 2015 4 commits
  4. 17 Jun, 2015 2 commits
  5. 16 Jun, 2015 1 commit
  6. 15 Jun, 2015 2 commits
  7. 12 Jun, 2015 3 commits
  8. 11 Jun, 2015 5 commits
  9. 10 Jun, 2015 2 commits
  10. 08 Jun, 2015 1 commit
  11. 05 Jun, 2015 4 commits
  12. 04 Jun, 2015 2 commits
    • Subzero: Legalize FP constants directly into memory operands. · 03ffa585
      Jim Stichnoth authored
      Previously, the legalize() function would always force a floating point constant into an xmm register before it could be used in an instruction.  This uses an extra register unnecessarily when the instruction allows a memory operand for that operand.
      
      We improve this by lowering the FP constant operand to an OperandX8632Mem that wraps a ConstantRelocatable representing the label for the constant pool entry, e.g. [.L$float$0].  (This may end up being copied into an xmm register if the instruction doesn't allow a memory operand for that operand.)
      
      BUG= https://code.google.com/p/nativeclient/issues/detail?id=4095
      R=jvoung@chromium.org
      
      Review URL: https://codereview.chromium.org/1163943005
    • Use report_fatal_error before destroying input object on error. · 2f7f2b7e
      Jan Voung authored
      The input object may be a QueueStreamer, which the compile
      server will still have a reference to (even though
      downstream the memory object API and parser API thinks it
      has a unique_ptr). Terminate the thread quickly on error,
      instead of free'ing and causing a use-after-free.
      
      Also set up a report_fatal_error handler which has access
      to the server's state. This allows the server to record the
      error and stop pushing bytes to the QueueStreamer.
      Otherwise the QueueStreamer can get full without a consumer
      still active to unblock.
      
      Unfortunately the fatal error handler only terminates the
      current thread, and not all worker threads. NaCl doesn't
      have support for signals or pthread_kill.
      E.g., with pthread_kill(std_thread.native_handle(), SIGABRT).
      So, other worker/emitter threads will have to hang waiting on
      more input or something.
      
      Random clang-format edits from 3.7.
      
      BUG= https://code.google.com/p/nativeclient/issues/detail?id=4163
      TEST= tbd:
      
      I manually ran the translator a dummy text file (invalid bitcode
      header), and observed that this no longer crashes. Instead the SRPC
      calls finish and I see:
      
      3> [17812,4147750656:14:23:02.025382] Streaming file at 100000 bps
      [17812,4147750656:14:23:12.511574] RPC call failed: Rpc application returned an error.
      [17812,4147750656:14:23:12.511625] StreamChunk failed
      [17812,4147750656:14:23:12.511655] stream_file: SendDataChunk failed, but returning without failing. Expect call to StreamEnd.4> rpc call initiated StreamEnd::isss
      [17812,4147750656:14:23:12.511931] RPC call failed: Rpc application returned an error.
      rpc call complete StreamEnd::isss
      output 0:  i(0)
      output 1:  s("")
      output 2:  s("")
      output 3:  s("Invalid PNaCl bitcode header")
      [17812,4147750656:14:23:12.512102] Command [rpc] failed.
      
      R=kschimpf@google.com, stichnot@chromium.org
      
      Review URL: https://codereview.chromium.org/1168543002
  13. 03 Jun, 2015 2 commits
    • Subzero: Improve/refactor folding loads into the next instruction. · 8e6bf6e1
      Jim Stichnoth authored
      This is turned into a separate (O2-only) pass that looks for opportunities:
      1. A Load instruction, or an AtomicLoad intrinsic that would be lowered just like a Load instruction
      2. Followed immediately by an instruction with a whitelisted kind that uses the Load dest variable as one of its operands
      3. Where the whitelisted instruction ends the live range of the Load dest variable.
      
      In such cases, the original two instructions are deleted and a new instruction is added that folds the load into the whitelisted instruction.
      
      We also do some work to splice the liveness information (Inst::LiveRangesEnded and Inst::isLastUse()) into the new instruction, so that the target lowering pass might still take advantage.  Currently this is used quite sparingly, but in the future we could use that along with operator commutativity to choose among different lowering sequences to reduce register pressure.
      
      The whitelisted instruction kinds are chosen based primarily on whether the main operation's native instruction can use a memory operand - e.g., arithmetic (add/sub/imul/etc), compare (cmp/ucomiss), cast (movsx/movzx/etc).  Notably, call and ret are not included because arg passing is done through simple assignments which normal lowering is sufficient for.
      
      BUG= none
      R=jvoung@chromium.org, mtrofin@chromium.org
      
      Review URL: https://codereview.chromium.org/1169493002
    • Subzero: Change pnacl_newlib ==> pnacl_newlib_raw in scripts. · bb9d11a5
      Jim Stichnoth authored
      BUG= none
      R=jvoung@chromium.org, kschimpf@google.com
      
      Review URL: https://codereview.chromium.org/1162903003