platform/upstream/llvm.git
6 years ago[llvm-mca] Removed an empty line generated by the timeline view. NFC.
Andrea Di Biagio [Mon, 21 May 2018 17:11:56 +0000 (17:11 +0000)]
[llvm-mca] Removed an empty line generated by the timeline view. NFC.

Also, regenerate all tests.

llvm-svn: 332853

6 years ago[OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.
Alexey Bataev [Mon, 21 May 2018 16:40:32 +0000 (16:40 +0000)]
[OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.

if `-fopenmp-simd` is specified alone, `_OPENMP` macro should not be
  defined. If `-fopenmp-simd` is specified along with the `-fopenmp`,
  `_OPENMP` macro should be defined with the value `201511`.

llvm-svn: 332852

6 years ago[X86][BtVer2] Add a 'J' prefix to the PRF/RCU defs. NFC
Andrea Di Biagio [Mon, 21 May 2018 16:30:26 +0000 (16:30 +0000)]
[X86][BtVer2] Add a 'J' prefix to the PRF/RCU defs. NFC

This is to keep the Jaguar model's naming convention. Processor resources all
have a 'J' prefix in the BtVer2 scheduling model.

llvm-svn: 332851

6 years ago[LLVM-C] Add DIBuilder Bindings For ObjC Classes
Robert Widmann [Mon, 21 May 2018 16:27:35 +0000 (16:27 +0000)]
[LLVM-C] Add DIBuilder Bindings For ObjC Classes

Summary: Add LLVMDIBuilderCreateObjCIVar, LLVMDIBuilderCreateObjCProperty, and LLVMDIBuilderCreateInheritance to allow declaring metadata for Objective-C class hierarchies and their associated properties and instance variables.

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: harlanhaskins, llvm-commits

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

llvm-svn: 332850

6 years ago[X86] - Avoid SFB pass - fix bug in updating the offsets for newly created copies
Lama Saba [Mon, 21 May 2018 16:23:16 +0000 (16:23 +0000)]
[X86] - Avoid SFB pass - fix bug in updating the offsets for newly created copies

Change-Id: I169ab6fe7e187727c0298c2a1e2868a683f3e688
llvm-svn: 332849

6 years ago[AMDGPU] fixes for lds f32 builtins
Daniil Fukalov [Mon, 21 May 2018 16:18:07 +0000 (16:18 +0000)]
[AMDGPU] fixes for lds f32 builtins

1. added restrictions to memory scope, order and volatile parameters
2. added custom processing for these builtins - currently is not used code,
   needed to switch off GCCBuiltin link to the builtins (ongoing change to llvm
   tree)
3. builtins renamed as requested

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

llvm-svn: 332848

6 years ago[CodeGen] Recognize more cases of zero initialization
Serge Pavlov [Mon, 21 May 2018 16:09:54 +0000 (16:09 +0000)]
[CodeGen] Recognize more cases of zero initialization

If a variable has an initializer, codegen tries to build its value. If
the variable is large in size, building its value requires substantial
resources. It causes strange behavior from user viewpoint: compilation
of huge zero initialized arrays like:

    char data_1[2147483648u] = { 0 };

consumes enormous amount of time and memory.

With this change codegen tries to determine if variable initializer is
equivalent to zero initializer. In this case variable value is not
constructed.

This change fixes PR18978.

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

llvm-svn: 332847

6 years ago[ELF] Update due to API change in .debug_line parsing
James Henderson [Mon, 21 May 2018 15:31:23 +0000 (15:31 +0000)]
[ELF] Update due to API change in .debug_line parsing

See r332845.

Reviewed by: grimar

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

llvm-svn: 332846

6 years ago[DWARF] Refactor callback usage for .debug_line error handling
James Henderson [Mon, 21 May 2018 15:30:54 +0000 (15:30 +0000)]
[DWARF] Refactor callback usage for .debug_line error handling

Change the "recoverable" error callback to take an Error instaed of a
string.

Reviewed by: JDevlieghere

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

llvm-svn: 332845

6 years ago[X86][SSE] Add an assert to ensure that rotation amount is converted to a scale
Simon Pilgrim [Mon, 21 May 2018 15:17:23 +0000 (15:17 +0000)]
[X86][SSE] Add an assert to ensure that rotation amount is converted to a scale

Missed in rL332832 where we added SSE v4i32 rotations for PR37426.

llvm-svn: 332844

6 years ago[Sema] Fix incorrect packed aligned structure layout
Momchil Velikov [Mon, 21 May 2018 14:28:43 +0000 (14:28 +0000)]
[Sema] Fix incorrect packed aligned structure layout

Handle attributes before checking the record layout (e.g. underalignment check
during `alignas` processing), as layout may be cached without taking into
account attributes that may affect it.

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

llvm-svn: 332843

6 years agoFix PathMappingList for relative and empty paths after recent FileSpec normalization...
Greg Clayton [Mon, 21 May 2018 14:14:36 +0000 (14:14 +0000)]
Fix PathMappingList for relative and empty paths after recent FileSpec normalization changes

PathMappingList was broken for relative and empty paths after normalization changes in FileSpec. There were also no tests for PathMappingList so I added those.

Changes include:

Change PathMappingList::ReverseRemapPath() to take FileSpec objects instead of ConstString. The only client of this was doing work to convert to and from ConstString objects for no reason.
Normalize all paths prefix and replacements that are added to the PathMappingList vector so they match the paths that have been already normalized in the debug info
Unify code in the two forms of PathMappingList::RemapPath() so only one contains the actual functionality. Prior to this, there were two versions of this code.
Use FileSpec::AppendPathComponent() and remove a long standing TODO so paths are correctly appended to each other.
Added tests for absolute, relative and empty paths.

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

llvm-svn: 332842

6 years agoReland "[DWARF] Extract indexing code into a separate class hierarchy"
Pavel Labath [Mon, 21 May 2018 14:12:52 +0000 (14:12 +0000)]
Reland "[DWARF] Extract indexing code into a separate class hierarchy"

After this commit, the xcode project will need to be updated to include
the new files added here.

llvm-svn: 332841

6 years agoARM: be conservative when asked load/store alignment of weird type.
Tim Northover [Mon, 21 May 2018 12:43:54 +0000 (12:43 +0000)]
ARM: be conservative when asked load/store alignment of weird type.

Chances are we'll be asked again after type legalization, but before that point
it's better to claim misaligned accesses aren't allowed than to assert.

llvm-svn: 332840

6 years ago[CodeGen] Disable aggressive structor optimizations at -O0, take 2
Pavel Labath [Mon, 21 May 2018 11:47:45 +0000 (11:47 +0000)]
[CodeGen] Disable aggressive structor optimizations at -O0, take 2

The first version of the patch (r332228) was flawed because it was
putting structors into C5/D5 comdats very eagerly. This is correct only
if we can ensure the comdat contains all required versions of the
structor (which wasn't the case). This version uses a more nuanced
approach:
- for local structor symbols we use an alias because we don't have to
  worry about comdats or other compilation units.
- linkonce symbols are emitted separately, as we cannot guarantee we
  will have all symbols we need to form a comdat (they are emitted
  lazily, only when referenced).
- available_externally symbols are also emitted separately, as the code
  seemed to be worried about emitting an alias in this case.
- other linkage types are not affected by the optimization level. They
  either get put into a comdat (weak) or get aliased (external).

Reviewers: rjmccall, aprantl

Subscribers: cfe-commits

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

llvm-svn: 332839

6 years agorevert r332610, it breaks cfi, see D46326
Nico Weber [Mon, 21 May 2018 11:44:39 +0000 (11:44 +0000)]
revert r332610, it breaks cfi, see D46326

llvm-svn: 332838

6 years ago[mips] Revert Merge MipsLongBranch and MipsHazardSchedule passes
Aleksandar Beserminji [Mon, 21 May 2018 11:38:52 +0000 (11:38 +0000)]
[mips] Revert Merge MipsLongBranch and MipsHazardSchedule passes

Revert this patch due buildbot failure.

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

llvm-svn: 332837

6 years ago[CVP] Require DomTree for new Pass Manager
David Green [Mon, 21 May 2018 11:06:28 +0000 (11:06 +0000)]
[CVP] Require DomTree for new Pass Manager

We were previously using a DT in CVP through SimplifyQuery, but not requiring it in
the new pass manager. Hence it would crash if DT was not already available. This now
gets DT directly and plumbs it through to where it is used (instead of using it
through SQ).

llvm-svn: 332836

6 years agoFix up a few grammar issues.
Eric Christopher [Mon, 21 May 2018 10:27:36 +0000 (10:27 +0000)]
Fix up a few grammar issues.

llvm-svn: 332835

6 years ago[mips] Merge MipsLongBranch and MipsHazardSchedule passes
Aleksandar Beserminji [Mon, 21 May 2018 10:20:02 +0000 (10:20 +0000)]
[mips] Merge MipsLongBranch and MipsHazardSchedule passes

MipsLongBranchPass and MipsHazardSchedule passes are joined to one pass
because of mutual conflict. When MipsHazardSchedule inserts 'nop's, it
potentially breaks some jumps, so they have to be expanded to long
branches. When some branch is expanded to long branch, it potentially
creates a hazard situation, which should be fixed by adding nops.
New pass is called MipsBranchExpansion, it combines these two passes,
and runs them alternately until one of them reports no changes were made.

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

llvm-svn: 332834

6 years agoImprove coverage of the apple-tables test
Pavel Labath [Mon, 21 May 2018 10:09:22 +0000 (10:09 +0000)]
Improve coverage of the apple-tables test

After closer examination, it turns out we mis-classify one of the
methods only if two of the structs have the same name. Since this was
meant to be a basic test, I rename one of the structs in the test so
that we have at least some coverage for the apple tables lookup.
Instead, I create an XFAILed test which specifically targets the
same-name case (and file a bug to track it).

llvm-svn: 332833

6 years ago[X86][SSE] Support v4i32 rotations (PR37426)
Simon Pilgrim [Mon, 21 May 2018 09:45:59 +0000 (09:45 +0000)]
[X86][SSE] Support v4i32 rotations (PR37426)

As suggested by Fabian on PR37426, we can use PMULUDQ to perform v4i32 vector rotations as the upper 32bits of the multiply will contain the 'wrapped' bits of the rotation.

v8i16/v16i8 rotations would be straightforward to add to lowerRotate in the future - ideally we'd mostly share code with the vector shifts lowering.

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

llvm-svn: 332832

6 years agoAdd some apple-tables lookup tests
Pavel Labath [Mon, 21 May 2018 09:27:16 +0000 (09:27 +0000)]
Add some apple-tables lookup tests

Summary:
Now that we are able to parse MachO files everywhere, we can write some
cross-platform tests for handling of apple accelerator tables. This
reruns the same lookup tests we have for manual indexes on MachO files
which will use the accelerator tables instead. This makes sure we return
the same results regardless of the method we used to access the debug
info.

The tests confirm we return the same results for looking up types,
namespaces and variables, but have found an inconsistency in the
treatment of function lookup. In the function case we mis-classify the
method "foo" declared in the local struct sbar (inside function ffbar).
We classify it as a function whereas it really is a method. Preliminary
analysis suggests this is because
DWARFASTParserClang::GetClangDeclContextForDIE returns null when given
the local "struct sbar" DIE. This causes us to get the wrong
CompilerDeclContext when we ask for the context of the inner foo, which
means CompilerDeclContext::ISStructUnionOrClass returns false.

Until this is fixed, I do not include the darwin versions of the "base"
and "method" function lookup tests.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, ilya-biryukov, ioeric, lldb-commits

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

llvm-svn: 332831

6 years ago[X86] Remove some preprocessor feature checks from intrinsic headers
Craig Topper [Mon, 21 May 2018 06:07:49 +0000 (06:07 +0000)]
[X86] Remove some preprocessor feature checks from intrinsic headers

Summary:
These look to be a couple things that weren't removed when we switched to target attribute.

The popcnt makes including just smmintrin.h also include popcntintrin.h. The popcnt file itself already contains target attrributes.

The prefetch ones are just wrappers around __builtin_prefetch which we have graceful fallbacks for in the backend if the exact instruction isn't available. So there's no reason to hide them. And it makes them available in functions that have the write target attribute but not a -march command line flag.

Reviewers: echristo, RKSimon, spatel, DavidKreitzer

Reviewed By: echristo

Subscribers: cfe-commits

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

llvm-svn: 332830

6 years ago[X86] Remove some unused builtins.
Craig Topper [Mon, 21 May 2018 03:36:57 +0000 (03:36 +0000)]
[X86] Remove some unused builtins.

These were upgraded to native shufflevectors months ago.

llvm-svn: 332829

6 years agowin: try more to fix dia tests with newer msvc versions
Nico Weber [Mon, 21 May 2018 02:55:41 +0000 (02:55 +0000)]
win: try more to fix dia tests with newer msvc versions

llvm-svn: 332828

6 years agowin: try to fix dia tests with newer msvc versions
Nico Weber [Mon, 21 May 2018 02:09:57 +0000 (02:09 +0000)]
win: try to fix dia tests with newer msvc versions

llvm-svn: 332827

6 years ago[LLVM-C] Improve Bindings For Aliases
Robert Widmann [Sun, 20 May 2018 23:49:08 +0000 (23:49 +0000)]
[LLVM-C] Improve Bindings For Aliases

Summary: Add wrappers for a module's alias iterators and a getter and setter for the aliasee value.

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: llvm-commits, harlanhaskins

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

llvm-svn: 332826

6 years ago[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR...
Craig Topper [Sun, 20 May 2018 23:34:10 +0000 (23:34 +0000)]
[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR instead.

Someday maybe we'll use selects for all the builtins.

llvm-svn: 332825

6 years ago[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR...
Craig Topper [Sun, 20 May 2018 23:34:04 +0000 (23:34 +0000)]
[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR instead.

Someday maybe we'll use selects for all intrinsics.

llvm-svn: 332824

6 years agoRevert 332750, llvm part (see comment on D46910).
Nico Weber [Sun, 20 May 2018 23:03:17 +0000 (23:03 +0000)]
Revert 332750, llvm part (see comment on D46910).

llvm-svn: 332823

6 years agoRevert 332750, clang part (see comment on D46910).
Nico Weber [Sun, 20 May 2018 23:02:20 +0000 (23:02 +0000)]
Revert 332750, clang part (see comment on D46910).

llvm-svn: 332822

6 years agoSema: diagnose invalid catch parameter in ObjC
Saleem Abdulrasool [Sun, 20 May 2018 19:26:44 +0000 (19:26 +0000)]
Sema: diagnose invalid catch parameter in ObjC

Ensure that the type being used has an associated interface when
declaring the parameter for `@catch`.

Resolves PR37384!

llvm-svn: 332821

6 years ago[mips] Add microMIPSR6 ll/sc instructions.
Simon Dardis [Sun, 20 May 2018 17:21:00 +0000 (17:21 +0000)]
[mips] Add microMIPSR6 ll/sc instructions.

Previously the compiler was using the microMIPSR3 variants, incorrectly.

Reviewers: atanasyan, abeserminji, smaksimovic

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

llvm-svn: 332820

6 years ago[InstCombine] choose 1 form of abs and nabs as canonical
Sanjay Patel [Sun, 20 May 2018 14:23:23 +0000 (14:23 +0000)]
[InstCombine] choose 1 form of abs and nabs as canonical

We already do this for min/max (see the blob above the diff),
so we should do the same for abs/nabs.
A sign-bit check (<s 0) is used as a predicate for other IR
transforms and it's likely the best for codegen.

This might solve the motivating cases for D47037 and D47041,
but I think those patches still make sense. We can't guarantee
this canonicalization if the icmp has more than one use.

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

llvm-svn: 332819

6 years agoDeduction guides for list
Marshall Clow [Sun, 20 May 2018 14:05:31 +0000 (14:05 +0000)]
Deduction guides for list

llvm-svn: 332818

6 years agoPrint the qualified name when dumping deserialized decls.
Vassil Vassilev [Sun, 20 May 2018 09:38:52 +0000 (09:38 +0000)]
Print the qualified name when dumping deserialized decls.

This is useful to understand and debug the lazy template specializations
used in the pch and modules.

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

llvm-svn: 332817

6 years ago[cmake] Add a switch to enable/disable bindings.
Vassil Vassilev [Sun, 20 May 2018 08:37:54 +0000 (08:37 +0000)]
[cmake] Add a switch to enable/disable bindings.

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

llvm-svn: 332816

6 years ago[X86] Add test cases to show missed rotate opportunities due to SimplifyDemandedBits.
Craig Topper [Sun, 20 May 2018 02:32:45 +0000 (02:32 +0000)]
[X86] Add test cases to show missed rotate opportunities due to SimplifyDemandedBits.

llvm-svn: 332815

6 years ago[polly] Drop nonexistant LLVM_PLUGIN_EXPORT macro from llvmGetPassPluginInfo()
Roman Lebedev [Sat, 19 May 2018 19:16:35 +0000 (19:16 +0000)]
[polly] Drop nonexistant LLVM_PLUGIN_EXPORT macro from llvmGetPassPluginInfo()

Fixes build:
/build/polly/lib/Support/RegisterPasses.cpp:709:80: error: expected ';' after top level declarator
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_PLUGIN_EXPORT
                                                                               ^
                                                                              ;

Was missed in rL332796 / D47082

llvm-svn: 332814

6 years ago[GlobalMerge] Exit early if only one global is to be merged
Haicheng Wu [Sat, 19 May 2018 18:00:02 +0000 (18:00 +0000)]
[GlobalMerge] Exit early if only one global is to be merged

To save some compilation time and prevent some unnecessary changes.

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

llvm-svn: 332813

6 years agoRe-revert "[Option] Fix PR37006 prefix choice in findNearest"
Brian Gesiak [Sat, 19 May 2018 16:21:01 +0000 (16:21 +0000)]
Re-revert "[Option] Fix PR37006 prefix choice in findNearest"

Summary:
Reverting due to a test failure in an llvm-mt test on some buildbots, namely
http://green.lab.llvm.org/green/job/clang-stage2-configure-Rlto/26020/.

llvm-svn: 332812

6 years agoImplement deduction guides for forward_list
Marshall Clow [Sat, 19 May 2018 16:02:05 +0000 (16:02 +0000)]
Implement deduction guides for forward_list

llvm-svn: 332811

6 years ago[LLVM-C] Use Length-Providing Value Name Getters and Setters
Robert Widmann [Sat, 19 May 2018 15:08:36 +0000 (15:08 +0000)]
[LLVM-C] Use Length-Providing Value Name Getters and Setters

Summary:
- Provide LLVMGetValueName2 and LLVMSetValueName2 that return and take the length of the provided C string respectively
- Deprecate LLVMGetValueName and LLVMSetValueName

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: llvm-commits, harlanhaskins

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

llvm-svn: 332810

6 years ago[IRCE] Fix miscompile with range checks against negative values
Max Kazantsev [Sat, 19 May 2018 13:06:37 +0000 (13:06 +0000)]
[IRCE] Fix miscompile with range checks against negative values

In the patch rL329547, we have lifted the over-restrictive limitation on collected range
checks, allowing to work with range checks with the end of their range not being
provably non-negative. However it appeared that the non-negativity of this value was
assumed in the utility function `ClampedSubtract`. In particular, its reasoning is based
on the fact that `0 <= SINT_MAX - X`, which is not true if `X` is negative.

The function `ClampedSubtract` is only called twice, once with `X = 0` (which is OK)
and the second time with `X = IRC.getEnd()`, where we may now see the problem if
the end is actually a negative value. In this case, we may sometimes miscompile.

This patch is the conservative fix of the miscompile problem. Rather than rejecting
non-provably non-negative `getEnd()` values, we will check it for non-negativity in
runtime. For this, we use function `smax(smin(X, 0), -1) + 1` that is equal to `1` if `X`
is non-negative and is equal to 0 if `X` is negative. If we multiply `Begin, End` of safe
iteration space by this function calculated for `X = IRC.getEnd()`, we will get the original
`[Begin, End)` if `IRC.getEnd()` was non-negative (and, thus, `ClampedSubtract` worked
correctly) and the empty range `[0, 0)` in case if ` IRC.getEnd()` was negative.

So we in fact prohibit execution of the main loop if at least one of range checks was
made against a negative value (and we figured it out in runtime). It is still better than
what we have before (non-negativity had to be proved in compile time) and prevents
us from miscompile, however it is sometiles too restrictive for unsigned range checks
against a negative value (which in fact can be eliminated).

Once we re-implement `ClampedSubtract` in a way that it handles negative `X` correctly,
this limitation can be lifted, too.

Differential Revision: https://reviews.llvm.org/D46860
Reviewed By: samparker

llvm-svn: 332809

6 years ago[MergeICmps] Don't crash when memcmp is not available
Benjamin Kramer [Sat, 19 May 2018 12:51:59 +0000 (12:51 +0000)]
[MergeICmps] Don't crash when memcmp is not available

Fixes clang crashing with -fno-builtin, PR37527.

llvm-svn: 332808

6 years agoFix MSVC unused variable warning. NFCI.
Simon Pilgrim [Sat, 19 May 2018 12:46:02 +0000 (12:46 +0000)]
Fix MSVC unused variable warning. NFCI.

AMDGPURegisterInfo::getSubRegFromChannel is a static method - we don't need to get the AMDGPURegisterInfo instance.

llvm-svn: 332807

6 years ago[Driver] Temporarily remove test for LLVM findNearest
Brian Gesiak [Sat, 19 May 2018 12:44:02 +0000 (12:44 +0000)]
[Driver] Temporarily remove test for LLVM findNearest

Summary:
This fixes a failure caused by the revert of https://reviews.llvm.org/rL332805.

llvm-svn: 332806

6 years agoUn-revert "[Option] Fix PR37006 prefix choice in findNearest"
Brian Gesiak [Sat, 19 May 2018 12:03:26 +0000 (12:03 +0000)]
Un-revert "[Option] Fix PR37006 prefix choice in findNearest"

Summary:
In https://reviews.llvm.org/rL332804 I loosed the assertion in
the Clang driver test that forced me to revert
https://reviews.llvm.org/rL332299. Once this lands I should be
able to narrow down what caused PS4 buildbots to fail, and
reinstate the check in that test.

Test Plan: check-llvm & check-clang

llvm-svn: 332805

6 years ago[Driver] Loosen test for LLVM findNearest
Brian Gesiak [Sat, 19 May 2018 11:46:58 +0000 (11:46 +0000)]
[Driver] Loosen test for LLVM findNearest

Summary:
When https://reviews.llvm.org/D46776 landed to improve the behavior of
`llvm::OptTable::findNearest`, a PS4 buildbot began failing due to an
assertion that a suggestion "-debug-info-macro" should be provided for
the unrecognized option `clang -cc1as -debug-info-macros`. All other
buildbots succeeded in this check, and the PS4 buildbot succeeded in the
other `findNearest` tests.

Temporarily loosen this check in order to reland the `findNearest`
change.

Test Plan: check-clang

llvm-svn: 332804

6 years agoCodeGen: block capture shouldn't ICE
JF Bastien [Sat, 19 May 2018 04:21:26 +0000 (04:21 +0000)]
CodeGen: block capture shouldn't ICE

When a lambda capture captures a __block in the same statement, the compiler asserts out because isCapturedBy assumes that an Expr can only be a BlockExpr, StmtExpr, or if it's a Stmt then all the statement's children are expressions. That's wrong, we need to visit all sub-statements even if they're not expressions to see if they also capture.

Fix this issue by pulling out the isCapturedBy logic to use RecursiveASTVisitor.

<rdar://problem/39926584>

llvm-svn: 332801

6 years agoAdjust and fix failing CXX tests after r332799
Eric Fiselier [Sat, 19 May 2018 03:33:56 +0000 (03:33 +0000)]
Adjust and fix failing CXX tests after r332799

llvm-svn: 332800

6 years ago[Clang Tablegen][RFC] Allow Early Textual Substitutions in `Diagnostic` messages.
Eric Fiselier [Sat, 19 May 2018 03:12:04 +0000 (03:12 +0000)]
[Clang Tablegen][RFC] Allow Early Textual Substitutions in `Diagnostic` messages.

Summary:
There are cases where the same string or select is repeated verbatim in a lot of diagnostics. This can be a pain to maintain and update. Tablegen provides no way stash the common text somewhere and reuse it in the diagnostics, until now!

This patch allows diagnostic texts to contain `%sub{<definition-name>}`, where `<definition-name>` names a Tablegen record of type `TextSubstitution`. These substitutions are done early, before the diagnostic string is otherwise processed. All `%sub` modifiers will be replaced before the diagnostic definitions are emitted.

The substitution must specify all arguments used by the substitution, and modifier indexes in the substitution are re-numbered accordingly. For example:

```
def select_ovl_candidate : TextSubstitution<"%select{function|constructor}0%select{| template| %2}1">;
```
when used as
```
"candidate `%sub{select_ovl_candidate}3,2,1 not viable"
```
will act as if we wrote:
```
"candidate %select{function|constructor}3%select{| template| %1}2 not viable"
```

Reviewers: rsmith, rjmccall, aaron.ballman, a.sidorin

Reviewed By: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 332799

6 years agoRemove expression '1L + INT_MAX', because it overflows on machines where int/long...
Marshall Clow [Sat, 19 May 2018 03:09:05 +0000 (03:09 +0000)]
Remove expression '1L + INT_MAX', because it overflows on machines where int/long are the same size

llvm-svn: 332797

6 years agoFix build warning compiling TestPlugin on Windows and disable Passes plugin stuff...
Nico Weber [Sat, 19 May 2018 03:05:30 +0000 (03:05 +0000)]
Fix build warning compiling TestPlugin on Windows and disable Passes plugin stuff on Windows since it fundamentally can't work

Aaron Ballman reported that TestPlugin warned about it using exception handling
without /EHsc flag, and that llvmGetPassInfo() had conflicting export
attributes (dllimport in the header, dllexport in the source file).

/EHsc is because TestPlugin didn't use the llvm_ cmake functions, so
llvm_update_compile_flags didn't get called for the target
(llvm_update_compile_flags explicitly passes /Ehs-c-, which fixes the warning).
Use add_llvm_loadable_module instead of add_library(... MODULE) to fix this.
This also has the side effect of not building the plugin on Windows. That's not
a big problem, since before the plugin was built on Windows, but the test
didn't attempt to load it, due to -DLLVM_ENABLE_PLUGIN not being passed to
PluginsTests.cpp during compilation on Windows. This makes the plugin behavior
consistent with e.g. lib/Transforms/Hello/CMakeLists.txt. (This also
automatically sets LTDL_SHLIB_EXT correctly.)

The dllimport/dllexport warning is more serious: Since LLVM doesn't generally
use export annotations for its code, the only way the plugin could link was by
linking in some LLVM libraries both into the test and the dll, so the plugin
would call the llvm code in the dll instead of the copy in the main executable.
This means globals weren't shared, and things generally can't work. (I think
there's a build config where you can build a LLVM.dll which might work, but
that wasn't how the test was configured. If that config is used, the dll should
still be built, but I haven't checked).

Now that add_llvm_loadable_module is used, LLVM_LINK_COMPONENTS got linked into
both executable and plugin on posix too, so unset it after the executable so
that the plugin doesn't end up with a 2nd copy of things on posix.

https://reviews.llvm.org/D47082

llvm-svn: 332796

6 years agoFix evaluator for non-zero alloca addr space
Yaxun Liu [Sat, 19 May 2018 02:58:16 +0000 (02:58 +0000)]
Fix evaluator for non-zero alloca addr space

The evaluator goes through BB and creates global vars as temporary values to evaluate
results of LLVM instructions. It creates undef for alloca, however it assumes alloca
in addr space 0. If the next instruction is addrspace cast to 0, then we get an invalid
cast instruction.

This patch let the temp global var have an address space matching alloca addr space,
so that the valuation can be done.

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

llvm-svn: 332794

6 years agoEnable colored diagnostics in ninja builds when building with gcc 4.9+.
Nico Weber [Sat, 19 May 2018 02:36:27 +0000 (02:36 +0000)]
Enable colored diagnostics in ninja builds when building with gcc 4.9+.

GCC has supported -fdiagnostics-color since 4.9.

https://reviews.llvm.org/D47083

llvm-svn: 332793

6 years agoAlign ClearShadowForThreadStackAndTLS for NetBSD/i386
Kamil Rytarowski [Sat, 19 May 2018 01:20:00 +0000 (01:20 +0000)]
Align ClearShadowForThreadStackAndTLS for NetBSD/i386

Summary:
The static TLS vector for the main thread on NetBSD/i386 can be
unaligned in terms of the shadow granularity. Align the start of it with
Round Down and end of it with Round Up operations for the shadow
granularity shift.

Example static TLS vector ranges on NetBSD/i386:
tls_begin_=0xfbee7244 tls_end_=0xfbee726c.

ClearShadowForThreadStackAndTLS() is called from the Main Thread
bootstrap functions.

This change restores the NetBSD x86 32-bit (i386) support.

Sponsored by <The NetBSD Foundation>

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 332792

6 years agoPort msan_test.cc to NetBSD
Kamil Rytarowski [Sat, 19 May 2018 01:10:25 +0000 (01:10 +0000)]
Port msan_test.cc to NetBSD

Summary:
The changes allows building this file on NetBSD, mostly by
disabling the unsupported functions and adding OS-specific
system includes.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 332791

6 years agoDo not link with -ldl in NetBSD/ASan tests
Kamil Rytarowski [Sat, 19 May 2018 01:02:51 +0000 (01:02 +0000)]
Do not link with -ldl in NetBSD/ASan tests

Summary:
The dlopen(3) features on NetBSD are in libc.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, kcc

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 332790

6 years agoFix unused variable warning in non-debug builds.
Richard Trieu [Sat, 19 May 2018 00:37:23 +0000 (00:37 +0000)]
Fix unused variable warning in non-debug builds.

llvm-svn: 332789

6 years agoPropagate nonnull and dereferenceable throught launder
Piotr Padlewski [Fri, 18 May 2018 23:54:33 +0000 (23:54 +0000)]
Propagate nonnull and dereferenceable throught launder

Summary:
invariant.group.launder should not stop propagation
of nonnull and dereferenceable, because e.g. we would not be
able to hoist loads speculatively.

Reviewers: rsmith, amharc, kuhar, xbolva00, hfinkel

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 332788

6 years agoDissallow non-empty metadata for invariant.group
Piotr Padlewski [Fri, 18 May 2018 23:53:46 +0000 (23:53 +0000)]
Dissallow non-empty metadata for invariant.group

Summary:
This feature is not needed, but it might be usefull in the future
to use metadata to mark what which function should support it
(and strip it when not).

Reviewers: rsmith, sanjoy, amharc, kuhar

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 332787

6 years agoConstant fold launder of null and undef
Piotr Padlewski [Fri, 18 May 2018 23:52:57 +0000 (23:52 +0000)]
Constant fold launder of null and undef

Summary:
This might be useful because clang will add
some barriers for pointer comparisons.

Reviewers: majnemer, dberlin, hfinkel, nlewycky, davide, rsmith, amharc,
kuhar

Subscribers: davide, amharc, llvm-commits

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

llvm-svn: 332786

6 years agoImplement deduction guides for <deque>
Marshall Clow [Fri, 18 May 2018 23:44:13 +0000 (23:44 +0000)]
Implement deduction guides for <deque>

llvm-svn: 332785

6 years agoDo not enable RTTI with -fexceptions, for PS4
Sunil Srivastava [Fri, 18 May 2018 23:32:01 +0000 (23:32 +0000)]
Do not enable RTTI with -fexceptions, for PS4

NFC for targets other than PS4.

This patch is a change in behavior for PS4, in that PS4 will no longer enable
RTTI when -fexceptions is specified (RTTI and Exceptions are disabled by default
on PS4). RTTI will remain disabled except for types being thrown or caught.
Also, '-fexceptions -fno-rtti' (previously prohibited on PS4) is now accepted,
as it is for other targets.

This patch removes some PS4 specific code, making the code cleaner.

Also, in the test file rtti-options.cpp, PS4 tests where the behavior is the
same as the generic x86_64-linux are removed, making the test cleaner.

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

llvm-svn: 332784

6 years ago[WebAssembly] Add option to remove LEB padding at relocate sites
Sam Clegg [Fri, 18 May 2018 23:28:05 +0000 (23:28 +0000)]
[WebAssembly] Add option to remove LEB padding at relocate sites

This change adds the ability for lld to remove LEB padding from
code section. This effectively shrinks the size of the resulting
binary in proportion to the number of code relocations.

Since there will be a performance cost this is currently only active for
-O1 and above. Some toolchains may instead want to perform this
compression as a post linker step (for example running a binary through
binaryen will automatically compress these values).

I imagine we might want to make this the default in the future.

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

llvm-svn: 332783

6 years ago[MemDep] Fixed handling of invariant.group
Piotr Padlewski [Fri, 18 May 2018 22:40:34 +0000 (22:40 +0000)]
[MemDep] Fixed handling of invariant.group

Summary:
Memdep had funny bug related to invariant.groups - because it did not
invalidated cache, in some very rare cases it was possible to show memory
dependence of the instruction that was deleted, but because other
instruction took it's place it resulted in call to vtable!
Thanks @amharc for repro!.

Reviewers: dberlin, kuhar, amharc

Subscribers: llvm-commits

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

Co-authored-by: Krzysztof Pszeniczny <krzysztof.pszeniczny@gmail.com>
llvm-svn: 332781

6 years ago[x86] add more FP with FMF simplification tests; NFC
Sanjay Patel [Fri, 18 May 2018 22:31:43 +0000 (22:31 +0000)]
[x86] add more FP with FMF simplification tests; NFC

llvm-svn: 332780

6 years agoDisable 'missing-braces' warning
Marshall Clow [Fri, 18 May 2018 22:21:33 +0000 (22:21 +0000)]
Disable 'missing-braces' warning

llvm-svn: 332779

6 years ago[test] Fix run line to use correct triple
Shoaib Meenai [Fri, 18 May 2018 21:59:29 +0000 (21:59 +0000)]
[test] Fix run line to use correct triple

objc_begin_catch/objc_end_catch are specific to the Itanium ABI, so we
should be using an Itanium triple for this test.

Additionally, while I'm here, convert the run line to invoke the
compiler directly rather than going through the driver.

llvm-svn: 332777

6 years ago[SCEVAffinator] BB can be null; don't use it to get the LLVMContext.
Eli Friedman [Fri, 18 May 2018 21:57:44 +0000 (21:57 +0000)]
[SCEVAffinator] BB can be null; don't use it to get the LLVMContext.

Fixes post-commit review comment on r332309.

llvm-svn: 332775

6 years agoDAG: Fix crash on shift with large shift amounts
Matt Arsenault [Fri, 18 May 2018 21:54:16 +0000 (21:54 +0000)]
DAG: Fix crash on shift with large shift amounts

Fixes bug 37521.

llvm-svn: 332774

6 years agoMaintain PS4 ABI compatibility by making the fix made in r331136 not apply when the...
Douglas Yung [Fri, 18 May 2018 21:51:46 +0000 (21:51 +0000)]
Maintain PS4 ABI compatibility by making the fix made in r331136 not apply when the target is the PS4.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 332773

6 years agoFixing buildbot error introduced with r332759.
Wolfgang Pieb [Fri, 18 May 2018 21:44:28 +0000 (21:44 +0000)]
Fixing buildbot error introduced with r332759.

llvm-svn: 332772

6 years agoAMDGPU: Add pass to optimize reqd_work_group_size
Matt Arsenault [Fri, 18 May 2018 21:35:00 +0000 (21:35 +0000)]
AMDGPU: Add pass to optimize reqd_work_group_size

Eliminate loads from the dispatch packet when they will have
a known value.

Also pattern match the code used by the library to handle partial
workgroup dispatches, which isn't necessary if reqd_work_group_size
is used.

llvm-svn: 332771

6 years ago[InstCombine] Qualify a select pattern based transform to restrct to only min/max...
Craig Topper [Fri, 18 May 2018 21:21:56 +0000 (21:21 +0000)]
[InstCombine] Qualify a select pattern based transform to restrct to only min/max and ignore abs/nabs.

llvm-svn: 332770

6 years ago[WebAssembly] Object: Add more error checking for object file reading
Sam Clegg [Fri, 18 May 2018 21:08:26 +0000 (21:08 +0000)]
[WebAssembly] Object: Add more error checking for object file reading

This should address some the assert failures the fuzzer has been
finding such as:
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6719

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

llvm-svn: 332769

6 years agoImplement deduction guides for <array>; Reviewed as https://reviews.llvm.org/D46964
Marshall Clow [Fri, 18 May 2018 21:01:04 +0000 (21:01 +0000)]
Implement deduction guides for <array>; Reviewed as https://reviews.llvm.org/D46964

llvm-svn: 332768

6 years agoprivate_typeinfo: limit is_dst_type_derived_from_static_type optimization
Eric Fiselier [Fri, 18 May 2018 20:51:38 +0000 (20:51 +0000)]
private_typeinfo: limit is_dst_type_derived_from_static_type optimization

Patch by Ryan Prichard

If the destination type does not derive from the static type, we can skip
the search_above_dst call, but we still need to run the
!does_dst_type_point_to_our_static_type block of code. That block of code
will increment info->number_to_dst_ptr to 2, and because dest isn't derived
from static, the cast will ultimately fail.

Fixes PR33439

Reviewed as https://reviews.llvm.org/D36447

llvm-svn: 332767

6 years agoAddressing a couple of compiler warnings introduced with r332759.
Wolfgang Pieb [Fri, 18 May 2018 20:51:16 +0000 (20:51 +0000)]
Addressing a couple of compiler warnings introduced with r332759.

llvm-svn: 332766

6 years agoprivate_typeinfo: propagate static flags in vmi search_above_dst method
Eric Fiselier [Fri, 18 May 2018 20:42:53 +0000 (20:42 +0000)]
private_typeinfo: propagate static flags in vmi search_above_dst method

This adds the test which was mistakenly not committed in r332763.

Patch by Ryan Prichard

Propagate the found_our_static_ptr and found_any_static_type flags from
__vmi_class_type_info::search_above_dst to its caller.

Fixes PR33425 and PR33487

Reviewed as https://reviews.llvm.org/D36446

llvm-svn: 332764

6 years agoprivate_typeinfo: propagate static flags in vmi search_above_dst method
Eric Fiselier [Fri, 18 May 2018 20:39:57 +0000 (20:39 +0000)]
private_typeinfo: propagate static flags in vmi search_above_dst method

Patch by Ryan Prichard

Propagate the found_our_static_ptr and found_any_static_type flags from
__vmi_class_type_info::search_above_dst to its caller.

Fixes PR33425 and PR33487

Reviewed as https://reviews.llvm.org/D36446

llvm-svn: 332763

6 years agoFixing build error introduced with r332759.
Wolfgang Pieb [Fri, 18 May 2018 20:35:13 +0000 (20:35 +0000)]
Fixing build error introduced with r332759.

llvm-svn: 332762

6 years ago[msan] Don't check divisor shadow in fdiv.
Evgeniy Stepanov [Fri, 18 May 2018 20:19:53 +0000 (20:19 +0000)]
[msan] Don't check divisor shadow in fdiv.

Summary:
Floating point division by zero or even undef does not have undefined
behavior and may occur due to optimizations.

Fixes https://bugs.llvm.org/show_bug.cgi?id=37523.

Reviewers: kcc

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 332761

6 years agoRevert r332470 (and corresponding tests in r332492).
Richard Smith [Fri, 18 May 2018 20:18:17 +0000 (20:18 +0000)]
Revert r332470 (and corresponding tests in r332492).

This regressed our support for __attribute__((section)). See added test file
for example of code broken by this.

llvm-svn: 332760

6 years ago[DWARF v5] Improved support for .debug_rnglists (consumer). Enables any consumer to
Wolfgang Pieb [Fri, 18 May 2018 20:12:54 +0000 (20:12 +0000)]
[DWARF v5] Improved support for .debug_rnglists (consumer). Enables any consumer to
extract DWARF v5 encoded rangelists.

Reviewer: JDevlieghere

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

llvm-svn: 332759

6 years ago[NFC] Change cast from r332739 to a static cast
Jessica Paquette [Fri, 18 May 2018 20:04:21 +0000 (20:04 +0000)]
[NFC] Change cast from r332739 to a static cast

The casts in the delta computation for size remarks should have
been static casts. This fixes that.

Thanks to Dávid Bolvanský for pointing that out.

llvm-svn: 332758

6 years agoSupport: Simplify endian stream interface. NFCI.
Peter Collingbourne [Fri, 18 May 2018 19:46:24 +0000 (19:46 +0000)]
Support: Simplify endian stream interface. NFCI.

Provide some free functions to reduce verbosity of endian-writing
a single value, and replace the endianness template parameter with
a field.

Part of PR37466.

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

llvm-svn: 332757

6 years agoadding baseline fp fold tests for unsafe on and off
Michael Berg [Fri, 18 May 2018 19:30:49 +0000 (19:30 +0000)]
adding baseline fp fold tests for unsafe on and off

llvm-svn: 332756

6 years agoDelete a test that was missed in the revert r332747.
Amara Emerson [Fri, 18 May 2018 19:21:40 +0000 (19:21 +0000)]
Delete a test that was missed in the revert r332747.

r332747 originally reverted r332654 which added this test.

llvm-svn: 332755

6 years agoRevert r332683 & r332684 relating to compiler runtime checks
Reid Kleckner [Fri, 18 May 2018 18:44:37 +0000 (18:44 +0000)]
Revert r332683 & r332684 relating to compiler runtime checks

r332683 passes flags to the compiler without first checking if they are
supported.

llvm-svn: 332754

6 years agoAMDGPU/NFC: Set symbol's type that is coming from an argument in
Konstantin Zhuravlyov [Fri, 18 May 2018 18:41:37 +0000 (18:41 +0000)]
AMDGPU/NFC: Set symbol's type that is coming from an argument in
EmitAMDGPUSymbolType, instead of hard-coding it to STT_AMDGPU_HSA_KERNEL.

llvm-svn: 332753

6 years agoRevert "[clangd] Adapt file migration in r332720"
Eric Liu [Fri, 18 May 2018 18:33:21 +0000 (18:33 +0000)]
Revert "[clangd] Adapt file migration in r332720"

This reverts commit r332721 because the dependency r33270 will be reverted.

llvm-svn: 332752

6 years agoRevert "Move #include manipulation code to new lib/Tooling/Inclusions."
Eric Liu [Fri, 18 May 2018 18:33:08 +0000 (18:33 +0000)]
Revert "Move #include manipulation code to new lib/Tooling/Inclusions."

This reverts commit r332720. This break build bot with modules. Need to
investigate. Revert the change to unbreak bots.

llvm-svn: 332751

6 years ago[Support] Avoid normalization in sys::getDefaultTargetTriple
Petr Hosek [Fri, 18 May 2018 18:33:07 +0000 (18:33 +0000)]
[Support] Avoid normalization in sys::getDefaultTargetTriple

The return value of sys::getDefaultTargetTriple, which is derived from
-DLLVM_DEFAULT_TRIPLE, is used to construct tool names, default target,
and in the future also to control the search path directly; as such it
should be used textually, without interpretation by LLVM.

Normalization of this value may lead to unexpected results, for example
if we configure LLVM with -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnu,
normalization will transform that value to x86_64--linux-gnu. Driver will
use that value to search for tools prefixed with x86_64--linux-gnu- which
may be confusing. This is also inconsistent with the behavior of the
--target flag which is taken as-is without any normalization and overrides
the value of LLVM_DEFAULT_TARGET_TRIPLE.

Users of sys::getDefaultTargetTriple already perform their own
normalization as needed, so this change shouldn't impact existing logic.

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

llvm-svn: 332750

6 years agoMC: Change the streamer ctors to take an object writer instead of a stream. NFCI.
Peter Collingbourne [Fri, 18 May 2018 18:26:45 +0000 (18:26 +0000)]
MC: Change the streamer ctors to take an object writer instead of a stream. NFCI.

The idea is that a client that wants split dwarf would create a
specific kind of object writer that creates two files, and use it to
create the streamer.

Part of PR37466.

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

llvm-svn: 332749

6 years ago[Hexagon] Generate post-increment for floating point types
Brendon Cahoon [Fri, 18 May 2018 18:14:44 +0000 (18:14 +0000)]
[Hexagon] Generate post-increment for floating point types

The code that generates post-increments for Hexagon considered
integer values only. This patch adds support to generate them for
floating point values, f32 and f64.

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

llvm-svn: 332748

6 years agoReverted r332654 as it has broken some buildbots and left unfixed for a long time.
Galina Kistanova [Fri, 18 May 2018 18:14:06 +0000 (18:14 +0000)]
Reverted r332654 as it has broken some buildbots and left unfixed for a long time.

The introduced problem is:
llvm.src/lib/Transforms/Vectorize/VPlanVerifier.cpp:29:13: error: unused function 'hasDuplicates' [-Werror,-Wunused-function]
static bool hasDuplicates(const SmallVectorImpl<VPBlockBase *> &VPBlockVec) {
            ^

llvm-svn: 332747

6 years ago[asan] Explicitly declare memintrinsics interceptors to have C linkage
Walter Lee [Fri, 18 May 2018 18:01:08 +0000 (18:01 +0000)]
[asan] Explicitly declare memintrinsics interceptors to have C linkage

This is needed on RTEMS.  Also update a comment.

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

llvm-svn: 332746