native_client/pnacl-llvm.git
3 weeks agoEmit acquire/release/acq_rel memory order by default master
JF Bastien [Mon, 2 Mar 2015 22:50:47 +0000 (14:50 -0800)]
Emit acquire/release/acq_rel memory order by default

The -pnacl-memory-order-seq-cst-only defaulted to false temporarily so that
using the Chrome canary SDK didn't make the Chrome beta translator sad. Now that
Chrome 43 has branched we can start emitting the new memory ordering FOR SPEED.

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

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

3 weeks agoAllow LLVM TOOLS_ONLY builds w/ subzero, localize noirt/srpc
Jan Voung [Mon, 2 Mar 2015 22:23:42 +0000 (14:23 -0800)]
Allow LLVM TOOLS_ONLY builds w/ subzero, localize noirt/srpc

We use TOOLS_ONLY in the sandboxed build, so make it aware
of subzero.

Localize the noirt, and libsrpc, etc. Makefile changes to
pnacl-llc only.

Goes w/ build script change https://codereview.chromium.org/945473003/

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

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

4 weeks agoMerge latest changes from branch 'master' into branch merge_36. merge_36
Jan Voung [Fri, 27 Feb 2015 01:19:47 +0000 (17:19 -0800)]
Merge latest changes from branch 'master' into branch merge_36.

4 weeks agoCherrypick upstream 230560
JF Bastien [Thu, 26 Feb 2015 23:41:04 +0000 (15:41 -0800)]
Cherrypick upstream 230560

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

Author: JF Bastien <jfb@google.com>
Date:   Wed Feb 25 22:30:51 2015 +0000

InstCombine: extract instead of shuffle when performing vector/array type punning

Summary: SROA generates code that isn't quite as easy to optimize and contains unusual-sized shuffles, but that code is generally correct. As dis
cussed in D7487 the right place to clean things up is InstCombine, which will pick up the type-punning pattern and transform it into a more obvious b
itcast+extractelement, while leaving the other patterns SROA encounters as-is.

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

4 weeks agoClean up ownership comments in NaClReaderWriter and unique_ptr in
Jan Voung [Tue, 24 Feb 2015 18:32:00 +0000 (10:32 -0800)]
Clean up ownership comments in NaClReaderWriter and unique_ptr in
pnacl-llc.

Also use range-based for loops for functions in a module in pnacl-llc.

Undo localmod for getEnvironment.

4 weeks agoFix size_t vs word_t comment in NaClBitstreamReader.
Jan Voung [Mon, 23 Feb 2015 21:22:15 +0000 (13:22 -0800)]
Fix size_t vs word_t comment in NaClBitstreamReader.

4 weeks agoSimplify one of the ThreadedStreamingCache checks that should be redundant.
Jan Voung [Sat, 21 Feb 2015 00:54:14 +0000 (16:54 -0800)]
Simplify one of the ThreadedStreamingCache checks that should be redundant.

4 weeks agoFix ThreadedStreamingCache for EOF based on readBytes. Update NaClBitstreamReader.
Jan Voung [Fri, 20 Feb 2015 23:18:13 +0000 (15:18 -0800)]
Fix ThreadedStreamingCache for EOF based on readBytes. Update NaClBitstreamReader.

4 weeks agoFix rebase and fix getNaClLazy... ownership changed.
Jan Voung [Fri, 20 Feb 2015 02:32:09 +0000 (18:32 -0800)]
Fix rebase and fix getNaClLazy... ownership changed.

5 weeks agoMerge latest changes from branch 'master' into merge_36 branch.
Jan Voung [Fri, 20 Feb 2015 00:16:40 +0000 (16:16 -0800)]
Merge latest changes from branch 'master' into merge_36 branch.

5 weeks agoDon't include inttypes.h
JF Bastien [Thu, 19 Feb 2015 23:44:17 +0000 (15:44 -0800)]
Don't include inttypes.h

MSVC doesn't support it, LLVM instead uses DataTypes.h which configure sets up properly.

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

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

5 weeks agoSwitch NACL_SANDBOX to PNACL_BROWSER_TRANSLATOR, use it consistently.
Brad Nelson [Thu, 19 Feb 2015 19:02:43 +0000 (11:02 -0800)]
Switch NACL_SANDBOX to PNACL_BROWSER_TRANSLATOR, use it consistently.

Replace the build variable NO_SANDBOX with a more clear name:
PNACL_BROWSER_TRANSLATOR. Add a define to allow it to be used
in place of defined(__native_client__) or defined(__pnacl__) when appropriate
inside C++ source.

This allows the subtle distinction between things that are enabled/disabled
because of NaCl's general limitations vs things that are the result of running
inside the PNaCl translator.

This is an incremental step towards building the pnacl tools with
the pnacl tools.

BUG=https://code.google.com/p/naclports/issues/detail?id=130
TEST=None
R=dschuff@chromium.org

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

5 weeks agoPNaCl: Remove `readnone` and `readonly` function argument attributes after promoting...
JF Bastien [Mon, 16 Feb 2015 05:06:15 +0000 (21:06 -0800)]
PNaCl: Remove `readnone` and `readonly` function argument attributes after promoting it in -replace-ptrs-with-ints.

R=jfb@chromium.org
TEST= (cd toolchain_build/out/llvm_x86_64_linux_work && make check)
BUG=

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

6 weeks agoWork around mingw enum/#define collision -- fseeko/ftello -> Fseeko/Ftello
Jan Voung [Thu, 12 Feb 2015 20:04:53 +0000 (12:04 -0800)]
Work around mingw enum/#define collision -- fseeko/ftello -> Fseeko/Ftello

When the gold plugin (which defines _FILE_OFFSET_BITS as 64)
is built on windows with mingw, the mingw stdio defines
collide with TargetLibraryInfo enum cases.

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

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

6 weeks agoCherry-pick: Gold-plugin: Broaden scope of get/release_input_file to scope of Module.
Jan Wen Voung [Wed, 11 Feb 2015 16:12:50 +0000 (16:12 +0000)]
Cherry-pick: Gold-plugin: Broaden scope of get/release_input_file to scope of Module.

Summary:
Move calls to get_input_file and release_input_file out of
getModuleForFile(). Otherwise release_input_file may end up
unmapping a view of the file while the view is still being
used by the Module (on 32-bit hosts).

Fix for PR22482.

Test Plan: Add test using --no-map-whole-files.

Reviewers: rafael, nlewycky

Subscribers: llvm-commits

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

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

6 weeks agoRemove some Mips localmods -- not needed after r215194, r215211, r221450
Jan Voung [Tue, 10 Feb 2015 23:44:20 +0000 (15:44 -0800)]
Remove some Mips localmods -- not needed after r215194, r215211, r221450

Remove from the merge_36 branch.
As mentioned: https://codereview.chromium.org/898823002/

Patch by Petar Jovanovic.

BUG=none
R=dschuff@chromium.org, petarj@mips.com

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

7 weeks agoFix the CMakeLists.txt dependencies for local tools after the merge.
Jan Voung [Thu, 5 Feb 2015 01:35:36 +0000 (17:35 -0800)]
Fix the CMakeLists.txt dependencies for local tools after the merge.

Support, Core, pthread etc. have to be explicitly listed.

7 weeks agoFix PNaCl bitcode files to not allow trailing pexe data.
Karl Schimpf [Tue, 3 Feb 2015 21:00:36 +0000 (13:00 -0800)]
Fix PNaCl bitcode files to not allow trailing pexe data.

Fixes loophole that pexes (using pnacl-llc) allow trailing pexe data.

Also fixes that all blocks within a bitcode file must be known (and
not skipped).

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

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

7 weeks agoFix -Winconsistent-missing-override that clang 3.6 warns about in localmods.
Jan Voung [Tue, 3 Feb 2015 03:09:36 +0000 (19:09 -0800)]
Fix -Winconsistent-missing-override that clang 3.6 warns about in localmods.

7 weeks agoFix ARM peephole optimizeCompare to avoid optimizing unsigned cmp to 0.
Jan Wen Voung [Mon, 2 Feb 2015 16:56:50 +0000 (16:56 +0000)]
Fix ARM peephole optimizeCompare to avoid optimizing unsigned cmp to 0.

Summary:
Previously it only avoided optimizing signed comparisons to 0.
Sometimes the DAGCombiner will optimize the unsigned comparisons
to 0 before it gets to the peephole pass, but sometimes it doesn't.

Fix for PR22373.

Test Plan: test/CodeGen/ARM/sub-cmp-peephole.ll

Reviewers: jfb, manmanren

Subscribers: aemerson, llvm-commits

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

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

7 weeks agoMerge latest changes from 'master' into merge_36.
Jan Voung [Mon, 2 Feb 2015 18:54:50 +0000 (10:54 -0800)]
Merge latest changes from 'master' into merge_36.

7 weeks agoExpand large integer: handle unsigned gt/ge/lt/le comparisons
JF Bastien [Sat, 31 Jan 2015 00:53:26 +0000 (16:53 -0800)]
Expand large integer: handle unsigned gt/ge/lt/le comparisons

ExpandLargeIntegers doesn't handle large comparisons other that equal/not-equal, but some code bases do generate these comparisons (fvwm and LLVM itself).

For now I'm not implementing signed gt/ge/lt/le because we haven't encountered them, and the fix would require generating negative and overflow flags, whereas unsigned only requires carry flag (easy to get from addition) and zero flag (obtained from eq/ne comparison).

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

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

7 weeks agoMerge latest changes from branch 'master' into merge_36.
Jan Voung [Fri, 30 Jan 2015 06:25:06 +0000 (22:25 -0800)]
Merge latest changes from branch 'master' into merge_36.

8 weeks agoTrade debug asserts in merge_36. Disable two debug asserts and reenable two.
Jan Voung [Thu, 29 Jan 2015 22:22:12 +0000 (14:22 -0800)]
Trade debug asserts in merge_36. Disable two debug asserts and reenable two.

Disable one which is expected to fail w/ -g + -gmlt + LTO.
Disable one which shows up when mixing -g with no -g.

Revert "Disable 2 debuginfo-related assertions" to
re-enable those two from the 3.5 merge.
This reverts commit 44a384ca1bceff5803d694e9f95a49e81c8c77da.

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

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

8 weeks agoExpand large integer: small refactoring of operations
JF Bastien [Wed, 28 Jan 2015 21:50:41 +0000 (13:50 -0800)]
Expand large integer: small refactoring of operations

ExpandLargeIntegers doesn't handle large comparisons other that equal/not-equal, but some code bases do generate these comparisons (fvwm and LLVM itself). In preparation to fix this issue, I've refactored some of the code so it's easier to implement comparisons using add. I've also annotated the comparisons with the status bits I'll rely on to implement.

This CL should contain no functional change, only code movement and additional comments.

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

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

8 weeks agoFix Windows build warning
JF Bastien [Tue, 27 Jan 2015 22:55:14 +0000 (14:55 -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, and is overall sad that variables are unused even if they are used in an assert.

R=dschuff@chromium.org
TBR=dschuff@chromium.org
BUG=none

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

8 weeks agoFix Windows build warning
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

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

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

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

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

2 months agoMerge branch 'master' into merge_36.
Jan Voung [Thu, 22 Jan 2015 01:53:22 +0000 (17:53 -0800)]
Merge branch 'master' into merge_36.

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

2 months agoMerge upstream LLVM 223109.
Jan Voung [Thu, 22 Jan 2015 00:16:39 +0000 (16:16 -0800)]
Merge upstream LLVM 223109.

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

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

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

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

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

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

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

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

2 months 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 months agoMerge latest from branch 'origin/master' into merge_36.
Jan Voung [Wed, 14 Jan 2015 02:41:00 +0000 (18:41 -0800)]
Merge latest from branch 'origin/master' into merge_36.

2 months agoUpdating branches/google/stable to r223109
Nick Lewycky [Wed, 14 Jan 2015 00:31:46 +0000 (00:31 +0000)]
Updating branches/google/stable to r223109

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/google/stable@225888 91177308-0d34-0410-b5e6-96231b3b80d8

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

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

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

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

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

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

3 months agoMerge branch 'master' into merge_more_testing2
Jan Voung [Thu, 18 Dec 2014 20:44:27 +0000 (12:44 -0800)]
Merge branch 'master' into merge_more_testing2

3 months agoMerge latest changes from branch 'master' into merge_36.
Jan Voung [Thu, 18 Dec 2014 20:42:45 +0000 (12:42 -0800)]
Merge latest changes from branch 'master' into merge_36.

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

3 months agoMerge-upstream: Fix stack frame adjustments to special case NaCl when not LP64.
Jan Voung [Thu, 18 Dec 2014 16:42:40 +0000 (08:42 -0800)]
Merge-upstream: Fix stack frame adjustments to special case NaCl when not LP64.

NaCl64 was always considered ILP32, but it was not considered "not LP64".

After the merge, NaCl64 is considered "not LP64", but some
parts that check for "not LP64" need to be special cased.
For example, there are some upstream special cases for the
StackPtr and FramePtr (the StackPtr field is set to RSP for
NaCl, but ESP for other "not LP64" 64-bit targets like
x32). Change another instance use of RSP/ESP to match the
special cases of "not LP64" || isNaCl64. This is done to
fix an assert later on (in the NaCl rewrite pass).

Add a test that touches naclssp, and naclspadj, which would
have triggered the asserts.

TODO upstream this too, but the test cannot be upstreamed
yet until the stack/frame ptr sandboxing is upstreamed.

BUG=none
R=jfb@chromium.org

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

3 months agoMerge upstream LLVM.
Jan Voung [Tue, 16 Dec 2014 20:44:02 +0000 (12:44 -0800)]
Merge upstream LLVM.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3 months agoUpdating branches/google/stable to r220284
Nick Lewycky [Wed, 3 Dec 2014 22:45:45 +0000 (22:45 +0000)]
Updating branches/google/stable to r220284

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/google/stable@223304 91177308-0d34-0410-b5e6-96231b3b80d8

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

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

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

3 months ago[signext.ll] Removal Of Duplicate Test Cases
Sonam Kumari [Tue, 2 Dec 2014 05:29:47 +0000 (05:29 +0000)]
[signext.ll] Removal Of Duplicate Test Cases

Removed the duplicate test case existing in signext.ll file.

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

3 months agoFix variable used only in assertion.
Nick Lewycky [Tue, 2 Dec 2014 01:09:56 +0000 (01:09 +0000)]
Fix variable used only in assertion.

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

3 months agoFix several bugs in r221220's new program finding code.
Chandler Carruth [Tue, 2 Dec 2014 00:52:01 +0000 (00:52 +0000)]
Fix several bugs in r221220's new program finding code.

In both the Unix and Windows variants, std::getenv was called and the
result passed directly to a function accepting a StringRef. This isn't
OK because it might return a null pointer and that causes the StringRef
constructor to assert (and generally produces crash-prone code if
asserts are disabled). Fix this by independently testing the result as
non-null prior to splitting things.

This in turn uncovered another bug in the Unix variant where it would
infinitely recurse if PATH="", or after this fix if PATH isn't set.
There is no need to recurse at all. Slightly re-arrange the code to make
it clear that we can just fixup the Paths argument based on the
environment if we find anything.

I don't know of a particularly useful way to test these routines in
LLVM. I'll commit a test to Clang that ensures that its driver correctly
handles various settings of PATH. However, I have no idea how to
correctly write a Windows test for the PATHEXT change. Any Windows
developers who could provide such a test, please have at. =D

Many thanks to Nick Lewycky and others for helping debug this. =/ It was
quite nasty for us to track down.

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

3 months agoSimplify pointer comparisons involving memory allocation functions
Hal Finkel [Mon, 1 Dec 2014 23:38:06 +0000 (23:38 +0000)]
Simplify pointer comparisons involving memory allocation functions

System memory allocation functions, which are identified at the IR level by the
noalias attribute on the return value, must return a pointer into a memory region
disjoint from any other memory accessible to the caller. We can use this
property to simplify pointer comparisons between allocated memory and local
stack addresses and the addresses of global variables. Neither the stack nor
global variables can overlap with the region used by the memory allocator.

Fixes PR21556.

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

3 months agoTry to fix a bot failure due to a variable used only in an assert.
Philip Reames [Mon, 1 Dec 2014 23:27:45 +0000 (23:27 +0000)]
Try to fix a bot failure due to a variable used only in an assert.

Specifically, bot lld-x86_64-darwin13.  Resulting from change 223085.

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

3 months ago[Statepoints 2/4] Statepoint infrastructure for garbage collection: MI & x86-64 Backend
Philip Reames [Mon, 1 Dec 2014 22:52:56 +0000 (22:52 +0000)]
[Statepoints 2/4] Statepoint infrastructure for garbage collection: MI & x86-64 Backend

This is the second patch in a small series.  This patch contains the MachineInstruction and x86-64 backend pieces required to lower Statepoints.  It does not include the code to actually generate the STATEPOINT machine instruction and as a result, the entire patch is currently dead code.  I will be submitting the SelectionDAG parts within the next 24-48 hours.  Since those pieces are by far the most complicated, I wanted to minimize the size of that patch.  That patch will include the tests which exercise the functionality in this patch.  The entire series can be seen as one combined whole in http://reviews.llvm.org/D5683.

The STATEPOINT psuedo node is generated after all gc values are explicitly spilled to stack slots.  The purpose of this node is to wrap an actual call instruction while recording the spill locations of the meta arguments used for garbage collection and other purposes.  The STATEPOINT is modeled as modifing all of those locations to prevent backend optimizations from forwarding the value from before the STATEPOINT to after the STATEPOINT.  (Doing so would break relocation semantics for collectors which wish to relocate roots.)

The implementation of STATEPOINT is closely modeled on PATCHPOINT.  Eventually, much of the code in this patch will be removed.  The long term plan is to merge the functionality provided by statepoints and patchpoints.  Merging their implementations in the backend is likely to be a good starting point.

Reviewed by: atrick, ributzka

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

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

3 months 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 months ago[Statepoints 1/4] Statepoint infrastructure for garbage collection: IR Intrinsics
Philip Reames [Mon, 1 Dec 2014 21:18:12 +0000 (21:18 +0000)]
[Statepoints 1/4] Statepoint infrastructure for garbage collection: IR Intrinsics

The statepoint intrinsics are intended to enable precise root tracking through the compiler as to support garbage collectors of all types. The addition of the statepoint intrinsics to LLVM should have no impact on the compilation of any program which does not contain them. There are no side tables created, no extra metadata, and no inhibited optimizations.

A statepoint works by transforming a call site (or safepoint poll site) into an explicit relocation operation. It is the frontend's responsibility (or eventually the safepoint insertion pass we've developed, but that's not part of this patch series) to ensure that any live pointer to a GC object is correctly added to the statepoint and explicitly relocated. The relocated value is just a normal SSA value (as seen by the optimizer), so merges of relocated and unrelocated values are just normal phis. The explicit relocation operation, the fact the statepoint is assumed to clobber all memory, and the optimizers standard semantics ensure that the relocations flow through IR optimizations correctly.

This is the first patch in a small series.  This patch contains only the IR parts; the documentation and backend support will be following separately.  The entire series can be seen as one combined whole in http://reviews.llvm.org/D5683.

Reviewed by: atrick, ributzka

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

3 months ago[NVPTX] Do not emit .weak symbols for NVPTX
Jingyue Wu [Mon, 1 Dec 2014 21:16:17 +0000 (21:16 +0000)]
[NVPTX] Do not emit .weak symbols for NVPTX

Summary:
".weak" symbols cannot be consumed by ptxas (PR21685). This patch makes the
weak directive in MCAsmPrinter customizable, and disables emitting ".weak"
symbols for NVPTX.

Test Plan: weak-linkage.ll

Reviewers: jholewinski

Reviewed By: jholewinski

Subscribers: majnemer, jholewinski, llvm-commits

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

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

3 months agoParse 'ghccc' in .ll files as the GHC convention (cc 10)
Reid Kleckner [Mon, 1 Dec 2014 21:04:44 +0000 (21:04 +0000)]
Parse 'ghccc' in .ll files as the GHC convention (cc 10)

Previously we just used "cc 10" in the .ll files, but that isn't very
human readable.

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

3 months ago[AArch64] Don't combine "select (setcc i1 LHS, RHS), vL, vR".
Ahmed Bougacha [Mon, 1 Dec 2014 20:59:00 +0000 (20:59 +0000)]
[AArch64] Don't combine "select (setcc i1 LHS, RHS), vL, vR".

r208210 introduced an optimization that improves the vector select
codegen by doing the setcc on vectors directly.
This is a problem they the setcc operands are i1s, because the
optimization would create vectors of i1, which aren't legal.

Part of PR21549.

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

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

3 months ago[AArch64] Fix v2i8->i16 bitcast legalization.
Ahmed Bougacha [Mon, 1 Dec 2014 20:52:32 +0000 (20:52 +0000)]
[AArch64] Fix v2i8->i16 bitcast legalization.

r213378 improved f16 bitcasts, so that they go directly through subregs,
instead of through the stack.  That code now causes an assertion failure
for bitcasts from other 16-bits types (most importantly v2i8).

Correct that by doing the custom lowering for i16 bitcasts only when the
input is an f16.

Part of PR21549.

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

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

3 months ago[OCaml] Move Llvm.clone_module to its own Llvm_transform_utils module.
Peter Zotov [Mon, 1 Dec 2014 19:50:39 +0000 (19:50 +0000)]
[OCaml] Move Llvm.clone_module to its own Llvm_transform_utils module.

This way most code won't link this (substantially large) library,
if compiled statically with LLVM.

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

3 months ago[OCaml] [cmake] Add CMake buildsystem for OCaml.
Peter Zotov [Mon, 1 Dec 2014 19:50:23 +0000 (19:50 +0000)]
[OCaml] [cmake] Add CMake buildsystem for OCaml.

Closes PR15325.

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