Commit Graph

27251 Commits

Author SHA1 Message Date
Lang Hames
4576e07c30 [ORC] Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266712 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 04:44:21 +00:00
Lang Hames
ffdeef411b [Orc] Tidy up some of the RPC primitives, add a unit-test for the callST
(synchronous call) primitive.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266711 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 04:43:09 +00:00
Michael Kuperstein
3445cc7801 Port DemandedBits to the new pass manager.
Differential Revision: http://reviews.llvm.org/D18679

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266699 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 23:55:01 +00:00
Richard Smith
19c0ba5178 Add missing #include, found by modules selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266697 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 23:27:25 +00:00
Richard Smith
d5d6cc9562 Add missing header, found by modules selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266696 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 23:24:39 +00:00
Reid Kleckner
4917541593 Remove old DIBuilder::createFunction overload used only by dragonegg, which does not currently build
NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266691 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 22:38:52 +00:00
Lang Hames
a6af3574e1 [Orc] Explicitly delete RPC::SequenceNumberManager's copy-constructor and
copy-assignment operator.

MSVC is trying to synthesize these and failing. Hopefully explicitly deleting
them will help.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266665 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 20:56:22 +00:00
Lang Hames
6320b788a2 [Orc] Re-commit r266581 with fixes for MSVC, and format cleanups.
Fixes:

(1) Removes constexpr (unsupported in MSVC)
(2) Move constructors (remove explicitly defaulted ones)
(3) <future> - Add warning suppression for MSVC.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266663 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 19:55:43 +00:00
JF Bastien
1b711b23e2 NFC: unify clang / LLVM atomic ordering
This makes the C11 / C++11 *ABI* atomic ordering accessible from LLVM,
as discussed in http://reviews.llvm.org/D18200#inline-151433

This re-applies r266573 which I had reverted in r266576.

Original review: http://reviews.llvm.org/D18875

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266640 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 18:01:43 +00:00
Xinliang David Li
cc76a0c46e Add missing new file for r266637
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266639 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 17:54:25 +00:00
Xinliang David Li
6be977abce Port InstrProfiling pass to the new pass manager
Differential Revision: http://reviews.llvm.org/D18126


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266637 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 17:47:38 +00:00
Eric Liu
dcefe3154e Revert "Replace the use of MaxFunctionCount module flag"
This reverts commit r266477.

This commit introduces cyclic dependency. This commit has "Analysis" depend on "ProfileData",
while "ProfileData" depends on "Object", which depends on "BitCode", which
depends on "Analysis".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266619 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 15:31:11 +00:00
Nico Weber
18061690cb Revert 266581 (and follow-up 266588), it doesn't build on Windows.
Three problems:
1. <future> can't be easily used.  If you must use it, see
   include/Support/ThreadPool.h for how.
2. constexpr problems, even after 266588.
3. Move assignment operators can't be defaulted in MSVC2013.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266615 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 13:57:08 +00:00
Nico Weber
2e7ff2cd6d Unbreak building LLVMTarget on Windows after r266595.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266613 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 13:38:58 +00:00
Mehdi Amini
f6071e14c5 [NFC] Header cleanup
Removed some unused headers, replaced some headers with forward class declarations.

Found using simple scripts like this one:
clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap'

Patch by Eugene Kosov <claprix@yandex.ru>

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266595 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 09:17:29 +00:00
Lang Hames
81499739d6 [Orc] Tweak some of the new RPC code to silence a warning (extraneous ';') and
MSVC errors related to constexpr.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266588 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 05:22:32 +00:00
Lang Hames
bd1968ac09 [ORC] Generalize the ORC RPC utils to support RPC function return values and
asynchronous call/handle. Also updates the ORC remote JIT API to use the new
scheme.

The previous version of the RPC tools only supported void functions, and
required the user to manually call a paired function to return results. This
patch replaces the Procedure typedef (which only supported void functions) with
the Function typedef which supports return values, e.g.:

  Function<FooId, int32_t(std::string)> Foo;

The RPC primitives and channel operations are also expanded. RPC channels must
support four new operations: startSendMessage, endSendMessage,
startRecieveMessage and endRecieveMessage, to handle channel locking. In
addition, serialization support for tuples to RPCChannels is added to enable
multiple return values.

The RPC primitives are expanded from callAppend, call, expect and handle, to:

appendCallAsync - Make an asynchronous call to the given function.

callAsync - The same as appendCallAsync, but calls send on the channel when
            done.

callSTHandling - Blocking call for single-threaded code. Wraps a call to
                 callAsync then waits on the result, using a user-supplied
                 handler to handle any callbacks from the remote.

callST - The same as callSTHandling, except that it doesn't handle
         callbacks - it expects the result to be the first return.

expect and handle - as before.

handleResponse - Handle a response from the remote.

waitForResult - Wait for the response with the given sequence number to arrive.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266581 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 01:06:49 +00:00
Duncan P. N. Exon Smith
034f0eea6b Linker: Share a single Metadata map for the lifetime of IRMover
Cache the result of mapping metadata nodes between instances of IRLinker
(i.e., for the lifetime of IRMover).  There shouldn't be any real
functional change here, but this should give a major speedup.  I had
loaned this to Mehdi when he tested performance of r266446, and the two
patches together gave a 10x speedup in metadata mapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266579 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 23:30:31 +00:00
JF Bastien
d6634d647a Revert "NFC: unify clang / LLVM atomic ordering"
This reverts commit 537951f2f1.

Causes an assert in:
  test/Transforms/AtomicExpand/SPARC/libcalls.ll
  (Ordering2 != AtomicOrdering::NotAtomic && "expect atomic MO")

Bot:
  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/21724/testReport/junit/LLVM/Transforms_AtomicExpand_SPARC/libcalls_ll/

I'm not getting this assert on my local debug build, but I'll revert
just to be sure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266576 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 21:29:01 +00:00
JF Bastien
537951f2f1 NFC: unify clang / LLVM atomic ordering
Summary: This makes the C11 / C++11 *ABI* atomic ordering accessible from LLVM, as discussed in http://reviews.llvm.org/D18200#inline-151433

Reviewers: jyknight, reames

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266573 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 21:00:57 +00:00
Rafael Espindola
ec86ae2bb5 Keep only the splitCodegen version that takes a factory.
This makes it much easier to see that all created TargetMachines are
equivalent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266564 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 18:42:27 +00:00
Craig Topper
ca89139c6d Declare MVT::SimpleValueType as an int8_t sized enum. This removes 400 bytes from TargetLoweringBase and probably other places.
This required changing several places to print VT enums as strings instead of raw ints since the proper method to use to print became ambiguous. This is probably an improvement anyway.

This also appears to save ~8K from an x86 self host build of llc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266562 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 17:37:33 +00:00
Duncan P. N. Exon Smith
9bb5d5d42c IR: Use an explicit map for debug info type uniquing
Rather than relying on the structural equivalence of DICompositeType to
merge type definitions, use an explicit map on the LLVMContext that
LLParser and BitcodeReader consult when constructing new nodes.
Each non-forward-declaration DICompositeType with a non-empty
'identifier:' field is stored/loaded from the type map, and the first
definiton will "win".

This map is opt-in: clients that expect ODR types from different modules
to be merged must call LLVMContext::ensureDITypeMap.

  - Clients that just happen to load more than one Module in the same
    LLVMContext won't magically merge types.

  - Clients (like LTO) that want to continue to merge types based on ODR
    identifiers should opt-in immediately.

I have updated LTOCodeGenerator.cpp, the two "linking" spots in
gold-plugin.cpp, and llvm-link (unless -disable-debug-info-type-map) to
set this.

With this in place, it will be straightforward to remove the DITypeRef
concept (i.e., referencing types by their 'identifier:' string rather
than pointing at them directly).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266549 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 03:58:21 +00:00
Craig Topper
9e15d9af12 [Target] Reduce size of the LoadExtActions array in TargetLoweringBase by half. Saving ~18K bytes from the array.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 01:34:37 +00:00
Craig Topper
664e2c80b4 [Target] Remove checks for Simple VTs before calling routines that can handle Extended VTs too. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266546 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 01:34:35 +00:00
Craig Topper
bf8d6bcffc [Target] Fix an assertion that should have been updated when the code below it was changed in r251033.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266545 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-17 01:34:32 +00:00
Duncan P. N. Exon Smith
d25d6b7783 IR: Remove extra blank line, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266539 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 22:26:04 +00:00
Vedant Kumar
bf62fd94a9 Add missing #include to fix build
Failing bot:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/23112/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266532 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 17:39:40 +00:00
Mehdi Amini
492acdd450 Remove some unneeded headers and replace some headers with forward class declarations (NFC)
Differential Revision: http://reviews.llvm.org/D19154

Patch by Eugene Kosov <claprix@yandex.ru>

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266524 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 07:51:28 +00:00
Mehdi Amini
29d66c4985 ThinLTO: Move the ODR resolution to be based purely on the summary.
This is a requirement for the cache handling in D18494

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266519 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 07:02:16 +00:00
Mehdi Amini
eb79e6e85d ThinLTO: Make aliases explicit in the summary
To be able to work accurately on the reference graph when taking
decision about internalizing, promoting, renaming, etc. We need
to have the alias information explicit.

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266517 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 06:56:44 +00:00
Davide Italiano
30f743e304 [DebugInfo] Correct the assertion introduced in r266509 + update test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266512 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 03:23:48 +00:00
Duncan P. N. Exon Smith
1f03619959 Reapply "ValueMapper: Eliminate cross-file co-recursion, NFC"
This reverts commit r266507, reapplying r266503 (and r266505
"ValueMapper: Use API from r266503 in unit tests, NFC") completely
unchanged.

I reverted because of a bot failure here:
  http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16810/

However, looking more closely, the failure was from a host-compiler
crash (clang 3.7.1) when building:
  lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/DwarfAccelTable.cpp.o

I didn't modify that file, or anything it includes, with that commit.

The next build (which hadn't picked up my revert) got past it:
  http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16811/

I think this was just unfortunate timing.  I suppose the bot must be
flakey.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266510 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 02:29:55 +00:00
Davide Italiano
b5fd6b390c [DebugInfo] Reduce size of DILocalVariable from 40 to 32 bytes.
This significantly contributes to peak memory usage during a
LTO Release+DebugInfo build of clang. In my profile the peak usage
is around 164MB before this change and ~130MB after.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266509 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 02:27:56 +00:00
Duncan P. N. Exon Smith
86a7a5ada2 Revert "ValueMapper: Eliminate cross-file co-recursion, NFC"
This reverts commit r266503, in case it's the root cause of this bot
failure:

  http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16810

I'm also reverting r266505 -- "ValueMapper: Use API from r266503 in unit
tests, NFC" -- since it's in the way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 02:05:33 +00:00
Duncan P. N. Exon Smith
d83a5e8fc6 ValueMapper: Eliminate cross-file co-recursion, NFC
Eliminate co-recursion of Mapper::mapValue through
ValueMaterializer::materializeInitFor, through a major redesign of the
ValueMapper.cpp interface.

  - Expose a ValueMapper class that controls the entry points to the
    mapping algorithms.
  - Change IRLinker to use ValueMapper directly, rather than
    llvm::RemapInstruction, llvm::MapValue, etc.
  - Use (e.g.) ValueMapper::scheduleMapGlobalInit to add mapping work to
    a worklist in ValueMapper instead of recursing.

There were two fairly major complications.

Firstly, IRLinker::linkAppendingVarProto incorporates an on-the-fly IR
ugprade that I had to split apart.  Long-term, this upgrade should be
done in the bitcode reader (and we should only accept the "new" form),
but for now I've just made it work and added a FIXME.  The hold-op is
that we need to deprecate C API that relies on this.

Secondly, IRLinker has special logic to correctly implement aliases with
comdats, and uses two ValueToValueMapTy instances and two
ValueMaterializers.  I supported this by allowing clients to register an
alternate mapping context, whose MCID can be passed in when scheduling
new work.

While out of scope for this commit, it should now be straightforward to
remove recursion from Mapper::mapValue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266503 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 01:29:08 +00:00
Richard Smith
d1d05a8bbb Add some missing #includes, found by C++ modules selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266500 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 00:42:37 +00:00
Richard Smith
b337fbb4a1 Make this header include the header it depends on, rather than trying to include itself. Found by C++ modules build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266492 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 23:30:57 +00:00
Wei Mi
1f5a2c3f94 Don't skip splitSeparateComponents in eliminateDeadDefs for HoistSpillHelper::hoistAllSpills.
Because HoistSpillHelper::hoistAllSpills is called in postOptimization, before the
patch we didn't want LiveRangeEdit::eliminateDeadDefs to call splitSeparateComponents
and generate unassigned new vregs. However, skipping splitSeparateComponents will make
verify-machineinstrs unhappy, so I remove the early return, and use
HoistSpillHelper::LRE_DidCloneVirtReg to assign physreg/stackslot for those new vregs.

In addition, some code reorganization to make class HoistSpillHelper privately inheriting
from LiveRangeEdit::Delegate possible. This is to be consistent with class RAGreedy and
class RegisterCoalescer.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266489 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 23:16:44 +00:00
Easwaran Raman
b87a1e69c3 Replace the use of MaxFunctionCount module flag
Adds an interface to get ProfileSummary for a module and makes InlineCost use ProfileSummary to get max function count.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266477 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 21:39:58 +00:00
Reid Kleckner
4479a5c08e [codeview] Dump char16_t and char32_t simple types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266465 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 18:26:45 +00:00
Davide Italiano
db52b36ad2 [ParallelCG] Add a new splitCodeGen() API which takes a TargetMachineFactory.
This is a recommit of r266390 with a fix that will allow tests to pass
(hopefully). Before we got a StringRef to M->getTargetTriple() and right
after we moved the Module so we were referencing a dangling object.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266456 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 17:34:32 +00:00
Adrian Prantl
4eeaa0da04 [PR27284] Reverse the ownership between DICompileUnit and DISubprogram.
Currently each Function points to a DISubprogram and DISubprogram has a
scope field. For member functions the scope is a DICompositeType. DIScopes
point to the DICompileUnit to facilitate type uniquing.

Distinct DISubprograms (with isDefinition: true) are not part of the type
hierarchy and cannot be uniqued. This change removes the subprograms
list from DICompileUnit and instead adds a pointer to the owning compile
unit to distinct DISubprograms. This would make it easy for ThinLTO to
strip unneeded DISubprograms and their transitively referenced debug info.

Motivation
----------

Materializing DISubprograms is currently the most expensive operation when
doing a ThinLTO build of clang.

We want the DISubprogram to be stored in a separate Bitcode block (or the
same block as the function body) so we can avoid having to expensively
deserialize all DISubprograms together with the global metadata. If a
function has been inlined into another subprogram we need to store a
reference the block containing the inlined subprogram.

Attached to https://llvm.org/bugs/show_bug.cgi?id=27284 is a python script
that updates LLVM IR testcases to the new format.

http://reviews.llvm.org/D19034
<rdar://problem/25256815>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266446 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 15:57:41 +00:00
Jun Bum Lim
232aafceb5 [MachineScheduler]Add support for store clustering
Perform store clustering just like load clustering. This change add
StoreClusterMutation in machine-scheduler. To control StoreClusterMutation,
added enableClusterStores() in TargetInstrInfo.h. This is enabled only on
AArch64 for now.

This change also add support for unscaled stores which were not handled in
getMemOpBaseRegImmOfs().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266437 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 14:58:38 +00:00
Craig Topper
cf943896dc Add a setOperationPromotedToType convenience method that sets an operation to promoted and set the type in one call. Use it so save code in X86.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266413 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 06:20:18 +00:00
Davide Italiano
0e3b20fef7 Revert "[LTO] Add a new splitCodeGen() API which takes a TargetMachineFactory."
This reverts commits r266390 and r266396 as they broke some bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266408 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 02:07:03 +00:00
Justin Lebar
dbebf40a3b [TTI] Add getInliningThresholdMultiplier.
Summary:
InlineCost's threshold is multiplied by this value.  This lets us adjust
the inlining threshold up or down on a per-target basis.  For example,
we might want to increase the threshold on targets where calls are
unusually expensive.

Reviewers: chandlerc

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266405 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 01:38:48 +00:00
Justin Lebar
41f2abf484 [Speculation] Add a SpeculativeExecution mode where the pass does nothing unless TTI::hasBranchDivergence() is true.
Summary:
This lets us add this pass to the IR pass manager unconditionally; it
will simply not do anything on targets without branch divergence.

Reviewers: tra

Subscribers: llvm-commits, jingyue, rnk, chandlerc

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266398 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 00:32:09 +00:00
Davide Italiano
2ef07c54e6 [ParallelCG] Attempt to placate MSVC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266396 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 00:25:19 +00:00
Hans Wennborg
9f34fd51ea Option parser: class for consuming a joined arg in addition to all remaining args
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266394 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 00:23:30 +00:00
Davide Italiano
8885fcd061 [LTO] Add a new splitCodeGen() API which takes a TargetMachineFactory.
This will be used in lld to avoid creating TargetMachine in two
different places. See D18999 for a more detailed discussion.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266390 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 00:07:28 +00:00
Michael Kuperstein
f66aab6e00 [AliasSetTracker] Correctly handle changing the size of an entry
If the size of an AST entry changes, we also need to make sure we perform
necessary alias set merges, as the new size may overlap pointers in other sets.
We happen to run into this with memset, because memset allows an entry for a
i8* pointer to have a decidedly non-i8 size.

This fixes PR27262.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266381 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 22:00:11 +00:00
Mehdi Amini
41b016e569 Nuke getGlobalContext() from LLVM (but the C API)
The only use for getGlobalContext() is in the C API.
Let's just move the static global here and nuke the C++ API.

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266380 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 21:59:18 +00:00
Mehdi Amini
8be7707c14 Remove every uses of getGlobalContext() in LLVM (but the C API)
At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.

This is the first part of http://reviews.llvm.org/D19094

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266379 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 21:59:01 +00:00
Geoff Berry
1a490607b5 [ScheduleDAGInstrs] Re-factor for based on review feedback. NFC.
Summary:
Re-factor some code to improve clarity and style based on review
comments from http://reviews.llvm.org/D18093.

Reviewers: MatzeB, mcrosier

Subscribers: MatzeB, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266372 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 21:31:07 +00:00
Renato Golin
a447ca5c09 [ARM] Adding IEEE-754 SIMD detection to loop vectorizer
Some SIMD implementations are not IEEE-754 compliant, for example ARM's NEON.

This patch teaches the loop vectorizer to only allow transformations of loops
that either contain no floating-point operations or have enough allowance
flags supporting lack of precision (ex. -ffast-math, Darwin).

For that, the target description now has a method which tells us if the
vectorizer is allowed to handle FP math without falling into unsafe
representations, plus a check on every FP instruction in the candidate loop
to check for the safety flags.

This commit makes LLVM behave like GCC with respect to ARM NEON support, but
it stops short of fixing the underlying problem: sub-normals. Neither GCC
nor LLVM have a flag for allowing sub-normal operations. Before this patch,
GCC only allows it using unsafe-math flags and LLVM allows it by default with
no way to turn it off (short of not using NEON at all).

As a first step, we push this change to make it safe and in sync with GCC.
The second step is to discuss a new sub-normal's flag on both communitues
and come up with a common solution. The third step is to improve the FastMath
flags in LLVM to encode sub-normals and use those flags to restrict NEON FP.

Fixes PR16275.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 20:42:18 +00:00
Reid Kleckner
13fb5a3f1f Sink DI metadata usage out of MachineInstr.h and MachineInstrBuilder.h
MachineInstr.h and MachineInstrBuilder.h are very popular headers,
widely included across all LLVM backends. It turns out that there only a
handful of TUs that actually care about DI operands on MachineInstrs.

After this change, touching DebugInfoMetadata.h and rebuilding llc only
needs 112 actions instead of 542.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266351 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 18:29:59 +00:00
Tom Stellard
bd1372842e [GlobalISel] Move GISelAccessor class into public headers
Reviewers: qcolombet

Subscribers: joker.eph, vkalintiris, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266348 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 17:45:38 +00:00
Nicolai Haehnle
a16ecd4300 [DivergenceAnalysis] Treat PHI with incoming undef as constant
Summary:
If a PHI has an incoming undef, we can pretend that it is equal to one
non-undef, non-self incoming value.

This is particularly relevant in combination with the StructurizeCFG
pass, which introduces PHI nodes with undefs. Previously, this lead to
branch conditions that were uniform before StructurizeCFG to become
non-uniform afterwards, which confused the SIAnnotateControlFlow
pass.

This fixes a crash when Mesa radeonsi compiles a shader from
dEQP-GLES3.functional.shaders.switch.switch_in_for_loop_dynamic_vertex

Reviewers: arsenm, tstellarAMD, jingyue

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266347 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 17:42:47 +00:00
Tom Stellard
b4b70a0f72 [GlobalISel] Coding style and whitespace fixes
Reviewers: qcolombet

Subscribers: joker.eph, llvm-commits, vkalintiris

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266342 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 17:23:33 +00:00
Tom Stellard
510a2b9622 AMDGPU: allow specifying a workgroup size that needs to fit in a compute unit
Summary:
For GL_ARB_compute_shader we need to support workgroup sizes of at least 1024. However, if we want to allow large workgroup sizes, we may need to use less registers, as we have to run more waves per SIMD.

This patch adds an attribute to specify the maximum work group size the compiled program needs to support. It defaults, to 256, as that has no wave restrictions.

Reducing the number of registers available is done similarly to how the registers were reserved for chips with the sgpr init bug.

Reviewers: mareko, arsenm, tstellarAMD, nhaehnle

Subscribers: FireBurn, kerberizer, llvm-commits, arsenm

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

Patch By: Bas Nieuwenhuizen

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266337 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 16:27:07 +00:00
Silviu Baranga
5cb657f8dd [SCEV][LAA] Add tests for SCEV expression transformations performed during LAA
Summary:
Add a print method to Predicated Scalar Evolution which prints all interesting
transformations done by PSE.

Loop Access Analysis will now print this as part of the analysis output.
We now use this to check the exact expression transformations that were done
by PSE in LAA.

The additional checking also acts as white-box testing for the getAsAddRec method.

Reviewers: anemet, sanjoy

Subscribers: sanjoy, mzolotukhin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266334 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 16:08:45 +00:00
Adam Nemet
cf0a711bff Revert "Support arbitrary addrspace pointers in masked load/store intrinsics"
This reverts commit r266086.

It breaks the LTO build of gcc in SPEC2000.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266282 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 08:47:17 +00:00
David Majnemer
1f0cfcc0d1 [CodeGen] Teach LLVM how to lower @llvm.{min,max}num to {MIN,MAX}NAN
The behavior of {MIN,MAX}NAN differs from that of {MIN,MAX}NUM when only
one of the inputs is NaN: -NUM will return the non-NaN argument while
-NAN would return NaN.

It is desirable to lower to @llvm.{min,max}num to -NAN if they don't
have a native instruction for -NUM.  Notably, ARMv7 NEON's vmin has the
-NAN semantics.

N.B.  Of course, it is only safe to do this if the intrinsic call is
marked nnan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266279 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 07:13:24 +00:00
Matt Arsenault
f5cccc3f63 AMDGPU: Implement canonicalize
Also add generic DAG node for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266272 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 01:42:16 +00:00
Matthias Braun
f8b5f15902 TargetLowering: Factor out common code for tail call eligibility checking; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266270 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 01:10:42 +00:00
Amaury Sechet
609cf3b89c Revert "Add LLVMGetAttrKindIDInContext in the C API in order to facilitate migration away from LLVMAttribute"
This reverts commit 0bcfd95c268bcb180a525e1837e84475df8acdc7.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266259 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 23:01:39 +00:00
Amaury Sechet
2af3e8f798 Add LLVMGetAttrKindIDInContext in the C API in order to facilitate migration away from LLVMAttribute
Summary: LLVMAttribute has outlived its utility and is becoming a problem for C API users that what to use all the LLVM attributes. In order to help moving away from LLVMAttribute in a smooth manner, this diff introduce LLVMGetAttrKindIDInContext, which can be used instead of the enum values.

Reviewers: Wallbraker, whitequark, joker.eph, echristo

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266257 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 22:51:40 +00:00
Reid Kleckner
55e47a634f [IR] Optimize memory usage of Metadata on MSVC
An unsigned 2 bit bitfield takes 4 bytes in MSVC. Instead of a bitfield,
just use an unsigned char. We can go back to a bitfield when someone
implements the TODO of exposing and reusing the remaining 6 bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266256 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 22:46:06 +00:00
Davide Italiano
0149731869 [DebugInfo] Optimize memory layout of DISubprogram.
A DISubprogram on x86_64 was 48 bytes. During an LTO build we
end up allocating *a lot* of these (see Duncan's numbers on
llvm-dev and/or my numbers in the review link).
This change reduces the size to 40 bytes, with a nice effect
on peak memory usage when LTO'ing clang.
There are more classes in the hierarchy which can be compacted
so more patches will come. DISubprogram was the biggest offender
in my profiling, anyway.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266241 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 20:17:42 +00:00
Mehdi Amini
387bdb41b0 Revert "Make aliases explicit in the summary"
Inadvertently commited...

This reverts commit e618ec9378.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266215 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 17:20:07 +00:00
Mehdi Amini
e618ec9378 Make aliases explicit in the summary
Summary:
To be able to work accurately on the reference graph when taking decision
about internalizing, promoting, renaming, etc. We need to have the alias
information explicit.

Reviewers: tejohnson

Subscribers: llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266214 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 17:18:42 +00:00
Mehdi Amini
7739723f0d Revert inadvertently modified comment in r266131
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266210 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 17:06:49 +00:00
David L Kreitzer
3592381ea1 Simplify strlen to a subtraction for certain cases.
Patch by Li Huang (li1.huang@intel.com)

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266200 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 14:31:06 +00:00
Petar Jovanovic
396d592ab0 Calculate __builtin_object_size when pointer depends on a condition
This patch fixes calculating of builtin_object_size if it depends on a
condition. Before this patch compiler did not know how to calculate the
object size when it finds a condition that cannot be eliminated.
This patch enables calculating of builtin_object_size even in case when
condition cannot be eliminated by choosing minimum or maximum value as a
result from condition. Choosing minimum or maximum value from condition
is based on the second argument of __builtin_object_size function.

Patch by Strahinja Petrovic.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266193 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 12:25:25 +00:00
David Majnemer
1559762512 [InstCombine] We folded an fcmp to an i1 instead of a vector of i1
Remove an ad-hoc transform in InstCombine and replace it with more
general machinery (ValueTracking, InstructionSimplify and VectorUtils).

This fixes PR27332.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266175 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 06:55:52 +00:00
Mehdi Amini
8fbafc9f4e Refactor the InternalizePass into a helper class, and expose it through a public free function (NFC)
There is really no reason to require to instanciate a pass manager to
internalize.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266167 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 05:25:08 +00:00
Mehdi Amini
a98cfea3ed Refactor Internalization pass to use as a callback instead of a StringSet (NFC)
This will save a bunch of copies / initialization of intermediate
datastructure, and (hopefully) simplify the code.

This also abstract the symbol preservation mechanism outside of the
Internalization pass into the client code, which is not forced
to keep a map of strings for instance (ThinLTO will prefere hashes).

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266163 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 04:20:32 +00:00
Wei Mi
815b02e9ce Recommit r265547, and r265610,r265639,r265657 on top of it, plus
two fixes with one about error verify-regalloc reported, and
another about live range update of phi after rematerialization.

r265547:
Replace analyzeSiblingValues with new algorithm to fix its compile
time issue. The patch is to solve PR17409 and its duplicates.

analyzeSiblingValues is a N x N complexity algorithm where N is
the number of siblings generated by reg splitting. Although it
causes siginificant compile time issue when N is large, it is also
important for performance since it removes redundent spills and
enables rematerialization.

To solve the compile time issue, the patch removes analyzeSiblingValues
and replaces it with lower cost alternatives containing two parts. The
first part creates a new spill hoisting method in postOptimization of
register allocation. It does spill hoisting at once after all the spills
are generated instead of inside every instance of selectOrSplit. The
second part queries the define expr of the original register for
rematerializaiton and keep it always available during register allocation
even if it is already dead. It deletes those dead instructions only in
postOptimization. With the two parts in the patch, it can remove
analyzeSiblingValues without sacrificing performance.

Patches on top of r265547:
r265610 "Fix the compare-clang diff error introduced by r265547."
r265639 "Fix the sanitizer bootstrap error in r265547."
r265657 "InlineSpiller.cpp: Escap \@ in r265547. [-Wdocumentation]"

Differential Revision: http://reviews.llvm.org/D15302
Differential Revision: http://reviews.llvm.org/D18934
Differential Revision: http://reviews.llvm.org/D18935
Differential Revision: http://reviews.llvm.org/D18936


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266162 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-13 03:08:27 +00:00
Mehdi Amini
28b33112e2 Add a pass to name anonymous/nameless function
Summary:
For correct handling of alias to nameless
function, we need to be able to refer them through a GUID in the summary.
Here we name them using a hash of the non-private global names in the module.

Reviewers: tejohnson

Subscribers: joker.eph, llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266132 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 21:35:28 +00:00
Mehdi Amini
e58bfc97e6 Move summary creation out of llvm-as into opt
Summary:
Let keep llvm-as "dumb": it converts textual IR to bitcode. This
commit removes the dependency from llvm-as to libLLVMAnalysis.
We'll add back summary in llvm-as if we get to a textual
representation for it at some point. In the meantime, opt seems
like a better place for that.

Reviewers: tejohnson

Subscribers: joker.eph, llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266131 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 21:35:18 +00:00
Nicolai Haehnle
756309c45b AMDGPU: add llvm.amdgcn.buffer.load/store intrinsics
Summary:
They correspond to BUFFER_LOAD/STORE_DWORD[_X2,X3,X4] and mostly behave like
llvm.amdgcn.buffer.load/store.format. They will be used by Mesa for SSBO and
atomic counters at least when robust buffer access behavior is desired.
(These instructions perform no format conversion and do buffer range checking
per component.)

As a side effect of sharing patterns with llvm.amdgcn.buffer.store.format,
it has become trivial to add support for the f32 and v2f32 variants of that
intrinsic, so the patch does so.

Also DAG-ify (and fix) some tests that I noticed intermittent failures in
while developing this patch.

Some tests were (temporarily) adjusted for the required mayLoad/hasSideEffects
changes to the BUFFER_STORE_DWORD* instructions. See also
http://reviews.llvm.org/D18291.

Reviewers: arsenm, tstellarAMD, mareko

Subscribers: arsenm, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266126 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 21:18:10 +00:00
Teresa Johnson
a439f48cb3 [ThinLTO] Only compute imports for current module in FunctionImport pass
Summary:
The function import pass was computing all the imports for all the
modules in the index, and only using the imports for the current module.
Change this to instead compute only for the given module. This means
that the exports list can't be populated, but they weren't being used
anyway.

Longer term, the linker can collect all the imports and export lists
and serialize them out for consumption by the distributed backend
processes which use this pass.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266125 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 21:13:11 +00:00
James Y Knight
238d8199af Add __atomic_* lowering to AtomicExpandPass.
(Recommit of r266002, with r266011, r266016, and not accidentally
including an extra unused/uninitialized element in LibcallRoutineNames)

AtomicExpandPass can now lower atomic load, atomic store, atomicrmw, and
cmpxchg instructions to __atomic_* library calls, when the target
doesn't support atomics of a given size.

This is the first step towards moving all atomic lowering from clang
into llvm. When all is done, the behavior of __sync_* builtins,
__atomic_* builtins, and C11 atomics will be unified.

Previously LLVM would pass everything through to the ISelLowering
code. There, unsupported atomic instructions would turn into __sync_*
library calls. Because of that behavior, Clang currently avoids emitting
llvm IR atomic instructions when this would happen, and emits __atomic_*
library functions itself, in the frontend.

This change makes LLVM able to emit __atomic_* libcalls, and thus will
eventually allow clang to depend on LLVM to do the right thing.

It is advantageous to do the new lowering to atomic libcalls in
AtomicExpandPass, before ISel time, because it's important that all
atomic operations for a given size either lower to __atomic_*
libcalls (which may use locks), or native instructions which won't. No
mixing and matching.

At the moment, this code is enabled only for SPARC, as a
demonstration. The next commit will expand support to all of the other
targets.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266115 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 20:18:48 +00:00
Matt Arsenault
1dca54625d APInt: Add overload of isMask
This mimics the version in MathExtras.h which isn't testing for a
specific mask size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266101 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 18:17:23 +00:00
Philip Reames
0802f714a2 Introduce an GCRelocateInst class [NFC]
Previously, we were using isGCRelocate predicates.  Using a subclass of IntrinsicInst is far more idiomatic.  The refactoring also enables a couple of minor simplifications and code sharing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266098 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 18:05:10 +00:00
Artur Pilipenko
80ce67004b Support arbitrary addrspace pointers in masked load/store intrinsics
This is a resubmittion of 263158 change.

This patch fixes the problem which occurs when loop-vectorize tries to use @llvm.masked.load/store intrinsic for a non-default addrspace pointer. It fails with "Calling a function with a bad signature!" assertion in CallInst constructor because it tries to pass a non-default addrspace pointer to the pointer argument which has default addrspace.

The fix is to add pointer type as another overloaded type to @llvm.masked.load/store intrinsics.

Reviewed By: reames

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266086 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 15:58:04 +00:00
Matt Arsenault
bc0aee542f AMDGPU: Add atomic_inc + atomic_dec intrinsics
These are different than atomicrmw add 1 because they have
an additional input value to clamp the result.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266074 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 14:05:04 +00:00
Rafael Espindola
586f018931 This reverts commit r266002, r266011 and r266016.
They broke the msan bot.

Original message:

Add __atomic_* lowering to AtomicExpandPass.

AtomicExpandPass can now lower atomic load, atomic store, atomicrmw,and
cmpxchg instructions to __atomic_* library calls, when the target
doesn't support atomics of a given size.

This is the first step towards moving all atomic lowering from clang
into llvm. When all is done, the behavior of __sync_* builtins,
__atomic_* builtins, and C11 atomics will be unified.

Previously LLVM would pass everything through to the ISelLowering
code. There, unsupported atomic instructions would turn into __sync_*
library calls. Because of that behavior, Clang currently avoids emitting
llvm IR atomic instructions when this would happen, and emits __atomic_*
library functions itself, in the frontend.

This change makes LLVM able to emit __atomic_* libcalls, and thus will
eventually allow clang to depend on LLVM to do the right thing.

It is advantageous to do the new lowering to atomic libcalls in
AtomicExpandPass, before ISel time, because it's important that all
atomic operations for a given size either lower to __atomic_*
libcalls (which may use locks), or native instructions which won't. No
mixing and matching.

At the moment, this code is enabled only for SPARC, as a
demonstration. The next commit will expand support to all of the other
targets.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 12:30:25 +00:00
Mehdi Amini
a6f183154e Refactor the Internalize stage of libLTO in a separate file (NFC)
This is intended to be shared by the ThinLTOCodeGenerator.

Note that there is a change in the way the verifier is run, previously
it was ran as a Pass on the merged module during internalization.
While now the verifier is called explicitely on the merged module
outside of the internalize "pass pipeline".

What remains strange in the API is the fact that `DisableVerify` in
the API does not disable this initial verifier.

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266047 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 06:34:10 +00:00
Mehdi Amini
861c3f6356 Use StringSet instead of StringMap where it makes sense to in LTOCodeGenerator (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266046 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 06:33:44 +00:00
Matthias Braun
b78b825147 TargetLowering: Add missing doxygen group end.
The missing end was also confusing the '{', '}' matching heuristics in
vim.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266036 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 02:16:15 +00:00
George Burgess IV
274105b8b5 Add the allocsize attribute to LLVM.
`allocsize` is a function attribute that allows users to request that
LLVM treat arbitrary functions as allocation functions.

This patch makes LLVM accept the `allocsize` attribute, and makes
`@llvm.objectsize` recognize said attribute.

The review for this was split into two patches for ease of reviewing:
D18974 and D14933. As promised on the revisions, I'm landing both
patches as a single commit.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266032 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 01:05:35 +00:00
Quentin Colombet
be78bfb92c [RegBankSelect] Teach how to repair definitions.
Although repairing definitions is not mandatory for correctness (only
phis would be impacted because of the RPO traversal), not repairing
might go against the cost model. Therefore, just repair when it is
possible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266025 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 00:12:59 +00:00
Quentin Colombet
4307705245 [MachineIRBuilder] Expose the insertion point in the public API.
It may be convenient to know where we are about to insert some code, for
instance to save and then restore this insertion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266024 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-12 00:07:14 +00:00
Derek Schuff
40e099b405 Replace MachineRegisterInfo::TracksLiveness with a MachineFunctionProperty
Use the MachineFunctionProperty mechanism to indicate whether the
liveness info is accurate instead of a bool flag on MRI.
Keeps the MRI accessor function for convenience. NFC

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266020 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 23:32:13 +00:00
Mehdi Amini
18a65be70f ThinLTO renaming: use module hash instead of position in the summary
This is more robust to changes in the link ordering.

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266018 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 23:26:46 +00:00
James Y Knight
36720c565c Add __atomic_* lowering to AtomicExpandPass.
AtomicExpandPass can now lower atomic load, atomic store, atomicrmw, and
cmpxchg instructions to __atomic_* library calls, when the target
doesn't support atomics of a given size.

This is the first step towards moving all atomic lowering from clang
into llvm. When all is done, the behavior of __sync_* builtins,
__atomic_* builtins, and C11 atomics will be unified.

Previously LLVM would pass everything through to the ISelLowering
code. There, unsupported atomic instructions would turn into __sync_*
library calls. Because of that behavior, Clang currently avoids emitting
llvm IR atomic instructions when this would happen, and emits __atomic_*
library functions itself, in the frontend.

This change makes LLVM able to emit __atomic_* libcalls, and thus will
eventually allow clang to depend on LLVM to do the right thing.

It is advantageous to do the new lowering to atomic libcalls in
AtomicExpandPass, before ISel time, because it's important that all
atomic operations for a given size either lower to __atomic_*
libcalls (which may use locks), or native instructions which won't. No
mixing and matching.

At the moment, this code is enabled only for SPARC, as a
demonstration. The next commit will expand support to all of the other
targets.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266002 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 22:22:33 +00:00
Reid Kleckner
41e5af8e94 Use member initializers for all scalar fields of MachineFrameInfo to save boilerplate
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265972 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 17:54:16 +00:00
Reid Kleckner
67e74634d3 Combine redundant stack realignment booleans in MachineFrameInfo
MachineFrameInfo does not need to be able to distinguish between the
user asking us not to realign the stack and the target telling us it
doesn't support stack realignment. Either way, fixed stack objects have
their alignment clamped.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265971 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 17:54:03 +00:00
Tom Stellard
94eb1d993e TargetRegisterInfo: Add getRegAsmName()
Summary:
The motivation for this new function is to move an invalid assumption
about the relationship between the names of register definitions in
tablegen files and their assembly names into TargetRegisterInfo, so that
we can begin working on fixing this assumption.

The current problem is that if you have a register definition in
TableGen like:

def MYReg0 : Register<"r0", 0>;

The function TargetLowering::getRegForInlineAsmConstraint() derives the
assembly name from the tablegen name: "MyReg0" rather than the given
assembly name "r0".  This is working, because on most targets the
tablegen name and the assembly names are case insensitive matches for
each other (e.g. def EAX : X86Reg<"eax", ...>

getRegAsmName() will allow targets to override this default assumption and
return the correct assembly name.

Reviewers: echristo, hfinkel

Subscribers: SamWot, echristo, hfinkel, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265955 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 16:21:12 +00:00
Sanjoy Das
5e07ce6898 This reverts commit r265913 and r265912
See PR27315

r265913: "[IndVars] Eliminate op.with.overflow when possible"

r265912: "[SCEV] See through op.with.overflow intrinsics"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265950 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 15:26:18 +00:00
Teresa Johnson
7ca333b425 [ThinLTO] Move summary computation from BitcodeWriter to new pass
Summary:
This is the first step in also serializing the index out to LLVM
assembly.

The per-module summary written to bitcode is moved out of the bitcode
writer and to a new analysis pass (ModuleSummaryIndexWrapperPass).
The pass itself uses a new builder class to compute index, and the
builder class is used directly in places where we don't have a pass
manager (e.g. llvm-as).

Because we are computing summaries outside of the bitcode writer, we no
longer can use value ids created by the bitcode writer's
ValueEnumerator. This required changing the reference graph edge type
to use a new ValueInfo class holding a union between a GUID (combined
index) and Value* (permodule index). The Value* are converted to the
appropriate value ID during bitcode writing.

Also, this enables removal of the BitWriter library's dependence on the
Analysis library that was previously required for the summary computation.

Reviewers: joker.eph

Subscribers: joker.eph, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265941 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 13:58:45 +00:00
Sanjoy Das
97ad447f43 [SCEV] See through op.with.overflow intrinsics
Summary:
This change teaches SCEV to see reduce `(extractvalue
0 (op.with.overflow X Y))` into `op X Y` (with a no-wrap tag if
possible).

Reviewers: atrick, regehr

Subscribers: mcrosier, mzolotukhin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265912 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-10 22:50:26 +00:00
Mehdi Amini
2187597b34 Plumb the option to emit the ModuleHash in the bitcode through the bitcode writer APIs
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265907 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-10 21:07:19 +00:00
Charles Davis
c15a907754 [CodeGen] Don't assume that fixed stack objects are aligned in a stack-realigned function.
Summary:
After we make the adjustment, we can assume that for local allocas, but
not for stack parameters, the return address, or any other fixed stack
object (which has a negative offset and therefore lies prior to the
adjusted SP).

Fixes PR26662.

Reviewers: hfinkel, qcolombet, rnk

Subscribers: rnk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265886 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-09 23:34:42 +00:00
JF Bastien
d28179ee17 Fix hash_integer_value
Broken in D18938 because underlying_type only works for enums and not all stdlibs are sad when given a non-enum. Bots error out with 'only enumeration types have underlying types'.

There's probably a clever enable_if-ism that I can do with underlying_type and the actual integer value, but is_integral_or_enum also accepts implicit conversion so I need to ponder my life choices a bit before committing to template magic. A quick fix for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265880 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-09 20:25:02 +00:00
JF Bastien
0b0b58f2c4 is_integral_or_enum ❥ enum class ⇒ hashable enum class
Summary:
As discussed in D18775 making AtomicOrdering an enum class makes it non-hashable, which shouldn't be the case. Hashing.h defines hash_value for all is_integral_or_enum, but type_traits.h's definition of is_integral_or_enum only checks for *inplicit* conversion to integral types which leaves enum classes out and is very confusing because is_enum is true for enum classes.

This patch:
  - Adds a check for is_enum when determining is_integral_or_enum.
  - Explicitly converts the value parameter in hash_value to handle enum class hashing.

Note that the warning at the top of Hashing.h still applies: each execution of the program has a high probability of producing a different hash_code for a given input. Thus their values are not stable to save or persist, and should only be used during the execution for the construction of hashing datastructures.

Reviewers: dberlin, chandlerc

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265879 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-09 20:04:34 +00:00
Sanjay Patel
b58a4e226b [x86] use BMI 'andn' for logic + compare ops
With BMI, we can use 'andn' to save an instruction when the result is only used in a compare.
This is related to one of the potential sequences to check 'isfinite' in:
https://llvm.org/bugs/show_bug.cgi?id=27164

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265875 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-09 16:02:52 +00:00
Adrian Prantl
48bb8b44d7 Support the Nodebug emission kind for DICompileUnits.
Sample-based profiling and optimization remarks currently remove
DICompileUnits from llvm.dbg.cu to suppress the emission of debug info
from them. This is somewhat of a hack and only borderline legal IR.

This patch uses the recently introduced NoDebug emission kind in
DICompileUnit to achieve the same result without breaking the Verifier.
A nice side-effect of this change is that it is now possible to combine
NoDebug and regular compile units under LTO.

http://reviews.llvm.org/D18808
<rdar://problem/25427165>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265861 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 22:43:03 +00:00
Sanjay Patel
7f8082cf9b fix documentation comments; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265855 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 21:42:43 +00:00
Tim Shen
1a7750eecd [SSP] Remove llvm.stackprotectorcheck.
This is a cleanup patch for SSP support in LLVM. There is no functional change.
llvm.stackprotectorcheck is not needed, because SelectionDAG isn't
actually lowering it in SelectBasicBlock; rather, it adds check code in
FinishBasicBlock, ignoring the position where the intrinsic is inserted
(See FindSplitPointForStackProtector()).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265851 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 21:26:31 +00:00
Kyle Butt
31fe4c9450 Codegen: Factor tail duplication into a utility class. NFC
This is in preparation for tail duplication during block placement. See D18226.
This needs to be a utility class for 2 reasons. No passes may run after block
placement, and also, tail-duplication affects subsequent layout decisions, so
it must be interleaved with placement, and can't be separated out into its own
pass. The original pass is still useful, and now runs by delegating to the
utility class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265842 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 20:35:01 +00:00
Duncan P. N. Exon Smith
287cd84a21 ValueMapper: Extract llvm::RemapFunction from IRMover.cpp, NFC
Strip out the remapping parts of IRLinker::linkFunctionBody and put them
in ValueMapper.cpp under the name Mapper::remapFunction (with a
top-level entry-point llvm::RemapFunction).

This is a nice cleanup on its own since it puts the remapping code
together and shares a single Mapper context for the entire
IRLinker::linkFunctionBody Call.  Besides that, this will make it easier
to break the co-recursion between IRMover.cpp and ValueMapper.cpp in
follow ups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265835 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 19:26:32 +00:00
Duncan P. N. Exon Smith
6ead16629e ValueMapper: Roll RemapInstruction into Mapper, NFC
Add Mapper::remapInstruction, move the guts of llvm::RemapInstruction
into it, and use the same Mapper for most of the calls to MapValue and
MapMetadata.  There should be no functionality change here.

I left off the call to MapValue that wasn't passing in a Materializer
argument (for basic blocks of PHINodes).  It shouldn't change
functionality either, but I'm suspicious enough to commit separately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265832 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 19:09:34 +00:00
Duncan P. N. Exon Smith
81361659c5 ValueMapper: Don't memoize metadata when RF_NoModuleLevelChanges
Prevent the Metadata side-table in ValueMap from growing unnecessarily
when RF_NoModuleLevelChanges.  As a drive-by, make ValueMap::hasMD,
which apparently had no users until I used it here for testing, actually
compile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265828 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 18:49:36 +00:00
Hans Wennborg
d8b70fb72f Revert r265547 "Recommit r265309 after fixed an invalid memory reference bug happened"
It caused PR27275: "ARM: Bad machine code: Using an undefined physical register"

Also reverting the following commits that were landed on top:
r265610 "Fix the compare-clang diff error introduced by r265547."
r265639 "Fix the sanitizer bootstrap error in r265547."
r265657 "InlineSpiller.cpp: Escap \@ in r265547. [-Wdocumentation]"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265790 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 15:17:43 +00:00
Silviu Baranga
d8cc816f81 Re-commit [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV
This re-commits r265535 which was reverted in r265541 because it
broke the windows bots. The problem was that we had a PointerIntPair
which took a pointer to a struct allocated with new. The problem
was that new doesn't provide sufficient alignment guarantees.
This pattern was already present before r265535 and it just happened
to work. To fix this, we now separate the PointerToIntPair from the
ExitNotTakenInfo struct into a pointer and a bool.

Original commit message:

Summary:
When the backedge taken codition is computed from an icmp, SCEV can
deduce the backedge taken count only if one of the sides of the icmp
is an AddRecExpr. However, due to sign/zero extensions, we sometimes
end up with something that is not an AddRecExpr.

However, we can use SCEV predicates to produce a 'guarded' expression.
This change adds a method to SCEV to get this expression, and the
SCEV predicate associated with it.

In HowManyGreaterThans and HowManyLessThans we will now add a SCEV
predicate associated with the guarded backedge taken count when the
analyzed SCEV expression is not an AddRecExpr. Note that we only do
this as an alternative to returning a 'CouldNotCompute'.

We use new feature in Loop Access Analysis and LoopVectorize to analyze
and transform more loops.

Reviewers: anemet, mzolotukhin, hfinkel, sanjoy

Subscribers: flyingforyou, mcrosier, atrick, mssimpso, sanjoy, mzolotukhin, llvm-commits

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265786 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 14:29:09 +00:00
Jeroen Ketema
9640ae7d9f [llvm-c] Expose LLVMContextGetDiagnostic{Handler,Context}
Differential Revision: http://reviews.llvm.org/D18820


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265773 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 09:19:02 +00:00
Duncan P. N. Exon Smith
41e362dd89 Reapply "ValueMapper: Treat LocalAsMetadata more like function-local Values"
This reverts commit r265765, reapplying r265759 after changing a call from
LocalAsMetadata::get to ValueAsMetadata::get (and adding a unit test).  When a
local value is mapped to a constant (like "i32 %a" => "i32 7"), the new debug
intrinsic operand may no longer be pointing at a local.

    http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_build/19020/

The previous coommit message follows:

--

This is a partial re-commit -- maybe more of a re-implementation -- of
r265631 (reverted in r265637).

This makes RF_IgnoreMissingLocals behave (almost) consistently between
the Value and the Metadata hierarchy.  In particular:

  - MapValue returns nullptr or "metadata !{}" for missing locals in
    MetadataAsValue/LocalAsMetadata bridging paris, depending on
    the RF_IgnoreMissingLocals flag.

  - MapValue doesn't memoize LocalAsMetadata-related results.

  - MapMetadata no longer deals with LocalAsMetadata or
    RF_IgnoreMissingLocals at all.  (This wasn't in r265631 at all, but
    I realized during testing it would make the patch simpler with no
    loss of generality.)

r265631 went too far, making both functions universally ignore
RF_IgnoreMissingLocals.  This broke building (e.g.) compiler-rt.
Reassociate (and possibly other passes) don't currently maintain
dominates-use invariants for metadata operands, resulting in IR like
this:

    define void @foo(i32 %arg) {
      call void @llvm.some.intrinsic(metadata i32 %x)
      %x = add i32 1, i32 %arg
    }

If the inliner chooses to inline @foo into another function, then
RemapInstruction will call `MapValue(metadata i32 %x)` and assert that
the return is not nullptr.

I've filed PR27273 to add a Verifier check and fix the underlying
problem in the optimization passes.

As a workaround, return `!{}` instead of nullptr for unmapped
LocalAsMetadata when RF_IgnoreMissingLocals is unset.  Otherwise, match
the behaviour of r265631.

Original commit message:

    ValueMapper: Make LocalAsMetadata match function-local Values

    Start treating LocalAsMetadata similarly to function-local members of
    the Value hierarchy in MapValue and MapMetadata.

      - Don't memoize them.
      - Return nullptr if they are missing.

    This also cleans up ConstantAsMetadata to stop listening to the
    RF_IgnoreMissingLocals flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265768 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 03:13:22 +00:00
Duncan P. N. Exon Smith
50c7f32d75 Revert "ValueMapper: Treat LocalAsMetadata more like function-local Values"
This reverts commit r265759, since even this limited version breaks some
bots:
  http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3311
  http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/17696

This also reverts r265761 "ValueMapper: Unduplicate
RF_NoModuleLevelChanges check, NFC", since I had trouble separating it
from r265759.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265765 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:56:21 +00:00
Quentin Colombet
2e5f81f19c [TargetRegisterInfo] Fix BitMaskClassIterator::moveToNextID implementation.
Make sure we do not read past the size of the mask. Although we were not using
the value read, this is bad and makes ASan complain.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265763 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:50:58 +00:00
Sanjoy Das
c9e3e3cbfd Don't IPO over functions that can be de-refined
Summary:
Fixes PR26774.

If you're aware of the issue, feel free to skip the "Motivation"
section and jump directly to "This patch".

Motivation:

I define "refinement" as discarding behaviors from a program that the
optimizer has license to discard.  So transforming:

```
void f(unsigned x) {
  unsigned t = 5 / x;
  (void)t;
}
```

to

```
void f(unsigned x) { }
```

is refinement, since the behavior went from "if x == 0 then undefined
else nothing" to "nothing" (the optimizer has license to discard
undefined behavior).

Refinement is a fundamental aspect of many mid-level optimizations done
by LLVM.  For instance, transforming `x == (x + 1)` to `false` also
involves refinement since the expression's value went from "if x is
`undef` then { `true` or `false` } else { `false` }" to "`false`" (by
definition, the optimizer has license to fold `undef` to any non-`undef`
value).

Unfortunately, refinement implies that the optimizer cannot assume
that the implementation of a function it can see has all of the
behavior an unoptimized or a differently optimized version of the same
function can have.  This is a problem for functions with comdat
linkage, where a function can be replaced by an unoptimized or a
differently optimized version of the same source level function.

For instance, FunctionAttrs cannot assume a comdat function is
actually `readnone` even if it does not have any loads or stores in
it; since there may have been loads and stores in the "original
function" that were refined out in the currently visible variant, and
at the link step the linker may in fact choose an implementation with
a load or a store.  As an example, consider a function that does two
atomic loads from the same memory location, and writes to memory only
if the two values are not equal.  The optimizer is allowed to refine
this function by first CSE'ing the two loads, and the folding the
comparision to always report that the two values are equal.  Such a
refined variant will look like it is `readonly`.  However, the
unoptimized version of the function can still write to memory (since
the two loads //can// result in different values), and selecting the
unoptimized version at link time will retroactively invalidate
transforms we may have done under the assumption that the function
does not write to memory.

Note: this is not just a problem with atomics or with linking
differently optimized object files.  See PR26774 for more realistic
examples that involved neither.

This patch:

This change introduces a new set of linkage types, predicated as
`GlobalValue::mayBeDerefined` that returns true if the linkage type
allows a function to be replaced by a differently optimized variant at
link time.  It then changes a set of IPO passes to bail out if they see
such a function.

Reviewers: chandlerc, hfinkel, dexonsmith, joker.eph, rnk

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265762 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:48:30 +00:00
Duncan P. N. Exon Smith
698c0a7097 ValueMapper: Treat LocalAsMetadata more like function-local Values
This is a partial re-commit -- maybe more of a re-implementation -- of
r265631 (reverted in r265637).

This makes RF_IgnoreMissingLocals behave (almost) consistently between
the Value and the Metadata hierarchy.  In particular:

  - MapValue returns nullptr or "metadata !{}" for missing locals in
    MetadataAsValue/LocalAsMetadata bridging paris, depending on
    the RF_IgnoreMissingLocals flag.

  - MapValue doesn't memoize LocalAsMetadata-related results.

  - MapMetadata no longer deals with LocalAsMetadata or
    RF_IgnoreMissingLocals at all.  (This wasn't in r265631 at all, but
    I realized during testing it would make the patch simpler with no
    loss of generality.)

r265631 went too far, making both functions universally ignore
RF_IgnoreMissingLocals.  This broke building (e.g.) compiler-rt.
Reassociate (and possibly other passes) don't currently maintain
dominates-use invariants for metadata operands, resulting in IR like
this:

    define void @foo(i32 %arg) {
      call void @llvm.some.intrinsic(metadata i32 %x)
      %x = add i32 1, i32 %arg
    }

If the inliner chooses to inline @foo into another function, then
RemapInstruction will call `MapValue(metadata i32 %x)` and assert that
the return is not nullptr.

I've filed PR27273 to add a Verifier check and fix the underlying
problem in the optimization passes.

As a workaround, return `!{}` instead of nullptr for unmapped
LocalAsMetadata when RF_IgnoreMissingLocals is unset.  Otherwise, match
the behaviour of r265631.

Original commit message:

    ValueMapper: Make LocalAsMetadata match function-local Values

    Start treating LocalAsMetadata similarly to function-local members of
    the Value hierarchy in MapValue and MapMetadata.

      - Don't memoize them.
      - Return nullptr if they are missing.

    This also cleans up ConstantAsMetadata to stop listening to the
    RF_IgnoreMissingLocals flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265759 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:33:44 +00:00
Quentin Colombet
437de15fe9 [RegisterBankInfo] Add print and dump method to the InstructionMapping
helper class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 23:31:58 +00:00
Quentin Colombet
b80cd97269 [RegisterBankInfo] Add print and dump method to the ValueMapping helper
class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265746 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 23:25:43 +00:00
Quentin Colombet
05e517fb2d [RegisterBankInfo] Escap \@ in r265741. [-Wdocumentation]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265742 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 23:08:52 +00:00
Quentin Colombet
0751f7f413 [RegisterBankInfo] Change the semantic of recordRegBankForType.
Now, recordRegBankForType records only the first register bank that
covers a type instead of the last. This behavior can, nevertheless, be
override with the additional Force parameter to force the update.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 23:02:00 +00:00
David Blaikie
a7f5efb254 llvm-dwarfdump: Use deque rather than vector to preserve object reference/pointer identity
TUs in each unit refer to the unit they are in, if the unit is moved
this reference is invalidated & things break.

No test case because UB isn't testable - ASan would likely catch this on
a large enough test case (just needs to have enough TUs that a
reallocation of the vector would occur) but didn't seem worthwhile. Up
for debate/revisiting if anyone feels strongly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265740 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 22:59:58 +00:00
Quentin Colombet
cea52301d3 [RegisterBankInfo] Add a way to record what register bank covers a
specific type.

This will be used to find the default mapping of the instruction.
Also, this information is recorded, instead of computed, because it is
expensive from a type to know which register bank maps it.
Indeed, we need to iterate through all the register classes of all the
register banks to find the one that maps the given type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265736 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 22:45:42 +00:00
Quentin Colombet
15fb12b7eb [RegisterBankInfo] Introduce getRegBankFromConstraints as an helper
method.

NFC.

The refactoring intends to make the code more readable and expose
more features to potential derived classes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265735 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 22:35:03 +00:00
Mehdi Amini
ca358261f0 Const correctness for BranchProbabilityInfo (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265731 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 21:59:28 +00:00
Quentin Colombet
12c70ede2c [TargetRegisterInfo] Introduce a helper class, BitMaskClassIterator, to
iterate over register class bitmask.

Thanks to this helper class, it would not require for each user of the
register classes bitmask to actually know how they are represents.
Moreover, it will make the code much easier to read.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265730 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 21:55:21 +00:00
Quentin Colombet
7880f4315b [RegBankSelect] Reuse RegisterBankInfo logic to get to the register bank
from a register.
On top of duplicating the logic, it was buggy! It would assert on
physical registers, since MachineRegisterInfo does not have any
information regarding register classes/banks for them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265727 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 21:32:23 +00:00
Quentin Colombet
cdc46058f6 [TargetRegisterInfo] Fix the comment of SuperRegClassIterator::getMask.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265721 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 21:04:30 +00:00
Quentin Colombet
e8aba9ba83 [GlobalISel] Add RegBankSelect hooks into the pass pipeline.
Now, RegBankSelect will happen after the IRTranslation and the target
may optionally add additional passes in between.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265716 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 20:27:33 +00:00
Quentin Colombet
13588d8354 [RegBankSelect] Initial implementation for non-optimized output.
The pass walk through the machine function and assign the register banks
using the default mapping. In other words, there is no attempt to reduce
cross register copies.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265707 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 18:19:27 +00:00
Quentin Colombet
f1b763c695 [RegisterBankInfo] Add more details on the expectation of
getInstrMapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265704 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 18:07:07 +00:00
Quentin Colombet
f9b131188b [RegisterBankInfo] Provide a target independent helper function to guess
the mapping of an instruction on register bank.

For most instructions, it is possible to guess the mapping of the
instruciton by using the encoding constraints.
It remains instructions without encoding constraints.
For copy-like instructions, we try to propagate the information we get
from the other operands. Otherwise, the target has to give this
information.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265703 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 18:01:19 +00:00
Quentin Colombet
83fadc56a6 [RegisterBankInfo] Change the signature of getSizeInBits to factor out
the access to MRI and TRI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265701 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 17:44:54 +00:00
Quentin Colombet
f77a6ecd34 [RegisterBankInfo] Provide a default constructor for InstructionMapping
helper class.

The default constructor creates invalid (isValid() == false) instances
and may be used to communicate that a mapping was not found.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265699 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 17:30:18 +00:00
Quentin Colombet
b92870665f [MachineRegisterInfo] Track register bank for virtual registers.
A virtual register may have either a register bank or a register class.
This is represented by a PointerUnion between the related classes.

Typically, a virtual register went through the following states
regarding register class and register bank:

1. Creation: None is set. Virtual registers are fully generic.
2. Register bank assignment: Register bank is set. Virtual registers
live into a register bank, but we do not know the constraints they need
to fulfil.
3. Instruction selection: Register class is set. Virtual registers are
bound by encoding constraints.

To map these states to GlobalISel, the IRTranslator implements #1,
RegBankSelect #2, and Select #3.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265696 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 17:20:29 +00:00
Quentin Colombet
8074e6007a [RegisterBank] Rename RegisterBank::contains into RegisterBank::covers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265695 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 17:09:39 +00:00
JF Bastien
fb9ead0bd9 NFC: disallow comparison of AtomicOrdering
Follow-up to D18775 and related clang change. AtomicOrdering is a lattice, 'stronger' is the right thing to do, direct comparison is fraught with peril.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265685 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 15:50:05 +00:00
Dmitry Polukhin
ba4922356c [GCC] Attribute ifunc support in llvm
This patch add support for GCC attribute((ifunc("resolver"))) for
targets that use ELF as object file format. In general ifunc is a
special kind of function alias with type @gnu_indirect_function. Patch
for Clang http://reviews.llvm.org/D15524

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265667 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 12:32:19 +00:00
Duncan P. N. Exon Smith
5c7a97c89b ValueMapper: Allow RF_IgnoreMissingLocals and RF_NullMapMissingGlobalValues
Remove the assertion that disallowed the combination, since
RF_IgnoreMissingLocals should have no effect on globals.  As it happens,
RF_NullMapMissingGlobalValues asserted in MapValue(Constant*,...), so I
also changed a cast to a cast_or_null to get my test passing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265633 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 01:22:45 +00:00
Duncan P. N. Exon Smith
fff8357845 IR: RF_IgnoreMissingValues => RF_IgnoreMissingLocals, NFC
Clarify what this RemapFlag actually means.

  - Change the flag name to match its intended behaviour.
  - Clearly document that it's not supposed to affect globals.
  - Add a host of FIXMEs to indicate how to fix the behaviour to match
    the intent of the flag.

RF_IgnoreMissingLocals should only affect the behaviour of
RemapInstruction for function-local operands; namely, for operands of
type Argument, Instruction, and BasicBlock.  Currently, it is *only*
passed into RemapInstruction calls (and the transitive MapValue calls
that it makes).

When I split Metadata from Value I didn't understand the flag, and I
used it in a bunch of places for "global" metadata.

This commit doesn't have any functionality change, but prepares to
cleanup MapMetadata and MapValue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265628 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 00:26:43 +00:00
Duncan P. N. Exon Smith
fb23bd1e2e ValueMapper: clang-format ValueMapper.h, NFC
Also remove duplicated identifiers from comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265611 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 22:37:30 +00:00
Peter Zotov
2a41371ff7 [llvm-c] Add LLVMGetValueKind.
Patch by Nicole Mazzuca <npmazzuca@gmail.com>.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265608 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 22:21:29 +00:00
Kevin Enderby
c6bf9be16d Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message
Produce the first specific error message for a malformed Mach-O file describing
the problem instead of the generic message for object_error::parse_failed of
"Invalid data was encountered while parsing the file”.  Many more good error
messages will follow after this first one.

This is built on Lang Hames’ great work of adding the ’Error' class for
structured error handling and threading Error through MachOObjectFile
construction.  And making createMachOObjectFile return Expected<...> .

So to to get the error to the llvm-obdump tool, I changed the stack of
these methods to also return Expected<...> :

  object::ObjectFile::createObjectFile()
  object::SymbolicFile::createSymbolicFile()
  object::createBinary()

Then finally in ParseInputMachO() in MachODump.cpp the error can
be reported and the specific error message can be printed in llvm-objdump
and can be seen in the existing test case for the existing malformed binary
but with the updated error message.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now use of
errorToErrorCode() and errorOrToExpected() are used where the callers
are yet to be converted.

Also there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comment:
“// TODO: Actually report errors helpfully” and a call something like
consumeError(ObjOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along
with this that I will commit right after this.  So expect lld not to built
after this commit and before the next one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265606 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 22:14:09 +00:00
Quentin Colombet
d50171b8c7 [RegisterBankInfo] Add methods to get the possible mapping of an instruction on a register bank.
This will be used by the register bank select pass to assign register banks
for generic virtual registers.

This was originally committed as r265573 but broke at least one windows bot.
The problem with the windows bot was that it was using a copy constructor for
the InstructionMappings class and could not synthesize it. Actually, the fact
that this class is not copy constructable is expected and the compiler should
use the move assignment constructor. Marking the problematic assignment
explicitly as using the move constructor has its own problems.

Indeed, with recent clang we get a warning that we may prevent the elision of
the copy by the compiler. A proper fix for both compilers would be to change the
API of getPossibleInstrMapping to take a InstructionMappings as input/output
parameter. This does not feel natural and since GISel is not used on windows
yet, I chose to workaround the problem by not compiling the problematic code on
windows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 21:37:22 +00:00
JF Bastien
b36d1a86f1 NFC: make AtomicOrdering an enum class
Summary:
In the context of http://wg21.link/lwg2445 C++ uses the concept of
'stronger' ordering but doesn't define it properly. This should be fixed
in C++17 barring a small question that's still open.

The code currently plays fast and loose with the AtomicOrdering
enum. Using an enum class is one step towards tightening things. I later
also want to tighten related enums, such as clang's
AtomicOrderingKind (which should be shared with LLVM as a 'C++ ABI'
enum).

This change touches a few lines of code which can be improved later, I'd
like to keep it as NFC for now as it's already quite complex. I have
related changes for clang.

As a follow-up I'll add:
  bool operator<(AtomicOrdering, AtomicOrdering) = delete;
  bool operator>(AtomicOrdering, AtomicOrdering) = delete;
  bool operator<=(AtomicOrdering, AtomicOrdering) = delete;
  bool operator>=(AtomicOrdering, AtomicOrdering) = delete;
This is separate so that clang and LLVM changes don't need to be in sync.

Reviewers: jyknight, reames

Subscribers: jyknight, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265602 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 21:19:33 +00:00
Nicolai Haehnle
ea7a0c0467 AMDGPU: Add a shader calling convention
This makes it possible to distinguish between mesa shaders
and other kernels even in the presence of compute shaders.

Patch By: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265589 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 19:40:20 +00:00
Quentin Colombet
e09831206a Revert "[RegisterBankInfo] Add methods to get the possible mapping of an
instruction on a register bank. This will be used by the register bank select
pass to assign register banks for generic virtual registers." and the follow-on
commits while I find out a way to fix the win7 bot:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/19882

This reverts commit r265578, r265581, r265584, and r265585.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265587 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 19:04:58 +00:00
Quentin Colombet
0fad13dc00 [RegisterBankInfo] Get rid of the assert in the constructor of InstructionMapping.
The default constructor now uses the regular constructor and the assert
is not valid anymore.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 18:43:46 +00:00
Quentin Colombet
d030a6cdd9 [RegisterBankInfo] Call the other constructor of InstructionMapping from the
default constructor, instead of relying on the default constructor of
unique_ptr.

Second attempt at fixing the windows bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265584 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 18:37:44 +00:00
Evgeniy Stepanov
d8c5d5c30e [gold] Save bitcode for module partitions (save-temps + split codegen).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265583 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 18:32:13 +00:00
Quentin Colombet
fe58f90a22 [RegisterBankInfo] Provide a default constructor for InstructionMapping
helper class.

The default constructor creates invalid (isValid() == false) instances
and may be used to communicate that a mapping was not found.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265581 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 18:24:34 +00:00
Duncan P. N. Exon Smith
a15c0e9ce0 IR: Use DenseSet instead of DenseMap for ConstantUniqueMap; NFC
Use a DenseSet instead of a DenseMap for constants in LLVMContextImpl.
Last time I looked at this was some time before r223588, when
DenseSet<V> had no advantage over DenseMap<V,char>.  After r223588,
there's a 50% memory savings.

This is all mechanical.  There were little bits of missing API from
DenseSet so I added the trivial implementations:

  - iterator::operator++(int)
  - template <class LookupKeyT> insert_as(ValueTy, LookupKeyT)

There should be no functionality change, just reduced memory consumption
(this wasn't on a profile or anything; just a cleanup I stumbled on).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265577 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 17:56:08 +00:00
Quentin Colombet
b5dd9acfff [RegisterBankInfo] Add a method to get the mapping RegClass -> RegBank.
This should be TableGen'ed at some point.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265574 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 17:51:41 +00:00
Quentin Colombet
4bbf81ac57 [RegisterBankInfo] Add methods to get the possible mapping of an instruction on a register bank.
This will be used by the register bank select pass to assign register banks
for generic virtual registers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265573 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 17:45:40 +00:00
Quentin Colombet
12ea314247 [RegisterBankInfo] Make the destructor public... that may be useful!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265565 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 17:09:34 +00:00
Quentin Colombet
e33ae0279e [RegisterBankInfo] Implement the verify method of the InstructionMapping helper class.
This checks that all the register operands get a proper mapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265563 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 17:01:43 +00:00
Fiona Glaser
a4b0d0e4db Loop Unroll: add options and tweak to make Partial unrolling more useful
1. Add FullUnrollMaxCount option that works like MaxCount, but also limits
   the unroll count for fully unrolled loops. So if a loop has an iteration
   count over this, it won't fully unroll.
2. Add CLI options for MaxCount and the new option, so they can be tested
   (plus a test).
3. Make partial unrolling obey MaxCount.

An example use-case (the out of tree one this is originally designed for) is
a target’s TTI can analyze a loop and decide on a max unroll count separate
from the size threshold, e.g. based on register pressure, then constrain
LoopUnroll to not exceed that, regardless of the size of the unrolled loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265562 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 16:57:25 +00:00
Quentin Colombet
a80c06540f [MachineRegisterInfo] Document what is the expected metric for the size of generic registers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265561 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 16:51:04 +00:00
Quentin Colombet
560a956259 [RegisterBankInfo] Implement the verify method for the ValueMapping helper class.
The method checks that the value is fully defined accross the different partial
mappings and that the partial mappings are compatible between each other.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265556 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 16:40:23 +00:00
Quentin Colombet
6f5e1e215f [RegisterBankInfo] Add a verify method for the PartialMapping helper class.
This verifies that the PartialMapping can be accomadated into the related
register bank.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265555 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 16:33:26 +00:00
Quentin Colombet
67f02253c9 [RegisterBankInfo] Add a couple of helper classes for the future cost model.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265553 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 16:27:01 +00:00
Quentin Colombet
bc6e9634c0 [RegisterBankInfo] Inline the destructor to avoid link-time error when GlobalISel is not built.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265548 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 15:47:17 +00:00
Wei Mi
1145b58255 Recommit r265309 after fixed an invalid memory reference bug happened
when DenseMap growed and moved memory. I verified it fixed the bootstrap
problem on x86_64-linux-gnu but I cannot verify whether it fixes
the bootstrap error on clang-ppc64be-linux. I will watch the build-bot
result closely.

Replace analyzeSiblingValues with new algorithm to fix its compile
time issue. The patch is to solve PR17409 and its duplicates.

analyzeSiblingValues is a N x N complexity algorithm where N is
the number of siblings generated by reg splitting. Although it
causes siginificant compile time issue when N is large, it is also
important for performance since it removes redundent spills and
enables rematerialization.

To solve the compile time issue, the patch removes analyzeSiblingValues
and replaces it with lower cost alternatives containing two parts. The
first part creates a new spill hoisting method in postOptimization of
register allocation. It does spill hoisting at once after all the spills
are generated instead of inside every instance of selectOrSplit. The
second part queries the define expr of the original register for
rematerializaiton and keep it always available during register allocation
even if it is already dead. It deletes those dead instructions only in
postOptimization. With the two parts in the patch, it can remove
analyzeSiblingValues without sacrificing performance.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 15:41:07 +00:00
Silviu Baranga
89e8236bfb Revert r265535 until we know how we can fix the bots
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265541 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 14:06:32 +00:00
Silviu Baranga
39fbde60e1 [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV
Summary:
When the backedge taken codition is computed from an icmp, SCEV can
deduce the backedge taken count only if one of the sides of the icmp
is an AddRecExpr. However, due to sign/zero extensions, we sometimes
end up with something that is not an AddRecExpr.

However, we can use SCEV predicates to produce a 'guarded' expression.
This change adds a method to SCEV to get this expression, and the
SCEV predicate associated with it.

In HowManyGreaterThans and HowManyLessThans we will now add a SCEV
predicate associated with the guarded backedge taken count when the
analyzed SCEV expression is not an AddRecExpr. Note that we only do
this as an alternative to returning a 'CouldNotCompute'.

We use new feature in Loop Access Analysis and LoopVectorize to analyze
and transform more loops.

Reviewers: anemet, mzolotukhin, hfinkel, sanjoy

Subscribers: flyingforyou, mcrosier, atrick, mssimpso, sanjoy, mzolotukhin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265535 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 13:18:26 +00:00
Duncan P. N. Exon Smith
e49dfa7e9a IRMover: Steal arguments when moving functions, NFC
Instead of copying arguments from the source function to the
destination, steal them.  This has a few advantages.

  - The ValueMap doesn't need to be seeded with (or cleared of)
    Arguments.

  - Often the destination function won't have created any arguments yet,
    so this avoids malloc traffic.

  - Argument names don't need to be copied.

Because argument lists are lazy, this required a new
Function::stealArgumentListFrom helper.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265519 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 06:38:15 +00:00
Matthias Braun
dc2f859a3f RegisterScavenger: Take a reference as enterBasicBlock() argument.
Make it obvious that the argument cannot be nullptr.
Remove an unnecessary nullptr check in initRegState.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 02:47:09 +00:00
Matthias Braun
72b4fa0d1c LivePhysRegs: removeReg() must remove aliased registers
We must remove all aliased registers which may be more than the all sub
and super registers combined.

Bug found while reading the code. The bug does not affect any existing
target as the only use of register aliases I could found were control
registers on ARM and Hexagon which are all reserved.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265510 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 02:46:35 +00:00
Quentin Colombet
c37faf21d0 [RegisterBankInfo] Include RegisterBank.h.
We actually need the definition of a RegisterBank to be able to inline
the implementation of the subscript operator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265492 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 23:57:25 +00:00
Quentin Colombet
717601810e [RegisterBankInfo] Add missing include for assert.
This should appease the linux bot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265491 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 23:43:58 +00:00
Quentin Colombet
6443af0d08 [RegisterBankInfo] Simplify the API for build a register bank.
As part of the TRI argument of addRegBankCoverage we already have access to
the TargetRegisterClass through the ID of that register class.
Therefore, there is no point in needing a TargetRegisterClass instance,
the ID is enough to get to it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265487 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 23:26:39 +00:00
Quentin Colombet
5a3e3ec846 [Target] Remove a deprecated comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265484 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 23:04:54 +00:00
Quentin Colombet
ca7369ade3 [Target] Add an accessor to the register bank information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265483 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 22:50:40 +00:00
Evgeniy Stepanov
9c4431f3cb Faster stack-protector for Android/AArch64.
Bionic has a defined thread-local location for the stack protector
cookie. Emit a direct load instead of going through __stack_chk_guard.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265481 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 22:41:50 +00:00
Quentin Colombet
6077d14b60 [RegisterBank] Add printable capabilities for future debugging.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265473 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 21:40:43 +00:00
Quentin Colombet
ccd741b08a [RegisterBankInfo] Make addRegBankCoverage more capable to ease
targeting jobs.
Now, addRegBankCoverage also adds the subreg-classes not just the
sub-classes of the given register class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265469 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 21:20:12 +00:00
Duncan P. N. Exon Smith
d7773c0d39 IR: Introduce ConstantAggregate, NFC
Add a common parent class for ConstantArray, ConstantVector, and
ConstantStruct called ConstantAggregate.  These are the aggregate
subclasses of Constant that take operands.

This is mainly a cleanup, adding common `isa` target and removing
duplicated code.  However, it also simplifies caching which constants
point transitively at `GlobalValue` (a possible future direction).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 21:10:45 +00:00
Quentin Colombet
062bf7c9dd [RegisterBankInfo] Implement the methods to create register banks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265464 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 21:06:15 +00:00
Quentin Colombet
aa40fb64ae [RegisterBank] Provide a way to check if a register bank is valid.
Change the default constructor to create invalid object.
The target will have to properly initialize the register banks before
using them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265460 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 20:48:32 +00:00
Duncan P. N. Exon Smith
f45d3278d3 Make constructors for final subclasses of Constant private, NFC
These were `protected` before, but might as well be `private`.  Also
marked the classes themselves `final`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 20:31:23 +00:00
Quentin Colombet
cdf87d0168 [TargetRegisterClass] Improve the comment for how to use getSubClassMask.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265455 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 20:21:53 +00:00
Quentin Colombet
baea9b2a9a [GlobalISel] Add the RegisterBankInfo class for the handling of register banks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265449 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 20:02:47 +00:00
Lang Hames
c224d81083 [Support] Add a checked flag to Expected<T>, require checks before access or
destruction.

This makes the Expected<T> class behave like Error, even when in success mode.
Expected<T> values must be checked to see whether they contain an error prior
to being dereferenced, assigned to, or destructed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265446 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 19:57:03 +00:00
Quentin Colombet
9b710764b9 [GlobalISel] Add a class, RegisterBank, to represent register banks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265445 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 19:54:44 +00:00
Quentin Colombet
278bb5de48 [GlobalISel] Add the skeleton of the RegBankSelect pass.
This pass is reponsible for assigning the generic virtual registers to register
banks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265440 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 19:06:01 +00:00
Lang Hames
8a1ae616c9 [Support] clang-format Error.h.
This tidies up the ExitOnError class and some other recently added code. NFC.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265438 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 18:50:09 +00:00
Manman Ren
2bf0ebe961 Swift Calling Convention: swifterror target-independent change.
At IR level, the swifterror argument is an input argument with type
ErrorObject**. For targets that support swifterror, we want to optimize it
to behave as an inout value with type ErrorObject*; it will be passed in a
fixed physical register.

The main idea is to track the virtual registers for each swifterror value. We
define swifterror values as AllocaInsts with swifterror attribute or a function
argument with swifterror attribute.

In SelectionDAGISel.cpp, we set up swifterror values (SwiftErrorVals) before
handling the basic blocks.

When iterating over all basic blocks in RPO, before actually visiting the basic
block, we call mergeIncomingSwiftErrors to merge incoming swifterror values when
there are multiple predecessors or to simply propagate them. There, we create a
virtual register for each swifterror value in the entry block. For predecessors
that are not yet visited, we create virtual registers to hold the swifterror
values at the end of the predecessor. The assignments are saved in
SwiftErrorWorklist and will be materialized at the end of visiting the basic
block.

When visiting a load from a swifterror value, we copy from the current virtual
register assignment. When visiting a store to a swifterror value, we create a
virtual register to hold the swifterror value and update SwiftErrorMap to
track the current virtual register assignment.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265433 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 18:13:16 +00:00
Rafael Espindola
00d9a04525 Use ArrayRef for contiguous areas in ELF. NFC.
This just simplifies the code a bit. More so in lld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265403 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 14:47:22 +00:00
Rafael Espindola
c5c3d28dda Centralize the definition of a few types. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265399 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 14:10:18 +00:00
Peter Zotov
2b8aed70d6 [llvm-c] Expose LLVM{Get,Set}ModuleIdentifier
Patch by Nicole Mazzuca <npmazzuca@gmail.com>.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265394 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 13:56:59 +00:00
David L Kreitzer
51dcabbf7c Adds the ability to use an epilog remainder loop during loop unrolling and makes
this the default behavior.

Patch by Evgeny Stupachenko (evstupac@gmail.com).

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265388 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 12:19:35 +00:00
Tamas Berghammer
2b45afffa0 Set the thumb flag for thumb symbols coming from an ELF file
Without setting the flag there is no way to determine if a symbol
points to an arm or to a thumb function as the LSB of the address
masked out in all getter function.

Note: Currently the thumb flag is only used for MachO files so
adding a test to this change is not possible. It will be used
by the upcoming fix for llvm-objdump for disassembling thumb
functions what is easily testable.

Differential revision: http://reviews.llvm.org/D17956

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265387 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 12:11:40 +00:00
Dmitry Polukhin
51a06a2c66 [IFUNC] Use GlobalIndirectSymbol when aliases and ifuncs have something similar
Second part extracted from http://reviews.llvm.org/D15525

Use GlobalIndirectSymbol in all cases when aliases and ifuncs have
something in common.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265382 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 08:47:51 +00:00
Teresa Johnson
3890d33905 [ThinLTO] Refactor some common code into getGlobalValueInfo method (NFC)
Refactor common code that queries the ModuleSummaryIndex for a value's
GlobalValueInfo struct into getGlobalValueInfo helper methods, which
will also be used by D18763.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265370 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 00:40:16 +00:00
Amaury Sechet
45cace0d9a Style update in Core.h/Core.cpp . NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265353 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 22:00:25 +00:00
Matthias Braun
bac1dd9d54 ARM, AArch64, X86: Check preserved registers for tail calls.
We can only perform a tail call to a callee that preserves all the
registers that the caller needs to preserve.

This situation happens with calling conventions like preserver_mostcc or
cxx_fast_tls. It was explicitely handled for fast_tls and failing for
preserve_most. This patch generalizes the check to any calling
convention.

Related to rdar://24207743

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265329 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 18:56:13 +00:00
Sanjay Patel
3555f1fd3b fix documentation comments; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265321 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 18:25:06 +00:00
Derek Schuff
cfaa4e0890 Replace MachineRegisterInfo::isSSA() with a MachineFunctionProperty
Use the MachineFunctionProperty mechanism to indicate whether a MachineFunction
is in SSA form instead of a custom method on MachineRegisterInfo. NFC

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265318 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 18:03:29 +00:00
Wei Mi
e19a68b607 Revert r265309 and r265312 because they caused some errors I need to investigate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265317 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 17:45:03 +00:00
Wei Mi
d31cb9b5c5 Replace analyzeSiblingValues with new algorithm to fix its compile
time issue. The patch is to solve PR17409 and its duplicates.

analyzeSiblingValues is a N x N complexity algorithm where N is
the number of siblings generated by reg splitting. Although it
causes siginificant compile time issue when N is large, it is also
important for performance since it removes redundent spills and
enables rematerialization.

To solve the compile time issue, the patch removes analyzeSiblingValues
and replaces it with lower cost alternatives containing two parts. The
first part creates a new spill hoisting method in postOptimization of
register allocation. It does spill hoisting at once after all the spills
are generated instead of inside every instance of selectOrSplit. The
second part queries the define expr of the original register for
rematerializaiton and keep it always available during register allocation
even if it is already dead. It deletes those dead instructions only in
postOptimization. With the two parts in the patch, it can remove
analyzeSiblingValues without sacrificing performance.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265309 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 16:42:40 +00:00
NAKAMURA Takumi
6bb99d27bb Fixup r265277 [-Wdocumentation]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265290 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 11:54:48 +00:00
Elena Demikhovsky
bd28e703b1 AVX-512: Truncating store for i1 vectors
Implemented truncstore for KNL and skylake-avx512.
Covered vectors from v2i1 to v64i1. We save the value in bits (not in bytes) - v32i1 is saved in 4 bytes.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265283 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 07:17:47 +00:00
Duncan P. N. Exon Smith
0568c3d1ac IR: Lazily create ReplaceableMetadataImpl on MDNode
RAUW support on MDNode usually requires an extra allocation for
ReplaceableMetadataImpl.  This is only strictly necessary if there are
tracking references to the MDNode.  Make the construction of
ReplaceableMetadataImpl lazy, so that we don't get allocations if we
don't need them.

Since MDNode::isResolved now checks MDNode::isTemporary and
MDNode::NumUnresolved instead of whether a ReplaceableMetadataImpl is
allocated, the internal changes are intrusive (at various internal
checkpoints, isResolved now has a different answer).

However, there should be no real functionality change here; just
slightly lazier allocation behaviour.  The external semantics should be
identical.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265279 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-03 21:23:52 +00:00
Duncan P. N. Exon Smith
14009479b5 IR: Make MDNode::Context private, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265278 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-03 21:10:00 +00:00
Amaury Sechet
7527b8c02a Various style fix in Core.h/Core.cpp . NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265277 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-03 21:06:04 +00:00
Duncan P. N. Exon Smith
23e40368ee ValueMapper: Disallow metadata mapping recursion through mapValue
This adds an assertion to maintain the property from r265273.  When
Mapper::mapSimpleMetadata calls Mapper::mapValue, it should not find its
way back to mapMetadataImpl.  This guarantees that mapSimpleMetadata is
not involved in any recursion.

Since Mapper::mapValue calls out to arbitrary materializers, we need to
save a bit on the ValueMap to make this assertion effective.

There should be no functionality change here.  This co-recursion should
already have been impossible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265276 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-03 20:54:51 +00:00
Duncan P. N. Exon Smith
f9fa1559e5 Linker: Remove IRMover::isMetadataUnneeded indirection; almost NFC
Instead of checking live during MapMetadata whether a subprogram is
needed, seed the ValueMap with `nullptr` up-front.

There is a small hypothetical functionality change.  Previously, calling
MapMetadataOp on a node whose "scope:" chain led to an unneeded
subprogram would return nullptr.  However, if that were ever called,
then the subprogram would be needed; a situation that the IRMover is
supposed to avoid a priori!

Besides cleaning up the code a little, this restores a nice property:
MapMetadataOp returns the same as MapMetadata.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265229 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 17:12:00 +00:00
Duncan P. N. Exon Smith
eeb2c7e32c ValueMapper: Add support for seeding metadata with nullptr
Support seeding a ValueMap with nullptr for Metadata entries, a
situation I didn't consider in the Metadata/Value split.

I added a ValueMapper::getMappedMD accessor that returns an
Optional<Metadata*> with the mapped (possibly null) metadata.  IRMover
needs to use this to avoid modifying the map when it's checking for
unneeded subprograms.  I updated a call from bugpoint since I find the
new code clearer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265228 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 17:04:38 +00:00
Mehdi Amini
398341689b constify GlobalValue::getGUID() and GlobalValue::getGlobalIdentifier() (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265217 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 05:25:27 +00:00
Mehdi Amini
b659366e9e Revert "ThinLTO: add module caching handling."
This reverts commit r265214, unintentionally commited.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265216 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 05:08:18 +00:00
Mehdi Amini
5f76ad9dd7 Create a typedef GlobalValue::GUID for uint64_t and RAUW (NFC)
Summary: This should make the code more readable, especially all the map declarations.

Reviewers: tejohnson

Subscribers: llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265215 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 05:07:53 +00:00
Mehdi Amini
4ac4b88b38 ThinLTO: add module caching handling.
Reviewers: tejohnson

Subscribers: llvm-commits, joker.eph

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265214 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 05:07:08 +00:00
Mehdi Amini
64a77d0033 Rename Context::discardValueNames() to shouldDiscardValueNames() (NFC)
Suggested by Sean Silva.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265211 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 03:46:17 +00:00
Mehdi Amini
22706dc4c0 Add Cache Pruning support
Incremental LTO will usea cache to store object files.
This patch handles the pruning part of the cache, exposing
a few knobs:

- Pruning interval: the implementation keeps a "timestamp" file in the
  directory and will scan it only after a given interval since the
  last modification of the timestamp file. This is for performance
  purpose, we don't want to scan continuously the folder.
- Entry expiration: this is the time after which a file that hasn't
  been used is remove from the cache.
- Maximum size: expressed in percentage of the available disk space,
  it helps to avoid that we blow up the disk space.

http://reviews.llvm.org/D18422

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265209 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 03:28:26 +00:00
Manman Ren
4bda882517 Swift Calling Convention: add swifterror attribute.
A ``swifterror`` attribute can be applied to a function parameter or an
AllocaInst.

This commit does not include any target-specific change. The target-specific
optimization will come as a follow-up patch.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265189 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 21:41:15 +00:00
Rong Xu
ba623ac1b5 Fix buildbot lldb-amd64-ninja-netbsd7 failure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265180 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 20:15:04 +00:00
Peter Collingbourne
302882987a LowerBitSets: Move declarations to separate namespace.
Should fix modules build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265176 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 18:46:50 +00:00
Rong Xu
a7f5174cd1 [PGO] Refactor PGOFuncName meta data code to be used in clang
Refactor the code that gets and creates PGOFuncName meta data so that it can be
used in clang's value profile annotation.

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





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265149 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 16:43:30 +00:00
Benjamin Kramer
c9fc333558 [ADT] Make StringMap's tombstone aligned.
This avoids undefined behavior when casting pointers to it. Also make
sure that we don't cast to a derived StringMapEntry before checking for
tombstone, as that may have different alignment requirements.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265145 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 15:51:51 +00:00
Benjamin Kramer
db555c94db [ThinLTO] Fix uninitialized flags.
Found by msan. Patch by Adrian Kuegel!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265133 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 11:49:59 +00:00
Mehdi Amini
51f5548e2a Add a libLTO API to stop/restart ThinLTO between optimizations and CodeGen
This allows the linker to instruct ThinLTO to perform only the
optimization part or only the codegen part of the process.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265113 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 06:47:02 +00:00
Mehdi Amini
d2f4701e4a Add a module Hash in the bitcode and the combined index, implementing a kind of "build-id"
This is intended to be used for ThinLTO incremental build.

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

This is a recommit of r265095 after fixing the Windows issues.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265111 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 05:33:11 +00:00
Mehdi Amini
167ce3f176 Const correctness in raw_sha1_ostream (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265108 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 05:12:18 +00:00
Mehdi Amini
74c634c6b8 Add support for computing SHA1 in LLVM
Provide a class to generate a SHA1 from a sequence of bytes, and
a convenience raw_ostream adaptor.
This will be used to provide a "build-id" by hashing the Module
block when writing bitcode. ThinLTO will use this information for
incremental build.

Reapply r265094 which was reverted in r265102 because it broke
MSVC bots (constexpr is not supported).

http://reviews.llvm.org/D16325

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265107 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 04:30:16 +00:00
Mehdi Amini
1fc660ff51 Revert "Add support for computing SHA1 in LLVM"
This reverts commit r265096, r265095, and r265094.
Windows build is broken, and the validation does not pass.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265102 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 03:03:21 +00:00
Mehdi Amini
515396cd38 Add a module Hash in the bitcode and the combined index, implementing a kind of "build-id"
This is intended to be used for ThinLTO incremental build.

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265095 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 01:30:06 +00:00
Mehdi Amini
696fe52985 Add support for computing SHA1 in LLVM
Provide a class to generate a SHA1 from a sequence of bytes, and
a convenience raw_ostream adaptor.
This will be used to provide a "build-id" by hashing the Module
block when writing bitcode. ThinLTO will use this information for
incremental build.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265094 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 01:29:54 +00:00
Akira Hatanaka
5fe8a3c994 [LoopVectorize] Don't unconditionally print vectorization diagnostics
when compiling with LTO.

r244523 a new class DiagnosticInfoOptimizationRemarkAnalysisAliasing for
optimization analysis remarks related to pointer aliasing without
guarding it in isDiagnosticEnabled in LLVMContext.cpp. This caused the
diagnostic message to be printed unconditionally when compiling with
LTO.

This commit cleans up isDiagnosticEnabled and makes sure all the
vectorization optimization remarks are guarded.

rdar://problem/25382153


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 00:34:39 +00:00
Mehdi Amini
e744acb2dd Add disk_space() to llvm::fs
Summary: Adapted from Boost::filesystem.
(This is a reapply by reverting commit r265080 and fixing the WinAPI part)

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265082 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 00:18:08 +00:00
Mehdi Amini
120652acc2 Revert "Add disk_space() to llvm::fs"
This reverts commit r265074 and r265068.
Breaks windows build

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265080 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 00:13:31 +00:00
Adrian Prantl
4964c02fbc Fix a captialization error in r265077.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265079 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 00:00:27 +00:00
Adrian Prantl
39bb84a097 Move the DebugEmissionKind enum from DIBuilder into DICompileUnit.
This mostly cosmetic patch moves the DebugEmissionKind enum from DIBuilder
into DICompileUnit. DIBuilder is not the right place for this enum to live
in — a metadata consumer should not have to include DIBuilder.h.
I also added a Verifier check that checks that the emission kind of a
DICompileUnit is actually legal.

http://reviews.llvm.org/D18612
<rdar://problem/25427165>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265077 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 23:56:58 +00:00
Mehdi Amini
ca1975ce41 clang-format the large enum definitions in LLVMBitCodes.h
Suggestion from Duncan in a review thread.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265075 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 23:27:37 +00:00
Mehdi Amini
3ddee86990 Use const ref instead of value for Twine in the disk_space() API
Thanks Rui for noticing!

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265074 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 23:14:45 +00:00
Mehdi Amini
f5e9ba6d1c Add disk_space() to llvm::fs
Summary: Adapted from Boost::filesystem.
(This is a reapply by reverting commit r265062 and fixing the WinAPI part)

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265068 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 23:05:26 +00:00
Peter Collingbourne
6ddf7daf8d Object: Add function for moving thin archive object buffer vector out of Archive.
Differential Revision: http://reviews.llvm.org/D18664

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265066 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 22:08:57 +00:00
Mehdi Amini
99811fe3c4 Revert "Add disk_space() to llvm::fs"
Breaks windows bot.
This reverts commit r265050.
This reverts commit r265055.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 21:55:35 +00:00
David Majnemer
54136ef7b3 [NVPTX] Infer __nvvm_reflect as nounwind, readnone
This patch simply mirrors the attributes we give to @llvm.nvvm.reflect
to the __nvvm_reflect libdevice call.  This shaves about 30% of the code
in libdevice away because of CSE opportunities.  It's also helps us
figure out that libdevice implementations of transcendental functions
don't have side-effects.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265060 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 21:29:57 +00:00
Simon Pilgrim
c7e42230b0 Wdocumentation parameter fix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265055 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 21:13:49 +00:00
Simon Pilgrim
1efc1b65d6 Fixed signed/unsigned warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265052 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 20:57:36 +00:00
Mehdi Amini
9bba5e5a48 Add disk_space() to llvm::fs
Summary: Adapted from Boost::filesystem.

Reviewers: bruno, silvas

Subscribers: tberghammer, danalbert, llvm-commits, srhines

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265050 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 20:48:27 +00:00
Hans Wennborg
f864a32c13 Change eliminateCallFramePseudoInstr() to return an iterator
This will become necessary in a subsequent change to make this method
merge adjacent stack adjustments, i.e. it might erase the previous
and/or next instruction.

It also greatly simplifies the calls to this function from Prolog-
EpilogInserter. Previously, that had a bunch of logic to resume iteration
after the call; now it just continues with the returned iterator.

Note that this changes the behaviour of PEI a little. Previously,
it attempted to re-visit the new instruction created by
eliminateCallFramePseudoInstr(). That code was added in r36625,
but I can't see any reason for it: the new instructions will obviously
not be pseudo instructions, they will not have FrameIndex operands,
and we have already accounted for the stack adjustment.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265036 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 18:33:38 +00:00
Dmitry Polukhin
dc022bad27 [IFUNC] Introduce GlobalIndirectSymbol as a base class for alias and ifunc
This patch is a part of http://reviews.llvm.org/D15525

GlobalIndirectSymbol class contains common implementation for both
aliases and ifuncs. This patch should be NFC change that just prepare
common code for ifunc support.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265016 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 14:16:21 +00:00