OSDN Git Service

android-x86/external-swiftshader.git
8 years agoBlacklisted instrumenting _Balloc.
Thomas Lively [Thu, 7 Jul 2016 21:56:21 +0000 (14:56 -0700)]
Blacklisted instrumenting _Balloc.

Increases number of spec2k tests that run successfully with ASan from 2 to 6.

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2128383002 .

8 years agoSubZero: legalize for f32/f64 constants in MIPS32
Mohit Bhakkad [Thu, 7 Jul 2016 12:07:35 +0000 (05:07 -0700)]
SubZero: legalize for f32/f64 constants in MIPS32

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2123723002 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years agoSubzero, MIPS32: Extend InstMIPS32Mov to support different data types
Srdjan Obucina [Wed, 6 Jul 2016 22:58:07 +0000 (15:58 -0700)]
Subzero, MIPS32: Extend InstMIPS32Mov to support different data types

This patch extends InstMIPS32Mov instruction to support different datatypes, and emit proper low level instruction depending on operands properties and data types.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2122043002 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years agoFixed instruction corruption bug for multiple returns.
Thomas Lively [Wed, 6 Jul 2016 20:46:12 +0000 (13:46 -0700)]
Fixed instruction corruption bug for multiple returns.

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2128643002 .

8 years agoImplemented loose checking for potential widened loads
Thomas Lively [Wed, 6 Jul 2016 17:02:45 +0000 (10:02 -0700)]
Implemented loose checking for potential widened loads

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2115693002 .

8 years agoImplemented aligning and poisoning global redzones
Thomas Lively [Thu, 30 Jun 2016 18:06:12 +0000 (11:06 -0700)]
Implemented aligning and poisoning global redzones

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com, stichnot@chromium.org

Review URL: https://codereview.chromium.org/2108083002 .

8 years agoSubzero: Fix Calling Convention for MIPS O32 abi
Mohit Bhakkad [Wed, 29 Jun 2016 13:51:08 +0000 (06:51 -0700)]
Subzero: Fix Calling Convention for MIPS O32 abi

We should take care of alignment while discarding GPR registers, I have written larger explanation in a comment.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2101093003 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years agoAdded tests for bug detection on locals
Thomas Lively [Wed, 29 Jun 2016 05:16:05 +0000 (22:16 -0700)]
Added tests for bug detection on locals

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2101173002 .

8 years agoSubzero: Merge SpillVariable functionality directly into Variable.
Jim Stichnoth [Wed, 29 Jun 2016 04:40:33 +0000 (21:40 -0700)]
Subzero: Merge SpillVariable functionality directly into Variable.

Specifically, this is the ability to link variable B to variable A, such that if neither A nor B get a register assignment, they share a stack slot.

This CL just refactors and keeps basically the same functionality, in preparation for new work on variable splitting.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2107073002 .

8 years agoShort Circuit Evaluation
Manasij Mukherjee [Mon, 27 Jun 2016 23:12:37 +0000 (16:12 -0700)]
Short Circuit Evaluation

Split Nodes whenever an early jump is possible by short circuiting boolean
operations. Nodes are split after conservatively checking for side effects,
which include definition of multi block variables, function calls and
instructions involving memory.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2069923004 .

8 years agoSubzero: Fix a potential null-pointer dereference.
Jim Stichnoth [Mon, 27 Jun 2016 23:11:03 +0000 (16:11 -0700)]
Subzero: Fix a potential null-pointer dereference.

BUG= none
R=jpp@chromium.org, manasijm@google.com

Review URL: https://codereview.chromium.org/2103613002 .

8 years agoReorder X8664 Register Defs so that scratch registers are allocated first
Manasij Mukherjee [Mon, 27 Jun 2016 22:42:12 +0000 (15:42 -0700)]
Reorder X8664 Register Defs so that scratch registers are allocated first

Reduces register pressure and the number of push/pops slightly.

BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2100333002 .

8 years agoInstrumented local variables and implemented runtime.
Thomas Lively [Mon, 27 Jun 2016 21:47:21 +0000 (14:47 -0700)]
Instrumented local variables and implemented runtime.

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2095763002 .

8 years agoTreat ORs as ADDs for address optimization if operand has enough zero bits on the...
Manasij Mukherjee [Mon, 27 Jun 2016 20:47:38 +0000 (13:47 -0700)]
Treat ORs as ADDs for address optimization if operand has enough zero bits on the right

  Index=Var Or Const to Index=Var + Const
  when Var = Var' << N and log2(Const) <= N
  or when Var = (2^M) * (2^N) and log2(Const) <= (M+N)
BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2085383002 .

8 years agoSubzero: Make -translate-only work with nonzero -threads=<N>.
Jim Stichnoth [Mon, 27 Jun 2016 14:30:56 +0000 (07:30 -0700)]
Subzero: Make -translate-only work with nonzero -threads=<N>.

When we skip translating an item due to the -translate-only option, we still need to add a dummy item to the work queue with the proper sequence number, otherwise the emitter thread waits endlessly for the next sequence number and never emits the rest of the items.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2099293002 .

8 years agoSubzero: Make -asm-verbose local var offsets local.
Jim Stichnoth [Sat, 25 Jun 2016 17:14:39 +0000 (10:14 -0700)]
Subzero: Make -asm-verbose local var offsets local.

When running with -asm-verbose, assembler directives like the following are generated:

  lv$__123 = 16

These symbols show up in "nm" output of the .o file, and cause inconsistencies in symbol numbering between filetype=asm and filetype=obj, when doing szbuild.py bisection debugging.

The fix is to prepend ".L" to the symbol name, so that the assembler treats it as local.  E.g.:

  .L$lv$__123 = 16

BUG= none
R=eholk@chromium.org

Review URL: https://codereview.chromium.org/2095633002 .

8 years agoSubzero: Fix x86-64 memory sandboxing.
Jim Stichnoth [Sat, 25 Jun 2016 17:01:24 +0000 (10:01 -0700)]
Subzero: Fix x86-64 memory sandboxing.

Commit 2e4b960 (https://codereview.chromium.org/2084793002), which made address mode inference more aggressive, exposed a long-standing bug in memory sandboxing, which now manifests in 164.gzip.

The problem is in sandboxed code like this:

  movl %eax, %eax
  movb 64(%rsp,%rax), %cl

If %eax starts out -1, the mov address is something close to %rsp+4GB, instead of %rsp+63.

To fix this, we need to use an lea instruction in more cases - specifically when the sandboxed address has an index register and the non-symbolic portion of the offset is nonzero.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2097193003 .

8 years ago[Subzero][MIPS32] Implements addEpilog for MIPS32
Sagar Thakur [Sat, 25 Jun 2016 15:34:10 +0000 (08:34 -0700)]
[Subzero][MIPS32] Implements addEpilog for MIPS32

BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2096563004 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoSubzero, MIPS32: Fix FP register table
Srdjan Obucina [Sat, 25 Jun 2016 15:19:11 +0000 (08:19 -0700)]
Subzero, MIPS32: Fix FP register table

FP register table did not contain correct register information.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2089043003 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years agoSubzero: Fix Makefile.standalone to enable format with DEBUG flag
Srdjan Obucina [Wed, 22 Jun 2016 16:04:07 +0000 (09:04 -0700)]
Subzero: Fix Makefile.standalone to enable format with DEBUG flag

When building pnacl with --host-flavor=debug, tools at

../../out/llvm_x86_64_linux_work/Release+Asserts/bin

are not available, so we need a fix to enable source code formatting
with tools from

../../out/llvm_x86_64_linux_debug_work/Debug+Asserts/bin

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2081223003 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years agoSubzero, MIPS32: UnimplementedError removed from most common crashers
Srdjan Obucina [Wed, 22 Jun 2016 15:57:02 +0000 (08:57 -0700)]
Subzero, MIPS32: UnimplementedError removed from most common crashers

UnimplementedError is removed from three functions because it causes
crashes in almost every test from tests_lit/llvm2ice_tests.

emitVariable appears as correct, UnimplementedError may be there by mistake.

lowerConstants is unimplemented, but its obvious without UnimeplementedError.

lowerJumpTables is unimplemented, but its obvious without UnimeplementedError.

We comment these three anyway while changing and testing, so removing them will
not affect final results anyway.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2086423002 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years agoSubzero[MIPS32]: Make liveness validation errors easier to interpret
Mohit Bhakkad [Wed, 22 Jun 2016 12:47:29 +0000 (05:47 -0700)]
Subzero[MIPS32]: Make liveness validation errors easier to interpret

This patch repeats the same changes for MIPS32, which are done in https://codereview.chromium.org/2080633004 for ARM and X86 archs.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2086273002 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years agoLowerCall for MIPS32
Mohit Bhakkad [Wed, 22 Jun 2016 12:44:05 +0000 (05:44 -0700)]
LowerCall for MIPS32

Lower call instructions for MIPS32.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2063653003 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years agoCatch addition patterns for Index in Address Optimization
Manasij Mukherjee [Tue, 21 Jun 2016 21:22:43 +0000 (14:22 -0700)]
Catch addition patterns for Index in Address Optimization

  Index is Index=Var+Const ==>
    set Index=Var, Offset+=(Const<<Shift)
  Index is Index=Const+Var ==>
    set Index=Var, Offset+=(Const<<Shift)
  Index is Index=Var-Const ==>
    set Index=Var, Offset-=(Const<<Shift)
BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2084793002 .

8 years agoInserted local redzones.
Thomas Lively [Tue, 21 Jun 2016 18:43:07 +0000 (11:43 -0700)]
Inserted local redzones.

BUG=chromium:https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com, stichnot@chromium.org

Review URL: https://codereview.chromium.org/2086593002 .

8 years agoSubzero: Make liveness validation errors easier to interpret.
Jim Stichnoth [Tue, 21 Jun 2016 18:22:17 +0000 (11:22 -0700)]
Subzero: Make liveness validation errors easier to interpret.

A portion of the translation workflow goes like this:

  dump #1
  renumber instructions
  liveness + live range construction
  validateLiveness (exit on failure)
  dump #2

If there are liveness validation errors, instruction numbers are reported with respect to the new instruction numbers, yet the most recent dump output is with respect to the old instruction numbers.  Confusion ensues.

To fix this, we just do dump #2 before validateLiveness.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2080633004 .

8 years agoSubzero: Fix frame size for floating-point register out-args.
Jim Stichnoth [Mon, 20 Jun 2016 13:46:07 +0000 (06:46 -0700)]
Subzero: Fix frame size for floating-point register out-args.

The code that calculates maximum out-arg stack space was neglecting the fact that on x86-64, the first N scalar floating-point arguments are passed through xmm registers, not the stack.  As a result, stack frames were sometimes larger than necessary.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2076663006 .

8 years agoSubzero: Improve lowering of rematerializable call args.
Jim Stichnoth [Mon, 20 Jun 2016 13:44:07 +0000 (06:44 -0700)]
Subzero: Improve lowering of rematerializable call args.

Normally, if a call argument is a rematerializable Variable, it is rematerialized into a GPR (via the "lea" instruction) and then written into the appropriate arg space.

This is appropriate for arguments passed on the stack, but for register arguments, it forces an unnecessary copy through another register.

This CL allows that intermediate register copy to be removed.

The resulting code looks cleaner, but it is unlikely to have much effect on performance - there really aren't register pressure issues because lots of scratch registers are available right before the call (which kills all scratch registers).

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2080443002 .

8 years agoInstrumented malloc and free with dummy functions.
Thomas Lively [Fri, 17 Jun 2016 22:53:24 +0000 (15:53 -0700)]
Instrumented malloc and free with dummy functions.

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com, stichnot@chromium.org

Review URL: https://codereview.chromium.org/2079723002 .

8 years ago[Subzero][MIPS32] Implements lowering of alloca instruction
Sagar Thakur [Thu, 16 Jun 2016 22:30:24 +0000 (15:30 -0700)]
[Subzero][MIPS32] Implements lowering of alloca instruction

BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2067183002 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoInstrumented load and store with dummy calls to __asan_check().
Thomas Lively [Thu, 16 Jun 2016 18:03:15 +0000 (11:03 -0700)]
Instrumented load and store with dummy calls to __asan_check().

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2067403002 .

8 years agoSubzero: Build a better bitcast.
Jim Stichnoth [Thu, 16 Jun 2016 17:02:48 +0000 (10:02 -0700)]
Subzero: Build a better bitcast.

The x86 lowering of bitcast between integers and floats forced the transfer through a stack slot (the original implementer *cough* *cough* wasn't aware of the movd instruction).  This requires excess instructions, but also a store to memory followed immediately by a load from that location is very slow.

This fixes the problem by using the movd instruction instead.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2077503002 .

8 years agoImplemented linking to a dummy ASan runtime
Thomas Lively [Wed, 15 Jun 2016 17:00:21 +0000 (10:00 -0700)]
Implemented linking to a dummy ASan runtime

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2068593003 .

8 years agoSubzero: Design doc: Include regalloc in Om1 pass list.
Jim Stichnoth [Wed, 15 Jun 2016 14:37:50 +0000 (07:37 -0700)]
Subzero: Design doc: Include regalloc in Om1 pass list.

The Om1 recipe also includes register allocation (minimal mode).

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2069953004 .

8 years agoSubzero: Improve register availability peephole for function return values.
Jim Stichnoth [Wed, 15 Jun 2016 05:21:33 +0000 (22:21 -0700)]
Subzero: Improve register availability peephole for function return values.

Originally, a call instruction was lowered like this:

  // %result = call @foo(...)
  %t1:eax = call foo
  %result = %t1:eax

Because t1 is pre-colored, it is not available as a substitution if the following instruction uses %result as a source operand.

To improve this, we copy it through an intermediate temporary:

  // %result = call @foo(...)
  %t1:eax = call foo
  %t2 = %t1:eax
  %result = %t2

BUG= none
R=eholk@chromium.org

Review URL: https://codereview.chromium.org/2064073005 .

8 years agoFinished small fixups.
Thomas Lively [Tue, 14 Jun 2016 21:06:17 +0000 (14:06 -0700)]
Finished small fixups.

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2064613006 .

8 years agoSubzero: x86-64: Allow immediates in 64-bit instructions.
Jim Stichnoth [Tue, 14 Jun 2016 14:27:22 +0000 (07:27 -0700)]
Subzero: x86-64: Allow immediates in 64-bit instructions.

The original code legalized *all* i64 constants into a register move, creating unnecessary instructions and slightly higher register pressure in most cases.

Generally, immediates can be used in 64-bit instructions as long as the immediate can be represented as a sign-extended 32-bit value.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2063053002 .

8 years agoImplemented global redzones.
Thomas Lively [Mon, 13 Jun 2016 18:23:29 +0000 (11:23 -0700)]
Implemented global redzones.

BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4374
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2054943002 .

8 years agoChange LowerArgument in MIPS to use CallingConvention class
Mohit Bhakkad [Mon, 13 Jun 2016 13:06:35 +0000 (06:06 -0700)]
Change LowerArgument in MIPS to use CallingConvention class

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2060203002 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years ago[Subzero][MIPS32] Adds prolog instructions for MIPS32
Sagar Thakur [Mon, 13 Jun 2016 12:55:00 +0000 (05:55 -0700)]
[Subzero][MIPS32] Adds prolog instructions for MIPS32

BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2051713002 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoThis patch provides calling convention class for MIPS with support of integer and...
Mohit Bhakkad [Mon, 13 Jun 2016 07:28:13 +0000 (00:28 -0700)]
This patch provides calling convention class for MIPS with support of integer and floating point types

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2052793003 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years agoSubzero: Improve effectiveness of local register availability peephole.
Jim Stichnoth [Fri, 10 Jun 2016 19:21:17 +0000 (12:21 -0700)]
Subzero: Improve effectiveness of local register availability peephole.

X86 only.  The register availability peephole optimization during lowering disallows available register substitution when the variable is pre-colored.  This is for good reasons (too complex to be discussed here).  However, that leaves some potential substitutions on the table.

Specifically, this happens a lot around register arguments to function calls, both at the call site and in the prolog.

The simplest solution seems to be to launder the pre-colored variable through a separate infinite-weight variable, as implemented in this CL through a combination of such copies and extra legalize() calls.

There are other situations where this technique can also work, which may be handled in a separate CL.

This CL also fixes a problem where the stack pointer adjustment in the prolog is subject to dead-code elimination if the function has no epilog.  This would only happen in asm-verbose mode, in the final liveness analysis pass prior to code emission.

BUG= none
R=eholk@chromium.org

Review URL: https://codereview.chromium.org/2052683003 .

8 years agoAdding float/double support in CopyToReg
Mohit Bhakkad [Thu, 9 Jun 2016 22:06:23 +0000 (15:06 -0700)]
Adding float/double support in CopyToReg

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2050473005 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years agoCreated Ice::Instrumentation base class and accompanying hooks.
Thomas Lively [Tue, 7 Jun 2016 20:54:59 +0000 (13:54 -0700)]
Created Ice::Instrumentation base class and accompanying hooks.

Also added a command line flag for AddressSanitizer

BUG=None
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2042063002 .

8 years agoSubzero, MIPS32: Floating point load/store and format conversion instructions
Srdjan Obucina [Thu, 2 Jun 2016 13:47:06 +0000 (06:47 -0700)]
Subzero, MIPS32: Floating point load/store and format conversion instructions

Introducing instructions for floating point format conversion.
These instructions are needed for full implementation of lowerCast
and missing floating point arithmetic instruction frem.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2024183002 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years ago[Subzero][MIPS32] Implement icmp operation for i8, i16 operands
Sagar Thakur [Wed, 1 Jun 2016 19:36:50 +0000 (12:36 -0700)]
[Subzero][MIPS32] Implement icmp operation for i8, i16 operands

BUG=none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/2022063003 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoSubzero: Crosstest test_arith properly tests i8/i16.
Jim Stichnoth [Tue, 31 May 2016 19:21:51 +0000 (12:21 -0700)]
Subzero: Crosstest test_arith properly tests i8/i16.

The problem is that because of C++ integral promotion rules, many of the i8 and i16 arithmetic tests were actually being performed as i32 operations.  Thus we weren't actually testing everything we meant to test.

The fix is to have a python script auto-generate the relevant tests with proper typing.

BUG= none
R=eholk@chromium.org, jpp@chromium.org, kschimpf@google.com

Review URL: https://codereview.chromium.org/2013863002 .

8 years agoRemoved an extraneous tab
Thomas Lively [Tue, 31 May 2016 18:44:22 +0000 (11:44 -0700)]
Removed an extraneous tab

BUG=None
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/2028733002 .

8 years ago- This patch implements lowerstore for i32, i64 types for mips32 arch.
Mohit Bhakkad [Tue, 31 May 2016 18:19:03 +0000 (11:19 -0700)]
- This patch implements lowerstore for i32, i64 types for mips32 arch.

- InstMIPS32Memory class is added to represent memory related instructions(load/store). I will add remaining load/store instructions if you are okay with this patch.

- Changed uncond_br.ll test as it was failing due to hardcoded label no. expected in output.

R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/2005823002 .

Patch from Mohit Bhakkad <mohit.bhakkad@imgtec.com>.

8 years ago[Subzero][MIPS32] Implement i1 cast operations
Sagar Thakur [Mon, 30 May 2016 14:54:47 +0000 (07:54 -0700)]
[Subzero][MIPS32] Implement i1 cast operations

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2017043002 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoSubzero, MIPS32: Introduction of floating point registers
Srdjan Obucina [Fri, 27 May 2016 21:40:32 +0000 (14:40 -0700)]
Subzero, MIPS32: Introduction of floating point registers

This patch introduces floating point registers used for 32-bit
operations, and basic handling of FP values in operands. It is
partial work needed as a base for further work.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1993993004 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years agoSubzero: Initial implementation of BB Local CSE
Manasij Mukherjee [Tue, 24 May 2016 21:25:04 +0000 (14:25 -0700)]
Subzero: Initial implementation of BB Local CSE

Adds Cfg::localCse for basic-block local common-subexpression elimination
If we have
    t1 = op b c
    t2 = op b c
This pass will replace future uses of t2 in a basic block by t1.

To enable, use -enable-experimental in O2

BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1997443002 .

8 years agoAdded bool folding machinery for MIPS32.
Sagar Thakur [Tue, 24 May 2016 13:25:50 +0000 (06:25 -0700)]
Added bool folding machinery for MIPS32.
Added implementation for conditional branch instructions.

R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1993773004 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoSubzero, MIPS32: Implements integer division instructions sdiv, udiv, srem, urem
Srdjan Obucina [Wed, 18 May 2016 18:31:15 +0000 (11:31 -0700)]
Subzero, MIPS32: Implements integer division instructions sdiv, udiv, srem, urem

This patch adds support for missing integer division instruction sdiv, udiv, srem, urem.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1989303002 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years agoSubzero, MIPS32: Implement logical instructions ashr, lshr, shl
Srdjan Obucina [Tue, 17 May 2016 20:16:02 +0000 (13:16 -0700)]
Subzero, MIPS32: Implement logical instructions ashr, lshr, shl

This patch adds support for logical operations ashr, lshr and shl.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1975283002 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

8 years agoRemove compiler warning when building within LLVM trunk.
Karl Schimpf [Thu, 12 May 2016 17:12:23 +0000 (10:12 -0700)]
Remove compiler warning when building within LLVM trunk.

Clang doesn't realize that the end of method
NaClBitstreamCursor::readArrayAbbreviatedField is unreachable. Add
unreachable call to make the compiler happy.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1963193003 .

8 years agoSubzero: Add necessary PNaCl files for standalone build.
Jim Stichnoth [Tue, 10 May 2016 18:20:41 +0000 (11:20 -0700)]
Subzero: Add necessary PNaCl files for standalone build.

The README.txt file is new; all other files under pnacl-llvm/ are copied verbatim from the pnacl-llvm repo.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1960393002 .

8 years agoSubzero: Update for LLVM 3.9 (trunk).
Jim Stichnoth [Mon, 9 May 2016 19:24:36 +0000 (12:24 -0700)]
Subzero: Update for LLVM 3.9 (trunk).

The purpose is to allow pnacl-sz to be built within an LLVM checkout (version 3.9 or later), and not require the complex PNaCl build environment.

Within an LLVM checkout, one would do something like the following:
  cd projects
  git clone https://chromium.googlesource.com/native_client/pnacl-subzero
  # change to LLVM build directory
  cmake -G "Ninja" <path_to_llvm_source_dir>
  ninja

A follow-on CL will add in the PNaCl bitcode reader source files that are needed for compiling and linking.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1961743002 .

8 years ago[Subzero][MIPS32] Implement sext, zext and trunc
Sagar Thakur [Mon, 9 May 2016 18:57:59 +0000 (11:57 -0700)]
[Subzero][MIPS32] Implement sext, zext and trunc

This patch adds support for sext, zext, trunc operations on i8, i16, i32 source operand types. Support for i1 source operand type will follow.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1948093002 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoSubzero WASM: avoid needless comparisons, add bounds check flag option
Eric Holk [Fri, 6 May 2016 21:28:04 +0000 (14:28 -0700)]
Subzero WASM: avoid needless comparisons, add bounds check flag option

Introduces a new BooleanVariable type which represents zero-extended
variables generated from an i1, saving a pointer to the original
i1. The Wasm frontend uses this to avoid comparing against 0 if
possible when translating branches. This led to about a 12%
improvement on the bzip2 spec benchmark.

This change also adds the -wasm-disable-bounds-check command line
option which omits bounds checking code.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4369
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1961583002 .

8 years agoSubzero: Suppress a warning as a result of an updated clang.
Jim Stichnoth [Mon, 2 May 2016 19:06:22 +0000 (12:06 -0700)]
Subzero: Suppress a warning as a result of an updated clang.

Also improve some diagnostic output in the Makefile.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1941593002 .

8 years agoSubzero, WASM: stop writing uninitialized data to .o file. Add timers.
Eric Holk [Mon, 2 May 2016 17:42:27 +0000 (10:42 -0700)]
Subzero, WASM: stop writing uninitialized data to .o file. Add timers.

Previously we were writing large numbers of zeros to the output
file. This change only writes out the initialized portion and
allocates the full address space at runtime. This reduces compile time
by around 50%.

This change also adds a couple of WASM-specific timers.

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

Review URL: https://codereview.chromium.org/1938643002 .

8 years agoSubzero, Wasm: Dynamically reallocate read buffer. Runtime improvements.
Eric Holk [Fri, 29 Apr 2016 21:42:17 +0000 (14:42 -0700)]
Subzero, Wasm: Dynamically reallocate read buffer. Runtime improvements.

This change fills in several more runtime functions needed by several
benchmarks, as well as changing the buffer handling in the WASM
decoder. Now the decoder will resize the buffer as needed to
accomodate large .wasm modules.

Tracing can now be enabled on runtime functions to aid with
debugging. Additionally, runtime failures such as bounds check
failures or invalid indirect function calls tell what kind of failure
occured.

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

Review URL: https://codereview.chromium.org/1918213003 .

8 years agoSubzero. X86. Uses pshufb for shufflevector lowering.
John Porto [Wed, 27 Apr 2016 02:16:07 +0000 (19:16 -0700)]
Subzero. X86. Uses pshufb for shufflevector lowering.

This CL enables subzero to lower shufflevector instructions in x86 using
pshufb (only for SSE 4.1)

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4136
BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4077
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1917863004 .

8 years agoSubzero. X86. Lowers shufflevector using xmm instructions.
John Porto [Tue, 26 Apr 2016 11:26:33 +0000 (04:26 -0700)]
Subzero. X86. Lowers shufflevector using xmm instructions.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4136
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1909013002 .

8 years agoSubzero. Wasm. Implement sbrk and correctly do bounds checks.
Eric Holk [Mon, 25 Apr 2016 19:52:49 +0000 (12:52 -0700)]
Subzero. Wasm. Implement sbrk and correctly do bounds checks.

Cleans up and generally improves memory handling in
WASM. WasmTranslator now outputs the number of pages requested so the
runtime can do correct bounds checks. The runtime also initializes the
stack pointer correctly (stored at address 1024), so we no longer have
to deal with negative pointers. This allows bounds checks to be done
with a single comparison against the size of the heap. Because of
this, we now support non-power-of-two heap sizes.

Sbrk is implemented by having the runtime keep track of the current
heap break and incrementing it as necessary. The heap break is
initialized to the start of the first page beyond any initialized data
in the WASM heap.

These changes allow us to pass the complete set of torture tests that
are passing on the Wasm waterfall.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4369
R=kschimpf@google.com, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1913153003 .

8 years ago[Subzero][MIPS] Implement conditional branches and integer comparisons
Sagar Thakur [Mon, 25 Apr 2016 15:39:19 +0000 (08:39 -0700)]
[Subzero][MIPS] Implement conditional branches and integer comparisons

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1898743002 .

Patch from Sagar Thakur <sagar.thakur@imgtec.com>.

8 years agoSubzero - WASM: Codegen fixes, better test infrastructure
Eric Holk [Fri, 22 Apr 2016 16:34:41 +0000 (09:34 -0700)]
Subzero - WASM: Codegen fixes, better test infrastructure

Fixes several bugs in code generation, including handling of booleans,
comparisons and shifts. The tests that get through code generation now
run successfully (except for the tests that are known to fail on
https://wasm-stat.us/).

This change also includes improvements to the test infrastructure. The
wasm test runner has a list of expected failures to skip. The tests
now run in parallel, which significantly cuts down the time to run the
whole test suite.

Finally, there are some minor improvements to the WASM runtime,
including an implementation of syscall20, i.e. getpid().

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4369
R=kschimpf@google.com, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1900213002 .

8 years agoSubzero: Provide missing isMemoryWrite() method.
Jim Stichnoth [Fri, 22 Apr 2016 00:57:56 +0000 (17:57 -0700)]
Subzero: Provide missing isMemoryWrite() method.

This is the result of an improper rebase in the previous CL.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1911983002 .

8 years agoSubzero: Fix over-aggressive bool folding.
Jim Stichnoth [Thu, 21 Apr 2016 23:54:33 +0000 (16:54 -0700)]
Subzero: Fix over-aggressive bool folding.

The problem is that bitcode like this:

  %cond = cmp %var, [mem]
  store ..., mem
  br cond, target1, target2

would be bool-folded into this:

  //deleted cmp
  store ..., mem
  br (%var==[mem]), target1, target2

And if the memory operands point to the same location, results are incorrect.

In addition to stores, this is a problem for RMW instructions, and most call instructions which could perform stores before returning.

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

Review URL: https://codereview.chromium.org/1904233002 .

8 years agoSubzero. Rematerializes shufflevector instructions.
John Porto [Thu, 21 Apr 2016 12:53:42 +0000 (05:53 -0700)]
Subzero. Rematerializes shufflevector instructions.

This CL is a first step towards optimizing vector shuffles in
Subzero.

PNaCl bitcode does not support the shufflevector instruction,
so pnacl-clang emits a series of extractelement/insertelement.
pnacl-llc is then responsible for performing a pattern match
on the output bitcode and rematerialize the shufflevector.

With this CL, we enable shufflevector rematerialization in
Subzero. To keep this CL simple, we introduce no efficient
shufflevector lowering. Instead, we scalarize the
rematerialized instructions.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4136
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1897243002 .

8 years agoSubzero: Fix a warning message in the browser build.
Jim Stichnoth [Thu, 21 Apr 2016 12:38:49 +0000 (05:38 -0700)]
Subzero: Fix a warning message in the browser build.

Due to a mistake in the logic in https://codereview.chromium.org/1903553004 , a warning is printed even when LogFilename is properly set to "-".

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

Review URL: https://codereview.chromium.org/1911713002 .

8 years agoSubzero: Fix srem.i8/urem.i8 lowering for x86-64.
Jim Stichnoth [Thu, 21 Apr 2016 12:38:15 +0000 (05:38 -0700)]
Subzero: Fix srem.i8/urem.i8 lowering for x86-64.

The problem was that the lowering sequence might lead to the rem result %ah being directly moved into an 8-bit register other than al/bl/cl/dl/ah/bh/ch/dh.  This is not encodable, and attempting to encode it leads to actually moving from %spl instead of %ah.

The machinery to handle this was already available - copy through a temporary with register class RCX86_IsAhRcvr.  So this was just a matter of hooking it up for srem/urem.

This CL also requires relaxing some checks in the register allocator for when the -reg-reserve option is used.

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

Review URL: https://codereview.chromium.org/1909853002 .

8 years agoSubzero: Allow overriding command-line args from the browser.
Jim Stichnoth [Wed, 20 Apr 2016 17:12:46 +0000 (10:12 -0700)]
Subzero: Allow overriding command-line args from the browser.

In the browser build only, allows arguments to be explicitly passed to pnacl-sz, in two ways:

1. The SZARGFILE envvar contains the name of a file with arguments, one per line.  For each line, initial whitespace is ignored, and lines starting with the '#' comment character are also ignored.

2. The SZARGLIST envvar contains all the arguments, separated by the '|' character.

Chrome needs to be started with special options to allow the envvars to be passed through, and also to allow access to the local file system.

In addition, specifying "-log=/dev/stderr" or "-o /dev/stderr" gets mapped to std::cerr, in the same way "-" gets mapped to std::cout.

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

Review URL: https://codereview.chromium.org/1903553004 .

8 years agoAdded definition of ALLOW_WASM to CMakeLists.
Sean Klein [Tue, 19 Apr 2016 17:53:10 +0000 (10:53 -0700)]
Added definition of ALLOW_WASM to CMakeLists.

This change is required to run "toolchain_build_pnacl.py --cmake", since
without it, ALLOW_WASM will be undefined and throw a compilation error.

BUG=None
R=eholk@chromium.org

Review URL: https://codereview.chromium.org/1897323002 .

8 years agoSubzero. ARM32. De-scalarizes icmp and fcmp for vectors.
John Porto [Mon, 18 Apr 2016 22:32:27 +0000 (15:32 -0700)]
Subzero. ARM32. De-scalarizes icmp and fcmp for vectors.

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

Review URL: https://codereview.chromium.org/1891243002 .

8 years agoSubzero, Wasm: Link and run torture tests; bug fixes.
Eric Holk [Mon, 18 Apr 2016 22:08:19 +0000 (15:08 -0700)]
Subzero, Wasm: Link and run torture tests; bug fixes.

This modifies the torture test script to actually link and run the
tests in addition to just translating them.

It includes a number of bug fixes as well, particularly in the
handling of boolean values. There is some cleanup of memory address
handling, and in many cases it can avoid generating useless address
computations.

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

Review URL: https://codereview.chromium.org/1890283002 .

8 years agoSubzero: Allow per-method controls.
Jim Stichnoth [Mon, 18 Apr 2016 19:52:09 +0000 (12:52 -0700)]
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 .

8 years agoSubzero. WASM. Additional progress.
Eric Holk [Fri, 15 Apr 2016 20:05:37 +0000 (13:05 -0700)]
Subzero. WASM. Additional progress.

This change includes a number of improvements since the last WASM
CL. It compiles against a newer version of V8 that matches the current
WASM binary format. Many more WASM instructions are supported, as well
as global variable initializers.

There is also the beginning of a runtime library that implements some
system calls required by the WASM C library. The c2wasm-exe.sh script
can be used to compile a C program to a .wasm module, which is then
compiled by Subzero into a native executable.

This change includes a new Breakpoint instruction, which inserts an
unconditional breakpoint into the executable. This has been helpful in
debugging code generation for some WASM instructions. The Breakpoint
instruction is only completely implemented on X86.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4369
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1876413002 .

8 years agoSubzero. ARM32. Implements vector select.
John Porto [Fri, 15 Apr 2016 13:26:58 +0000 (06:26 -0700)]
Subzero. ARM32. Implements vector select.

Also piggy-backs necro-comments from cl 1878943009.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4076
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1886263004 .

8 years agoSubzero. ARM32. Vector casts.
John Porto [Thu, 14 Apr 2016 18:51:38 +0000 (11:51 -0700)]
Subzero. ARM32. Vector casts.

This CL un-scalarizes all vector casts operations in Subzero.

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

Review URL: https://codereview.chromium.org/1878943009 .

8 years agoSubzero. ARM32. Vector shifts.
John Porto [Wed, 13 Apr 2016 19:57:14 +0000 (12:57 -0700)]
Subzero. ARM32. Vector shifts.

BUG=
R=kschimpf@google.com, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1881623002 .

8 years agoReduce wait times for very large PEXE files.
Karl Schimpf [Mon, 11 Apr 2016 21:49:01 +0000 (14:49 -0700)]
Reduce wait times for very large PEXE files.

Investigated how many parser waits occur when the OptQ fills up. The
current implementation has 64k entries, which for 10Mb examples, never
fill up (but do come close to filling up).

To test, I dropped the queue size down. The numbers I got was that the
queue size plus the number of parse waits was within 2% of the total
number of function blocks. Hence, once OptQ fills up a lot of slow
notifies get applied.

Hence, for scaling, I modifed the code to not wake up the parse thread
(during a pop) until OptQ got half empty. The results were that once
the Opt got up to size 1024, less than 100 notifies would be
issued. From 1024 on, as the queue size doubled, the number of
notifies would drop roughly in half.

Based on this, I decided to add the feature that the OptQ did not wake
up the waiting parse thread until half empty. Since the queue size was
not shrunk, this CL shouldn't add any overhead for the PEXES we have,
and very few waits with significantly largers than the current (10Mb)
PEXES.

BUG=None
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1877873002 .

8 years agoAdd "vmov.<dt> <Qd>, #<imm>" to integrated ARM assembler.
Karl Schimpf [Mon, 11 Apr 2016 21:32:15 +0000 (14:32 -0700)]
Add "vmov.<dt> <Qd>, #<imm>" to integrated ARM assembler.

Adds the VMOV instruction to the integrated assembler. Because #<imm> is
complex, and we don't currently have a special ARM class to encode
constants defined by ARM method AdvSIMDExpandImm(), it currently only
accepts (nonnegative) integer32 constants that can fit into 8 bits.

There are no tests for this instruction, since there currently no
callers to this instruction. However, John will be checking in a CL
shortly that will use this instruction.

Add example generator for vector add.

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

Review URL: https://codereview.chromium.org/1879463003 .

8 years agoSubzero. ARM32. Fixes Insert/Extract v(8|16)i1 bug.
John Porto [Mon, 11 Apr 2016 18:33:34 +0000 (11:33 -0700)]
Subzero. ARM32. Fixes Insert/Extract v(8|16)i1 bug.

Subzero emits the following sequence when extracting elements from a
vector of i1:

vmov.8 Rt, Dm[I]

I should be scaled when accessing v4i1, and v8i1, i.e., to extract the
n-th boolean in a v8i1, the emitted code should be

vmov.8 Rt, Dm[I*n]

Insertions are handled by changing the operands' types, so that a
v4i1 is handled as a v4i32, and a v8i1, as a v8i16. I.e., to insert
the n-th boolean into a v8i1, the emitted code should be

mov.16 Dt[I], Rm

instead of

mov.8 Dt[I*n], Rm

This clears the upper bits for that element.

BUG=
R=eholk@chromium.org

Review URL: https://codereview.chromium.org/1876083004 .

8 years agoSubzero: Shorten and normalize strings in non-DUMP builds.
Jim Stichnoth [Sat, 9 Apr 2016 15:54:20 +0000 (08:54 -0700)]
Subzero: Shorten and normalize strings in non-DUMP builds.

Jump table labels change from ".Lxxxxx_yy" to "$Jxxxxx_yy".

Pooled float labels change from ".L$float$xxxxyyyy" to "$Fxxxxyyyy".

Pooled double labels change from ".L$double$xxxxxxxxyyyyyyyy" to "$Dxxxxxxxxyyyyyyyy".

All these should in theory not conflict with C/C++ user symbols.

Float labels now likely fit into short strings and don't require extra memory allocation.

Double labels may exceed the limit - encoding in base64 instead of hex would fix that.  Or, directly use the binary bytes as the string value.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1868113002 .

8 years agoSubzero: Improve the -timing output.
Jim Stichnoth [Sat, 9 Apr 2016 00:09:29 +0000 (17:09 -0700)]
Subzero: Improve the -timing output.

For "Flat times" output, adds a column with cumulative percentage.  Also, since these percentages add up to less than 100% due to timer overhead, we go ahead and scale up all of the "Flat times" percentages proportionally, to make them add to 100%.  This makes it easier to compare breakdowns across different pexes.

Also, simplify the output to be simple tabular without extra brackets and whatnot.  E.g.:

Total across all functions - Cumulative times:
     Seconds   Pct  EventCnt TimerPath
    8.580407 82.6%         0 szmain
    8.580054 82.6%         0 szmain.parseModule
    8.405447 80.9%     46473 szmain.parseModule.parseFunctions
...
Total across all functions - Flat times:
     Seconds   Pct CumPct  EventCnt TimerName
    1.354678 16.0%  16.0%    100716 linearScan
    1.131292 13.3%  29.3%    139419 liveness
    0.728727  8.6%  37.9%     46473 genCode
...

BUG= none
R=jpp@chromium.org, kschimpf@google.com

Review URL: https://codereview.chromium.org/1870073005 .

8 years agoSubzero: Fix an incorrect StringPool assert.
Jim Stichnoth [Thu, 7 Apr 2016 14:17:35 +0000 (07:17 -0700)]
Subzero: Fix an incorrect StringPool assert.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1866993002 .

8 years agoSubzero: Remove a couple clumsy uses of snprintf.
Jim Stichnoth [Wed, 6 Apr 2016 19:21:14 +0000 (12:21 -0700)]
Subzero: Remove a couple clumsy uses of snprintf.

We can use llvm::format() to achieve the same result in these cases.

BUG= none
R=jpp@chromium.org, kschimpf@google.com

Review URL: https://codereview.chromium.org/1866633003 .

8 years agoSubzero: Dump register numbers as signed quantities.
Jim Stichnoth [Wed, 6 Apr 2016 19:20:18 +0000 (12:20 -0700)]
Subzero: Dump register numbers as signed quantities.

Undo an overly aggression application of unsigned to register numbers in 8aa396610b7baf728631a43ea16ad3d13e38397a (https://codereview.chromium.org/1676123002).

Now, instead of -verbose=regalloc output like:

++++++ Unhandled:
R=jpp@chromium.org, kschimpf@google.com, 4294967295  V=%__4  Range=[2:7), 4294967295  V=%__5  Range=[7:8), 4294967295  V=%__6  Range=[9:11), -1  V=%__4  Range=[2:7), -1  V=%__5  Range=[7:8), -1  V=%__6  Range=[9:11)

we have the originally intended:

++++++ Unhandled:

BUG= none

Review URL: https://codereview.chromium.org/1868543002 .

8 years agoSubzero: Fix -timing-focus .
Jim Stichnoth [Wed, 6 Apr 2016 13:37:15 +0000 (06:37 -0700)]
Subzero: Fix -timing-focus .

The problem is that the default timer is renamed to be the current function name, instead of "Total across all functions", but this causes an assertion failure during the final merge of thread-local timers into the global timers, because the names don't match.

The solution is to temporarily rename the timer to be the function name, until the timer is dumped, and then restore it to its original value.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1867473002 .

8 years agoSubzero: Improve non-MINIMAL string performance.
Jim Stichnoth [Tue, 5 Apr 2016 22:31:43 +0000 (15:31 -0700)]
Subzero: Improve non-MINIMAL string performance.

In a DUMP-enabled build, such as the standard Release+Asserts build, translator performance has regressed as a result of 467ffe51bebcb3ae3e3ce745c38fc20e8837c31c (https://codereview.chromium.org/1838753002).

This is because Variable and CfgNode names are being instantiated unconditionally, rather than on-demand.

This CL restores most of that performance by going back to being on-demand.  Note that it should have no effect on MINIMAL build performance.

Also, it turns out that Variable::getName() does not really need the Cfg* parameter, so that is removed (and all its callers are fixed transitively).

In addition, Variable and CfgNode are made more uniform with respect to each other in terms of inline definitions of the ctor, getName(), and setName().

BUG= none
R=jpp@chromium.org, kschimpf@google.com

Review URL: https://codereview.chromium.org/1866463002 .

8 years agoSubzero. Refactors Switch Lowering.
John Porto [Tue, 5 Apr 2016 13:30:21 +0000 (06:30 -0700)]
Subzero. Refactors Switch Lowering.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1860473002 .

8 years agoSubzero. Fixes Browser build.
John Porto [Tue, 5 Apr 2016 13:20:50 +0000 (06:20 -0700)]
Subzero. Fixes Browser build.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1856323004 .

8 years agoInitial Subzero WASM prototype.
Eric Holk [Tue, 5 Apr 2016 00:07:42 +0000 (17:07 -0700)]
Initial Subzero WASM prototype.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1837663002 .

8 years agoReplace constant conditional branches by unconditional branches
David Sehr [Mon, 4 Apr 2016 17:11:08 +0000 (10:11 -0700)]
Replace constant conditional branches by unconditional branches

BUG=
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1847423003 .

8 years agoSubzero: Fix -timing-funcs and -timing-focus flags.
Jim Stichnoth [Mon, 4 Apr 2016 04:58:03 +0000 (21:58 -0700)]
Subzero: Fix -timing-funcs and -timing-focus flags.

1. Generate dummy FunctionXXX function names when either of those flags is given.

2. Remove the browser code that automatically sets F/G prefixes instead of Function/Global, since that performance tweak is no longer relevant.

3. Fix a presumably long-standing bug where -timing-focus would accumulate timings into the TLS copy of the timers, but would then try to print timing info based on the currently-empty GlobalContext copy of the timers.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1855683002 .

8 years agoFix error reporting for parallel parsed function blocks.
Karl Schimpf [Sat, 2 Apr 2016 17:06:56 +0000 (10:06 -0700)]
Fix error reporting for parallel parsed function blocks.

Fixes error reporting in function blocks by adding a start address
with parallel parses, and then using the getErrorBitNo() method
of the bitstream cursor to correct error bit number, based on the
start address.

Dependent on CL https://codereview.chromium.org/1851163002.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4363
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1848313003 .

8 years agoSimplify references to command line flags.
Karl Schimpf [Sat, 2 Apr 2016 16:55:31 +0000 (09:55 -0700)]
Simplify references to command line flags.

This CL removes all indirect pointer chasing to get the values of
command line flags. Since we are only using 1 copy of ClFlags, this CL
introduces a static field Flags to hold the defined command line flags
(it was previously a static field of GlobalContext).

For those few contexts where one must change CL flags due to context
(such as testsing and running in the browser), use ClFlags::Flags.

In the remainder of the cases, the code uses getFlags() which returns
a constant reference to ClFlags::Flags, allowing access to the get
accessors.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1848303003 .

8 years agoSubzero: Fix a cleanup error after the IceString removal CL.
Jim Stichnoth [Sat, 2 Apr 2016 01:26:16 +0000 (18:26 -0700)]
Subzero: Fix a cleanup error after the IceString removal CL.

This corrects a "cleanup" mistake in line 414/417 of https://codereview.chromium.org/1838753002/diff/120001/src/IceTargetLoweringX8664.cpp .

This wasn't caught before because "make presubmit" doesn't run any sandboxed x86-64 tests.  So we add that to the presubmit script.

In addition, the "make check-spec" is changed to run each spec component via the "--run" flag of szbuild_spec2k.py.  Otherwise, the makefile was hard-coding running the native binary setup instead of the sandboxed or nonsfi setup.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1852713004 .