oota-llvm.git
9 years agoSuppress inlining when the block address is taken
Gerolf Hoflehner [Tue, 1 Jul 2014 00:19:34 +0000 (00:19 +0000)]
Suppress inlining when the block address is taken

Inlining functions with block addresses can cause many problem and requires a
rich infrastructure to support including escape analysis.  At this point the
safest approach to address these problems is by blocking inlining from
happening.

Background:
There have been reports on Ruby segmentation faults triggered by inlining
functions with block addresses like

//Ruby code snippet
vm_exec_core() {
    finish_insn_seq_0 = &&INSN_LABEL_finish;
    INSN_LABEL_finish:
      ;
}

This kind of scenario can also happen when LLVM picks a subset of blocks for
inlining, which is the case with the actual code in the Ruby environment.

LLVM suppresses inlining for such functions when there is an indirect branch.
The attached patch does so even when there is no indirect branch.  Note that
user code like above would not make much sense: using the global for jumping
across function boundaries would be illegal.

Why was there a segfault:

In the snipped above the block with the label is recognized as dead So it is
eliminated. Instead of a block address the cloner stores a constant (sic!) into
the global resulting in the segfault (when the global is used in a goto).

Why had it worked in the past then:

By luck. In older versions vm_exec_core was also inlined but the label address
used was the block label address in vm_exec_core.  So the global jump ended up
in the original function rather than in the caller which accidentally happened
to work.

Test case ./tools/clang/test/CodeGen/indirect-goto.c will fail as a result
of this commit.

rdar://17245966

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

9 years agoAArch64: Follow-up to r212073
Duncan P. N. Exon Smith [Tue, 1 Jul 2014 00:05:37 +0000 (00:05 +0000)]
AArch64: Follow-up to r212073

In r212073 I missed a call of `use_begin()` that assumed the wrong
semantics.  It's not clear to me at all what this code does without the
fix, so I'm not sure how to write a testcase.

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

9 years agoAArch64: Actually do address type promotion
Duncan P. N. Exon Smith [Mon, 30 Jun 2014 23:42:14 +0000 (23:42 +0000)]
AArch64: Actually do address type promotion

AArch64AddressTypePromotion was doing nothing because it was using the
old semantics of `Use` and `uses()`, when it really wanted to get at the
`users()`.

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

9 years agoConvert some byval argpromotion grep tests to FileCheck
Reid Kleckner [Mon, 30 Jun 2014 20:44:28 +0000 (20:44 +0000)]
Convert some byval argpromotion grep tests to FileCheck

Surprisingly, the i32* byval parameter is not transformed by
argpromotion.

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

9 years agoDebugInfo: Preserve debug location information when transforming a call into an invok...
David Blaikie [Mon, 30 Jun 2014 20:30:39 +0000 (20:30 +0000)]
DebugInfo: Preserve debug location information when transforming a call into an invoke during inlining.

This both improves basic debug info quality, but also fixes a larger
hole whenever we inline a call/invoke without a location (debug info for
the entire inlining is lost and other badness that the debug info
emission code is currently working around but shouldn't have to).

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

9 years agoRemove unnecessary datalayout string from a test case.
David Blaikie [Mon, 30 Jun 2014 20:26:12 +0000 (20:26 +0000)]
Remove unnecessary datalayout string from a test case.

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

9 years agoSpeculatively fix some code handling Power64 MachO files
Reid Kleckner [Mon, 30 Jun 2014 20:12:59 +0000 (20:12 +0000)]
Speculatively fix some code handling Power64 MachO files

MSVC was warning on a switch containing only default labels.  In this
instance, it looks like it uncovered a real bug.  :)

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

9 years agomsan: Stop stripping the 'tail' modifier off of calls
Reid Kleckner [Mon, 30 Jun 2014 20:12:27 +0000 (20:12 +0000)]
msan: Stop stripping the 'tail' modifier off of calls

This probably isn't necessary since msan started to unpoison the return
value shadow memory before all calls.

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

9 years agoobjdump: Add test for ELF file with no section table
Ed Maste [Mon, 30 Jun 2014 20:03:02 +0000 (20:03 +0000)]
objdump: Add test for ELF file with no section table

This is a test for the fix in r211904.

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

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

9 years agoRefactor the code in clang to find a file in a PATH like environment variable into...
Ehsan Akhgari [Mon, 30 Jun 2014 19:54:20 +0000 (19:54 +0000)]
Refactor the code in clang to find a file in a PATH like environment variable into a helper function

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

9 years agoFix 'platform-specific' hyphenations
Alp Toker [Mon, 30 Jun 2014 18:57:16 +0000 (18:57 +0000)]
Fix 'platform-specific' hyphenations

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

9 years agoBuild fix for systems without futimes/futimens
Alp Toker [Mon, 30 Jun 2014 18:57:04 +0000 (18:57 +0000)]
Build fix for systems without futimes/futimens

Some versions of Android don't have futimes/futimens and this code wasn't
updated during the recent errc refactoring.

Patch by Luqman Aden!

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

9 years agoAdd the -arch flag support to llvm-nm to select the slice out of a Mach-O
Kevin Enderby [Mon, 30 Jun 2014 18:45:23 +0000 (18:45 +0000)]
Add the -arch flag support to llvm-nm to select the slice out of a Mach-O
universal file.  This also includes support for -arch all, selecting the host
architecture by default from a universal file and checking if -arch is used
with a standard Mach-O it matches that architecture.

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

9 years agoR600: Move mul combine to separate function
Matt Arsenault [Mon, 30 Jun 2014 17:55:48 +0000 (17:55 +0000)]
R600: Move mul combine to separate function

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

9 years agoR600: Remove unused declarations leftover from AMDIL
Matt Arsenault [Mon, 30 Jun 2014 17:37:17 +0000 (17:37 +0000)]
R600: Remove unused declarations leftover from AMDIL

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

9 years agoDebug info: split out complex DIVariable address expressions into a
Adrian Prantl [Mon, 30 Jun 2014 17:17:35 +0000 (17:17 +0000)]
Debug info: split out complex DIVariable address expressions into a
separate MDNode so they can be uniqued via folding set magic. To conserve
space, DIVariable nodes are still variable-length, with the last two
fields being optional.

No functional change.
http://reviews.llvm.org/D3526

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

9 years ago[X86] Add support for builtin to read performance monitoring counters.
Andrea Di Biagio [Mon, 30 Jun 2014 17:14:21 +0000 (17:14 +0000)]
[X86] Add support for builtin to read performance monitoring counters.

This patch adds support for a new builtin instruction called
__builtin_ia32_rdpmc.

Builtin '__builtin_ia32_rdpmc' is defined as a 'GCC builtin'; on X86, it can
be used to read performance monitoring counters. It takes as input the index
of the performance counter to read, and returns the value of the specified
performance counter as a 64-bit number.

Calls to this new builtin will map to instruction RDPMC.
The index in input to the builtin call is moved to register %ECX. The result
of the builtin call is the value of the specified performance counter (RDPMC
would return that quantity in registers RDX:RAX).

This patch:
 - Adds builtin int_x86_rdpmc as a GCCBuiltin;
 - Adds a new x86 DAG node called 'RDPMC_DAG';
 - Teaches how to lower this new builtin;
 - Adds an ISel pattern to select instruction RDPMC;
 - Fixes the definition of instruction RDPMC adding %RAX and %RDX as
   implicit definitions, and adding %ECX as implicit use;
 - Adds a LLVM test to verify that the new builtin is correctly selected.

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

9 years ago[OCaml] Documentation improvements.
Peter Zotov [Mon, 30 Jun 2014 16:53:53 +0000 (16:53 +0000)]
[OCaml] Documentation improvements.

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

9 years ago[AArch64] Unsized types don't specify an alignment.
Chad Rosier [Mon, 30 Jun 2014 15:03:00 +0000 (15:03 +0000)]
[AArch64] Unsized types don't specify an alignment.
PR20109

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

9 years ago[AArch64] Convert mul x, -(pow2 +/- 1) to shift + add/sub.
Chad Rosier [Mon, 30 Jun 2014 14:51:14 +0000 (14:51 +0000)]
[AArch64] Convert mul x, -(pow2 +/- 1) to shift + add/sub.

The combine for mul x, pow2 +/- 1 is unchanged. Test cases for
both combines as well as mul x, pow2 have been added as well.

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

9 years agomacho-dump: add code to print LC_ID_DYLIB load commands.
Tim Northover [Mon, 30 Jun 2014 14:40:57 +0000 (14:40 +0000)]
macho-dump: add code to print LC_ID_DYLIB load commands.

I want to check them in lld.

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

9 years agoARM: take care not to set the ThumbFunc bit on TLS data symbols
Scott Douglass [Mon, 30 Jun 2014 09:37:24 +0000 (09:37 +0000)]
ARM: take care not to set the ThumbFunc bit on TLS data symbols

This fixes LNT SingleSource/UnitTests/Threads with -mthumb.

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

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

9 years agoundo test commit (whitespace only)
Scott Douglass [Mon, 30 Jun 2014 08:09:35 +0000 (08:09 +0000)]
undo test commit (whitespace only)

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

9 years agotest commit (whitespace only)
Scott Douglass [Mon, 30 Jun 2014 08:07:32 +0000 (08:07 +0000)]
test commit (whitespace only)

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

9 years agotest commit: add a comment line in GVN test file
Erik Eckstein [Mon, 30 Jun 2014 07:19:02 +0000 (07:19 +0000)]
test commit: add a comment line in GVN test file

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

9 years agoX86: fix comment
Saleem Abdulrasool [Mon, 30 Jun 2014 03:11:18 +0000 (03:11 +0000)]
X86: fix comment

Fix a comment typo `DbgLocLImport` instead of `DLLImport`.

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

9 years agoARM: use symbolic name for constant
Saleem Abdulrasool [Mon, 30 Jun 2014 03:11:14 +0000 (03:11 +0000)]
ARM: use symbolic name for constant

This just changes the constant value to the symbolic name corresponding to it.
NFC.

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

9 years agoCodeGen: rename Win64 ExceptionHandling to WinEH
Saleem Abdulrasool [Sun, 29 Jun 2014 21:43:47 +0000 (21:43 +0000)]
CodeGen: rename Win64 ExceptionHandling to WinEH

This exception format is not specific to Windows x64.  A similar approach is
taken on nearly all architectures.  Generalise the name to reflect reality.
This will eventually be used for Windows on ARM data emission as well.

Switch the enum and namespace into an enum class.

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

9 years agoMC: rename EmitWin64EH routines
Saleem Abdulrasool [Sun, 29 Jun 2014 01:52:01 +0000 (01:52 +0000)]
MC: rename EmitWin64EH routines

Rename the routines to reflect the reality that they are more related to call
frame information than to Win64 EH. Although EH is implemented in an intertwined
manner by augmenting with an exception handler and an associated parameter, the
majority of these routines emit information required to unwind the frames. This
also helps identify that these routines are generic for most windows platforms
(they apply equally to nearly all architectures except x86) although the
encoding of the information is architecture dependent.

Unwinding data is emitted via EmitWinCFI* and exception handling information via
EmitWinEH*.

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

9 years agoAdd ops() method to SDNode that returns an ArrayRef<SDUse>. Use it to simplify some...
Craig Topper [Sun, 29 Jun 2014 00:40:57 +0000 (00:40 +0000)]
Add ops() method to SDNode that returns an ArrayRef<SDUse>. Use it to simplify some code.

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

9 years agoUse a range loop. No functionality change.
Rafael Espindola [Sat, 28 Jun 2014 18:44:59 +0000 (18:44 +0000)]
Use a range loop. No functionality change.

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

9 years agoSimplify code a bit, no functionality change.
Rafael Espindola [Sat, 28 Jun 2014 17:46:19 +0000 (17:46 +0000)]
Simplify code a bit, no functionality change.

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

9 years agoFix build following r211956
Alp Toker [Sat, 28 Jun 2014 06:31:47 +0000 (06:31 +0000)]
Fix build following r211956

RuntimeDyld now uses MCInst::dump_pretty() which introduces a dependency on
'MC'.

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

9 years agoVerifier: Update assert message to reflect LangRef
David Majnemer [Sat, 28 Jun 2014 06:24:49 +0000 (06:24 +0000)]
Verifier: Update assert message to reflect LangRef

No functionality change, just correcting the assertion message.

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

9 years ago[x86] Fix a bug in the v8i16 shuffling exposed by the new splat-like
Chandler Carruth [Sat, 28 Jun 2014 05:46:28 +0000 (05:46 +0000)]
[x86] Fix a bug in the v8i16 shuffling exposed by the new splat-like
lowering for v16i8.

ASan and some bots caught this bug with existing test cases. Fixing it
even fixed a miscompile with one of the test cases. I'm still a bit
suspicious of this test case as I've not taken a proper amount of time
to think about it, but the fix here is strict goodness.

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

9 years agoFix this test to not write to the source tree, and instead to write to
Chandler Carruth [Sat, 28 Jun 2014 05:18:49 +0000 (05:18 +0000)]
Fix this test to not write to the source tree, and instead to write to
a temporary file. This fixes the test in cases where the source tree is
mounted read-only.

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

9 years ago[x86] Add handling for splat-like widenings of v16i8 shuffles.
Chandler Carruth [Sat, 28 Jun 2014 05:16:40 +0000 (05:16 +0000)]
[x86] Add handling for splat-like widenings of v16i8 shuffles.

These show up really frequently, not the least with actual splats. =] We
lowered these quite badly before. The new code path tries to widen i8
shuffles to i16 shuffles in a splat-like way. There are still some
inefficiencies in our i16 splat logic though, so we aren't really done
here.

Also, for certain patterns (bit of a gather-and-splat) we still
generate pretty silly code, and I've left a fixme for addressing it.
However, I'm not actually worried about this code pattern as much. The
old shuffle lowering generates a 29 instruction monstrosity for it that
should execute much more slowly.

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

9 years agoThis file wasn't supposed to be checked in
David Majnemer [Sat, 28 Jun 2014 01:56:50 +0000 (01:56 +0000)]
This file wasn't supposed to be checked in

This was generated while trying to debug a test, it shouldn't have been
checked in.

Thanks to Alexander Kornienko for spotting this.

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

9 years ago[RuntimeDyld] Make sure that RuntimeDyld regression tests only run for targets
Lang Hames [Fri, 27 Jun 2014 23:29:18 +0000 (23:29 +0000)]
[RuntimeDyld] Make sure that RuntimeDyld regression tests only run for targets
that have been enabled.

Without this, testers will fail when llvm-rtdyld is invoked with triples for
unsupported targets.

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

9 years agoRevert "Temporary hack to try cleaning extra .s file from bots."
Matt Arsenault [Fri, 27 Jun 2014 23:11:26 +0000 (23:11 +0000)]
Revert "Temporary hack to try cleaning extra .s file from bots."

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

9 years agoTemporary hack to try cleaning extra .s file from bots.
Matt Arsenault [Fri, 27 Jun 2014 21:43:50 +0000 (21:43 +0000)]
Temporary hack to try cleaning extra .s file from bots.

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

9 years ago[RuntimeDyld] Use a raw_ostream and llvm::format for int-to-string conversions.
Lang Hames [Fri, 27 Jun 2014 21:07:00 +0000 (21:07 +0000)]
[RuntimeDyld] Use a raw_ostream and llvm::format for int-to-string conversions.

Some users' C++11 standard libraries don't support std::to_string yet.

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

9 years ago[AArch64] Fix memset ICE when memset value is f128.
Chad Rosier [Fri, 27 Jun 2014 21:05:09 +0000 (21:05 +0000)]
[AArch64] Fix memset ICE when memset value is f128.

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

9 years agollvm-cov: Support specifying multiple source files
Justin Bogner [Fri, 27 Jun 2014 20:41:25 +0000 (20:41 +0000)]
llvm-cov: Support specifying multiple source files

Make llvm-cov compatible with gcov for cases where multiple files are
specified on the command line. That is, loop over each one and report
coverage, and report errors on stderr only rather than via return
code.

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

9 years ago[RuntimeDyld] #include <cctype> header in RuntimeDyldChecker.cpp.
Lang Hames [Fri, 27 Jun 2014 20:37:39 +0000 (20:37 +0000)]
[RuntimeDyld] #include <cctype> header in RuntimeDyldChecker.cpp.

Hopefully this will unbreak the windows bots.

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

9 years ago[RuntimeDyld] Add a framework for testing relocation logic in RuntimeDyld.
Lang Hames [Fri, 27 Jun 2014 20:20:57 +0000 (20:20 +0000)]
[RuntimeDyld] Add a framework for testing relocation logic in RuntimeDyld.

This patch adds a "-verify" mode to the llvm-rtdyld utility. In verify mode,
llvm-rtdyld will test supplied expressions against the linked program images
that it creates in memory. This scheme can be used to verify the correctness
of the relocation logic applied by RuntimeDyld.

The expressions to test will be read out of files passed via the -check option
(there may be more than one of these). Expressions to check are extracted from
lines of the form:
# rtdyld-check: <expression>

This system is designed to fit the llvm-lit regression test workflow. It is
format and target agnostic, and supports verification of images linked for
remote targets. The expression language is defined in
llvm/include/llvm/RuntimeDyldChecker.h . Examples can be found in
test/ExecutionEngine/RuntimeDyld.

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

9 years ago[x86] Fix another bug hit when bootstrapping with the new shuffle
Chandler Carruth [Fri, 27 Jun 2014 20:07:40 +0000 (20:07 +0000)]
[x86] Fix another bug hit when bootstrapping with the new shuffle
lowering.

For maximum irony, I had already discovered this bug, diagnosed it, and
left FIXMEs about it in the test cases. =[ I just failed to go back over
those until after i had reduced a bootstrap miscompile down to a single
TU, stared at the assembly for an hour, and figured out the bug. Again.

Oh well.

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

9 years agoReverting r211950 -- it did not help resolve the -Wcomment warnings triggered in...
Aaron Ballman [Fri, 27 Jun 2014 19:52:34 +0000 (19:52 +0000)]
Reverting r211950 -- it did not help resolve the -Wcomment warnings triggered in GCC.

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

9 years ago[NVPTX] Use GreatestCommonDivisor64 from MathExtras instead of using our own. Thanks...
Justin Holewinski [Fri, 27 Jun 2014 19:36:25 +0000 (19:36 +0000)]
[NVPTX] Use GreatestCommonDivisor64 from MathExtras instead of using our own.  Thanks Hal!

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

9 years agoAdding some trailing whitespace after a comment previously ending with \ to ensure...
Aaron Ballman [Fri, 27 Jun 2014 19:05:17 +0000 (19:05 +0000)]
Adding some trailing whitespace after a comment previously ending with \ to ensure that it isn't lexed as a multiline comment. This silences some -Wcomment warnings.

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

9 years agoInclude <tuple> to make buildbots happy
David Majnemer [Fri, 27 Jun 2014 18:38:12 +0000 (18:38 +0000)]
Include <tuple> to make buildbots happy

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

9 years ago[NVPTX] Add reflect intrinsic (better than matching by function name)
Justin Holewinski [Fri, 27 Jun 2014 18:36:11 +0000 (18:36 +0000)]
[NVPTX] Add reflect intrinsic (better than matching by function name)

Also clean up some of the logic in NVVMReflect.cpp while we're messing around in there.

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

9 years ago[NVPTX] Handle all possible vector types in getSetCCResultType, not just the ones...
Justin Holewinski [Fri, 27 Jun 2014 18:36:08 +0000 (18:36 +0000)]
[NVPTX] Handle all possible vector types in getSetCCResultType, not just the ones representable as MVTs

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

9 years ago[NVPTX] Add 'b' asm constraint
Justin Holewinski [Fri, 27 Jun 2014 18:36:06 +0000 (18:36 +0000)]
[NVPTX] Add 'b' asm constraint

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

9 years ago[NVPTX] Simplify some argument lowering logic
Justin Holewinski [Fri, 27 Jun 2014 18:36:04 +0000 (18:36 +0000)]
[NVPTX] Simplify some argument lowering logic

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

9 years ago[NVPTX] Do not process samplers in GenericToNVVM
Justin Holewinski [Fri, 27 Jun 2014 18:36:02 +0000 (18:36 +0000)]
[NVPTX] Do not process samplers in GenericToNVVM

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

9 years ago[NVPTX] Error out if initializer is given for variable in an address space that does...
Justin Holewinski [Fri, 27 Jun 2014 18:36:01 +0000 (18:36 +0000)]
[NVPTX] Error out if initializer is given for variable in an address space that does not support initialization

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

9 years ago[NVPTX] Add support for .managed variables for UVM
Justin Holewinski [Fri, 27 Jun 2014 18:35:58 +0000 (18:35 +0000)]
[NVPTX] Add support for .managed variables for UVM

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

9 years ago[NVPTX] Emit .weak linkage for link_once, weak, available_externally, and common...
Justin Holewinski [Fri, 27 Jun 2014 18:35:56 +0000 (18:35 +0000)]
[NVPTX] Emit .weak linkage for link_once, weak, available_externally, and common linkage

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

9 years ago[NVPTX] Variables that start with llvm. or nvvm. are reserved and should not be emitted
Justin Holewinski [Fri, 27 Jun 2014 18:35:53 +0000 (18:35 +0000)]
[NVPTX] Variables that start with llvm. or nvvm. are reserved and should not be emitted

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

9 years ago[NVPTX] Fix handling of ldg/ldu intrinsics.
Justin Holewinski [Fri, 27 Jun 2014 18:35:51 +0000 (18:35 +0000)]
[NVPTX] Fix handling of ldg/ldu intrinsics.

The address space of the pointer must be global (1) for these intrinsics.  There must also be alignment metadata attached to the intrinsic calls, e.g.

%val = tail call i32 @llvm.nvvm.ldu.i.global.i32.p1i32(i32 addrspace(1)* %ptr), !align !0

!0 = metadata !{i32 4}

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

9 years ago[NVPTX] Clean up argument lowering code and properly handle alignment for structs...
Justin Holewinski [Fri, 27 Jun 2014 18:35:44 +0000 (18:35 +0000)]
[NVPTX] Clean up argument lowering code and properly handle alignment for structs and vectors

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

9 years ago[NVPTX] Add missing boolean vector contents flag
Justin Holewinski [Fri, 27 Jun 2014 18:35:42 +0000 (18:35 +0000)]
[NVPTX] Add missing boolean vector contents flag

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

9 years ago[NVPTX] Add support for [SHL,SRA,SRL]_PARTS
Justin Holewinski [Fri, 27 Jun 2014 18:35:40 +0000 (18:35 +0000)]
[NVPTX] Add support for [SHL,SRA,SRL]_PARTS

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

9 years ago[NVPTX] Implement fma and imad contraction as target DAGCombiner patterns
Justin Holewinski [Fri, 27 Jun 2014 18:35:37 +0000 (18:35 +0000)]
[NVPTX] Implement fma and imad contraction as target DAGCombiner patterns

This also introduces DAGCombiner patterns for mul.wide to multiply two smaller integers and produce a larger integer

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

9 years ago[NVPTX] Add support for efficient rotate instructions on SM 3.2+
Justin Holewinski [Fri, 27 Jun 2014 18:35:33 +0000 (18:35 +0000)]
[NVPTX] Add support for efficient rotate instructions on SM 3.2+

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

9 years ago[NVPTX] Add missing isel patterns for 64-bit atomics
Justin Holewinski [Fri, 27 Jun 2014 18:35:30 +0000 (18:35 +0000)]
[NVPTX] Add missing isel patterns for 64-bit atomics

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

9 years ago[NVPTX] Add isel patterns for bit-field extract (bfe)
Justin Holewinski [Fri, 27 Jun 2014 18:35:27 +0000 (18:35 +0000)]
[NVPTX] Add isel patterns for bit-field extract (bfe)

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

9 years ago[NVPTX] Add support for isspacep instruction
Justin Holewinski [Fri, 27 Jun 2014 18:35:24 +0000 (18:35 +0000)]
[NVPTX] Add support for isspacep instruction

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

9 years ago[NVPTX] Add support for envreg reads
Justin Holewinski [Fri, 27 Jun 2014 18:35:21 +0000 (18:35 +0000)]
[NVPTX] Add support for envreg reads

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

9 years ago[NVPTX] Add target options for PTX 3.2/4.0 and SM 5.0 (Maxwell)
Justin Holewinski [Fri, 27 Jun 2014 18:35:18 +0000 (18:35 +0000)]
[NVPTX] Add target options for PTX 3.2/4.0 and SM 5.0 (Maxwell)

Default PTX version is set to PTX 3.2

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

9 years ago[NVPTX] Update sub-target feature detection
Justin Holewinski [Fri, 27 Jun 2014 18:35:16 +0000 (18:35 +0000)]
[NVPTX] Update sub-target feature detection

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

9 years ago[NVPTX] Directly control the Machine SSA passes that are invoked for NVPTX.
Justin Holewinski [Fri, 27 Jun 2014 18:35:14 +0000 (18:35 +0000)]
[NVPTX] Directly control the Machine SSA passes that are invoked for NVPTX.

NVPTX is a bit special in the optimizations it requires, so this gives
us better control over the backend optimization pipeline.

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

9 years ago[NVPTX] Emit .weak when linkage is not external, internal, or private
Justin Holewinski [Fri, 27 Jun 2014 18:35:10 +0000 (18:35 +0000)]
[NVPTX] Emit .weak when linkage is not external, internal, or private

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

9 years ago[NVPTX] Just use getTypeAllocSize() when computing return value size for structures...
Justin Holewinski [Fri, 27 Jun 2014 18:35:08 +0000 (18:35 +0000)]
[NVPTX] Just use getTypeAllocSize() when computing return value size for structures and vectors

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

9 years agoVectorization documentation for loop hint pragmas and Rpass diagnostics.
Tyler Nowicki [Fri, 27 Jun 2014 18:30:08 +0000 (18:30 +0000)]
Vectorization documentation for loop hint pragmas and Rpass diagnostics.

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

9 years agoSilencing some -Wcast-qual warnings. No functional changes intended.
Aaron Ballman [Fri, 27 Jun 2014 18:25:49 +0000 (18:25 +0000)]
Silencing some -Wcast-qual warnings. No functional changes intended.

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

9 years ago[x86] Fix a miscompile in the new shuffle lowering uncovered by
Chandler Carruth [Fri, 27 Jun 2014 18:25:23 +0000 (18:25 +0000)]
[x86] Fix a miscompile in the new shuffle lowering uncovered by
a bootstrap.

I managed to mis-remember how PACKUS worked on x86, and was using undef
for the high bytes instead of zero. The fix is fairly obvious.

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

9 years agoIR: Add COMDATs to the IR
David Majnemer [Fri, 27 Jun 2014 18:19:56 +0000 (18:19 +0000)]
IR: Add COMDATs to the IR

This new IR facility allows us to represent the object-file semantic of
a COMDAT group.

COMDATs allow us to tie together sections and make the inclusion of one
dependent on another. This is required to implement features like MS
ABI VFTables and optimizing away certain kinds of initialization in C++.

This functionality is only representable in COFF and ELF, Mach-O has no
similar mechanism.

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

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

9 years agocmake: Don't do anything for LLVM_ENABLE_ASSERTIONS=OFF
Reid Kleckner [Fri, 27 Jun 2014 18:17:30 +0000 (18:17 +0000)]
cmake: Don't do anything for LLVM_ENABLE_ASSERTIONS=OFF

By default, CMake will set NDEBUG in Rel* builds and leave it off in
debug builds, so we shouldn't need to do anything ourselves.

Before this change, it was possible to a Debug build without assertions
(aka Debug-Asserts in the autoconf system) by configuring with
-DLLVM_ENABLE_ASSERTIONS=OFF, but this configuration isn't very useful.
You can still get the same effect by explicitly adding -DNDEBUG to
CFLAGS.

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

Patch by Janusz Sobczak!

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

9 years agolldb can interrupt waitpid, so EINTR shouldn't be an error. This fixes the case
Julien Lerouge [Fri, 27 Jun 2014 18:02:54 +0000 (18:02 +0000)]
lldb can interrupt waitpid, so EINTR shouldn't be an error. This fixes the case
where there is no timeout. In the case where there is a timeout though, the
code is still wrong since it doesn't check that the alarm really went off.

Without this patch, I cannot debug a program that forks itself using
sys::ExecuteAndWait with lldb.

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

9 years agoR600: Move trivial getters into header, use initializer list
Matt Arsenault [Fri, 27 Jun 2014 17:57:00 +0000 (17:57 +0000)]
R600: Move trivial getters into header, use initializer list

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

9 years agoFix test so it doesn't try to write out temporary files into the test tree.
David Blaikie [Fri, 27 Jun 2014 17:45:43 +0000 (17:45 +0000)]
Fix test so it doesn't try to write out temporary files into the test tree.

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

9 years agoAvoid non-ascii character in the source code.
Logan Chien [Fri, 27 Jun 2014 17:25:54 +0000 (17:25 +0000)]
Avoid non-ascii character in the source code.

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

9 years agoMC: Fix associative sections on COFF
David Majnemer [Fri, 27 Jun 2014 17:19:44 +0000 (17:19 +0000)]
MC: Fix associative sections on COFF

COFF sections in MC were represented by a tuple of section-name and
COMDAT-name.  This is not sufficient to represent a .text section
associated with another .text section; we need a way to distinguish
between the key section and the one marked associative.

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

9 years ago[FastISel][X86] Fix typos.
Juergen Ributzka [Fri, 27 Jun 2014 17:16:34 +0000 (17:16 +0000)]
[FastISel][X86] Fix typos.

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

9 years agoR600: Don't crash on unhandled instruction in promote alloca
Matt Arsenault [Fri, 27 Jun 2014 16:52:49 +0000 (16:52 +0000)]
R600: Don't crash on unhandled instruction in promote alloca

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

9 years agollvm-objdump: don't assert if ELF file has no sections
Ed Maste [Fri, 27 Jun 2014 16:37:20 +0000 (16:37 +0000)]
llvm-objdump: don't assert if ELF file has no sections

FreeBSD core files, for example, have no sections (only program headers).

llvm.org/pr20139
Differential Revision: http://reviews.llvm.org/D4323

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

9 years agoClean up unused variable warning in release build.
Alexander Kornienko [Fri, 27 Jun 2014 15:30:55 +0000 (15:30 +0000)]
Clean up unused variable warning in release build.

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

9 years agoRe-apply r211287: Remove support for LLVM runtime multi-threading.
Chandler Carruth [Fri, 27 Jun 2014 15:13:01 +0000 (15:13 +0000)]
Re-apply r211287: Remove support for LLVM runtime multi-threading.

I'll fix the problems in libclang and other projects in ways that don't
require <mutex> until we sort out the cygwin situation.

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

9 years ago[PowerPC] Constrain base register in PPCRegisterInfo::resolveFrameIndex
Ulrich Weigand [Fri, 27 Jun 2014 13:04:12 +0000 (13:04 +0000)]
[PowerPC] Constrain base register in PPCRegisterInfo::resolveFrameIndex

I've run into a bug where current LLVM at -O0 (with fast-isel)
generated invalid code like:

        ld 0, 20936(1)                  # 8-byte Folded Reload
        stw 12, 10348(0)
        stw 12, 10344(0)

The underlying vreg had been introduced as base register by the
Local Stack Slot Allocation pass.  That register was constrained
to G8RC by PPCRegisterInfo::materializeFrameBaseRegister to match
the ADDI instruction used to set it, but it was *not* constrained
to G8RC_NOX0 to fit the *use* of the register in an address.

That should have happened in PPCRegisterInfo::resolveFrameIndex.
This patch adds an appropriate constrainRegClass call.

Reviewed by Hal Finkel.

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

9 years ago[x86] Clean up some unused variables, especially in release builds.
Chandler Carruth [Fri, 27 Jun 2014 12:04:18 +0000 (12:04 +0000)]
[x86] Clean up some unused variables, especially in release builds.

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

9 years ago[x86] Teach the target combine step to aggressively fold pshufd insturcions.
Chandler Carruth [Fri, 27 Jun 2014 11:40:13 +0000 (11:40 +0000)]
[x86] Teach the target combine step to aggressively fold pshufd insturcions.

Summary:
This allows it to fold pshufd instructions across intervening
half-shuffles and other noise. This pattern actually shows up in the
generic lowering tests, but I've also added direct tests using
intrinsics to make sure that the specific desired functionality is
working even if the lowering stuff changes in the future.

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

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

9 years ago[ELF][Mips] Fix recognition of MIPS 64-bit arch in the ELFObjectFile:getArch() method.
Simon Atanasyan [Fri, 27 Jun 2014 11:36:45 +0000 (11:36 +0000)]
[ELF][Mips] Fix recognition of MIPS 64-bit arch in the ELFObjectFile:getArch() method.

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

9 years ago[x86] Teach the target-specific combining how to aggressively fold
Chandler Carruth [Fri, 27 Jun 2014 11:34:40 +0000 (11:34 +0000)]
[x86] Teach the target-specific combining how to aggressively fold
half-shuffles, even looking through intervening instructions in a chain.

Summary:
This doesn't happen to show up with any test cases I've found for the current
shuffle lowering, but previous attempts would benefit from this and it seems
generally useful. I've tested it directly using intrinsics, which also shows
that it will work with hand vectorized code as well.

Note that even though pshufd isn't directly used in these tests, it gets
exercised because we combine some of the half shuffles into a pshufd
first, and then merge them.

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

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

9 years ago[x86] Teach the X86 backend to DAG-combine SSE2 shuffles that are
Chandler Carruth [Fri, 27 Jun 2014 11:27:52 +0000 (11:27 +0000)]
[x86] Teach the X86 backend to DAG-combine SSE2 shuffles that are
trivially redundant.

This fixes several cases in the new vector shuffle lowering algorithm
which would generate redundant shuffle instructions for the sake of
simplicity.

I'm also deleting a testcase which was somewhat ridiculous. It was
checking for a bug in 2007 about incorrectly transforming shuffles by
looking for the string "-86" in the output of a pretty substantial
function. This test case doesn't seem to have any value at this point.

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

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

9 years ago[x86] Begin a significant overhaul of how vector lowering is done in the
Chandler Carruth [Fri, 27 Jun 2014 11:23:44 +0000 (11:23 +0000)]
[x86] Begin a significant overhaul of how vector lowering is done in the
x86 backend.

This sketches out a new code path for vector lowering, hidden behind an
off-by-default flag while it is under development. The fundamental idea
behind the new code path is to aggressively break down the problem space
in ways that ease selecting the odd set of instructions available on
x86, and carefully avoid scalarizing code even when forced to use older
ISAs. Notably, this starts off restricting itself to SSE2 and implements
the complete vector shuffle and blend space for 128-bit vectors in SSE2
without scalarizing. The plan is to layer on top of this ISA extensions
where we can bail out of the complex SSE2 lowering and opt for
a cheaper, specialized instruction (or set of instructions). It also
needs to be generalized to AVX and AVX512 vector widths.

Currently, this does a decent but not perfect job for SSE2. There are
some specific shortcomings that I plan to address:
- We need a peephole combine to fold together shuffles where possible.
  There are cases where a previous shuffle could be modified slightly to
  arrange for elements to be in the correct position and a later shuffle
  eliminated. Doing this eagerly added quite a bit of complexity, and
  so my plan is to combine away these redundancies afterward.
- There are a lot more clever ways to use unpck and pack that need to be
  added. This is essential for real world shuffles as it turns out...

Once SSE2 is polished a bit I should be able to get interesting numbers
on performance improvements on benchmarks conducive to vectorization.
All of this will be off by default until it is functionally equivalent
of course.

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

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

9 years ago[RuntimeDyld, PowerPC] Fix/improve handling of TOC relocations
Ulrich Weigand [Fri, 27 Jun 2014 10:32:14 +0000 (10:32 +0000)]
[RuntimeDyld, PowerPC] Fix/improve handling of TOC relocations

Current PPC64 RuntimeDyld code to handle TOC relocations has two
problems:

- With recent linkers, in addition to the relocations that implicitly
  refer to the TOC base (R_PPC64_TOC*), you can now also use the .TOC.
  magic symbol with any other relocation to refer to the TOC base
  explicitly.  This isn't currently used much in ELFv1 code (although
  it could be), but it is essential in ELFv2 code.

- In a complex JIT environment with multiple modules, each module may
  have its own .toc section, and TOC relocations in one module must
  refer to *its own* TOC section.  The current findPPC64TOC implementation
  does not correctly implement this; in fact, it will always return the
  address of the first TOC section it finds anywhere.  (Note that at the
  time findPPC64TOC is called, we don't even *know* which module the
  relocation originally resided in, so it is not even possible to fix
  this routine as-is.)

This commit fixes both problems by handling TOC relocations earlier, in
processRelocationRef.  To do this, I've removed the findPPC64TOC routine
and replaced it by a new routine findPPC64TOCSection, which works
analogously to findOPDEntrySection in scanning the sections of the
ObjImage provided by its caller, processRelocationRef.  This solves the
issue of finding the correct TOC section associated with the current
module.

This makes it straightforward to implement both R_PPC64_TOC relocations,
and relocations explicitly refering to the .TOC. symbol, directly in
processRelocationRef.  There is now a new problem in implementing the
R_PPC64_TOC16* relocations, because those can now in theory involve
*three* different sections: the relocation may be applied in section A,
refer explicitly to a symbol in section B, and refer implicitly to the
TOC section C.  The final processing of the relocation thus may only
happen after all three of these sections have been assigned final
addresses.  There is currently no obvious means to implement this in
its general form with the common-code RuntimeDyld infrastructure.

Fortunately, ppc64 code usually makes no use of this most general form;
in fact, TOC16 relocations are only ever generated by LLVM for symbols
residing themselves in the TOC, which means "section B" == "section C"
in the above terminology.  This special case can easily be handled with
the current infrastructure, and that is what this patch does.
[ Unhandled cases result in an explicit error, unlike the current code
which silently returns the wrong TOC base address ... ]

This patch makes the JIT work on both BE and LE (ELFv2 requires
additional patches, of course), and allowed me to successfully run
complex JIT scenarios (via mesa/llvmpipe).

Reviewed by Hal Finkel.

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

9 years agoIRReader: don't mark MemoryBuffers const
Alp Toker [Fri, 27 Jun 2014 09:19:14 +0000 (09:19 +0000)]
IRReader: don't mark MemoryBuffers const

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

9 years agoAdded instruction combine to transform few more negative values addition to subtracti...
Dinesh Dwivedi [Fri, 27 Jun 2014 07:47:35 +0000 (07:47 +0000)]
Added instruction combine to transform few more negative values addition to subtraction (Part 3)
This patch enables transforms for

(x + (~(y | c) + 1) --> x - (y | c) if c is odd

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

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