platform/upstream/llvm.git
5 years agoFirst part of P0482 - Establish that char8_t is an integral type, and that numeric_li...
Marshall Clow [Thu, 29 Nov 2018 19:49:48 +0000 (19:49 +0000)]
First part of P0482 - Establish that char8_t is an integral type, and that numeric_limits<char8_t> is valid and sane.

llvm-svn: 347904

5 years ago[libcxx] Remove bad_array_length
Louis Dionne [Thu, 29 Nov 2018 19:44:57 +0000 (19:44 +0000)]
[libcxx] Remove bad_array_length

Summary:
std::bad_array_length was added by n3467, but this never made it into C++.
This commit removes the definition of std::bad_array_length from the headers
AND from the shared library. See the comments in the ABI changelog for details
about the ABI implications of this change.

Reviewers: mclow.lists, dexonsmith, howard.hinnant, EricWF

Subscribers: christof, jkorous, libcxx-commits

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

llvm-svn: 347903

5 years ago[SelectionDAG][AArch64][X86] Move legalization of vector MULHS/MULHU from LegalizeDAG...
Craig Topper [Thu, 29 Nov 2018 19:36:17 +0000 (19:36 +0000)]
[SelectionDAG][AArch64][X86] Move legalization of vector MULHS/MULHU from LegalizeDAG to LegalizeVectorOps

I believe we should be legalizing these with the rest of vector binary operations. If any custom lowering is required for these nodes, this will give the DAG combine between LegalizeVectorOps and LegalizeDAG to run on the custom code before constant build_vectors are lowered in LegalizeDAG.

I've moved MULHU/MULHS handling in AArch64 from Lowering to isel. Moving the lowering earlier caused build_vector+extract_subvector simplifications to kick in which made the generated code worse.

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

llvm-svn: 347902

5 years agoNFC: Fix case of CommentVisitor::Visit methods
Stephen Kelly [Thu, 29 Nov 2018 19:31:32 +0000 (19:31 +0000)]
NFC: Fix case of CommentVisitor::Visit methods

This difference is very visible because it is used with other Visitor
classes together.

llvm-svn: 347901

5 years agoNFC: Move ColorScope to global scope
Stephen Kelly [Thu, 29 Nov 2018 19:30:37 +0000 (19:30 +0000)]
NFC: Move ColorScope to global scope

llvm-svn: 347900

5 years agoNFC: Constify ShowColors
Stephen Kelly [Thu, 29 Nov 2018 19:30:08 +0000 (19:30 +0000)]
NFC: Constify ShowColors

llvm-svn: 347899

5 years ago[X86] Add a DAG combine pre type legalization to widen division by constant splat...
Craig Topper [Thu, 29 Nov 2018 19:13:38 +0000 (19:13 +0000)]
[X86] Add a DAG combine pre type legalization to widen division by constant splat on narrow vectors to avoid scalarization

This is another patch for -x86-experimental-vector-widening. This pre widens narrow division by constants so that we can get pass the legal type check in the generic DAG combiner. Otherwise we end up scalarizing.

I've restricted this to splats for now because it was easy to just call DAG.getConstant. Not sure what we should do for non-splat? Increase the element size?Widen the constant vector by padding with 1?

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

llvm-svn: 347898

5 years agoset default max-page-size to 4KB in lld for Android Aarch64
Zhizhou Yang [Thu, 29 Nov 2018 18:52:22 +0000 (18:52 +0000)]
set default max-page-size to 4KB in lld for Android Aarch64

Summary:
This patch passes an option '-z max-page-size=4096' to lld through clang driver.

This is for Android on Aarch64 target.

The lld default page size is too large for Aarch64, which produces larger .so files and images for arm64 device targets.
In this patch we set default page size to 4KB for Android Aarch64 targets instead.

Reviewers: srhines, danalbert, ruiu, chh, peter.smith

Reviewed By: srhines

Subscribers: javed.absar, kristof.beyls, cfe-commits, george.burgess.iv, llozano

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

llvm-svn: 347897

5 years ago[InstSimplify] fold select with implied condition
Sanjay Patel [Thu, 29 Nov 2018 18:44:39 +0000 (18:44 +0000)]
[InstSimplify] fold select with implied condition

This is an almost direct move of the functionality from InstCombine to
InstSimplify. There's no reason not to do this in InstSimplify because
we never create a new value with this transform.

(There's a question of whether any dominance-based transform belongs in
either of these passes, but that's a separate issue.)

I've changed 1 of the conditions for the fold (1 of the blocks for the
branch must be the block we started with) into an assert because I'm not
sure how that could ever be false.

We need 1 extra check to make sure that the instruction itself is in a
basic block because passes other than InstCombine may be using InstSimplify
as an analysis on values that are not wired up yet.

The 3-way compare changes show that InstCombine has some kind of
phase-ordering hole. Otherwise, we would have already gotten the intended
final result that we now show here.

llvm-svn: 347896

5 years agoSimplify the __builtin_constant_p test that was used to catch rC347417 failure
Fangrui Song [Thu, 29 Nov 2018 18:26:39 +0000 (18:26 +0000)]
Simplify the __builtin_constant_p test that was used to catch rC347417 failure

Reviewers: rsmith, void, shafik

Reviewed By: void

Subscribers: kristina, cfe-commits

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

llvm-svn: 347895

5 years ago[TableGen] Examine entire subreg compositions to detect ambiguity
Krzysztof Parzyszek [Thu, 29 Nov 2018 18:20:08 +0000 (18:20 +0000)]
[TableGen] Examine entire subreg compositions to detect ambiguity

When tablegen detects that there exist two subregister compositions that
result in the same value for some register, it will emit a warning. This
kind of an overlap in compositions should only happen when it is caused
by a user-defined composition. It can happen, however, that the user-
defined composition is not identically equal to another one, but it does
produce the same value for one or more registers. In such cases suppress
the warning.
This patch is to silence the warning when building the System Z backend
after D50725.

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

llvm-svn: 347894

5 years ago[GlobalISel] LegalizationArtifactCombiner: Combine aext([asz]ext x) -> [asz]ext x
Volkan Keles [Thu, 29 Nov 2018 18:19:24 +0000 (18:19 +0000)]
[GlobalISel] LegalizationArtifactCombiner: Combine aext([asz]ext x) -> [asz]ext x

Summary:
Replace `aext([asz]ext x)` with `aext/sext/zext x` in order to
reduce the number of instructions generated to clean up some
legalization artifacts.

Reviewers: aditya_nandakumar, dsanders, aemerson, bogner

Reviewed By: aemerson

Subscribers: rovka, kristof.beyls, javed.absar, llvm-commits

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

llvm-svn: 347893

5 years agoAdd missing REQUIRES to new test
Teresa Johnson [Thu, 29 Nov 2018 18:02:31 +0000 (18:02 +0000)]
Add missing REQUIRES to new test

Test added in r347887 requires an x86 target.

llvm-svn: 347892

5 years ago[llvm-objcopy] Delete redundant !Config.xx.empty() when followed by positive is_conta...
Fangrui Song [Thu, 29 Nov 2018 17:32:51 +0000 (17:32 +0000)]
[llvm-objcopy] Delete redundant !Config.xx.empty() when followed by positive is_contained() check

Summary: The original intention of !Config.xx.empty() was probably to emphasize the thing that is currently considered, but I feel the simplified form is actually easier to understand and it is also consistent with the call sites in other llvm components.

Reviewers: alexshap, rupprecht, jakehehrlich, jhenderson, espindola

Reviewed By: alexshap, rupprecht

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 347891

5 years agoAvoid redundant reference to isPodLike in SmallVect/Optional implementation
Serge Guelton [Thu, 29 Nov 2018 17:21:54 +0000 (17:21 +0000)]
Avoid redundant reference to isPodLike in SmallVect/Optional implementation

NFC, preparatory work for isPodLike cleaning.

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

llvm-svn: 347890

5 years ago[LICM] Reapply r347776 "Make LICM able to hoist phis" with fix
John Brawn [Thu, 29 Nov 2018 17:10:00 +0000 (17:10 +0000)]
[LICM] Reapply r347776 "Make LICM able to hoist phis" with fix

This commit caused a large compile-time slowdown in some cases when NDEBUG is
off due to the dominator tree verification it added. Fix this by only doing
dominator tree and loop info verification when something has been hoisted.

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

llvm-svn: 347889

5 years ago[analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__
Kristof Umann [Thu, 29 Nov 2018 17:09:41 +0000 (17:09 +0000)]
[analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__

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

llvm-svn: 347888

5 years ago[ThinLTO] Allow importing of multiple symbols with same GUID
Teresa Johnson [Thu, 29 Nov 2018 17:02:59 +0000 (17:02 +0000)]
[ThinLTO] Allow importing of multiple symbols with same GUID

Summary:
The is the clang side of the fix in D55047, to handle the case where
two different modules have local variables with the same GUID because
they had the same source file name at compilation time. Allow multiple
symbols with the same GUID to be imported, and test that this case works
with the distributed backend path.

Depends on D55047.

Reviewers: evgeny777

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, cfe-commits

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

llvm-svn: 347887

5 years ago[ThinLTO] Import local variables from the same module as caller
Teresa Johnson [Thu, 29 Nov 2018 17:02:42 +0000 (17:02 +0000)]
[ThinLTO] Import local variables from the same module as caller

Summary:
We can sometimes end up with multiple copies of a local variable that
have the same GUID in the index. This happens when there are local
variables with the same name that are in different source files having the
same name/path at compile time (but compiled into different bitcode objects).

In this case make sure we import the copy in the caller's module.
This enables importing both of the variables having the same GUID
(but which will have different promoted names since the module paths,
and therefore the module hashes, will be distinct).

Importing the wrong copy is particularly problematic for read only
variables, since we must import them as a local copy whenever
referenced. Otherwise we get undefs at link time.

Note that the llvm-lto.cpp and ThinLTOCodeGenerator changes are needed
for testing the distributed index case via clang, which will be sent as
a separate clang-side patch shortly. We were previously not doing the
dead code/read only computation before computing imports when testing
distributed index generation (like it was for testing importing and
other ThinLTO mechanisms alone).

Reviewers: evgeny777

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, dang, llvm-commits

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

llvm-svn: 347886

5 years agogit-llvm: Fix incremental population of svn tree.
James Y Knight [Thu, 29 Nov 2018 16:46:34 +0000 (16:46 +0000)]
git-llvm: Fix incremental population of svn tree.

"svn update --depth=..." is, annoyingly, not a specification of the
desired depth, but rather a _limit_ added on top of the "sticky" depth
in the working-directory. However, if the directory doesn't exist yet,
then it sets the sticky depth of the new directory entries.

Unfortunately, the svn command-line has no way of expanding the depth
of a directory from "empty" to "files", without also removing any
already-expanded subdirectories. The way you're supposed to increase
the depth of an existing directory is via --set-depth, but
--set-depth=files will also remove any subdirs which were already
requested.

This change avoids getting into the state of ever needing to increase
the depth of an existing directory from "empty" to "files" in the
first place, by:

1. Use svn update --depth=files, not --depth=immediates.

The latter has the effect of checking out the subdirectories and
marking them as depth=empty. The former excludes sub-directories from
the list of entries, which avoids the problem.

2. Explicitly populate missing parent directories.

Using --parents seemed nice and easy, but it marks the parent dirs as
depth=empty. Instead, check out parents explicitly if they're missing.

llvm-svn: 347883

5 years ago[SimplifyCFG] auto-generate complete checks; NFC
Sanjay Patel [Thu, 29 Nov 2018 16:28:37 +0000 (16:28 +0000)]
[SimplifyCFG] auto-generate complete checks; NFC

llvm-svn: 347882

5 years ago[InstCombine] auto-generate complete checks; NFC
Sanjay Patel [Thu, 29 Nov 2018 16:26:03 +0000 (16:26 +0000)]
[InstCombine] auto-generate complete checks; NFC

llvm-svn: 347881

5 years ago[AMDGPU] Add and update scalar instructions
Graham Sellers [Thu, 29 Nov 2018 16:05:38 +0000 (16:05 +0000)]
[AMDGPU] Add and update scalar instructions

This patch adds support for S_ANDN2, S_ORN2 32-bit and 64-bit instructions and adds splits to move them to the vector unit (for which there is no equivalent instruction). It modifies the way that the more complex scalar instructions are lowered to vector instructions by first breaking them down to sequences of simpler scalar instructions which are then lowered through the existing code paths. The pattern for S_XNOR has also been updated to apply inversion to one input rather than the output of the XOR as the result is equivalent and may allow leaving the NOT instruction on the scalar unit.

A new tests for NAND, NOR, ANDN2 and ORN2 have been added, and existing tests now hit the new instructions (and have been modified accordingly).

Differential: https://reviews.llvm.org/D54714
llvm-svn: 347877

5 years agoFix: Add support for TFE/LWE in image intrinsic
David Stuttard [Thu, 29 Nov 2018 15:56:36 +0000 (15:56 +0000)]
Fix: Add support for TFE/LWE in image intrinsic

My change svn-id: 347871 caused a buildbot failure due to an unused
variable def (used in an assert).

Change-Id: Ia882d18bb6fa79b4d7bbfda422b9ea5d23eab336
llvm-svn: 347876

5 years ago[libcxx] More fixes to XFAILs for aligned allocation tests for macosx 10.13
Louis Dionne [Thu, 29 Nov 2018 15:52:36 +0000 (15:52 +0000)]
[libcxx] More fixes to XFAILs for aligned allocation tests for macosx 10.13

Those tests are a real pain to tweak.

llvm-svn: 347875

5 years agoRevert r347823 "[TextAPI] Switch back to a custom Platform enum."
Hans Wennborg [Thu, 29 Nov 2018 15:47:24 +0000 (15:47 +0000)]
Revert r347823 "[TextAPI] Switch back to a custom Platform enum."

It broke the Windows buildbots, e.g.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/21829/steps/test/logs/stdio

This also reverts the follow-ups: r347824, r347827, and r347836.

llvm-svn: 347874

5 years agoMark __builtin_shufflevector as using custom type checking
Matt Arsenault [Thu, 29 Nov 2018 15:45:05 +0000 (15:45 +0000)]
Mark __builtin_shufflevector as using custom type checking

The custom handling seems to all be implemented already.
This avoids regressions in a future patch when float vectors
are ordinarily promoted to double vectors in variadic calls.

llvm-svn: 347873

5 years ago[CallSiteSplitting] Report edge deletion to DomTreeUpdater
Joseph Tremoulet [Thu, 29 Nov 2018 15:27:04 +0000 (15:27 +0000)]
[CallSiteSplitting] Report edge deletion to DomTreeUpdater

Summary:
When splitting musttail calls, the split blocks' original terminators
get removed; inform the DTU when this happens.

Also add a testcase that fails an assertion in the DTU without this fix.

Reviewers: fhahn, junbuml

Reviewed By: fhahn

Subscribers: llvm-commits

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

llvm-svn: 347872

5 years agoAdd support for TFE/LWE in image intrinsics
David Stuttard [Thu, 29 Nov 2018 15:21:13 +0000 (15:21 +0000)]
Add support for TFE/LWE in image intrinsics

TFE and LWE support requires extra result registers that are written in the
event of a failure in order to detect that failure case.
The specific use-case that initiated these changes is sparse texture support.

This means that if image intrinsics are used with either option turned on, the
programmer must ensure that the return type can contain all of the expected
results. This can result in redundant registers since the vector size must be a
power-of-2.

This change takes roughly 6 parts:
1. Modify the instruction defs in tablegen to add new instruction variants that
can accomodate the extra return values.
2. Updates to lowerImage in SIISelLowering.cpp to accomodate setting TFE or LWE
(where the bulk of the work for these instruction types is now done)
3. Extra verification code to catch cases where intrinsics have been used but
insufficient return registers are used.
4. Modification to the adjustWritemask optimisation to account for TFE/LWE being
enabled (requires extra registers to be maintained for error return value).
5. An extra pass to zero initialize the error value return - this is because if
the error does not occur, the register is not written and thus must be zeroed
before use. Also added a new (on by default) option to ensure ALL return values
are zero-initialized that is required for sparse texture support.
6. Disable the inst_combine optimization in the presence of tfe/lwe (later TODO
for this to re-enable and handle correctly).

There's an additional fix now to avoid a dmask=0

For an image intrinsic with tfe where all result channels except tfe
were unused, I was getting an image instruction with dmask=0 and only a
single vgpr result for tfe. That is incorrect because the hardware
assumes there is at least one vgpr result, plus the one for tfe.

Fixed by forcing dmask to 1, which gives the desired two vgpr result
with tfe in the second one.

The TFE or LWE result is returned from the intrinsics using an aggregate
type. Look in the test code provided to see how this works, but in essence IR
code to invoke the intrinsic looks as follows:

%v = call {<4 x float>,i32} @llvm.amdgcn.image.load.1d.v4f32i32.i32(i32 15,
                                      i32 %s, <8 x i32> %rsrc, i32 1, i32 0)
%v.vec = extractvalue {<4 x float>, i32} %v, 0
%v.err = extractvalue {<4 x float>, i32} %v, 1

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

Change-Id: If222bc03642e76cf98059a6bef5d5bffeda38dda
llvm-svn: 347871

5 years agoinhereit LLVM_ENABLE_LIBXML2
David Callahan [Thu, 29 Nov 2018 14:57:14 +0000 (14:57 +0000)]
inhereit LLVM_ENABLE_LIBXML2

Summary: When building in an LLVM context, we should respect its LLVM_ENABLE_LIBXML2 option.

Reviewers: vitalybuka, mspertus, modocache

Reviewed By: modocache

Subscribers: mgorny, cfe-commits

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

llvm-svn: 347870

5 years ago[CMake] Fix standalone build for debugserver on macOS
Stefan Granitz [Thu, 29 Nov 2018 14:51:49 +0000 (14:51 +0000)]
[CMake] Fix standalone build for debugserver on macOS

Summary:
Quick-fix to avoid CMake config issue:
```
CMake Error at /path/to/lldb/cmake/modules/AddLLDB.cmake:116 (add_dependencies):
  Cannot add target-level dependencies to non-existent target "lldb-suite".
```

Reviewers: xiaobai, beanz

Subscribers: mgorny, lldb-commits

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

llvm-svn: 347869

5 years ago[CVP] tidy processCmp(); NFC
Sanjay Patel [Thu, 29 Nov 2018 14:41:21 +0000 (14:41 +0000)]
[CVP] tidy processCmp(); NFC

1. The variables were confusing: 'C' typically refers to a constant, but here it was the Cmp.
2. Formatting violations.
3. Simplify code to return true/false constant.

llvm-svn: 347868

5 years agoRevert "[LICM] Enable control flow hoisting by default" and "[LICM] Reapply r347190...
Martin Storsjo [Thu, 29 Nov 2018 14:39:39 +0000 (14:39 +0000)]
Revert "[LICM] Enable control flow hoisting by default" and "[LICM] Reapply r347190 "Make LICM able to hoist phis" with fix"

This reverts commits r347776 and r347778.

The first one, r347776, caused significant compile time regressions
for certain input files, see PR39836 for details.

llvm-svn: 347867

5 years ago[CVP] auto-generate complete test checks; NFC
Sanjay Patel [Thu, 29 Nov 2018 14:28:47 +0000 (14:28 +0000)]
[CVP] auto-generate complete test checks; NFC

llvm-svn: 347866

5 years ago[OpenCL] Improve diags for addr spaces in templates
Anastasia Stulova [Thu, 29 Nov 2018 14:11:15 +0000 (14:11 +0000)]
[OpenCL] Improve diags for addr spaces in templates

Fix ICEs on template instantiations that were leading to
the creation of invalid code patterns with address spaces.

Incorrect cases are now diagnosed properly.

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

llvm-svn: 347865

5 years agoRevert r347596 "Support for inserting profile-directed cache prefetches"
Hans Wennborg [Thu, 29 Nov 2018 13:58:02 +0000 (13:58 +0000)]
Revert r347596 "Support for inserting profile-directed cache prefetches"

It causes asserts building BoringSSL. See https://crbug.com/91009#c3 for
repro.

This also reverts the follow-ups:
Revert r347724 "Do not insert prefetches with unsupported memory operands."
Revert r347606 "[X86] Add dependency from X86 to ProfileData after rL347596"
Revert r347607 "Add new passes to X86 pipeline tests"

llvm-svn: 347864

5 years agoSet MustBuildLookupTable on PrimaryContext in ExternalASTMerger
Raphael Isemann [Thu, 29 Nov 2018 13:50:30 +0000 (13:50 +0000)]
Set MustBuildLookupTable on PrimaryContext in ExternalASTMerger

Summary:
`MustBuildLookupTable` must always be called on a primary context as we otherwise
trigger an assert, but we don't ensure that this will always happen in our code right now.

This patch explicitly requests the primary context when doing this call as this shouldn't break
anything (as calling `getPrimaryContext` on a context which is its own primary context is a no-op)
but will catch these rare cases where we somehow operate on a declaration context that is
not its own primary context.

See also D54863.

Reviewers: martong, a.sidorin, shafik

Reviewed By: martong

Subscribers: davide, rnkovacs, cfe-commits

Tags: #lldb

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

llvm-svn: 347863

5 years ago[GlobalISel] Fix insertion of stack-protector epilogue
Petr Pavlu [Thu, 29 Nov 2018 13:22:53 +0000 (13:22 +0000)]
[GlobalISel] Fix insertion of stack-protector epilogue

* Tell the StackProtector pass to generate the epilogue instrumentation
  when GlobalISel is enabled because GISel currently does not implement
  the same deferred epilogue insertion as SelectionDAG.
* Update StackProtector::InsertStackProtectors() to find a stack guard
  slot by searching for the llvm.stackprotector intrinsic when the
  prologue was not created by StackProtector itself but the pass still
  needs to generate the epilogue instrumentation. This fixes a problem
  when the pass would abort because the stack guard AllocInst pointer
  was null when generating the epilogue -- test
  CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll.

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

llvm-svn: 347862

5 years ago[GlobalISel] Make EnableGlobalISel always set when GISel is enabled
Petr Pavlu [Thu, 29 Nov 2018 12:56:32 +0000 (12:56 +0000)]
[GlobalISel] Make EnableGlobalISel always set when GISel is enabled

Change meaning of TargetOptions::EnableGlobalISel. The flag was
previously set only when a target switched on GlobalISel but it is now
always set when the GlobalISel pipeline is enabled. This makes the flag
consistent with TargetOptions::EnableFastISel and allows its use in
other parts of the compiler to determine when GlobalISel is enabled.

The EnableGlobalISel flag had previouly only one use in
TargetPassConfig::isGlobalISelAbortEnabled(). The method used its value
to determine if GlobalISel was enabled by a target and returned false in
such a case. To preserve the current behaviour, a new flag
TargetOptions::GlobalISelAbort is introduced to separately record the
abort behaviour.

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

llvm-svn: 347861

5 years agoAdding a FIXME test to document an area for improvement with the cert-err58-cpp check...
Aaron Ballman [Thu, 29 Nov 2018 12:45:50 +0000 (12:45 +0000)]
Adding a FIXME test to document an area for improvement with the cert-err58-cpp check; NFC.

llvm-svn: 347860

5 years ago[LLDB] - Improve the support of .debug_str_offsets/.debug_str_offsets.dwo
George Rimar [Thu, 29 Nov 2018 12:44:10 +0000 (12:44 +0000)]
[LLDB] - Improve the support of .debug_str_offsets/.debug_str_offsets.dwo

A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
that points to the first string offset of the CU contribution to the
.debug_str_offsets. At the same time, when we use split dwarf,
the corresponding split debug unit also
may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo.
In that case, DWO does not contain DW_AT_str_offsets_base, but LLDB
still need to know and skip the .debug_str_offsets.dwo section header to
access the offsets.

The patch implements the support of DW_AT_str_offsets_base.

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

llvm-svn: 347859

5 years ago[llvm-rc] Support EXSTYLE statement.
Martin Storsjo [Thu, 29 Nov 2018 12:17:39 +0000 (12:17 +0000)]
[llvm-rc] Support EXSTYLE statement.

Patch by Jacek Caban!

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

llvm-svn: 347858

5 years ago[llvm-mca][MC] Add the ability to declare which processor resources model load/store...
Andrea Di Biagio [Thu, 29 Nov 2018 12:15:56 +0000 (12:15 +0000)]
[llvm-mca][MC] Add the ability to declare which processor resources model load/store queues (PR36666).

This patch adds the ability to specify via tablegen which processor resources
are load/store queue resources.

A new tablegen class named MemoryQueue can be optionally used to mark resources
that model load/store queues.  Information about the load/store queue is
collected at 'CodeGenSchedule' stage, and analyzed by the 'SubtargetEmitter' to
initialize two new fields in struct MCExtraProcessorInfo named `LoadQueueID` and
`StoreQueueID`.  Those two fields are identifiers for buffered resources used to
describe the load queue and the store queue.
Field `BufferSize` is interpreted as the number of entries in the queue, while
the number of units is a throughput indicator (i.e. number of available pickers
for loads/stores).

At construction time, LSUnit in llvm-mca checks for the presence of extra
processor information (i.e. MCExtraProcessorInfo) in the scheduling model.  If
that information is available, and fields LoadQueueID and StoreQueueID are set
to a value different than zero (i.e. the invalid processor resource index), then
LSUnit initializes its LoadQueue/StoreQueue based on the BufferSize value
declared by the two processor resources.

With this patch, we more accurately track dynamic dispatch stalls caused by the
lack of LS tokens (i.e. load/store queue full). This is also shown by the
differences in two BdVer2 tests. Stalls that were previously classified as
generic SCHEDULER FULL stalls, are not correctly classified either as "load
queue full" or "store queue full".

About the differences in the -scheduler-stats view: those differences are
expected, because entries in the load/store queue are not released at
instruction issue stage. Instead, those are released at instruction executed
stage.  This is the main reason why for the modified tests, the load/store
queues gets full before PdEx is full.

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

llvm-svn: 347857

5 years agoFix windows build broken by r347846
Pavel Labath [Thu, 29 Nov 2018 11:53:12 +0000 (11:53 +0000)]
Fix windows build broken by r347846

The changed order of includes caused compile errors on MSVC due to
snprintf macro definition. snprintf should available since VS2015, and
the rest of the code seems to be able to use snprintf just fine without
this macro, so this removes it from the lldb driver as well.

llvm-svn: 347855

5 years ago[LLD][ELF] Error if _GLOBAL_OFFSET_TABLE_ is defined in input objects
Peter Smith [Thu, 29 Nov 2018 11:18:07 +0000 (11:18 +0000)]
[LLD][ELF] Error if _GLOBAL_OFFSET_TABLE_ is defined in input objects

The _GLOBAL_OFFSET_TABLE_ is a linker defined symbol that is placed at
some location relative to the .got, .got.plt or .toc section. On some
targets such as Arm the correctness of some code sequences using a
relocation to _GLOBAL_OFFSET_TABLE_ depend on the value of the symbol
being in the linker defined place. Follow the ld.gold example and give
a multiple symbol definition error. The ld.bfd behaviour is to ignore the
definition in the input object and redefine it, which seems like it could
be more surprising.

fixes pr39587

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

llvm-svn: 347854

5 years agoAMDGPU/InsertWaitcnts: Remove the dependence on MachineLoopInfo
Nicolai Haehnle [Thu, 29 Nov 2018 11:06:26 +0000 (11:06 +0000)]
AMDGPU/InsertWaitcnts: Remove the dependence on MachineLoopInfo

Summary:
MachineLoopInfo cannot be relied on for correctness, because it cannot
properly recognize loops in irreducible control flow which can be
introduced by late machine basic block optimization passes. See the new
test case for the reduced form of an example that occurred in practice.

Use a simple fixpoint iteration instead.

In order to facilitate this change, refactor WaitcntBrackets so that it
only tracks pending events and registers, rather than also maintaining
state that is relevant for the high-level algorithm. Various accessor
methods can be removed or made private as a consequence.

Affects (in radv):
- dEQP-VK.glsl.loops.special.{for,while}_uniform_iterations.select_iteration_count_{fragment,vertex}

Fixes: r345719 ("AMDGPU: Rewrite SILowerI1Copies to always stay on SALU")

Reviewers: msearles, rampitec, scott.linder, kanarayan

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits, hakzsam

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

llvm-svn: 347853

5 years agoAMDGPU/InsertWaitcnt: Consistently use uint32_t for scores / time points
Nicolai Haehnle [Thu, 29 Nov 2018 11:06:21 +0000 (11:06 +0000)]
AMDGPU/InsertWaitcnt: Consistently use uint32_t for scores / time points

Summary:
There is one obsolete reference to using -1 as an indication of "unknown",
but this isn't actually used anywhere.

Using unsigned makes robust wrapping checks easier.

Reviewers: msearles, rampitec, scott.linder, kanarayan

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, llvm-commits, tpr, t-tye, hakzsam

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

llvm-svn: 347852

5 years agoAMDGPU/InsertWaitcnt: Remove unused WaitAtBeginning
Nicolai Haehnle [Thu, 29 Nov 2018 11:06:18 +0000 (11:06 +0000)]
AMDGPU/InsertWaitcnt: Remove unused WaitAtBeginning

Reviewers: msearles, rampitec, scott.linder, kanarayan

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits, hakzsam

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

llvm-svn: 347851

5 years agoAMDGPU/InsertWaitcnts: Simplify pending events tracking
Nicolai Haehnle [Thu, 29 Nov 2018 11:06:14 +0000 (11:06 +0000)]
AMDGPU/InsertWaitcnts: Simplify pending events tracking

Summary:
Instead of storing the "score" (last time point) of the various relevant
events, only store whether an event is pending or not.

This is sufficient, because whenever only one event of a count type is
pending, its last time point is naturally the upper bound of all time
points of this count type, and when multiple event types are pending,
the count type has gone out of order and an s_waitcnt to 0 is required
to clear any pending event type (and will then clear all pending event
types for that count type).

This also removes the special handling of GDS_GPR_LOCK and EXP_GPR_LOCK.
I do not understand what this special handling ever attempted to achieve.
It has existed ever since the original port from an internal code base,
so my best guess is that it solved a problem related to EXEC handling in
that internal code base.

Reviewers: msearles, rampitec, scott.linder, kanarayan

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits, hakzsam

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

llvm-svn: 347850

5 years agoAMDGPU/InsertWaitcnts: Use foreach loops for inst and wait event types
Nicolai Haehnle [Thu, 29 Nov 2018 11:06:11 +0000 (11:06 +0000)]
AMDGPU/InsertWaitcnts: Use foreach loops for inst and wait event types

Summary:
It hides the type casting ugliness, and I happened to have to add a new
such loop (in a later patch).

Reviewers: msearles, rampitec, scott.linder, kanarayan

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits, hakzsam

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

llvm-svn: 347849

5 years agoAMDGPU/InsertWaitcnts: Untangle some semi-global state
Nicolai Haehnle [Thu, 29 Nov 2018 11:06:06 +0000 (11:06 +0000)]
AMDGPU/InsertWaitcnts: Untangle some semi-global state

Summary:
Reduce the statefulness of the algorithm in two ways:

1. More clearly split generateWaitcntInstBefore into two phases: the
   first one which determines the required wait, if any, without changing
   the ScoreBrackets, and the second one which actually inserts the wait
   and updates the brackets.

2. Communicate pre-existing s_waitcnt instructions using an argument to
   generateWaitcntInstBefore instead of through the ScoreBrackets.

To simplify these changes, a Waitcnt structure is introduced which carries
the counts of an s_waitcnt instruction in decoded form.

There are some functional changes:

1. The FIXME for the VCCZ bug workaround was implemented: we only wait for
   SMEM instructions as required instead of waiting on all counters.

2. We now properly track pre-existing waitcnt's in all cases, which leads
   to less conservative waitcnts being emitted in some cases.

     s_load_dword ...
     s_waitcnt lgkmcnt(0)    <-- pre-existing wait count
     ds_read_b32 v0, ...
     ds_read_b32 v1, ...
     s_waitcnt lgkmcnt(0)    <-- this is too conservative
     use(v0)
     more code
     use(v1)

   This increases code size a bit, but the reduced latency should still be a
   win in basically all cases. The worst code size regressions in my shader-db
   are:

 WORST REGRESSIONS - Code Size
 Before After     Delta Percentage
   1724  1736        12    0.70 %   shaders/private/f1-2015/1334.shader_test [0]
   2276  2284         8    0.35 %   shaders/private/f1-2015/1306.shader_test [0]
   4632  4640         8    0.17 %   shaders/private/ue4_elemental/62.shader_test [0]
   2376  2384         8    0.34 %   shaders/private/f1-2015/1308.shader_test [0]
   3284  3292         8    0.24 %   shaders/private/talos_principle/1955.shader_test [0]

Reviewers: msearles, rampitec, scott.linder, kanarayan

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits, hakzsam

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

llvm-svn: 347848

5 years ago[CODE_OWNERS] Add myself as code owner for MinGW
Martin Storsjo [Thu, 29 Nov 2018 10:58:15 +0000 (10:58 +0000)]
[CODE_OWNERS] Add myself as code owner for MinGW

llvm-svn: 347847

5 years agoRemove getopt includes from the driver
Pavel Labath [Thu, 29 Nov 2018 10:45:41 +0000 (10:45 +0000)]
Remove getopt includes from the driver

They are not needed now that we use LLVMOption for command-line parsing
thank you, Jonas).  This also allows us to avoid linking of lldbHost
into the driver which was breaking liblldb encapsulation.

(Technically, there is still a lldb/Host/windows/windows.h include which
is needed on windows, but this is a header-only wrapper for <windows.h>,
so it is not necessary to link lldbHost for that. But ideally, that
should go away too.)

llvm-svn: 347846

5 years ago[NFC] Add two XFAIL tests from PR39783
Max Kazantsev [Thu, 29 Nov 2018 09:38:22 +0000 (09:38 +0000)]
[NFC] Add two XFAIL tests from PR39783

llvm-svn: 347845

5 years agoDisable TermFolding in LoopSimplifyCFG until PR39783 is fixed
Max Kazantsev [Thu, 29 Nov 2018 09:00:19 +0000 (09:00 +0000)]
Disable TermFolding in LoopSimplifyCFG until PR39783 is fixed

llvm-svn: 347844

5 years ago[LoopStrengthReduce] ComplexityLimit as an option
Sam Parker [Thu, 29 Nov 2018 08:34:22 +0000 (08:34 +0000)]
[LoopStrengthReduce] ComplexityLimit as an option

Convert ComplexityLimit into a command line value.

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

llvm-svn: 347843

5 years ago[LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for...
George Rimar [Thu, 29 Nov 2018 08:16:07 +0000 (08:16 +0000)]
[LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

The issue happens because starting from DWARF v5
DW_AT_addr_base attribute should be used
instead of DW_AT_GNU_addr_base. LLDB does not do that and
we end up reading the .debug_addr header as section content
(as addresses) instead of skipping it and reading the real addresses.
Then LLDB is unable to match 2 similar locations and
thinks they are different.

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

llvm-svn: 347842

5 years ago[Inliner] Modify the merging of min-legal-vector-width attribute to better handle...
Craig Topper [Thu, 29 Nov 2018 07:27:38 +0000 (07:27 +0000)]
[Inliner] Modify the merging of min-legal-vector-width attribute to better handle when the caller or callee don't have the attribute.

Lack of an attribute means that the function hasn't been checked for what vector width it requires. So if the caller or the callee doesn't have the attribute we should make sure the combined function after inlining does not have the attribute.

If the caller already doesn't have the attribute we can just avoid adding it. Otherwise if the callee doesn't have the attribute just remove the caller's attribute.

llvm-svn: 347841

5 years ago[Inliner] Add test for merging of min-legal-vector-width function attribute.
Craig Topper [Thu, 29 Nov 2018 07:02:47 +0000 (07:02 +0000)]
[Inliner] Add test for merging of min-legal-vector-width function attribute.

This should have been added in r337844, but apparently was I failed to 'git add' the file.

llvm-svn: 347840

5 years ago[CGP] Improve compile time for complex addressing mode
Serguei Katkov [Thu, 29 Nov 2018 06:45:18 +0000 (06:45 +0000)]
[CGP] Improve compile time for complex addressing mode

This is a fix for PR39625 with improvement the compile time
by reducing the number of intermediate Phi nodes created.

Reviewers: john.brawn, reames
Reviewed By: john.brawn
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D54932

llvm-svn: 347839

5 years agoRevert "[TextAPI] Fix a memory leak in the TBD reader."
Juergen Ributzka [Thu, 29 Nov 2018 06:32:49 +0000 (06:32 +0000)]
Revert "[TextAPI] Fix a memory leak in the TBD reader."

llvm-svn: 347838

5 years ago[TextAPI] Fix a memory leak in the TBD reader.
Juergen Ributzka [Thu, 29 Nov 2018 06:16:33 +0000 (06:16 +0000)]
[TextAPI] Fix a memory leak in the TBD reader.

This fixes an issue where we were leaking the YAML document if there was a
parsing error.

llvm-svn: 347837

5 years ago[TextAPI] Switch back to a custom Platform enum.
Juergen Ributzka [Thu, 29 Nov 2018 05:56:03 +0000 (05:56 +0000)]
[TextAPI] Switch back to a custom Platform enum.

Moving to PlatformType from BinaryFormat had some UB fallout when handing
unknown platforms or malformed input files.

This should fix the sanitizer bots.

llvm-svn: 347836

5 years ago[X86] Correct comment. NFC
Craig Topper [Thu, 29 Nov 2018 05:56:03 +0000 (05:56 +0000)]
[X86] Correct comment. NFC

llvm-svn: 347835

5 years agoAdd Hurd target to Clang driver (2/2)
Kristina Brooks [Thu, 29 Nov 2018 03:49:14 +0000 (03:49 +0000)]
Add Hurd target to Clang driver (2/2)

This adds Hurd toolchain support to Clang's driver in addition
to handling translating the triple from Hurd-compatible form to
the actual triple registered in LLVM.

(Phabricator was stripping the empty files from the patch so I
manually created them)

Patch by sthibaul (Samuel Thibault)

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

llvm-svn: 347833

5 years agoAdd Hurd target to LLVMSupport (1/2)
Kristina Brooks [Thu, 29 Nov 2018 03:23:01 +0000 (03:23 +0000)]
Add Hurd target to LLVMSupport (1/2)

Add the required target triples to LLVMSupport to support Hurd
in LLVM (formally `pc-hurd-gnu`).

Patch by sthibaul (Samuel Thibault)

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

llvm-svn: 347832

5 years ago[PowerPC] Fix a conversion is not considered when the ISD::BR_CC node making the...
Li Jia He [Thu, 29 Nov 2018 03:04:39 +0000 (03:04 +0000)]
[PowerPC] Fix a conversion is not considered when the ISD::BR_CC node making the instruction selection

Summary:
 A signed comparison of i1 values produces the opposite result to an unsigned one if the condition code
 includes less-than or greater-than. This is so because 1 is the most negative signed i1 number and the
 most positive unsigned i1 number. The CR-logical operations used for such comparisons are non-commutative
 so for signed comparisons vs. unsigned ones, the input operands just need to be swapped.

Reviewed By: steven.zhang

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

llvm-svn: 347831

5 years ago[WebAssembly] Update docs
Sam Clegg [Thu, 29 Nov 2018 02:55:25 +0000 (02:55 +0000)]
[WebAssembly] Update docs

This is an reland of rL343155 which got reverted because
of a sphinx failure on the buildbot.

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

llvm-svn: 347830

5 years ago[PowerPC] [NFC] Add test cases to the ISD::BR_CC node in the instruction selection
Li Jia He [Thu, 29 Nov 2018 02:51:03 +0000 (02:51 +0000)]
[PowerPC] [NFC] Add test cases to the ISD::BR_CC node in the instruction selection
Add the following test case for the ISD::BR_CC node in the instruction selection
define i64 @testi64slt(i64 %c1, i64 %c2, i64 %c3, i64 %c4, i64 %a1, i64 %a2) #0 {
entry:
  %cmp1 = icmp eq i64 %c3, %c4
  %cmp3tmp = icmp eq i64 %c1, %c2
  %cmp3 = icmp slt i1 %cmp3tmp, %cmp1
  br i1 %cmp3, label %iftrue, label %iffalse
iftrue:
  ret i64 %a1
iffalse:
  ret i64 %a2
}
The data type i64 can be replaced by i32, i64, float, double

And condition codes can be replaced by: SETEQ, SETEN, SELT, SETLE, SETGT, SETGE,SETULT, SETULE, SSETGT, and SETUGE

Reviewed By: steven.zhang

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

llvm-svn: 347828

5 years ago[TextAPI] TBD Reader/Writer (bot fixes: take 2)
Juergen Ributzka [Thu, 29 Nov 2018 02:28:58 +0000 (02:28 +0000)]
[TextAPI] TBD Reader/Writer (bot fixes: take 2)

Replace the tuple with a struct to work around an explicit constructor bug.

llvm-svn: 347827

5 years agoNFC. Use unsigned type for uses counter in CaptureTracking
Artur Pilipenko [Thu, 29 Nov 2018 02:15:35 +0000 (02:15 +0000)]
NFC. Use unsigned type for uses counter in CaptureTracking

llvm-svn: 347826

5 years ago[Documentation] Try to fix build failure in cppcoreguidelines-narrowing-conversions...
Eugene Zelenko [Thu, 29 Nov 2018 02:13:25 +0000 (02:13 +0000)]
[Documentation] Try to fix build failure in cppcoreguidelines-narrowing-conversions documentation

llvm-svn: 347825

5 years ago[TextAPI] TBD Reader/Writer (bot fixes)
Juergen Ributzka [Thu, 29 Nov 2018 01:55:57 +0000 (01:55 +0000)]
[TextAPI] TBD Reader/Writer (bot fixes)

Trying if switching from a vector to an array will appeas the bots.

llvm-svn: 347824

5 years ago[TextAPI] TBD Reader/Writer
Juergen Ributzka [Thu, 29 Nov 2018 01:20:46 +0000 (01:20 +0000)]
[TextAPI] TBD Reader/Writer

Add basic infrastructure for reading and writting TBD files (version 1 - 3).

The TextAPI library is not used by anything yet (besides the unit tests). Tool
support will be added in a separate commit.

The TBD format is currently documented in the implementation file (TextStub.cpp).

https://reviews.llvm.org/D53945

Update: This contains changes to fix issues discovered by the bots:
 - add parentheses to silence warnings.
 - rename variables
 - use PlatformType from BinaryFormat
llvm-svn: 347823

5 years ago[driver] Fix --core/-c and add test
Jonas Devlieghere [Thu, 29 Nov 2018 00:22:28 +0000 (00:22 +0000)]
[driver] Fix --core/-c and add test

Because the optarg variable was shadowed we didn't notice we weren't
extracting the value from the option. This patch fixes that and renames
the variable to prevent this from happening in the future.

I also added two tests to check the error output for --core and --file
when the given value doesn't exist.

llvm-svn: 347821

5 years ago[ELF] --gdb-index: use lower_bound to compute relative CU index in the object file
Fangrui Song [Thu, 29 Nov 2018 00:17:00 +0000 (00:17 +0000)]
[ELF] --gdb-index: use lower_bound to compute relative CU index in the object file

Summary:
This reinstates what I originally intended to do in D54361.
It removes the assumption that .debug_gnu_pubnames has increasing CuOffset.

Now we do better than gold here: when .debug_gnu_pubnames contains
multiple sets, gold would think every set has the same CU index as the
first set (incorrect).

Reviewed By: ruiu

Reviewers: ruiu, dblaikie, espindola

Subscribers: emaste, arichardson, arphaman, llvm-commits

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

llvm-svn: 347820

5 years ago[x86] try select simplification for target-specific nodes
Sanjay Patel [Wed, 28 Nov 2018 22:51:04 +0000 (22:51 +0000)]
[x86] try select simplification for target-specific nodes

This failed to select (which might be a separate bug) in
X86ISelDAGToDAG because we try to create a select node
that can be simplified away after rL347227.

This change avoids the problem by simplifying the SHRUNKBLEND
node sooner. In the test case, we manage to realize that the
true/false values of the select (SHRUNKBLEND) are the same thing,
so it simplifies away completely.

llvm-svn: 347818

5 years ago[driver] Some NFC cleanup
Jonas Devlieghere [Wed, 28 Nov 2018 22:39:17 +0000 (22:39 +0000)]
[driver] Some NFC cleanup

This patch includes some small things I noticed while refactoring the
driver but didn't want to include in that patch.

llvm-svn: 347817

5 years agoRevert "Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`. "
Eric Fiselier [Wed, 28 Nov 2018 22:24:19 +0000 (22:24 +0000)]
Revert "Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`. "

This reverts commit 087f065cb0c7463f521a62599884493aaee2ea12.

The tests were failing on 32 bit builds, and I don't have time
to clean them up right now. I'll recommit tomorrow with fixed tests.

llvm-svn: 347816

5 years agoEnsure that test clang-tidy/export-relpath.cpp works with Windows path separators.
Matthew Voss [Wed, 28 Nov 2018 22:16:18 +0000 (22:16 +0000)]
Ensure that test clang-tidy/export-relpath.cpp works with Windows path separators.

llvm-svn: 347815

5 years agoMake standalone build find tabelgen
Jonas Devlieghere [Wed, 28 Nov 2018 22:10:01 +0000 (22:10 +0000)]
Make standalone build find tabelgen

The standalone build couldn't find tablegen because we didn't include
it. This patch rectifies that.

llvm-svn: 347814

5 years ago[lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_except...
Kuba Mracek [Wed, 28 Nov 2018 22:01:52 +0000 (22:01 +0000)]
[lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes

This adds new APIs and a command to deal with exceptions (mostly Obj-C exceptions): SBThread and Thread get GetCurrentException API, which returns an SBValue/ValueObjectSP with the current exception for a thread. "Current" means an exception that is currently being thrown, caught or otherwise processed. In this patch, we only know about the exception when in objc_exception_throw, but subsequent patches will expand this (and add GetCurrentExceptionBacktrace, which will return an SBThread/ThreadSP containing a historical thread backtrace retrieved from the exception object. Currently unimplemented, subsequent patches will implement this).

Extracting the exception from objc_exception_throw is implemented by adding a frame recognizer.

This also add a new sub-command "thread exception", which prints the current exception.

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

llvm-svn: 347813

5 years agoAllow cpu-dispatch forward declarations.
Erich Keane [Wed, 28 Nov 2018 21:54:04 +0000 (21:54 +0000)]
Allow cpu-dispatch forward declarations.

As a followup to r347805, allow forward declarations of cpu-dispatch and
cpu-specific for the same reasons.

Change-Id: Ic1bde9be369b1f8f1d47d58e6fbdc2f9dfcdd785
llvm-svn: 347812

5 years agoEnsure sanitizer check function calls have a !dbg location
Adrian Prantl [Wed, 28 Nov 2018 21:44:06 +0000 (21:44 +0000)]
Ensure sanitizer check function calls have a !dbg location

Function calls without a !dbg location inside a function that has a
DISubprogram make it impossible to construct inline information and
are rejected by the verifier. This patch ensures that sanitizer check
function calls have a !dbg location, by carrying forward the location
of the preceding instruction or by inserting an artificial location if
necessary.

This fixes a crash when compiling the attached testcase with -Os.

rdar://problem/45311226

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

Note: This reapllies r344915, modified to reuse the IRBuilder's
DebugLoc if one exists instead of picking the one from CGDebugInfo
since the latter may get reset when emitting thunks such as block
helpers in the middle of emitting another function.

llvm-svn: 347810

5 years agoRevert "[TextAPI] TBD Reader/Writer"
Juergen Ributzka [Wed, 28 Nov 2018 21:38:28 +0000 (21:38 +0000)]
Revert "[TextAPI] TBD Reader/Writer"

Reverting to unbreak bots.

llvm-svn: 347809

5 years ago[TextAPI] TBD Reader/Writer
Juergen Ributzka [Wed, 28 Nov 2018 21:27:00 +0000 (21:27 +0000)]
[TextAPI] TBD Reader/Writer

Add basic infrastructure for reading and writting TBD files (version 1 - 3).

The TextAPI library is not used by anything yet (besides the unit tests). Tool
support will be added in a separate commit.

The TBD format is currently documented in the implementation file (TextStub.cpp).

https://reviews.llvm.org/D53945

llvm-svn: 347808

5 years ago[DebugInfo] NFC Clang test changes for: IR/Bitcode changes for DISubprogram flags.
Paul Robinson [Wed, 28 Nov 2018 21:18:07 +0000 (21:18 +0000)]
[DebugInfo] NFC Clang test changes for: IR/Bitcode changes for DISubprogram flags.

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

llvm-svn: 347807

5 years ago[DebugInfo] IR/Bitcode changes for DISubprogram flags.
Paul Robinson [Wed, 28 Nov 2018 21:14:32 +0000 (21:14 +0000)]
[DebugInfo] IR/Bitcode changes for DISubprogram flags.

Packing the flags into one bitcode word will save effort in
adding new flags in the future.

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

llvm-svn: 347806

5 years agoCorrect 'target' default behavior on redecl, allow forward declaration.
Erich Keane [Wed, 28 Nov 2018 20:58:43 +0000 (20:58 +0000)]
Correct 'target' default behavior on redecl, allow forward declaration.

Declarations without the attribute were disallowed because it would be
ambiguous which 'target' it was supposed to be on.  For example:

void ___attribute__((target("v1"))) foo();
void foo(); // Redecl of above, or fwd decl of below?
void ___attribute__((target("v2"))) foo();

However, a first declaration doesn't have that problem, and erroring
prevents it from working in cases where the forward declaration is
useful.

Additionally, a forward declaration of target==default wouldn't properly
cause multiversioning, so this patch fixes that.

The patch was not split since the 'default' fix would require
implementing the same check for that case, followed by undoing the same
change for the fwd-decl implementation.

Change-Id: I66f2c5bc2477bcd3f7544b9c16c83ece257077b0
llvm-svn: 347805

5 years ago[Coverage] Specify the Itanium ABI triple for a C++ test
Vedant Kumar [Wed, 28 Nov 2018 20:51:09 +0000 (20:51 +0000)]
[Coverage] Specify the Itanium ABI triple for a C++ test

llvm-svn: 347804

5 years ago[Coverage] Do not visit artificial stmts in defaulted methods (PR39822)
Vedant Kumar [Wed, 28 Nov 2018 20:48:07 +0000 (20:48 +0000)]
[Coverage] Do not visit artificial stmts in defaulted methods (PR39822)

There is no reason to emit coverage mappings for artificial statements
contained within defaulted methods, as these statements are not visible
to users.

Only emit a mapping for the body of the defaulted method (clang treats
the text of the "default" keyword as the body when reporting locations).
This allows users to see how often the default method is called, but
trims down the coverage mapping by skipping visitation of the children
of the method.

The immediate motivation for this change is that the lexer's
getPreciseTokenLocEnd API cannot return the correct location when given
an artificial statement (with a somewhat made-up location) as an input.

Test by Orivej Desh!

Fixes llvm.org/PR39822.

llvm-svn: 347803

5 years ago[OpenMP] Rename ompt_mutex_impl_unknown to ompt_mutex_impl_none
Jonathan Peyton [Wed, 28 Nov 2018 20:19:53 +0000 (20:19 +0000)]
[OpenMP] Rename ompt_mutex_impl_unknown to ompt_mutex_impl_none

This change renames ompt_mutex_impl_unknown to ompt_mutex_impl_none,
following the name change in the specification.

Patch by Hansang Bae

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

llvm-svn: 347802

5 years ago[OpenMP] Minor cleanup of debug code
Jonathan Peyton [Wed, 28 Nov 2018 20:18:06 +0000 (20:18 +0000)]
[OpenMP] Minor cleanup of debug code

* Fix calculation of string length.
* Remove NULL-check of pointer which has been dereferenced.

Patch by Andrey Churbanov

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

llvm-svn: 347801

5 years ago[OpenMP] Fixed possible array out of bound access
Jonathan Peyton [Wed, 28 Nov 2018 20:15:11 +0000 (20:15 +0000)]
[OpenMP] Fixed possible array out of bound access

There is low probability that array th_hot_teams can be
accessed out of bound (when many nested levels are requested
to keep hot teams via KMP_HOT_TEAMS_MAX_LEVEL). The patch
adds the check of index that fixes the problem.

Patch by Andrey Churbanov

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

llvm-svn: 347800

5 years ago[OpenMP] Add omp_get_device_num() and update several other device API functions
Jonathan Peyton [Wed, 28 Nov 2018 20:10:26 +0000 (20:10 +0000)]
[OpenMP] Add omp_get_device_num() and update several other device API functions

Add omp_get_device_num() function for 5.0 which returns the number of the device
the current thread is running on. Also, did some cleanup and updating of device
API functions to make them into weak functions that should be replaced with
libomptarget functions when libomptarget is present.

Patch by Terry Wilmarth

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

llvm-svn: 347799

5 years ago[unittests] Fix the File System Test on Windows
Stella Stamenova [Wed, 28 Nov 2018 19:34:01 +0000 (19:34 +0000)]
[unittests] Fix the File System Test on Windows

Two of the file system tests are failing on Windows - this updates them to expect the correct values after the refactor of the file system code.

llvm-svn: 347796

5 years agoReapply "[llvm-mca] Return the total number of cycles from method Pipeline::run()."
Andrea Di Biagio [Wed, 28 Nov 2018 19:31:19 +0000 (19:31 +0000)]
Reapply "[llvm-mca] Return the total number of cycles from method Pipeline::run()."

This reapplies r347767 (originally reviewed at: https://reviews.llvm.org/D55000)
with a fix for the missing std::move of the Error returned by the call to
Pipeline::runCycle().

Below is the original commit message from r347767.

If a user only cares about the overall latency, then the best/quickest way is to
change method Pipeline::run() so that it returns the total number of cycles to
the caller.

When the simulation pipeline is run, the number of cycles (or an error) is
returned from method Pipeline::run().
The advantage is that no hardware event listener is needed for computing that
latency. So, the whole process should be faster (and simpler - at least for that
particular use case).

llvm-svn: 347795

5 years agoRevert "[ASTImporter] Changed use of Import to Import_New in ASTImporter."
Davide Italiano [Wed, 28 Nov 2018 19:15:23 +0000 (19:15 +0000)]
Revert "[ASTImporter] Changed use of Import to Import_New in ASTImporter."

This broke the lldb bots.

llvm-svn: 347794

5 years ago[OPENMP]Fix emission of the target regions in virtual functions.
Alexey Bataev [Wed, 28 Nov 2018 19:00:07 +0000 (19:00 +0000)]
[OPENMP]Fix emission of the target regions in virtual functions.

Fixed emission of the target regions found in the virtual functions.
Previously we may end up with the situation when those regions could be
skipped.

llvm-svn: 347793

5 years agoRevert "[clang-tools-extra] r347753 - [clangd] Build and test IndexBenchmark in check...
Matthew Voss [Wed, 28 Nov 2018 18:48:32 +0000 (18:48 +0000)]
Revert "[clang-tools-extra] r347753 - [clangd] Build and test IndexBenchmark in check-clangd"

This revision was causing failures on the buildbots, and our internal CI.

See: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/20856
llvm-svn: 347792