native_client/pnacl-llvm.git
18 hours agoDon't allow instructions/globals to use alignment > 2**29. master
Karl Schimpf [Thu, 18 Dec 2014 20:38:42 +0000 (12:38 -0800)]
Don't allow instructions/globals to use alignment > 2**29.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3998
R=jvoung@chromium.org

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

3 days agoUpdate ReplacePtrsWithInts to also fix up refs from subprogram debug metadata.
Jan Voung [Tue, 16 Dec 2014 01:10:00 +0000 (17:10 -0800)]
Update ReplacePtrsWithInts to also fix up refs from subprogram debug metadata.

Cargo culted some code from the DeadArgumentElimination pass.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4023
R=mseaborn@chromium.org

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

3 days agoCherry-pick: Use 32-bit ebp for NaCl64 in a limited case: llvm.frameaddress.
Jan Voung [Mon, 15 Dec 2014 22:03:16 +0000 (14:03 -0800)]
Cherry-pick: Use 32-bit ebp for NaCl64 in a limited case: llvm.frameaddress.

When merging up further, will need to fix up the way the
RegisterInfo is accessed. Also need to merge in and fix up
the test for the x32 case, since that depends on a
different commit (that was dropped in this cherrypick).

This also differs from the upstream test in that load
sandboxing and base address hiding is actually being done.

Summary:
Follow up to [x32] "Use ebp/esp as frame and stack pointer":
http://reviews.llvm.org/D4617

In that earlier patch, NaCl64 was made to always use rbp.
That's needed for most cases because rbp should hold a full
64-bit address within the NaCl sandbox so that load/stores
off of rbp don't require sandbox adjustment (zeroing the top
32-bits, then filling those by adding r15).

However, llvm.frameaddress returns a pointer and pointers
are 32-bit for NaCl64. In this case, use ebp instead, which
will make the register copy type check. A similar mechanism
may be needed for llvm.eh.return, but is not added in this change.

Test Plan: test/CodeGen/X86/frameaddr.ll

Reviewers: dschuff, nadav

Subscribers: jfb, llvm-commits

Differential Revision: http://reviews.llvm.org/D6514

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223510 91177308-0d34-0410-b5e6-96231b3b80d8

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4005
R=dschuff@chromium.org, jfb@chromium.org

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

6 days agoCherrypick upstream r220447: Fix Mips nacl-mask test
Petar Jovanovic [Sat, 13 Dec 2014 01:09:10 +0000 (02:09 +0100)]
Cherrypick upstream r220447: Fix Mips nacl-mask test

Original commit:

From 5385df6bba672e254d017027d769e3ed5f4fd003 Mon Sep 17 00:00:00 2001
From: Derek Schuff <dschuff@google.com>
Date: Wed, 22 Oct 2014 23:32:00 +0000
Subject: [PATCH] Fix Mips nacl-mask test for new bundle-aligned label
 behavior

After r220439 the behavior of labels in bundle-align mode changed,
and I neglected to update this test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220447 91177308-0d34-0410-b5e6-96231b3b80d8

BUG= make check failure MC/Mips/nacl-mask.s
R=dschuff@chromium.org

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

6 days agoApply missing parts from upstream r218744
Petar Jovanovic [Sat, 13 Dec 2014 01:06:59 +0000 (02:06 +0100)]
Apply missing parts from upstream r218744

Previous cherry-pick [1] could not apply changes for prevent-hoisting.ll
as that file did not exist in the pnacl-llvm trunk at the time.
This change applies the missing parts and this should resolve make check
failure in this test.

[1] https://codereview.chromium.org/633143002/

BUG= make check failure CodeGen/Mips/prevent-hoisting.ll
TEST= make check
R=dschuff@chromium.org

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

6 days agoDefault to an armv7 cpu when march=arm
Derek Schuff [Fri, 12 Dec 2014 22:29:54 +0000 (14:29 -0800)]
Default to an armv7 cpu when march=arm

When the arch is given as "arm" clang uses the default target CPU from
LLVM to determine what the real arch should be (i.e. "arm" becomes
"armv4t" because LLVM's getARMCPUForArch falls back to "arm7tdmi").
Default to "cortex-a9" so that we end up with "armv7" in clang.

the nacl-direct.c test in clang covers this case.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4018

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

6 days agoRemove GR32_TC_64 previously used by NaCl. Also put PSEUDO_NACL_SEG in SEGMENT_REG...
Jan Voung [Fri, 12 Dec 2014 16:06:26 +0000 (08:06 -0800)]
Remove GR32_TC_64 previously used by NaCl. Also put PSEUDO_NACL_SEG in SEGMENT_REG class.

A later CL will make it "nacl:..." inline asm unparseable
if the pseudo-nacl-seg is not part of the segment
registers class:
http://llvm.org/viewvc/llvm-project?view=revision&revision=214456

BUG=none
R=dschuff@chromium.org

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

7 days agoEmit LAHF/SAHF instead of PUSHF/POPF
JF Bastien [Thu, 11 Dec 2014 22:45:09 +0000 (14:45 -0800)]
Emit LAHF/SAHF instead of PUSHF/POPF

NaCl's sandbox doesn't allow PUSHF/POPF out of security concerns.

This is a follow-up to cherrypick:
  https://codereview.chromium.org/795683002

If we agree on this patch I'll try to upstream it.

R=jvoung@chromium.org
TEST= ./scons run_synchronization_sync_test bitcode=1 platform=x86-32
BUG= http://llvm.org/bugs/show_bug.cgi?id=20376
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2518
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2981
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3579
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3673
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4015

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

7 days agoCherrypick upstream patch: ScheduleDAG: record PhysReg dependencies represented by...
JF Bastien [Thu, 11 Dec 2014 22:42:04 +0000 (14:42 -0800)]
Cherrypick upstream patch: ScheduleDAG: record PhysReg dependencies represented by CopyFromReg nodes

The LLVM 3.5 merge broke some corner-case usage of cmpxchg on x86, this
cherrypick fixes the breakage but adds new breakage by making LLVM emit
PUSHF/POPF which the NaCl validator disallows. A separate patch will fix that
issue.

R=jvoung@chromium.org
TEST= ./scons run_synchronization_sync_test bitcode=1 platform=x86-32
BUG= http://llvm.org/bugs/show_bug.cgi?id=20376
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2518
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2981
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3579
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3673
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4015

Original patch description:

x86's CMPXCHG -> EFLAGS consumer wasn't being recorded as a real EFLAGS
dependency because it was represented by a pair of CopyFromReg(EFLAGS) ->
CopyToReg(EFLAGS) nodes. ScheduleDAG was expecting the source to be an
implicit-def on the instruction, where the result numbers in the DAG and the
Uses list in TableGen matched up precisely.

The Copy notation seems much more robust, so this patch extends ScheduleDAG
rather than refactoring x86.

Should fix PR20376.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220529 91177308-0d34-0410-b5e6-96231b3b80d8

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

7 days agoRemove PNaCl's x86-32 hack for 16-bit atomics
JF Bastien [Thu, 11 Dec 2014 22:40:09 +0000 (14:40 -0800)]
Remove PNaCl's x86-32 hack for 16-bit atomics

The x86-32 NaCl validator now accepts multi-prefix x86 instructions, which 16-bit atomics require (LOCK and DATA16).

TEST= ./scons run_synchronization_sync_test bitcode=1 platform=x86-32
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3579
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2981
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2518
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3673
R=dschuff@chromium.org

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

7 days agoEmit LOCK prefix after DATA16
JF Bastien [Thu, 11 Dec 2014 22:02:31 +0000 (14:02 -0800)]
Emit LOCK prefix after DATA16

This matches the order in GCC's code generation, which NaCl's x86-32 expects. Note that both orderings are valid in x86.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=2518
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3673
R=jvoung@chromium.org
TEST= ninja check

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

8 days agoCherrypick 217435 and 217942 which conflict with NACL_CG_CALL64r, and adjust localmod.
Jan Voung [Wed, 10 Dec 2014 20:53:25 +0000 (12:53 -0800)]
Cherrypick 217435 and 217942 which conflict with NACL_CG_CALL64r, and adjust localmod.

217942 adds some limited zero-extension to make 32-bit
pointers 64-bit before pattern matching the indirect call
with CALL64r. This is done for all ILP32 targets including
NaCl, so the NACL_CG_CALL64r pattern no longer matches.

Adjust by removing NACL_CG_CALL64r, and use CALL64r.
This allows NaCl to also use CALL64r without defining a
separate NACL_CG_CALL64r.

However, we keep 32-bit operands for the the asm
"naclcall" (NACL_CALL64r), because gas expects "naclcall
%exx, %r15" and not "naclcall %rxx, %r15".

Also remove the NACL_CG_TCxxr for indirect tail calls.
We cannot remove indirect branch and direct call
NACL_CG_* yet, because 217942's zero-extension does not
apply to those cases.

Slip in a similar adjustment for FastIsel.

Cherrypick 217435 because 217942 modifies a test that is added by 217435.

BUG= merge to upstream/google/stable
R=dschuff@chromium.org

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

8 days agoModify X86NaClRewritePass ApplyMemorySFI to handle multiple memory operands
Derek Schuff [Wed, 10 Dec 2014 18:24:24 +0000 (10:24 -0800)]
Modify X86NaClRewritePass ApplyMemorySFI to handle multiple memory operands

Previously FindMemoryOperand expected there to be only one memory operand
per MachineInstr. This was reasonable for X86 instructions, but inline asm
MIs can have 2 if the "+" constraint modifier is used (the same operand
is used as input and output).
Fix ApplyMemorySFI to pass a vector of operands rather than a single
one, and fix up all of them.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4014

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

8 days agoFix more error handling code wrt to handling the input bitcode buffer.
Karl Schimpf [Wed, 10 Dec 2014 18:06:59 +0000 (10:06 -0800)]
Fix more error handling code wrt to handling the input bitcode buffer.

Adds a few additional fixes to error handling and releasing of the
input bitcode buffer (for NaCl). Changes make the handling of the input buffer
consistent in all (known) contexts, which is to never take ownership of
the input buffer inside NaClParseBitcodeFile.

Also cleans up unit tests to no longer work around this issue. Also
fixes issue 3999 (i.e. the pexe from issue 3999 now cleanly exits with an
appropriate error message).

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4006
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3999
R=jvoung@chromium.org

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

9 days agoFix PNaCl bitcode when function call argument is has invalid reference.
Karl Schimpf [Tue, 9 Dec 2014 21:41:21 +0000 (13:41 -0800)]
Fix PNaCl bitcode when function call argument is has invalid reference.

Fixes case where function call argument (in bitcode) is defined by
an invalid, forward value reference.

Also fixes minor mistakes in PNaCl bitcode parsing where error
codes are not properly migrated up.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3999
R=jvoung@chromium.org

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

9 days agoRemove localmod for disabling libcall simplifications while compiling implementations...
Jan Voung [Tue, 9 Dec 2014 18:19:41 +0000 (10:19 -0800)]
Remove localmod for disabling libcall simplifications while compiling implementations of libs.

If I remember correctly, the original problem was that
exp2() is implemented as a call to pow(). However if
the optimizer does XYZ to pow's implementation... then
there is trouble?

A couple of recommendations were to use some -fno-builtin-*
flag or some other way of not relying on TLI when compiling
library code:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20121210/158679.html
Newlib is built with -fno-builtin.

An earlier problem with, -fno-builtin was that it doesn't
help with LTO because the commandline flags are lost by
then. If the commandline options are embedded in the
bitcode it might help. However, we also explicitly disable
simplify libcalls during LTO in the driver, because
static linking plus simplify libcalls can cause other
problems. E.g., It may mean that some library code is not
linked in, so transforming calls from one lib func to
another after linking can break.

BUG= none (I ran into a merge conflict with this, where
code is inlined, so wanted to see if it can just be
removed)

R=dschuff@chromium.org

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

9 days agoEmit callq instead of call on x86-64
JF Bastien [Tue, 9 Dec 2014 16:49:38 +0000 (08:49 -0800)]
Emit callq instead of call on x86-64

This matches x86-64 assembly the same way we currently match x86-32 assembly on calll, and makes tests similar to the non-NaCl ones.

R=dschuff@chromium.org
TEST= ninja check
BUG= none

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

13 days agoFix a couple of warnings about unused private fields, use TRI, etc.
Jan Voung [Fri, 5 Dec 2014 23:52:18 +0000 (15:52 -0800)]
Fix a couple of warnings about unused private fields, use TRI, etc.

Also, while I noticed that the TRI for NaClRewritePass is
unused, it looks like that can be used to check if a
register is modified (or its super register is modified),
so use that instead of separately checking ESP & RSP mods.

BUG=none

Just happened to notice while searching for errors in
a broken merge build.

R=dschuff@chromium.org, kschimpf@google.com

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

13 days agoUse PushSection and PopSection when initializing NaCl MC streamer
Derek Schuff [Fri, 5 Dec 2014 20:49:34 +0000 (12:49 -0800)]
Use PushSection and PopSection when initializing NaCl MC streamer

Currently if there is top-level inline assembly in a C file before
any C code, it gets put into the ABI note section instead of
the text section. Using PushSection/PopSection fixes that.
However PushSection requires that there has been a section
switched to already (which sometimes doesn't happen in
text asm files), so change llvm-mc to initialize the sections
before calling the NaCl MCStreamer initialization

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3968
R=jvoung@chromium.org

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

13 days agoRemove localmod of C-API for linker symbol wrapping. Switched to C++.
Jan Voung [Fri, 5 Dec 2014 20:04:55 +0000 (12:04 -0800)]
Remove localmod of C-API for linker symbol wrapping. Switched to C++.

During the last merge, the gold-plugin switched to using
a C++ api instead of this, so I think it can be removed.

In the next merge, I noticed that gold-plugin doesn't use
LTO anymore at all:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140825/233009.html

In the merge, I tried to just inline the LTO code into
gold-plugin.cpp and remove from LTO completely.
The gold-plugin.cpp later starts including "llvm/IR/"
headers, so most of what's needed will be there to
do the inlining (except the llvm/IR/Constants.h header,
which shows up at a later revision too).

BUG=none
R=dschuff@chromium.org, jfb@chromium.org

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

2 weeks agoFix error reporting in the PNaCl bitcode reader.
Karl Schimpf [Wed, 3 Dec 2014 22:47:30 +0000 (14:47 -0800)]
Fix error reporting in the PNaCl bitcode reader.

When LLVM 3.5 was merged, the handling of errors was not fixed.
The effect is that error messages do not percolate up to the
top-level routines (Which expect: ErrorOr<Module*>). Rather,
pnacl-llc (and similar reading tools) core dump if there is
an error in the bitcode file.

This CL fixes this issue.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4006
R=jvoung@chromium.org

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

2 weeks agoRemove workaround for call+bundle_lock under gas in LowerTlsAddr
Derek Schuff [Tue, 2 Dec 2014 23:53:51 +0000 (15:53 -0800)]
Remove workaround for call+bundle_lock under gas in LowerTlsAddr

Gas now properly handles calls in bundle-locked groups.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4008
R=jvoung@chromium.org

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

2 weeks agoRemove localmod for 16-bit shld/shrd on x86-32.
Jan Voung [Tue, 2 Dec 2014 23:14:08 +0000 (15:14 -0800)]
Remove localmod for 16-bit shld/shrd on x86-32.

Validator accepts it now.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=2978
R=dschuff@chromium.org

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

2 weeks agoRemove a couple random localmods that don't seem relevant anymore.
Jan Voung [Tue, 2 Dec 2014 23:11:39 +0000 (15:11 -0800)]
Remove a couple random localmods that don't seem relevant anymore.

*) Code for NaCl bundling with the old JIT.
*) Stub out raise for NaCl build of JIT/Interpreter.
*) Localmod that for varargs alignment that is the same as upstream now
(and not quite working).

BUG=none
R=dschuff@chromium.org

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

2 weeks agoUse "." instead of label difference for GOT address calculations with gas
Derek Schuff [Mon, 1 Dec 2014 21:47:50 +0000 (13:47 -0800)]
Use "." instead of label difference for GOT address calculations with gas

LLVM's MC layer has no way to generate a "." symbol in assembly files
(or its equivalent for direct object emission). When calculating the GOT's
address, it emits a label and refers to it, but this doesn't work for NaCl
if the instruction after the label gets nop-padded. For this case, we
directly emit the assembly text with "." instead of using the MC layers
(but only when emitting text assembly).

R=mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3982

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

2 weeks agoRemove nacltlsaddr32 from assembly layer
Derek Schuff [Mon, 1 Dec 2014 21:42:27 +0000 (13:42 -0800)]
Remove nacltlsaddr32 from assembly layer

nacltlsaddr32 was a pseudo-instruction that essentially duplicated the
existing tlsaddr32 but was parsed by the assembler and expanded in the
MC layer rather than being expanded in X86MCInstLower.cpp. This was to ensure
that the TLS GD sequence stayed bundle-locked. Now that both assemblers
support .bundle_lock we can emit that in X86MCInstLower directly and
remove the special MC support.

However we can't turn that on everywhere yet because gas has a bug when
a call instruction is used in an explicit bundle-locked group,
so we work around it for now. See the comment in
LowerTlsAddr for more details.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3966
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4008

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

3 weeks agoEmit (and support) .dwarf_addr_size directive
Derek Schuff [Wed, 26 Nov 2014 16:52:33 +0000 (08:52 -0800)]
Emit (and support) .dwarf_addr_size directive

gas assumes that the address size used for DWARF debug info (and thus the
line tables it generates from .loc directives) will always match the ELF
class. However LLVM generates debug info that matches the actual address
size (32 bit on x86-64 NaCl), which results in a mismatch between LLVM's
debug info and gas' line tables.

This CL modifies LLVM to emit this directive when emitting text assembly.
It also adds x86AsmParser support for this directive, because otherwise
we would need to only emit it when disabling the integrated assembler;
and initializeNaClMCStreamer has no good way of knowing when we are
using gas or the LLVM assembler.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3966

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

3 weeks agoRevert "De-C++11ify cherrypick of r220439"
Derek Schuff [Wed, 26 Nov 2014 16:38:10 +0000 (08:38 -0800)]
Revert "De-C++11ify cherrypick of r220439"

This reverts commit 8e57321b7ca418fd71000c7b02494ab0df116fa7.
Now that we are in C++11 land we can revert
https://codereview.chromium.org/676643003

R=jvoung@chromium.org
BUG=None

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

3 weeks agoMake all non-weak symbols hidden for better code
Shinichiro Hamaji [Tue, 25 Nov 2014 05:12:02 +0000 (14:12 +0900)]
Make all non-weak symbols hidden for better code

This is a necessary change for non-SFI mode. Without this,
pnacl-llc creates R_386_TLS_IE relocations and they may be
left as R_386_TLS_TPOFF after the link. With this patch,
pnacl-llc creates R_386_TLS_LE and they are resolved by the
linker.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3868
TEST=toolchain_build/toolchain_build_pnacl.py --install \
     toolchain/linux_x86/pnacl_newlib

R=mseaborn@chromium.org

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

3 weeks agoFix cmake build: MinSFI was incorrect
JF Bastien [Mon, 24 Nov 2014 22:13:24 +0000 (14:13 -0800)]
Fix cmake build: MinSFI was incorrect

R=dschuff@chromium.org, mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
TEST= cmake build

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

4 weeks agoAdd flag to enable Dwarf exception handling on ARM merge_35
Derek Schuff [Thu, 20 Nov 2014 19:32:41 +0000 (11:32 -0800)]
Add flag to enable Dwarf exception handling on ARM

Previously EABI EH was disabled for NaCl but not explicitly disabled for
Non-SFI mode. Some changes upstream for better ARM EHABI support caused
EHABI unwind info to be unconditionally emitted (into the .ARM.exidx section)
which has references to aeabi_ functions which we do not include in our
compiler-rt.
Introduce a flag to fully disable EHABI support for ARM (to be used by
Non-SFI mode) and clean up the disabling of EHABI for SFI mode as well.

R=jfb@chromium.org, mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930

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

4 weeks ago[MIPS] Add missing support dropped in the 3.5 merge
Petar Jovanovic [Thu, 20 Nov 2014 00:11:55 +0000 (01:11 +0100)]
[MIPS] Add missing support dropped in the 3.5 merge

LLVM 3.5 merge dropped some MIPS specific parts.
This change puts it back. It also includes cherry-pick of r218744
that was committed after the 3.5 branch.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
R=dschuff@chromium.org

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

4 weeks agoApply jvoung's suggestion for strip-module-flags
JF Bastien [Wed, 19 Nov 2014 21:39:55 +0000 (13:39 -0800)]
Apply jvoung's suggestion for strip-module-flags

4 weeks agoUse BUILD_CFLAGS along with BUILD_{CC,CXX} for LLVM BuildTools
Derek Schuff [Fri, 14 Nov 2014 19:23:00 +0000 (11:23 -0800)]
Use BUILD_CFLAGS along with BUILD_{CC,CXX} for LLVM BuildTools

Previously these flags were cleared, but we to set need them in order to use
clang/libc++ to build the translator on Precise.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930

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

5 weeks agoDisable 2 debuginfo-related assertions
Derek Schuff [Thu, 13 Nov 2014 23:56:39 +0000 (15:56 -0800)]
Disable 2 debuginfo-related assertions

Both seem to fire sometimes at LLVM 3.5, but there has been a lot of work on
this code upstream since the branch, so we should investigate more after
we merge closer to 3.6

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930

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

5 weeks agoDisable instcombine overflow-intrinsic optimizations only for PNaCl
Derek Schuff [Thu, 13 Nov 2014 23:54:12 +0000 (15:54 -0800)]
Disable instcombine overflow-intrinsic optimizations only for PNaCl

Previously these optimizations were unconditionally disabled, which
broke their tests. Instead disable them only for PNaCl and re-enable
the tests (and keep the new test in 3.5 enabled). Also keep the previous
local test that ensured that the optimization was disabled for PNaCl and
also apply it to the new test.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930

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

5 weeks agoDisable JumpInstrTables pass when using only a FunctionPassManager
Derek Schuff [Thu, 13 Nov 2014 23:46:46 +0000 (15:46 -0800)]
Disable JumpInstrTables pass when using only a FunctionPassManager

If there is not a ModulePassManager in the pass manager stack, do not schedule
the pass. pnacl-llc uses only a FunctionPassManager but for some reason it will
happily schedule any module passes that are handed to it and call them with
bogus arguments. We could move this mod up into ModulePass::assignPassManager
except that the JIT also uses a FPM and schedules a DebugInfoVerifier (which we
do not use). That is still probably wrong but DebugInfoVerifier seems to
accidentally work anyway for that case.  All of this should be fixed upstream,
except that the pass manager is being completely rewritten. So for now this is a
noninvasive solution that does not affect non-PNaCl runs.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930

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

5 weeks agoChange ARM/varargs-spill-stack-align-nacl.ll test to have armv7 as base.
Jan Voung [Wed, 12 Nov 2014 23:57:42 +0000 (15:57 -0800)]
Change ARM/varargs-spill-stack-align-nacl.ll test to have armv7 as base.

The test needs to materialize a global address, and for NaCl we use
movw/movt. ARMExpandPseudos will assert if v6t2 ops for movw/movt
aren't available.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
R=dschuff@chromium.org

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

5 weeks agoFix up td change from earlier for tconstpool.
Jan Voung [Wed, 12 Nov 2014 21:37:14 +0000 (13:37 -0800)]
Fix up td change from earlier for tconstpool.

"Requires" replaces the list of predicates, not appends to it.
By adding Requires[UseConstIslands], that nuked the implicit
requires IsARM coming from ARMPat. So, add back the IsARM explicitly.

This fixes the CodeGen/ARM/debug-info-branch-folding.ll test,
which was originally selecting the t2LEApcrel instead of LEApcrel.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
R=dschuff@chromium.org

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

5 weeks agoFollowup for translator-trimming -- stub out getObjectFormat too.
Jan Voung [Wed, 12 Nov 2014 18:18:23 +0000 (10:18 -0800)]
Followup for translator-trimming -- stub out getObjectFormat too.

The object writer is now chosen based on object format, which seems
more direct than the previous 3.4 approach of choosing it based
on the OS. Stub out the object format-getter for the self-build
to be ELF always, to make the prune_test.py happy.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
R=dschuff@chromium.org

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

5 weeks agoAdjust asm_memory transform test expectation
Derek Schuff [Tue, 11 Nov 2014 23:10:40 +0000 (15:10 -0800)]
Adjust asm_memory transform test expectation

The assembly output now uses the 'l' suffix on the mov instruction.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930

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

5 weeks agoMerge remote-tracking branch 'origin/master' into merge_35
Derek Schuff [Tue, 11 Nov 2014 22:56:52 +0000 (14:56 -0800)]
Merge remote-tracking branch 'origin/master' into merge_35

Conflicts:
lib/MC/MCAsmStreamer.cpp
tools/llvm-mc/llvm-mc.cpp

5 weeks agollvm 3.5: Use gnu++11 in self-build instead of c++11, fix other self-build localmods.
Jan Voung [Tue, 11 Nov 2014 21:11:57 +0000 (13:11 -0800)]
llvm 3.5: Use gnu++11 in self-build instead of c++11, fix other self-build localmods.

Testing the arm build more w/ the self build...

- Use std=gnu++11 instead of std=c++11, since strdup isn't
included with __STRICT_ANSI__, and the "or" condition in newlib
is checking for _XOPEN_SOURCE, instead of something like
GNU_SOURCE. Basically, reuse the mingw and cygwin check.
- Fix translator-trimming where we hardcode OS to NaCl and
binformat is hardcoded to ELF. Macho is finally a binformat instead of an env.
- minor change for error_code::success
- IsLockFree __native_client__ version returns a Constant*, not a bool.

Translator compiles and links, after hacking the driver more to pass
through --gc-sections, and such. (alternatively, hack the makefile
to not use --gc-sections during a bitcode link...)

However, it explodes translating:
DwarfUnit.cpp:953: llvm::DIE *llvm::DwarfUnit::getOrCreateTypeDIE(const llvm::MDNode *): Assertion `Ty == resolve(Ty.getRef()) && "type was not uniqued, possible ODR violation."' failed.

=( =( =(

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
R=dschuff@chromium.org

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

5 weeks agoDon't delete the bitcode buffer in NaClParseIR
Derek Schuff [Tue, 11 Nov 2014 19:25:04 +0000 (11:25 -0800)]
Don't delete the bitcode buffer in NaClParseIR

The IRReader interface upstream changed the way it handles the bitcode
buffer. Change NaClParseIR to match

R=kschimpf@google.com, jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930

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

5 weeks agoLLVM 3.5 merge: Don't run constant island pass 2x. Adjust tconstpool pattern match.
Jan Voung [Mon, 10 Nov 2014 20:35:18 +0000 (12:35 -0800)]
LLVM 3.5 merge: Don't run constant island pass 2x. Adjust tconstpool pattern match.

Some small adjustments to the merge conflict fixes.

For the ARM compiler-rt build, we are currently seeing an assertion
failure. This appears to be because it is using a constant island for
floating point constants w/ NaCl, when it isn't prepared to do so.
Adjust the the .td file pattern match for tconstpool to check
for our Use/DontUse constant island predicate,
instead of being unconditional.

For make check, a bunch of ARM tests are asserting because the
constant island pass is added twice to the pass manager. This
causes the pass to assert on some duplicated state.

There are still about 20 lit test failures (jumptable
stuff, mips, and some clang failures).
There's also a datalayout mismatch when building the
biased bitcode version of newlib for ARM.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3930
R=dschuff@chromium.org

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

6 weeks agoCherrypick 220866: Fix getRelocationValueString to return the symbol name for EM_386.
Jan Voung [Thu, 6 Nov 2014 00:31:25 +0000 (16:31 -0800)]
Cherrypick 220866: Fix getRelocationValueString to return the symbol name for EM_386.

Summary: This helps llvm-objdump -r to print out the symbol name along
with the relocation type on x86. Adjust existing tests from checking
for "Unknown" to check for the symbol now.

Test Plan: Adjusted test/Object tests.

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5987

BUG=none
R=dschuff@chromium.org

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

6 weeks agoCherry-pick r221386 and r221389 from upstream
Derek Schuff [Wed, 5 Nov 2014 23:09:04 +0000 (15:09 -0800)]
Cherry-pick r221386 and r221389 from upstream

[x86 fast-isel] Materialize allocas with the correct-sized lea for ILP32

    Summary:
    X86FastISel::fastMaterializeAlloca was incorrectly conditioning its
    opcode selection on subtarget bitness rather than pointer size.

    Differential Revision: http://reviews.llvm.org/D6136

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3966

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

6 weeks agoHook up CustomExpandInst to asm streamer as well as object streamer
Derek Schuff [Wed, 5 Nov 2014 17:42:28 +0000 (09:42 -0800)]
Hook up CustomExpandInst to asm streamer as well as object streamer

For now, only expand pseudos not supported by gas. Also ensure that
an AsmBackend is always available for NaCl in llvm-mc.
Add a test to ensure that the naclandsp pseudo is expanded.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3966

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

6 weeks agoAddress dschuff and jvoung's comments
JF Bastien [Sat, 1 Nov 2014 22:53:01 +0000 (15:53 -0700)]
Address dschuff and jvoung's comments

7 weeks agoFix sandboxing of inline assembly memory operands on x86-64
Derek Schuff [Mon, 27 Oct 2014 15:58:47 +0000 (08:58 -0700)]
Fix sandboxing of inline assembly memory operands on x86-64

There were 2 problems with inline assembly memory operands:

The first is that when the DAG address-mode-selection code created a new DAG
node to zero-extend a 32-bit memory pointer to a 64-bit value usable as
an index, it failed to actually insert the node in the appropriate ordering
location, meaning the node never actually got selected
(X86DAGToDAGIsel::SelectAddr gets called with a NULL Parent in that case).

Secondly, the X86NaClRewritePass failed to apply the memory-operand rewrite
for inline asm MachineInstrs because the mayload/maystore properties for
inline asm MIs are distinct from the mayload/maystore properties for real
instruction MIs; the MCInstrDesc mayStore() method does not account for
them but the mayStore() method on MachineInstr itself does.

R=jvoung@google.com, jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3957

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

7 weeks agoMerge branch 'master' into merge_35_squashed
JF Bastien [Fri, 24 Oct 2014 21:27:10 +0000 (14:27 -0700)]
Merge branch 'master' into merge_35_squashed

8 weeks agoAdd a new STI to X86MCNaCl.cpp
JF Bastien [Thu, 23 Oct 2014 19:31:59 +0000 (12:31 -0700)]
Add a new STI to X86MCNaCl.cpp

8 weeks agoMinSFI: fix usage of Use/User.
JF Bastien [Thu, 23 Oct 2014 19:30:40 +0000 (12:30 -0700)]
MinSFI: fix usage of Use/User.

8 weeks agoMinSFI: fix usage of Use/User.
JF Bastien [Thu, 23 Oct 2014 19:29:51 +0000 (12:29 -0700)]
MinSFI: fix usage of Use/User.

8 weeks agoFix X86MCInstLower.cpp to match upstream.
JF Bastien [Thu, 23 Oct 2014 19:26:22 +0000 (12:26 -0700)]
Fix X86MCInstLower.cpp to match upstream.

8 weeks agoFix type conversion for enum class.
JF Bastien [Thu, 23 Oct 2014 17:54:27 +0000 (10:54 -0700)]
Fix type conversion for enum class.

8 weeks agoFix -Wc++11-narrowing warning.
JF Bastien [Thu, 23 Oct 2014 17:53:34 +0000 (10:53 -0700)]
Fix -Wc++11-narrowing warning.

8 weeks agos/OwningPtr/unique_ptr/
JF Bastien [Thu, 23 Oct 2014 17:24:52 +0000 (10:24 -0700)]
s/OwningPtr/unique_ptr/

8 weeks agoMissing include.
JF Bastien [Thu, 23 Oct 2014 17:23:57 +0000 (10:23 -0700)]
Missing include.

8 weeks agoSilly fix because of C++11 user-defined litterals.
JF Bastien [Thu, 23 Oct 2014 17:22:53 +0000 (10:22 -0700)]
Silly fix because of C++11 user-defined litterals.

8 weeks agoFix pointer/reference change.
JF Bastien [Thu, 23 Oct 2014 17:18:30 +0000 (10:18 -0700)]
Fix pointer/reference change.

8 weeks agoFix type conversion for enum class.
JF Bastien [Thu, 23 Oct 2014 17:11:29 +0000 (10:11 -0700)]
Fix type conversion for enum class.

8 weeks agoFix missing parameter.
JF Bastien [Thu, 23 Oct 2014 17:11:12 +0000 (10:11 -0700)]
Fix missing parameter.

8 weeks agoFix -Wc++11-narrowing warning.
JF Bastien [Thu, 23 Oct 2014 17:10:54 +0000 (10:10 -0700)]
Fix -Wc++11-narrowing warning.

8 weeks agoDe-C++11ify cherrypick of r220439
Derek Schuff [Thu, 23 Oct 2014 17:06:28 +0000 (10:06 -0700)]
De-C++11ify cherrypick of r220439

Clang is happy to emit a warning about C++11 extensions and compile the use
of auto and range-for anyway, but mingw is not.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3982
R=jvoung@chromium.org

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

8 weeks agoMerge the latest upstream/release_35.
JF Bastien [Thu, 23 Oct 2014 16:28:03 +0000 (09:28 -0700)]
Merge the latest upstream/release_35.

8 weeks agoRevert Mips to upstream/release_35 state, the merge isn't consistent otherwise.
JF Bastien [Thu, 23 Oct 2014 16:23:39 +0000 (09:23 -0700)]
Revert Mips to upstream/release_35 state, the merge isn't consistent otherwise.

8 weeks agoMerge in latest changes from the PNaCl repo.
JF Bastien [Thu, 23 Oct 2014 16:19:03 +0000 (09:19 -0700)]
Merge in latest changes from the PNaCl repo.

8 weeks agoCherrypick upstream r220439
Derek Schuff [Wed, 22 Oct 2014 23:55:57 +0000 (16:55 -0700)]
Cherrypick upstream r220439
[MC] Attach labels to existing fragments instead of using a separate fragment

    Summary:
    Currently when emitting a label, a new data fragment is created for it if the
    current fragment isn't a data fragment.
    This change instead enqueues the label and attaches it to the next fragment
    (e.g. created for the next instruction) if possible.

    When bundle alignment is not enabled, this has no functionality change (it
    just results in fewer extra fragments being created). For bundle alignment,
    previously labels would point to the beginning of the bundle padding instead
    of the beginning of the emitted instruction. This was not only less efficient
    (e.g. jumping to the nops instead of past them) but also led to miscalculation
    of the address of the GOT (since MC uses a label difference rather than
    emitting a "." symbol).

    Fixes https://code.google.com/p/nativeclient/issues/detail?id=3982

    Test Plan: regression test attached

    Reviewers: jvoung, eliben

    Subscribers: jfb, llvm-commits

    Differential Revision: http://reviews.llvm.org/D5915

(one change is that nullptr is replaced by NULL to build without
-std=c++11, but the auto and range-for are left because they
 will just be a warning until we merge 3.5 and switch)

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3982

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

8 weeks agoAdd a -strip-module-flags pass, which supplements -strip-metadata by also stripping...
JF Bastien [Wed, 22 Oct 2014 22:43:38 +0000 (15:43 -0700)]
Add a -strip-module-flags pass, which supplements -strip-metadata by also stripping the llvm.module.flags metadata. This requires a corresponding change in pnacl-finalize. This fixes an issue where llvm.module.flags now contains a Debug Info Version node, which forces all debug info to be discarded when it's not present. llvm.module.flags doesn't get removed by -strip, hence the need for a new pass.

8 weeks agoCherry-pick r215837 from upstream.
Derek Schuff [Wed, 22 Oct 2014 21:01:54 +0000 (14:01 -0700)]
Cherry-pick r215837 from upstream.

This fix for llvm-objdump will be required to keep our bundling tests
passing after we apply the change in http://reviews.llvm.org/D5915

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3982

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

8 weeks agoDisable the loop vectorizer and SLP vectorizer in PassManageBuilder when doing LTO...
JF Bastien [Mon, 20 Oct 2014 20:07:04 +0000 (13:07 -0700)]
Disable the loop vectorizer and SLP vectorizer in PassManageBuilder when doing LTO, they were ignoring the command line options. I sent a patch upstream to do something similar (the code ahs changed a bit since then).

2 months agoFix filename handling in pnacl-llc, my merge had previously messed it up when splitti...
JF Bastien [Fri, 17 Oct 2014 21:42:26 +0000 (14:42 -0700)]
Fix filename handling in pnacl-llc, my merge had previously messed it up when splitting modules.

2 months agoHard-disable the JumpInstrTables passes, they cause a crash in the translator when...
JF Bastien [Thu, 16 Oct 2014 22:44:31 +0000 (15:44 -0700)]
Hard-disable the JumpInstrTables passes, they cause a crash in the translator when trying to access attributes, and I haven't diagnosed the issues because we currently don't use these passes.

2 months agoExpandStructRegs should ignore atomic cmpxchg instructions (which now returns a struc...
JF Bastien [Thu, 16 Oct 2014 20:32:14 +0000 (13:32 -0700)]
ExpandStructRegs should ignore atomic cmpxchg instructions (which now returns a struct) and let RewriteAtomics change the instruction to an intrinsic. The ExpandStructRegs pass then needs to be re-run as a post-opt pass.

2 months agoEnsure jump tables get a unique rodata section if their corresponding
Derek Schuff [Thu, 16 Oct 2014 17:42:26 +0000 (10:42 -0700)]
Ensure jump tables get a unique rodata section if their corresponding
function has a unique text section

Jump tables for switch statements usually go in the .rodata section;
however when the function is weak/linkonce_odr, LLVM puts them into the
function's text section (which is a unique comdat) so it can be discarded
by the linker along with the function.
For NaCl we never put data in the text segment so we have a localmod
to always put the jumptables in .rodata. However if the function is
weak and gets discarded, the jumptable is still in .rodata with a
relocation to the discarded text, which causes a linker error. (This
was not a problem with bitcode linking where the LLVM function is
discarded all together before translation, but it is a problem for
direct-to-native use).

This CL chooses an ro section for the jumptable based on the attributes
of the function, (which means that if the function gets its own section
then the jumptable does too).

R=mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3952

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

2 months agoFix mov register size sandbox-hiding frame setup
Derek Schuff [Thu, 16 Oct 2014 00:32:22 +0000 (17:32 -0700)]
Fix mov register size sandbox-hiding frame setup

When hiding the sandbox base on x86-64 we do not push the whole frame pointer
onto the stack; instead we use a 32-bit mov to a register (leaving the
upper half zeroed) and push that. Previously the BuildMI creation
used the frame pointer (a 64-bit register) as an operand to the 32-bit mov,
which is wrong, and results in assembly like
movl %rbp, %eax
which assemblers reject. But for some reason things just worked using direct
object emission, so it was never discovered before.

R=stichnot@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3966

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

2 months agoFix an x87 code generation issue when building compiler-rt. Patch sent upstream as...
JF Bastien [Wed, 15 Oct 2014 22:30:24 +0000 (15:30 -0700)]
Fix an x87 code generation issue when building compiler-rt. Patch sent upstream as reviews.llvm.org/D5807

2 months agoCherrypick Upstream r219811:
Derek Schuff [Wed, 15 Oct 2014 19:51:52 +0000 (12:51 -0700)]
Cherrypick Upstream r219811:
[MC] Make bundle alignment mode setting idempotent and support nested bundles

Summary:
Currently an error is thrown if bundle alignment mode is set more than once
per module (either via the API or the .bundle_align_mode directive). This
change allows setting it multiple times as long as the alignment doesn't
change.

Also nested bundle_lock groups are currently not allowed. This change allows
them, with the effect that the group stays open until all nests are exited,
and if any of the bundle_lock directives has the align_to_end flag, the
group becomes align_to_end.

These changes make the bundle aligment simpler to use in the compiler, and
also better match the corresponding support in GNU as.

Reviewers: jvoung, eliben

Differential Revision: http://reviews.llvm.org/D5801

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3966

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

2 months agoFix the test/NaCl/ARM/GOT-with-disabled-constpools.ll test so that it actually checks...
JF Bastien [Wed, 15 Oct 2014 18:18:06 +0000 (11:18 -0700)]
Fix the test/NaCl/ARM/GOT-with-disabled-constpools.ll test so that it actually checks relocations correctly *before the merge*: it wasn't passing -r to llvm-objdump, and was only checking for movw/movt without checkout which relocations they corresponded to. This test is now broken *after the merge* (regardless of my fixing it), because LLVM now tries to emit fixup_arm_adr_pcrel_12 and fails to do so in ARMELFObjectWriter::GetRelocTypeInner: the switch under IsPCRel doesn't handle fixup_arm_adr_pcrel_12 and it looks like it should, but I'm not sure which type of relocation it should be. The switch under \!IsPCRel does handle fixup_arm_adr_pcrel_12 (as unimplemented), and that seems wrong (it simply shouldn't handle it, I don't think there's anything to implement). I'll open a bug to fix this later, since PIC is probably broken under PNaCl (because we disable constant pools). This is a great reason to upstream our constant pool disabling code.

2 months agoChange usage of naclcall and nacljmp pseudo-instructions to match x86 gas
Derek Schuff [Wed, 15 Oct 2014 17:13:46 +0000 (10:13 -0700)]
Change usage of naclcall and nacljmp pseudo-instructions to match x86 gas

x86 gas uses "call" for direct calls and "naclcall" for indirect calls,
and implicitly handles bundle-align-to-end for all calls in nacl mode;
previously we used "naclcall" for all calls which used bundle alignment.
This makes the assembler automatically align bare "call"
instructions. On x86-32 we remove our custom nacl-flavored
call instruction in favor of the bare call. On x86-64 we
still need a different codegen target for isel that takes
a 32-bit operand due to our pointer-size differences,
but we also sandbox bare call instructions.

Also for 64-bit forms of "nacljmp %foo, %r15" gas uses 32-bit operands
(nacljmp %r11d, %r15), whereas we had been using 64-bit operands
(nacljmp %r11, %r15). Using a 32-bit operand makes some sense since
the pointers are 32 bits; using a 64-bit operand makes some sense since
the entire register is cleared, but it's better to match. The operands
used in codegen are the same so again this is mostly just a change in
assembler spelling that's invisible to the compiler.

R=jvoung@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3966

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

2 months agoApply upstream: [mips] For indirect calls we don't need $gp to point to .got
Petar Jovanovic [Wed, 8 Oct 2014 00:07:06 +0000 (02:07 +0200)]
Apply upstream: [mips] For indirect calls we don't need $gp to point to .got

Cherry-pick r218744 from upstream.

Original commit message:

Author: Sasa Stankovic <Sasa.Stankovic@imgtec.com>
Date:   Wed Oct 1 08:22:21 2014 +0000

[mips] For indirect calls we don't need $gp to point to .got.  Mips linker
doesn't generate lazy binding stub for a function whose address is taken in
the program.

Differential Revision: http://reviews.llvm.org/D5067

R=mseaborn@chromium.org
TBR=mseaborn@chromium.org
BUG= barebones/top_of_sandbox fails for MIPS

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

2 months agoPNaCl: Handle invoke instructions in -expand-small-arguments...
JF Bastien [Fri, 3 Oct 2014 22:00:38 +0000 (15:00 -0700)]
PNaCl: Handle invoke instructions in -expand-small-arguments...

...instead of reporting a fatal error. The sole purpose of this commit is to facilitate -expand-small-arguments' use in bugpoint.

BUG= none
R=jfb@chromium.org, mseaborn@chromium.org
TEST= (cd toolchain_build/out/llvm_i686_linux_work && make check)

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

2 months agoFix PIC indirect call sequence with sandbox-base hiding
Derek Schuff [Wed, 1 Oct 2014 04:38:59 +0000 (21:38 -0700)]
Fix PIC indirect call sequence with sandbox-base hiding

When making indirect calls with sandbox-base hiding, the call sequence
pushes the return address on the stack (using r10) and jumps to the
call target through r11. This sequence clobbers r10, which is OK because
r10 is call-clobbered. However if the call target is stored in r10
before the call, it must be copied into r11 before the indirect jump
sequence.
This CL puts the mov of the call target into r11 before the return-
address push.

R=mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3958

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

2 months agoFix pnacl-hides-sandbox-x86-64.ll to expect jmp instead of jmpq: it looks like the...
JF Bastien [Thu, 25 Sep 2014 18:36:21 +0000 (11:36 -0700)]
Fix pnacl-hides-sandbox-x86-64.ll to expect jmp instead of jmpq: it looks like the assembly now properly applies -code-model=small when nothing is specified (it's the default behavior).

2 months agoFix X86AsmBackend again, my previous creation of the X86SubtargetInfo wasn't quite...
JF Bastien [Thu, 25 Sep 2014 18:29:00 +0000 (11:29 -0700)]
Fix X86AsmBackend again, my previous creation of the X86SubtargetInfo wasn't quite right.

2 months agoMake our localmod smaller.
JF Bastien [Thu, 25 Sep 2014 00:00:26 +0000 (17:00 -0700)]
Make our localmod smaller.

2 months agoModule verification still returns 1 but doens't crash in test/NaCl/PNaClLLC/test...
JF Bastien [Wed, 24 Sep 2014 23:30:07 +0000 (16:30 -0700)]
Module verification still returns 1 but doens't crash in test/NaCl/PNaClLLC/test-runs-verify.ll.

2 months agoFix debug info version.
JF Bastien [Wed, 24 Sep 2014 23:05:26 +0000 (16:05 -0700)]
Fix debug info version.

2 months agoFix debug info version.
JF Bastien [Wed, 24 Sep 2014 23:04:22 +0000 (16:04 -0700)]
Fix debug info version.

2 months agoFix debug info version.
JF Bastien [Wed, 24 Sep 2014 23:03:04 +0000 (16:03 -0700)]
Fix debug info version.

2 months agoI figured out the previous problem: bitcode files need to specify their debug info...
JF Bastien [Wed, 24 Sep 2014 22:51:26 +0000 (15:51 -0700)]
I figured out the previous problem: bitcode files need to specify their debug info version, otherwise it gets stripped.

2 months agoFix another s/use/user/ in RewritePNaClLibraryCalls.
JF Bastien [Wed, 24 Sep 2014 22:27:07 +0000 (15:27 -0700)]
Fix another s/use/user/ in RewritePNaClLibraryCalls.

2 months agoreplace-ptrs-with-ints seems to have regressed becasue it now entirely drops llvm...
JF Bastien [Wed, 24 Sep 2014 22:20:16 +0000 (15:20 -0700)]
replace-ptrs-with-ints seems to have regressed becasue it now entirely drops llvm.dbg.{declare,value} instead of adding nulls to it. Update the test to reflect this, but we should investigate further.

2 months agoFix another cmpxchg in test bitcode.
JF Bastien [Wed, 24 Sep 2014 22:10:52 +0000 (15:10 -0700)]
Fix another cmpxchg in test bitcode.

2 months agoFix another s/use/user/ in RewriteLLVMIntrinsics.
JF Bastien [Wed, 24 Sep 2014 22:05:04 +0000 (15:05 -0700)]
Fix another s/use/user/ in RewriteLLVMIntrinsics.

2 months agoFix another s/use/user/ in ExpandIndirectBr.
JF Bastien [Wed, 24 Sep 2014 21:51:01 +0000 (14:51 -0700)]
Fix another s/use/user/ in ExpandIndirectBr.

2 months agoFix ResolvePNaClIntrinsics to properly generate LLVM's new cmpxchg form, and apply...
JF Bastien [Wed, 24 Sep 2014 20:57:53 +0000 (13:57 -0700)]
Fix ResolvePNaClIntrinsics to properly generate LLVM's new cmpxchg form, and apply some limited peepholing to ensure that the code generated is optimal. Update the tests accordingly.

2 months agoDo not destroy linkage property when deleting function body
Petar Jovanovic [Wed, 24 Sep 2014 10:18:25 +0000 (12:18 +0200)]
Do not destroy linkage property when deleting function body

When dematerializing function, call dropAllReferences() instead of
deleteBody(), since deleteBody() has a side effect to destroy linkage
type. It is important to preserve linkage type, so correct relocations
can be emitted for internal and external functions.

It fixes the issue #3943.

The same chage has been upstreamed to LLVM BitcodeReader.cpp in r218302.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3943
TEST= Run PNaCL examples in the browser with relocation_model=PIC
R=mseaborn@chromium.org

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

3 months agoFix ReweriteAtomics to porperly handle cmpxchg now that it returns a struct instead...
JF Bastien [Thu, 18 Sep 2014 02:40:59 +0000 (19:40 -0700)]
Fix ReweriteAtomics to porperly handle cmpxchg now that it returns a struct instead of just a value. Update the val_compare_and_swap test accordingly.