Commit Graph

251926 Commits

Author SHA1 Message Date
Eric Fiselier faf2a81380 Diagnose invalid memory orderings in <atomic>
llvm-svn: 291976
2017-01-13 23:45:39 +00:00
Sanjay Patel 40f401776b [InstCombine] optimize unsigned icmp of increment
Allows LLVM to optimize sequences like the following:

%add = add nuw i32 %x, 1
%cmp = icmp ugt i32 %add, %y

Into:

%cmp = icmp uge i32 %x, %y

Previously, only signed comparisons were being handled.

Decrements could also be handled, but 'sub nuw %x, 1' is currently canonicalized to
'add %x, -1' in InstCombineAddSub, losing the nuw flag. Removing that canonicalization
seems like it might have far-reaching ramifications so I kept this simple for now.

Patch by Matti Niemenmaa!

Differential Revision: https://reviews.llvm.org/D24700

llvm-svn: 291975
2017-01-13 23:25:46 +00:00
Daniel Jasper e61f9f9949 clang-format: Fix bug in making line break decisions.
Here, the optimization to not line wrap when it would not lead to a
reduction in columns was overwriting and enforced break that we want to
do no matter what.

Before:
  int i = someFunction(
              aaaaaaa,
              0).aaa(aaaaaaaaaaaaa) *
              aaaaaaa +
          aaaaaaa;

After:
  int i = someFunction(aaaaaaa, 0)
                  .aaa(aaaaaaaaaaaaa) *
              aaaaaaa +
          aaaaaaa;

llvm-svn: 291974
2017-01-13 23:18:16 +00:00
Tim Northover 2b57987827 [GlobalISel] track predecessor mapping during switch lowering.
Correctly populating Machine PHIs relies on knowing exactly how the IR level
CFG was lowered to MachineIR. This needs to be tracked by any translation
phases that meddle (currently only SwitchInst handling).

llvm-svn: 291973
2017-01-13 23:11:37 +00:00
Sanjay Patel 2d4b456427 [InstCombine] use m_APInt to allow lshr folds for vectors with splat constants
llvm-svn: 291972
2017-01-13 23:04:10 +00:00
Sanjay Patel d511dde2ec [InstCombine / InstSimplify] add and move tests for lshr transforms; NFC
llvm-svn: 291970
2017-01-13 22:54:12 +00:00
Eric Fiselier 04333f9bda Diagnose non-const-callable hash functions and comparators
llvm-svn: 291969
2017-01-13 22:42:53 +00:00
Daniel Berlin c0431fd02d NewGVN: Move leaders around properly to ensure we have a canonical dominating leader. Fixes PR 31613.
Summary:
This is a testcase where phi node cycling happens, and because we do
not order the leaders by domination or anything similar, the leader
keeps changing.

Using std::set for the members is too expensive, and we actually don't
need them sorted all the time, only at leader changes.

We could keep both a set and a vector, and keep them mostly sorted and
resort as necessary, or use a set and a fibheap, but all of this seems
premature.

After running some statistics, we are able to avoid the vast majority
of sorting by keeping a "next leader" field.  Most congruence classes only have
leader changes once or twice during GVN.

Reviewers: davide

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28594

llvm-svn: 291968
2017-01-13 22:40:01 +00:00
Greg Clayton c109bbea57 Add a variant of DWARFDie::find() and DWARFDie::findRecursively() that takes a llvm::ArrayRef<dwarf::Attribute>.
This allows us efficiently look for more than one attribute, something that is quite common in DWARF consumption.

Differential Revision: https://reviews.llvm.org/D28704

llvm-svn: 291967
2017-01-13 22:32:12 +00:00
David Majnemer bba17390c7 [LoopStrengthReduce] Don't bother rewriting PHIs in catchswitch blocks
The catchswitch instruction cannot be split, don't bother trying to
rewrite it.

This fixes PR31627.

llvm-svn: 291966
2017-01-13 22:24:27 +00:00
David Majnemer e0ebdf4bc7 [CodeGen] Simplify getRecipEstimateForFunc
It used two attribute lookups when only one was needed.

llvm-svn: 291965
2017-01-13 22:24:25 +00:00
Richard Smith 509bbd1a66 PR31631: fix bad CFG (and bogus warnings) when an if-statement has an init-statement and has binary operator as its condition.
llvm-svn: 291964
2017-01-13 22:16:41 +00:00
Eric Fiselier 251099171f [clang] Emit `diagnose_if` warnings from system headers
Summary: In order for libc++ to meaningfully use `diagnose_if` warnings they need to be emitted from system headers by default. This patch changes the `diagnose_if` warning diagnostic to be shown in system headers.

Reviewers: george.burgess.iv, rsmith, aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28703

llvm-svn: 291963
2017-01-13 22:11:40 +00:00
Bob Haarman 848c569734 COFF: include relocation type in unsupported relocation message
Summary: When we encouter a relocation type we don't know how to handle, this change causes us to print out the hexadecimal value of the relocation type. This makes troubleshooting a little easier.

Reviewers: ruiu, zturner

Differential Revision: https://reviews.llvm.org/D28576

llvm-svn: 291962
2017-01-13 22:05:22 +00:00
Eric Fiselier b1e7a12ee8 Add _LIBCPP_DIAGNOSE_WARNING and _LIBCPP_DIAGNOSE_ERROR macros.
Clang recently added a `diagnose_if(cond, msg, type)` attribute
which can be used to generate diagnostics when `cond` is a constant
expression that evaluates to true. Otherwise no attribute has no
effect.

This patch adds _LIBCPP_DIAGNOSE_ERROR/WARNING macros which
use this new attribute. Additionally this patch implements
a diagnostic message when a non-const-callable comparator is
given to a container.

Note: For now the warning version of the diagnostic is useless
within libc++ since warning diagnostics are suppressed by the
system header pragma. I'm going to work on fixing this.

llvm-svn: 291961
2017-01-13 22:02:08 +00:00
Tobias Grosser 4e8d1475bd ScopInfo: use correct enum type in type definition
Instead of a plain 'int' we use the correct enum type. This does not give
us type safety yet, but at least makes the code more correct in terms of typing.
To avoid such mismatches it might sense to switch these enums to C++11 typed
enums.

llvm-svn: 291960
2017-01-13 21:46:48 +00:00
Greg Clayton 97d22187d0 Cleanup how DWARFDie attributes are accessed and decoded.
Removed all DWARFDie::getAttributeValueAs*() calls.
Renamed:
  Optional<DWARFFormValue> DWARFDie::getAttributeValue(dwarf::Attribute);
To:
  Optional<DWARFFormValue> DWARFDie::find(dwarf::Attribute);
Added:
  Optional<DWARFFormValue> DWARFDie::findRecursively(dwarf::Attribute);
  
All decoding of Optional<DWARFFormValue> values are now done using the dwarf::to*() functions from DWARFFormValue.h:

Old code:
  
  auto DeclLine = DWARFDie.getAttributeValueAsSignedConstant(DW_AT_decl_line).getValueOr(0);
  
New code:

  auto DeclLine = toUnsigned(DWARFDie.find(DW_AT_decl_line), 0);
  
This composition helps us since we can now easily do:

  auto DeclLine = toUnsigned(DWARFDie.findRecursively(DW_AT_decl_line), 0);
  
This allows us to easily find attribute values in the current DIE only (the first new code above) or in any DW_AT_abstract_origin or DW_AT_specification Dies using the line above. Note that the code line length is shorter and more concise.

Differential Revision: https://reviews.llvm.org/D28581

llvm-svn: 291959
2017-01-13 21:08:18 +00:00
Rafael Espindola 1ebfc59c89 Implement -Map.
The format is not exactly the same as the one in bfd since bfd always
follows a linker script and prints it along.

llvm-svn: 291958
2017-01-13 21:05:46 +00:00
David L. Jones 41cecba8e9 "Use" lambda captures which are otherwise only used in asserts. NFC
Summary:
The LLVM coding standards recommend "using" values that are only
needed by asserts:
http://llvm.org/docs/CodingStandards.html#assert-liberally

Without this change, LLVM cannot bootstrap with -Werror as the second
stage fails with this new warning:
https://reviews.llvm.org/rL291905

See also the previous fixes:
https://reviews.llvm.org/rL291916
https://reviews.llvm.org/rL291939
https://reviews.llvm.org/rL291940
https://reviews.llvm.org/rL291941

Reviewers: rsmith

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28695

llvm-svn: 291957
2017-01-13 21:02:41 +00:00
Artem Belevich 64dc9be7b4 [NVPTX] Added support for half-precision floating point.
Only scalar half-precision operations are supported at the moment.

- Adds general support for 'half' type in NVPTX.
- fp16 math operations are supported on sm_53+ GPUs only
  (can be disabled with --nvptx-no-f16-math).
- Type conversions to/from fp16 are supported on all GPU variants.
- On GPU variants that do not have full fp16 support (or if it's disabled),
  fp16 operations are promoted to fp32 and results are converted back
  to fp16 for storage.

Differential Revision: https://reviews.llvm.org/D28540

llvm-svn: 291956
2017-01-13 20:56:17 +00:00
Richard Smith 836a3b416d PR31606: Generalize our tentative DR resolution for inheriting copy/move
constructors to better match the pre-P0136R1 behavior.

llvm-svn: 291955
2017-01-13 20:46:54 +00:00
Konstantin Zhuravlyov 7d88275577 [AMDGPU] Implement f16 fcopysign and fcopysign(f32, f64)
Differential Revision: https://reviews.llvm.org/D28496

llvm-svn: 291954
2017-01-13 19:49:25 +00:00
David Blaikie ecb29d54f7 Fix shared library build after r291938 by adding missing dependency on libOption
Thanks to Reid Kleckner for the help reproducing/fixing.

llvm-svn: 291953
2017-01-13 19:47:55 +00:00
Omair Javaid 56e70dd8cf Fix TestRegisterVariables for linux arm/arm64 gcc ver > 5
We are going to turn off buffer overflow introduced by gcc by turning off
FORTIFY_SOURCE.

Differential revision: https://reviews.llvm.org/D28666

llvm-svn: 291949
2017-01-13 19:28:42 +00:00
Rui Ueyama afedf82d6d Add a description how to checkout the LLD repository.
Differential Revision: https://reviews.llvm.org/D28687

llvm-svn: 291948
2017-01-13 19:27:18 +00:00
Reid Kleckner c397aff091 Remove SANITIZER_LINUX ifdefs
Somehow this causes lots of test failures on Windows. These appear to
have been accidentally added back in r291736.

llvm-svn: 291947
2017-01-13 19:25:58 +00:00
James Y Knight 0d3145ff8d [libc++abi] Add a silent terminate handler to libcxxabi.
The current std::terminate_handler pulls in some string code, some I/O
code, and more. Since it is automatically setup as the default, this
means that any trivial binary linking against libcxxabi will get this
extra bloat.

This patch allows disabling it as a build-time option, if you want to
avoid the extra bloat.

Patch by Tom Rybka!

Reviewers: EricWF

Subscribers: danalbert, llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28497

llvm-svn: 291946
2017-01-13 19:22:26 +00:00
Rafael Espindola 8a59f5c79f Don't add DT_INIT/DT_FINI for undef and shared symbols.
The freebsd dynamic linker doesn't check if the value is null (and it
is reasonable for it to do that). That means that producing a .so with
a null DT_INIT/DT_FINI causes the base address to be called.

This should fix the libreoffice build.

llvm-svn: 291944
2017-01-13 19:18:11 +00:00
James Y Knight 99a2ce2af2 Check for register clobbers when merging a vreg live range with a
reserved physreg in RegisterCoalescer.

Previously, we only checked for clobbers when merging into a READ of
the physreg, but not when merging from a WRITE to the physreg.

Differential Revision: https://reviews.llvm.org/D28527

llvm-svn: 291942
2017-01-13 19:08:36 +00:00
Malcolm Parsons e65b1029ca Remove unused lambda captures. NFC
llvm-svn: 291941
2017-01-13 19:02:50 +00:00
Malcolm Parsons 3c3ae0e6db Remove unused lambda captures. NFC
llvm-svn: 291940
2017-01-13 18:56:04 +00:00
Malcolm Parsons c6e4583dbb Remove unused lambda captures. NFC
llvm-svn: 291939
2017-01-13 18:55:32 +00:00
David Blaikie 6ad71010ab unique_ptrify Driver::ToolChains
llvm-svn: 291938
2017-01-13 18:53:43 +00:00
Sanjay Patel acd24c7b6a [InstCombine] use 'match' and other clean-up; NFCI
llvm-svn: 291937
2017-01-13 18:52:10 +00:00
Artem Belevich d109f46573 [NVPTX] Only lower sin/cos to approximate instructions if unsafe math is allowed.
Previously we'd always lower @llvm.{sin,cos}.f32 to {sin.cos}.approx.f32
instruction even when unsafe FP math was not allowed.

Clang-generated IR is not affected by this as it uses precise sin/cos
from CUDA's libdevice when unsafe math is disabled.

Differential Revision: https://reviews.llvm.org/D28619

llvm-svn: 291936
2017-01-13 18:48:13 +00:00
Sanjay Patel b22f6c5f26 [InstCombine] use m_APInt to allow shl folds for vectors with splat constants
llvm-svn: 291934
2017-01-13 18:39:09 +00:00
Eric Fiselier d066f3af61 Update version to 5.0
llvm-svn: 291928
2017-01-13 18:29:56 +00:00
Michael Liao 468fb745e8 [SCEV] Limit recursion depth of constant evolving.
- For a loop body with VERY complicated exit condition evaluation, constant
  evolving may run out of stack on platforms such as Windows. Need to limit the
  recursion depth.

Differential Revision: https://reviews.llvm.org/D28629

llvm-svn: 291927
2017-01-13 18:28:30 +00:00
Sanjay Patel bbc1c1e46b [InstCombine] add tests to show missing transforms for vector shl; NFC
llvm-svn: 291926
2017-01-13 18:27:23 +00:00
Eric Fiselier a0f7252b03 Fix merge conflict caused by r291921
llvm-svn: 291925
2017-01-13 18:25:13 +00:00
Simon Pilgrim 79fb07066c [X86][AVX] Bad v4f64/v4i64 '1z3z' shuffle test case
This lowers to SHUFPD if the input is zeroinitializer but not with a demanded elts optimized build vector.

llvm-svn: 291924
2017-01-13 18:23:47 +00:00
Sanjay Patel cf08203105 [InstCombine] use Op0/Op1 local variables more consistently with shifts; NFC
llvm-svn: 291923
2017-01-13 18:08:25 +00:00
Eric Fiselier c8bd38a15d Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."
This reverts commit 3a1b90a866b6d5d62a5f37fbfb3a1ee36cc70dd1.

llvm-svn: 291921
2017-01-13 18:03:46 +00:00
Simon Pilgrim 7f329becb7 Regenerate test.
llvm-svn: 291920
2017-01-13 17:44:28 +00:00
David Blaikie 0aaa7625e1 unique_ptrify createDriverOptTable
llvm-svn: 291919
2017-01-13 17:34:15 +00:00
Ivan Krasin 10527a9253 Fix UBSan bots by blacklisting bits/stl_tree.h.
Summary:
libstdc++ has some undefined behavior in bits/stl_tree.h that
has recently became excercised by some of the LLVM code.
Given that fixing libstdc++ will take years, adding the file
into a blacklist to fix bots seems like a necessity.

Reviewers: vitalybuka

Subscribers: llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28686

llvm-svn: 291918
2017-01-13 17:30:10 +00:00
Reid Kleckner 791bbf6f18 Use less byval on 32-bit Windows x86 for classes with bases
This comes up in V8, which has a Handle template class that wraps a
typed pointer, and is frequently passed by value. The pointer is stored
in the base, HandleBase. This change allows us to pass the struct as a
pointer instead of using byval. This avoids creating tons of temporary
allocas that we copy from during call lowering.

Eventually, it would be good to use FCAs here instead.

llvm-svn: 291917
2017-01-13 17:18:19 +00:00
Malcolm Parsons 17d266bc96 Remove unused lambda captures. NFC
llvm-svn: 291916
2017-01-13 17:12:16 +00:00
Sanjay Patel 5178363687 [InstCombine] if the condition of a select may be known via assumes, eliminate the select
This is a limited solution for PR31512:
https://llvm.org/bugs/show_bug.cgi?id=31512

The motivation is that we will need to increase usage of llvm.assume and/or metadata to solve PR28430:
https://llvm.org/bugs/show_bug.cgi?id=28430

...and this kind of simplification is needed to take advantage of that extra information.

The 'not' test case would be handled by:
https://reviews.llvm.org/D28485

Differential Revision:
https://reviews.llvm.org/D28337

llvm-svn: 291915
2017-01-13 17:02:42 +00:00
Ivan Krasin 1ed7896c1b Revert r291903 and r291898. Reason: they break check-lld on the bots.
Summary:
Revert [ARM] Fix ubig32_t read in ARMAttributeParser

Now using support functions to read data instead of trying to
perform casts.
===========================================================

Revert [ARM] Enable objdump to construct triple for ARM

Now that The ARMAttributeParser has been moved into the library,
it has been modified so that it can parse the attributes without
printing them and stores them in a map. ELFObjectFile now queries
the attributes to fill out the architecture details of a provided
triple for 'arm' and 'thumb' targets. llvm-objdump uses this new
functionality.

Subscribers: llvm-commits, samparker, aemerson, mgorny

Differential Revision: https://reviews.llvm.org/D28683

llvm-svn: 291911
2017-01-13 16:45:15 +00:00