native_client/pnacl-llvm.git
15 hours agoEmit (and support) .dwarf_addr_size directive master
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

15 hours 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 days 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 days 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

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

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

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

12 days 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

13 days 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

13 days 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

13 days 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 weeks agoChange ARM/varargs-spill-stack-align-nacl.ll test to have armv7 as base.
Jan Voung [Wed, 12 Nov 2014 23:57:42 +0000 (15:57 -0800)]
Change ARM/varargs-spill-stack-align-nacl.ll test to have armv7 as base.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

=( =( =(

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

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

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

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

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

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

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

Some small adjustments to the merge conflict fixes.

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

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

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

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

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

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

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

Test Plan: Adjusted test/Object tests.

Subscribers: llvm-commits

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

BUG=none
R=dschuff@chromium.org

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

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

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

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

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

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

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

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

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

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

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

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

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

There were 2 problems with inline assembly memory operands:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Test Plan: regression test attached

    Reviewers: jvoung, eliben

    Subscribers: jfb, llvm-commits

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reviewers: jvoung, eliben

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

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

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

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

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

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

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

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

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

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

Cherry-pick r218744 from upstream.

Original commit message:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

It fixes the issue #3943.

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

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

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

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

2 months agoExpandArithWithOverflow also needed Use->User change, and it further had to be modifi...
JF Bastien [Wed, 17 Sep 2014 17:54:54 +0000 (10:54 -0700)]
ExpandArithWithOverflow also needed Use->User change, and it further had to be modified to first create a worklist before modifying the Users (iterator invalidation bit it otherwise).

2 months agoCanonicalizeMemIntrinsics also needed Use->User change, and it further had to be...
JF Bastien [Wed, 17 Sep 2014 17:50:07 +0000 (10:50 -0700)]
CanonicalizeMemIntrinsics also needed Use->User change, and it further had to be modified to first create a worklist before modifying the Users (iterator invalidation bit it otherwise).

2 months agoUse Not64BitMode instead of In32BitMode, it's the new canonical flag.
JF Bastien [Wed, 17 Sep 2014 00:01:38 +0000 (17:01 -0700)]
Use Not64BitMode instead of In32BitMode, it's the new canonical flag.

2 months agoAdd another debuginfo.
JF Bastien [Tue, 16 Sep 2014 18:39:58 +0000 (11:39 -0700)]
Add another debuginfo.

2 months agopnacl-llc needs to automatically output to stdout when no explicit -o is given. Follo...
JF Bastien [Tue, 16 Sep 2014 18:39:46 +0000 (11:39 -0700)]
pnacl-llc needs to automatically output to stdout when no explicit -o is given. Follow the code from llc.

2 months agolinkage types slightly changed: linker_private and linker_private_weak are now deprec...
JF Bastien [Tue, 16 Sep 2014 18:14:59 +0000 (11:14 -0700)]
linkage types slightly changed: linker_private and linker_private_weak are now deprecated and treated as private. dllimport and dllexport now generate slightly different warnings.

2 months agoAdd another debuginfo.
JF Bastien [Tue, 16 Sep 2014 17:44:05 +0000 (10:44 -0700)]
Add another debuginfo.

2 months agoLLVM debug metadata now depends on llvm.module.flags setting 'Debug Info Version...
JF Bastien [Tue, 16 Sep 2014 17:41:28 +0000 (10:41 -0700)]
LLVM debug metadata now depends on llvm.module.flags setting 'Debug Info Version'. Without it the debug metadata is dropped, which means that we have to whitelist llvm.module.flags when -pnaclabi-allow-debug-metadata is specified. Note that this could be used to detect when pnacl-clang and the PNaCl translator have diverged.

2 months agoAllow errors in PNaCl bitcode readers to be directed to any raw_ostream.
Karl Schimpf [Tue, 16 Sep 2014 17:22:00 +0000 (10:22 -0700)]
Allow errors in PNaCl bitcode readers to be directed to any raw_ostream.

BUG=None
R=jvoung@chromium.org

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

2 months agor208263 disallows non-default visibility on local linkage, remove 'hidden' from ...
JF Bastien [Tue, 16 Sep 2014 17:03:13 +0000 (10:03 -0700)]
r208263 disallows non-default visibility on local linkage, remove 'hidden' from 'internal hidden' and 'internal protected'.

2 months agocmpxchg has been changed upstream to take two atomic orderigns, change our bitcode...
JF Bastien [Tue, 16 Sep 2014 16:34:42 +0000 (09:34 -0700)]
cmpxchg has been changed upstream to take two atomic orderigns, change our bitcode files accordingly (the PNaCl instruction can remain the same, it already had two orderings).

2 months agoFix the triple for impplicit-datalayout.ll: it now abbreviates p:32:32:32 to p:32...
JF Bastien [Tue, 16 Sep 2014 16:14:08 +0000 (09:14 -0700)]
Fix the triple for impplicit-datalayout.ll: it now abbreviates p:32:32:32 to p:32:32 (the third one is, ironically, implicit).

2 months agoFix a bad merge of ARMISelLowering.cpp.
JF Bastien [Tue, 16 Sep 2014 16:11:02 +0000 (09:11 -0700)]
Fix a bad merge of ARMISelLowering.cpp.

2 months agoFix Use->User in ResolvePNaClIntrinsics.cpp
JF Bastien [Tue, 16 Sep 2014 15:45:18 +0000 (08:45 -0700)]
Fix Use->User in ResolvePNaClIntrinsics.cpp

2 months agoFix a think-o in the previous Use/User fixes. It caused an infinite loop.
JF Bastien [Tue, 16 Sep 2014 00:17:02 +0000 (17:17 -0700)]
Fix a think-o in the previous Use/User fixes. It caused an infinite loop.

2 months agoEnsure that x86 prefixes are bundled-locked to instruction (in asm mode).
Jan Voung [Mon, 15 Sep 2014 18:15:10 +0000 (11:15 -0700)]
Ensure that x86 prefixes are bundled-locked to instruction (in asm mode).

Otherwise, if the instruction straddles a boundary, it can
be padded and separated.

We aren't hitting this in practice (w/ pexes), because LLVM
would end up using special LXADD32, or LCMPXCHG32 opcodes
instead of separate opcodes: LOCK_PREFIX ; XADD.

However, we do run into this when parsing .s files. The
asm parser does not manage to convert "lock foo" into
the LFOO opcode.

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

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

2 months agoFix think-o in previous patch.
JF Bastien [Fri, 12 Sep 2014 18:28:35 +0000 (11:28 -0700)]
Fix think-o in previous patch.

2 months agoFix the previous PhiSafeReplace change: the Use/User fix wasn't correct.
JF Bastien [Fri, 12 Sep 2014 17:53:42 +0000 (10:53 -0700)]
Fix the previous PhiSafeReplace change: the Use/User fix wasn't correct.

2 months agoMerging r217490:
Dan Liew [Thu, 11 Sep 2014 23:00:09 +0000 (23:00 +0000)]
Merging r217490:
------------------------------------------------------------------------
r217490 | delcypher | 2014-09-10 12:09:23 +0100 (Wed, 10 Sep 2014) | 4 lines

Don't attempt to run llvm-config in cmake/modules/Makefile when doing
``make clean`` because it won't be available.

This is an attempt to unbreak buildbots broken by r217484.
------------------------------------------------------------------------

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

2 months agoMerging r217484:
Dan Liew [Thu, 11 Sep 2014 22:56:28 +0000 (22:56 +0000)]
Merging r217484:
------------------------------------------------------------------------
r217484 | delcypher | 2014-09-10 11:18:59 +0100 (Wed, 10 Sep 2014) | 13 lines

Attempt to fix PR20884

This fixes the generation of broken LLVMExports.cmake file by
the Autoconf/Makefile build system when --enable-shared is passed to
configure.

When --enable_shared is passed the Makefile.rules does not set the
LLVMConfigLibs variable which cmake/modules/Makefile previously relied
on. Now it runs the llvm-config command itself to get the library names.

This still isn't perfect because the generated LLVM targets refer to the
static libraries and not the shared library but that is much larger
problem to fix.
------------------------------------------------------------------------

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

2 months agoSimplify a localmod's whitespace compared to the original.
JF Bastien [Wed, 10 Sep 2014 18:38:22 +0000 (11:38 -0700)]
Simplify a localmod's whitespace compared to the original.

2 months agoSimplify a localmod's whitespace compared to the original.
JF Bastien [Wed, 10 Sep 2014 18:34:01 +0000 (11:34 -0700)]
Simplify a localmod's whitespace compared to the original.

2 months agoUse llvm_unreachable("...") instead of assert(0 && "...") in our localmods, a patch...
JF Bastien [Wed, 10 Sep 2014 18:17:31 +0000 (11:17 -0700)]
Use llvm_unreachable("...") instead of assert(0 && "...") in our localmods, a patch upstream did this change in a few places.

2 months agoFix PhiSafeInsertPt and PhiSafeReplaceUsers to take in User instead of Use. The API...
JF Bastien [Wed, 10 Sep 2014 17:41:47 +0000 (10:41 -0700)]
Fix PhiSafeInsertPt and PhiSafeReplaceUsers to take in User instead of Use. The API change meant that the code still compiled but did entirely the wrong thing, and crashed at runtime.

2 months agoAdded flag to the PNaCl ABI verifier which whitelists MinSFI syscalls
David Brazdil [Wed, 10 Sep 2014 15:00:48 +0000 (08:00 -0700)]
Added flag to the PNaCl ABI verifier which whitelists MinSFI syscalls

MinSFI emulates syscalls by allowing the semi-trusted PNaCl bitcode to
contain external declarations of functions with '__minsfi_syscall_' prefix.
These are implemented inside the MinSFI runtime and become the only ways
of jumping to the trusted domain once the trusted and untrusted binaries
are linked together. This patch adds a '-pnaclabi-allow-minsfi-syscalls'
option flag into the PNaCl ABI module verifier which allows these functions
inside the verified module.

BUG= https://code.google.com/p/chromium/issues/detail?id=397177
TEST= (cd ./toolchain_build/out/llvm_i686_linux_work/ && ninja check)
R=jvoung@chromium.org

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

2 months agoAdd -malign-double llc flag to use NaCl datalayout on linux
Derek Schuff [Tue, 9 Sep 2014 23:09:11 +0000 (16:09 -0700)]
Add -malign-double llc flag to use NaCl datalayout on linux

The -malign-double flag causes i64 and f64 types to have alignment
8 (the default on NaCl and when using the -malign-double clang
flag) instead of 4 (the default on Linux).

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

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