native_client/pnacl-llvm.git
3 hours agoFix Windows build warning master
JF Bastien [Tue, 27 Jan 2015 17:18:15 +0000 (09:18 -0800)]
Fix Windows build warning

Another fix for:
  https://codereview.chromium.org/863093002

GCC 4.8.1 is again being silly and thinking control reaches end of non-void function.

TBR= kschimpf@chromium.org
BUG=none

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

16 hours agoFix Windows build warning
JF Bastien [Tue, 27 Jan 2015 04:34:53 +0000 (20:34 -0800)]
Fix Windows build warning

This CL:
  https://codereview.chromium.org/863093002

Is trying to turn on -Werror, and Windows' compiler thinks control reaches end of non-void function, but it's wrong because all cases are handled. Note our disagreement using llvm_unreachable.

TBR= kschimpf@chromium.org
BUG= none

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

4 days agoRemove unused LOCALMOD to disable libxml
Derek Schuff [Fri, 23 Jan 2015 00:26:22 +0000 (16:26 -0800)]
Remove unused LOCALMOD to disable libxml

The rest of the localmod appears to have already been removed.

R=jfb@chromium.org
BUG=cleanup

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

4 days agoFix more build warnings
JF Bastien [Thu, 22 Jan 2015 22:35:47 +0000 (14:35 -0800)]
Fix more build warnings

The following CL enables -Werror:
  https://codereview.chromium.org/863093002/

There were two warnings left in our LLVM build:
  - The ObjDump private member was unused.
  - GCC 4.8 on Windows thinks the function can fallthrough when it actually can't (because all cases are handled).

R=dschuff@chromium.org, kschimpf@chromium.org
TEST= make check
BUG= none

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

5 days agoAllow temporary overrides of error stream in NaClBitcodeParser.
Karl Schimpf [Thu, 22 Jan 2015 17:58:17 +0000 (09:58 -0800)]
Allow temporary overrides of error stream in NaClBitcodeParser.

Generalizes method setErrStream to return old error stream, so that
one can temporarily replace the error stream, and replace it to its
old value afterwards.

BUG=None
R=stichnot@chromium.org

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

5 days agoRemove unused variable warning
JF Bastien [Thu, 22 Jan 2015 00:35:58 +0000 (16:35 -0800)]
Remove unused variable warning

I'm trying to enable -Werror:
  https://codereview.chromium.org/863093002

Our localmods are creating warnings. Mark the variables as used.

R=dschuff@chromium.org
NOTRY=true

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

5 days agoAllow pnacl-abicheck to autodetect file format.
Karl Schimpf [Wed, 21 Jan 2015 23:10:01 +0000 (15:10 -0800)]
Allow pnacl-abicheck to autodetect file format.

Adds AutodetectFileFormat to list of possible NaClFileFormat's.
Modifies NaClParseIR and NaClParseIRFile to accept this value.  Only
modifies default value for input file format of command
pnacl-abicheck. All other tools only accept LLVMFormat or PNaClFormat.

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

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

5 days agoSimplify implementation of LLVM bitcode abbreviations.
Karl Schimpf [Wed, 21 Jan 2015 21:06:28 +0000 (13:06 -0800)]
Simplify implementation of LLVM bitcode abbreviations.

The previous implementation of bitcode abbreviations treated literals
as a special case. As such, most code had to test if it is a literal, and
apply a switch on all other encodings separately. This change makes
literals just another encoding, letting a single switch statement to describe
actions to be applied to a bitcode abbreviation.

Also adds error checking to bitstream reader when reading
bitcode abbreviations, so that it generates better error
messages if malformed abbreviation operators are found.

BUG=None
R=jvoung@chromium.org

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

6 days agoFix reading switch on pointer type for PNaCl Bitcode.
Karl Schimpf [Wed, 21 Jan 2015 19:11:09 +0000 (11:11 -0800)]
Fix reading switch on pointer type for PNaCl Bitcode.

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

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

6 days agoEmit atomic memory order other than seq_cst on demand only
JF Bastien [Wed, 21 Jan 2015 03:50:48 +0000 (19:50 -0800)]
Emit atomic memory order other than seq_cst on demand only

The following CL:
  https://codereview.chromium.org/791053006/
Taught PNaCl to support atomic memory orderings other than seq_cst (which was
the only supported memory ordering at launch). This is desirable for
performance, but it causes issues for users when rolling out the new SDK: old
versions of the translator don't accept anything but seq_cst and the canary SDK
emits them, which makes testing harder. This CL makes the SDK default to
emitting only seq_cst memory ordering, but leaves the translator as is (i.e. it
still accepts the new memory ordering). This makes it easier to roll out this
new feature, and users can still opt-in to emitting the new memory order by
specifying -pnacl-memory-order-seq-cst-only=false. The flag currently defaults
to seq_cst only, and for Chrome 43 it will be made to default to false
(i.e. acq/rel/acq_rel/seq_cst can be emitted).

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

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

6 days agoFix initialization of the NaClBitstreamCursor.
Karl Schimpf [Tue, 20 Jan 2015 23:46:36 +0000 (15:46 -0800)]
Fix initialization of the NaClBitstreamCursor.

Initializes all fields of the NaClBitstreamCursor at construction time,
rather than waiting to initialize some during reader initialization.
This guarantees that method GetCurrentBitNo always returns a reasonable value.

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

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

7 days agoReport all legal alignments when wrong on load/stores in pnacl-bcdis.
Karl Schimpf [Tue, 20 Jan 2015 20:09:19 +0000 (12:09 -0800)]
Report all legal alignments when wrong on load/stores in pnacl-bcdis.

BUG=None
R=jvoung@chromium.org

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

7 days agoDelete operator= and copy ctor from NaClBitstreamCursor.
Jan Voung [Tue, 20 Jan 2015 19:30:56 +0000 (11:30 -0800)]
Delete operator= and copy ctor from NaClBitstreamCursor.

It doesn't appear to be used anymore.

A later merge commit will remove this from the non-NaCl
bitstream reader too (Ben Kramer's r217778),
though it's not called out explicitly in the commit message.
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140915/235335.html

Also, the operator= has to manage all the fields, and a later
commit will be adding fields in the non-NaCl bitstream cursor
to compensate for changes in lib/Support. Having it around will
be more pain to keep in sync:
http://llvm.org/klaus/llvm/commit/ea3c2111f43cd8f67dd44e03cd58d019efa5f634/

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4026
TEST= it compiles
R=kschimpf@google.com

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

11 days agoPNaCl large integer expansion: don't split volatile/atomic load/store
JF Bastien [Fri, 16 Jan 2015 05:40:21 +0000 (21:40 -0800)]
PNaCl large integer expansion: don't split volatile/atomic load/store

It's technically OK to split volatile load/store, but it may be unexpected. It's definitely not OK to split atomic load/store, we'd need to punt to a runtime function instead.

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

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

12 days agoAllow the fabs f32, f64, and v4f32 intrinsics under PNaCl bitcode.
Jan Voung [Thu, 15 Jan 2015 16:30:56 +0000 (08:30 -0800)]
Allow the fabs f32, f64, and v4f32 intrinsics under PNaCl bitcode.

The backend lowerings for these intrinsics seem
straight forward:

x86: andps/andpd 128-bit-vector-MASK
arm: vabs variants
mips: abs.s/abs.d, and possibly a simd variant

I checked that for -nan, the output is nan and -inf the
output is inf:
https://codereview.chromium.org/855483002/

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

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

2 weeks agoWork around MSVC bug 1085387.
JF Bastien [Mon, 12 Jan 2015 19:29:38 +0000 (11:29 -0800)]
Work around MSVC bug 1085387.

Work around the following bug:
  https://connect.microsoft.com/VisualStudio/feedback/details/1085387

Patched in Emscripten by juj:
  https://github.com/kripken/emscripten-fastcomp/pull/61

Discussed fixing differently with clb on Emscripten's IRC channel. My previous patch didn't quite do the right thing: I also needed to remove the ::.

R=dschuff@chromium.org
TEST= build with MSVC
BUG= doesn't build with MSVC

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

2 weeks agoWrok around MSVC bug 1085387.
JF Bastien [Mon, 12 Jan 2015 19:17:17 +0000 (11:17 -0800)]
Wrok around MSVC bug 1085387.

Work around the following bug:
  https://connect.microsoft.com/VisualStudio/feedback/details/1085387

Patched in Emscripten by juj:
  https://github.com/kripken/emscripten-fastcomp/pull/61

Discussed fixing differently with clb on Emscripten's IRC channel.

R=dschuff@chromium.org
TEST= build with MSVC
BUG= doesn't build with MSVC

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

2 weeks agoFix some build warnings.
JF Bastien [Mon, 12 Jan 2015 18:32:16 +0000 (10:32 -0800)]
Fix some build warnings.

There were warnings for:
  - Using a default label when the switch already handles all enum values cases (LLVM will instead warn when one enum value isn't handled by a switch);
  - Missing virtual dtor when the class has virtual methods;
  - Missing virtual dtor in the base class;
  - A virtual method hiding a parent's overloaded virtual function;
  - Comparing integers of different types (passing constants to gtest).
I also moved some of the virtual to override when that made sense.

I think most of these appeared when we moved to LLVM 3.5 but went unnoticed.

There are still two warnings left in X86ISelLowering.cpp (RegInfo is an unused variable in two places) which I've left as-is because it may hinder jvoung's upcoming merge.

R=kschimpf@google.com, kschimpf@chromium.org
TEST= ninja check
BUG= build warnings

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

2 weeks agoPNaCl: Strip GlobalValue section attributes in -nacl-strip-attributes.
JF Bastien [Sat, 10 Jan 2015 19:21:23 +0000 (11:21 -0800)]
PNaCl: Strip GlobalValue section attributes in -nacl-strip-attributes.

BUG=
R=jfb@chromium.org, jvoung@chromium.org

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

2 weeks agoAdd support for acquire, release, and acq_rel memory ordering in PNaCl
JF Bastien [Thu, 8 Jan 2015 20:20:46 +0000 (12:20 -0800)]
Add support for acquire, release, and acq_rel memory ordering in PNaCl

PNaCl currently upgrades all atomic operations to seq_cst.

As discussed in:
  https://groups.google.com/forum/#!topic/native-client-dev/wh1jEr9nsfk
PNaCl should support more than just seq_cst memory ordering to offer full access to the hardware's capabilities. For now we're still holding off on comsume ordering (which no compiler implements) and relaxed ordering (which is highly desirable performance-wise but has unsolved theoretical issues with out-of-thin-air values).

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

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

2 weeks agoSpeed up reading of NaCl bitcode records.
Karl Schimpf [Thu, 8 Jan 2015 17:57:23 +0000 (09:57 -0800)]
Speed up reading of NaCl bitcode records.

Speeds up reading PNaCl bitcode records using abbreviations. Removes
need to pop off record code from read record (which is proportional to
the size of the number of elements in the record). Results in a 3%
speed up in parsing PNaCl records in subzero.

BUG=None
R=jvoung@chromium.org

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

3 weeks agoExpand some integer operations greater than 64 bits
JF Bastien [Mon, 5 Jan 2015 21:09:16 +0000 (13:09 -0800)]
Expand some integer operations greater than 64 bits

For packed bitfields with more than 64 bits, clang generates some operations (loads, stores, shifts, zext/trunc) on integer types larger than i64, which are illegal in the PNaCl ABI. This pass expands them into operations on multiple smaller values.

This is a rebase of dschuff's:
  https://codereview.chromium.org/108593002/

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3714
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3905
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4024
R=stichnot@chromium.org, dschuff@chromium.org, jvoung@chromium.org, mseaborn@chromium.org
TEST= ninja check

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

3 weeks agoRemove unused parameter warnings from NaClBitcodeParser.h
Karl Schimpf [Mon, 5 Jan 2015 19:12:44 +0000 (11:12 -0800)]
Remove unused parameter warnings from NaClBitcodeParser.h

BUG=None
R=stichnot@chromium.org

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

4 weeks agoAdd missing deps to bugpoint, pnacl-benchmark, && a unittest.
JF Bastien [Mon, 29 Dec 2014 16:42:05 +0000 (08:42 -0800)]
Add missing deps to bugpoint, pnacl-benchmark, && a unittest.

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

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

4 weeks agoPNaCl: Handle nested structure types in -expand-struct-regs.
JF Bastien [Sat, 27 Dec 2014 19:43:49 +0000 (11:43 -0800)]
PNaCl: Handle nested structure types in -expand-struct-regs.

This pass now runs in one or more passes, triggered if splitting any instruction
inserts another struct instruction. ExpandExtractValues now handles n-arty trees.
Also, preserve load/store alignments, if specified.

-expand-struct-regs now exhibits O(mn) complexity, where m is the height of the
type tree (not a graph; broken by pointer) and n is the instruction count.

This pass could actually be split in two: first part handling load/store/phi,
the second handling expandvalue/insertvalue.

This is for Rust, which generates quite a bit of nesting.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3815
R=jfb@chromium.org, mseaborn@chromium.org
TEST= (cd toolchain_build/out/llvm_i686_linux_work && make check)

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

4 weeks agoPNaCl: Split alloca simplification into its own pass.
JF Bastien [Sat, 27 Dec 2014 19:22:47 +0000 (11:22 -0800)]
PNaCl: Split alloca simplification into its own pass.

Previously, this transformation was done in -replace-pts-with-ints. Additionally, trunc or zext to int-pointer all non-int-pointer sized dynamic allocas for completeness.

I did this in Rust's LLVM to make it easier to read while diff-ing.

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

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

5 weeks agoDon't allow instructions/globals to use alignment > 2**29.
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

6 weeks 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

6 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

7 weeks 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

7 weeks 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

7 weeks 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

7 weeks 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

7 weeks 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

7 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

7 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

7 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

7 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

8 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

8 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

2 months 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

3 months 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

3 months 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

3 months 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

3 months 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.

3 months 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.

3 months 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.

3 months 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.

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

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

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

3 months 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.

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

3 months 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.

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

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

3 months 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

3 months 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.

3 months 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.

3 months 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.

3 months 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

3 months 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.

3 months 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

3 months 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).

3 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.

3 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.