platform/upstream/llvm.git
6 years ago[Utility] Simplify and generalize the CleanUp helper, NFC
Vedant Kumar [Fri, 23 Feb 2018 22:08:38 +0000 (22:08 +0000)]
[Utility] Simplify and generalize the CleanUp helper, NFC

Removing the template arguments and most of the mutating methods from
CleanUp makes it easier to understand and reuse.

In its present state, CleanUp would be too cumbersome to adapt to cases
where multiple objects need to be released. Take for example this change
in swift-lldb:

  https://github.com/apple/swift-lldb/pull/334/files#diff-6f474df750f75c8ba675f2a8408a5629R219

This change is simple to express with the new CleanUp, but not so simple
with the old version.

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

llvm-svn: 325964

6 years ago[ELF] Fix IsPreemptible comment and typo. NFC
Fangrui Song [Fri, 23 Feb 2018 21:57:49 +0000 (21:57 +0000)]
[ELF] Fix IsPreemptible comment and typo. NFC

llvm-svn: 325963

6 years agoIntrinsics calls should avoid the PLT when "RtLibUseGOT" metadata is present.
Sriraman Tallam [Fri, 23 Feb 2018 21:32:06 +0000 (21:32 +0000)]
Intrinsics calls should avoid the PLT when "RtLibUseGOT" metadata is present.

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

llvm-svn: 325962

6 years agoSet Module Metadata "RtLibUseGOT" when fno-plt is used.
Sriraman Tallam [Fri, 23 Feb 2018 21:27:33 +0000 (21:27 +0000)]
Set Module Metadata "RtLibUseGOT" when fno-plt is used.

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

llvm-svn: 325961

6 years ago[InstCombine] allow fmul-sqrt folds with less than full -ffast-math
Sanjay Patel [Fri, 23 Feb 2018 21:16:12 +0000 (21:16 +0000)]
[InstCombine] allow fmul-sqrt folds with less than full -ffast-math

Also, add a Builder method for intrinsics to reduce code duplication for clients.

llvm-svn: 325960

6 years agoSimplify a DEBUG statement to remove a set but not used variable in release builds.
Eric Christopher [Fri, 23 Feb 2018 21:14:47 +0000 (21:14 +0000)]
Simplify a DEBUG statement to remove a set but not used variable in release builds.

llvm-svn: 325959

6 years agoFix breakpoint thread name conditionals after breakpoint options refactor.
Jim Ingham [Fri, 23 Feb 2018 21:10:42 +0000 (21:10 +0000)]
Fix breakpoint thread name conditionals after breakpoint options refactor.

PR36435

llvm-svn: 325958

6 years ago[X86] Add assembler/disassembler support for blendm with zero masking and broacast.
Craig Topper [Fri, 23 Feb 2018 20:48:44 +0000 (20:48 +0000)]
[X86] Add assembler/disassembler support for blendm with zero masking and broacast.

Fixes PR31617

llvm-svn: 325957

6 years ago[Power9] Add missing instructions to the Power 9 scheduler
Stefan Pintilie [Fri, 23 Feb 2018 20:37:10 +0000 (20:37 +0000)]
[Power9] Add missing instructions to the Power 9 scheduler

This is the first in a series of patches that will define more
instructions using InstRW so that we can move away from ItinRW
and ultimately have a complete Power 9 scheduler.

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

llvm-svn: 325956

6 years agoRemove dead code.
Rui Ueyama [Fri, 23 Feb 2018 20:33:43 +0000 (20:33 +0000)]
Remove dead code.

llvm-svn: 325955

6 years ago[Hexagon] Recognize non-immediate constants in HexagonConstPropagation
Krzysztof Parzyszek [Fri, 23 Feb 2018 20:33:26 +0000 (20:33 +0000)]
[Hexagon] Recognize non-immediate constants in HexagonConstPropagation

llvm-svn: 325954

6 years agoInline printHelp.
Rui Ueyama [Fri, 23 Feb 2018 20:24:40 +0000 (20:24 +0000)]
Inline printHelp.

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

llvm-svn: 325953

6 years agoHandle --version before handling --mllvm.
Rui Ueyama [Fri, 23 Feb 2018 20:24:28 +0000 (20:24 +0000)]
Handle --version before handling --mllvm.

Because it's a waste of time to handle --mllvm before --version.

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

llvm-svn: 325952

6 years agoFixed unused variable warning. NFCI.
Simon Pilgrim [Fri, 23 Feb 2018 20:16:18 +0000 (20:16 +0000)]
Fixed unused variable warning. NFCI.

llvm-svn: 325950

6 years ago[X86] Add DAG combine to remove (and X, 1) from in front of a v1i1 scalar to vector.
Craig Topper [Fri, 23 Feb 2018 20:13:42 +0000 (20:13 +0000)]
[X86] Add DAG combine to remove (and X, 1) from in front of a v1i1 scalar to vector.

These can be created by type legalization promoting the inputs to select to match scalar boolean contents.

We were trying to pattern match them away during isel, but its better to just remove them from the DAG.

I've cleaned up some patterns to not check for this 'and' anymore. But I suspect this has also opened up opportunities for pattern removal.

llvm-svn: 325949

6 years agoInline a trivial ctor.
Rui Ueyama [Fri, 23 Feb 2018 20:13:38 +0000 (20:13 +0000)]
Inline a trivial ctor.

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

llvm-svn: 325948

6 years ago[WebAssembly] Fix macro metaprogram to not duplicate code as much.
Benjamin Kramer [Fri, 23 Feb 2018 20:13:03 +0000 (20:13 +0000)]
[WebAssembly] Fix macro metaprogram to not duplicate code as much.

No functionality change intended.

llvm-svn: 325947

6 years agoBecause of CVE-2018-6574, some compiler options and linker options are restricted...
Eric Christopher [Fri, 23 Feb 2018 20:12:24 +0000 (20:12 +0000)]
Because of CVE-2018-6574, some compiler options and linker options are restricted to prevent arbitrary code execution.

https://github.com/golang/go/issues/23672

By this change, building a Go code with LLVM Go bindings causes a compilation error as follows.

  go build llvm.org/llvm/bindings/go/llvm: invalid flag in #cgo LDFLAGS: -Wl,-headerpad_max_install_names

llvm-go tool generates cgo LDFLAGS directive from `llvm-config --ldflags` and it contains -Wl,option options. But -Wl,option is banned by default. To avoid this problem, we need to set $CGO_LDFLAGS_ALLOW environment variable to notify a compiler that the flags should be allowed.

  $ export CGO_LDFLAGS_ALLOW='-Wl,(-search_paths_first|-headerpad_max_install_names)'

By default for go 1.10 and go 1.9.5 these options should appear in the accepted set of options, however, if you're running into the error it's useful to have this documented.

Patch by Ryuichi Hayashida

llvm-svn: 325946

6 years ago[Driver] Make -fno-common default for Fuchsia
Petr Hosek [Fri, 23 Feb 2018 20:10:14 +0000 (20:10 +0000)]
[Driver] Make -fno-common default for Fuchsia

We never want to generate common symbols on Fuchsia.

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

llvm-svn: 325945

6 years ago[X86][SSE] Generalize x > C-1 ? x+-C : 0 --> subus x, C combine for non-uniform constants
Simon Pilgrim [Fri, 23 Feb 2018 19:58:44 +0000 (19:58 +0000)]
[X86][SSE] Generalize x > C-1 ? x+-C : 0 --> subus x, C combine for non-uniform constants

llvm-svn: 325944

6 years agoReally fix test on windows.
Rafael Espindola [Fri, 23 Feb 2018 19:38:41 +0000 (19:38 +0000)]
Really fix test on windows.

Sorry for the noise.

llvm-svn: 325943

6 years agoFix one last test on a windows host.
Rafael Espindola [Fri, 23 Feb 2018 19:36:20 +0000 (19:36 +0000)]
Fix one last test on a windows host.

llvm-svn: 325942

6 years agoShrink various scheduling tables by using narrower types.
Benjamin Kramer [Fri, 23 Feb 2018 19:32:56 +0000 (19:32 +0000)]
Shrink various scheduling tables by using narrower types.

16 bits ought to be enough for everyone. This shrinks clang by ~1MB.

llvm-svn: 325941

6 years agoBring r325915 back.
Rafael Espindola [Fri, 23 Feb 2018 19:30:48 +0000 (19:30 +0000)]
Bring r325915 back.

The tests that failed on a windows host have been fixed.

Original message:

Start setting dso_local for COFF.

With this there are still some GVs where we don't set dso_local
because setGVProperties is never called. I intend to fix that in
followup commits. This is just the bare minimum to teach
shouldAssumeDSOLocal what it should do for COFF.

llvm-svn: 325940

6 years ago[PATCH] [AArch64] Add new target feature to fuse conditional select
Evandro Menezes [Fri, 23 Feb 2018 19:27:43 +0000 (19:27 +0000)]
[PATCH] [AArch64] Add new target feature to fuse conditional select

This feature enables the fusion of the comparison and the conditional select
instructions together.

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

llvm-svn: 325939

6 years agoFix compiler warning introduced in r325931. NFC.
Geoff Berry [Fri, 23 Feb 2018 19:11:33 +0000 (19:11 +0000)]
Fix compiler warning introduced in r325931. NFC.

llvm-svn: 325938

6 years ago[Test] Fix the test to output to /dev/null instead of redirecting.
Matt Davis [Fri, 23 Feb 2018 19:03:04 +0000 (19:03 +0000)]
[Test] Fix the test to output to /dev/null instead of redirecting.

The redirection was confusing the windows build machine.

llvm-svn: 325937

6 years ago[X86][SSE] Add x > C-1 ? x+-C : 0 --> subus x, C test caaes for non-uniform constants
Simon Pilgrim [Fri, 23 Feb 2018 18:57:26 +0000 (18:57 +0000)]
[X86][SSE] Add x > C-1 ? x+-C : 0 --> subus x, C test caaes for non-uniform constants

llvm-svn: 325936

6 years ago[MemorySSA] Use fewer magic numbers. NFC
George Burgess IV [Fri, 23 Feb 2018 18:56:42 +0000 (18:56 +0000)]
[MemorySSA] Use fewer magic numbers. NFC

INVALID_MEMORYACCESS_ID == 0.

This patch also makes this initialization consistent with the rest of
the "invalid" ones in this file.

llvm-svn: 325935

6 years ago[MemorySSA] Reduce padding in MemoryDefs. NFC
George Burgess IV [Fri, 23 Feb 2018 18:50:39 +0000 (18:50 +0000)]
[MemorySSA] Reduce padding in MemoryDefs. NFC

llvm-svn: 325934

6 years ago[X86] Custom split v32i16/v64i8 bitcasts when AVX512F is available, but BWI is not.
Craig Topper [Fri, 23 Feb 2018 18:43:36 +0000 (18:43 +0000)]
[X86] Custom split v32i16/v64i8 bitcasts when AVX512F is available, but BWI is not.

The test changes you can see are related to the changes in ReplaceNodeResults. Though shuffle-vs-trunc-512.ll does have a test that exercises the code in LowerBITCAST. Looks like the test output didn't change because DAG combining is able to clean up the resulting type legalization. Adding the custom hook just makes type legalization work less hard.

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

llvm-svn: 325933

6 years ago[MachineOperand][Target] MachineOperand::isRenamable semantics changes
Geoff Berry [Fri, 23 Feb 2018 18:25:08 +0000 (18:25 +0000)]
[MachineOperand][Target] MachineOperand::isRenamable semantics changes

Summary:
Add a target option AllowRegisterRenaming that is used to opt in to
post-register-allocation renaming of registers.  This is set to 0 by
default, which causes the hasExtraSrcRegAllocReq/hasExtraDstRegAllocReq
fields of all opcodes to be set to 1, causing
MachineOperand::isRenamable to always return false.

Set the AllowRegisterRenaming flag to 1 for all in-tree targets that
have lit tests that were effected by enabling COPY forwarding in
MachineCopyPropagation (AArch64, AMDGPU, ARM, Hexagon, Mips, PowerPC,
RISCV, Sparc, SystemZ and X86).

Add some more comments describing the semantics of the
MachineOperand::isRenamable function and how it is set and maintained.

Change isRenamable to check the operand's opcode
hasExtraSrcRegAllocReq/hasExtraDstRegAllocReq bit directly instead of
relying on it being consistently reflected in the IsRenamable bit
setting.

Clear the IsRenamable bit when changing an operand's register value.

Remove target code that was clearing the IsRenamable bit when changing
registers/opcodes now that this is done conservatively by default.

Change setting of hasExtraSrcRegAllocReq in AMDGPU target to be done in
one place covering all opcodes that have constant pipe read limit
restrictions.

Reviewers: qcolombet, MatzeB

Subscribers: aemerson, arsenm, jyknight, mcrosier, sdardis, nhaehnle, javed.absar, tpr, arichardson, kristof.beyls, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, jordy.potman.lists, apazos, sabuasal, niosHD, escha, nemanjai, llvm-commits

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

llvm-svn: 325931

6 years agoConvert test to FileCheck. NFC.
Rafael Espindola [Fri, 23 Feb 2018 18:18:01 +0000 (18:18 +0000)]
Convert test to FileCheck. NFC.

llvm-svn: 325930

6 years agoRevert "Start setting dso_local for COFF."
Rafael Espindola [Fri, 23 Feb 2018 18:09:29 +0000 (18:09 +0000)]
Revert "Start setting dso_local for COFF."

This reverts commit r325915.

It will take some time to fix the failures on a windows host.

llvm-svn: 325929

6 years ago[Darwin] Add a test to make sure clang emits __apple accelerator tables.
Davide Italiano [Fri, 23 Feb 2018 18:04:55 +0000 (18:04 +0000)]
[Darwin] Add a test to make sure clang emits __apple accelerator tables.

llvm-svn: 325928

6 years agoReplace HashStringUsingDJB with llvm::djbHash
Pavel Labath [Fri, 23 Feb 2018 17:49:26 +0000 (17:49 +0000)]
Replace HashStringUsingDJB with llvm::djbHash

Summary:
The llvm function is equivalent to this one. Where possible I tried to
replace const char* with llvm::StringRef to avoid extra strlen
computations. In most places, I was able to track the c string back to
the ConstString it was created from.

I also create a test that verifies we are able to lookup names with
unicode characters, as a bug in the llvm compiler (it accidentally used
a different hash function) meant this was not working until recently.

This also removes the unused ExportTable class.

Reviewers: aprantl, davide

Subscribers: JDevlieghere, lldb-commits

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

llvm-svn: 325927

6 years ago[Debug] Add dbg.value intrinsics for PHIs created during LCSSA.
Matt Davis [Fri, 23 Feb 2018 17:38:27 +0000 (17:38 +0000)]
[Debug] Add dbg.value intrinsics for PHIs created during LCSSA.

Summary:
This patch is an enhancement to propagate dbg.value information when Phis are created on behalf of LCSSA.
I noticed a case where a value carried across a loop was reported as <optimized out>.

Specifically this case:
```
int bar(int x, int y) {
  return x + y;
}

int foo(int size) {
  int val = 0;
  for (int i = 0; i < size; ++i) {
    val = bar(val, i);  // Both val and i are correct
  }
  return val; // <optimized out>
}
```

In the above case, after all of the interesting computation completes our value
is reported as "optimized out." This change will add a dbg.value to correct this.

This patch also moves the dbg.value insertion routine from LoopRotation.cpp
into Local.cpp, so that we can share it in both places (LoopRotation and LCSSA).

Reviewers: mzolotukhin, aprantl, vsk, davide

Reviewed By: aprantl, vsk

Subscribers: dberlin, llvm-commits

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

llvm-svn: 325926

6 years ago[BPI] Detect branches in loops that make themselves not taken
John Brawn [Fri, 23 Feb 2018 17:17:31 +0000 (17:17 +0000)]
[BPI] Detect branches in loops that make themselves not taken

If we have a loop like this:
 int n = 0;
 while (...) {
  if (++n >= MAX) {
    n = 0;
  }
 }
then the body of the 'if' statement will only be executed once every MAX
iterations. Detect this by looking for branches in loops where taking the branch
makes the branch condition evaluate to 'not taken' in the next iteration of the
loop, and reduce the probability of such branches.

This slightly improves EEMBC benchmarks on cortex-m4/cortex-m33 due to making
better choices in if-conversion, but has no effect on any other cpu/benchmark
that I could detect.

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

llvm-svn: 325925

6 years ago[InstCombine] refactor fmul with negated op folds; NFCI
Sanjay Patel [Fri, 23 Feb 2018 17:14:28 +0000 (17:14 +0000)]
[InstCombine] refactor fmul with negated op folds; NFCI

The existing code was inefficiently looking for 'nsz' variants.
That's unnecessary because we canonicalize those to the expected
form with -0.0.

We may also want to adjust or remove the fold that sinks negation.
We don't do that for fdiv (or integer ops?). That should be uniform?
It may also lead to missed optimization as in PR21914:
https://bugs.llvm.org/show_bug.cgi?id=21914
...or we just have to fix other passes to avoid that problem.

llvm-svn: 325924

6 years ago[InstCombine] use FMF-copying functions to reduce code; NFCI
Sanjay Patel [Fri, 23 Feb 2018 17:07:29 +0000 (17:07 +0000)]
[InstCombine] use FMF-copying functions to reduce code; NFCI

llvm-svn: 325923

6 years ago[OMPT] Fix parallel_data in implicit barrier-end
Jonas Hahnfeld [Fri, 23 Feb 2018 16:46:25 +0000 (16:46 +0000)]
[OMPT] Fix parallel_data in implicit barrier-end

This is required to be NULL for implicit barriers at the end of a
parallel region. Noticed in review of D43191.

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

llvm-svn: 325922

6 years ago[OMPT] Fix test tasks/serialized.c with optimization
Jonas Hahnfeld [Fri, 23 Feb 2018 16:46:11 +0000 (16:46 +0000)]
[OMPT] Fix test tasks/serialized.c with optimization

The compiler inlines the user code in the task. Check for that case at
runtime by comparing the frame addresses and print the expected exit
address.

Also showcase how I think the OMPT tests could be reformatted to match
LLVM's code style. In my opinion it would be great to that kind of change
to all tests that need to be touched for whatever reason...

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

llvm-svn: 325921

6 years agoRevert "[Darwin] Add a test to check clang produces accelerator tables."
Paul Robinson [Fri, 23 Feb 2018 16:36:48 +0000 (16:36 +0000)]
Revert "[Darwin] Add a test to check clang produces accelerator tables."

This reverts commit 7e24e5f8bff77b7e78da3bfcc68abf42457a66c9.
aka r325850.  Clang should not have end-to-end tests.

llvm-svn: 325920

6 years ago[X86] Regenerate i128 multiply tests
Simon Pilgrim [Fri, 23 Feb 2018 15:55:27 +0000 (15:55 +0000)]
[X86] Regenerate i128 multiply tests

llvm-svn: 325919

6 years ago[PowerPC] Code cleanup. Remove instructions that were withdrawn from Power 9.
Stefan Pintilie [Fri, 23 Feb 2018 15:55:16 +0000 (15:55 +0000)]
[PowerPC] Code cleanup. Remove instructions that were withdrawn from Power 9.

The following set of instructions was originally planned to be added for Power 9
and so code was added to support them. However, a decision was made later on to
withdraw support for these instructions in the hardware.
xscmpnedp
xvcmpnesp
xvcmpnedp
This patch removes support for the instructions that were not added.

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

llvm-svn: 325918

6 years ago[mips] finish removal of unused fields in MipsInstructionSelector
Petar Jovanovic [Fri, 23 Feb 2018 15:47:05 +0000 (15:47 +0000)]
[mips] finish removal of unused fields in MipsInstructionSelector

r325916 missed to remove calls in constructor.

llvm-svn: 325917

6 years ago[mips] remove unused fields in MipsInstructionSelector
Petar Jovanovic [Fri, 23 Feb 2018 15:34:02 +0000 (15:34 +0000)]
[mips] remove unused fields in MipsInstructionSelector

Unused fields cause buildbreak if -Werror,-Wunused-private-field is passed.

llvm-svn: 325916

6 years agoStart setting dso_local for COFF.
Rafael Espindola [Fri, 23 Feb 2018 15:32:32 +0000 (15:32 +0000)]
Start setting dso_local for COFF.

With this there are still some GVs where we don't set dso_local
because setGVProperties is never called. I intend to fix that in
followup commits. This is just the bare minimum to teach
shouldAssumeDSOLocal what it should do for COFF.

llvm-svn: 325915

6 years agoAllow passing additional compiler/linker flags for the tests
Alexander Richardson [Fri, 23 Feb 2018 15:19:48 +0000 (15:19 +0000)]
Allow passing additional compiler/linker flags for the tests

Summary:
These flags can be specified using the CMake variables
LIBCXX_TEST_LINKER_FLAGS and LIBCXX_TEST_COMPILER_FLAGS.
When building the tests for CHERI I need to pass additional
flags (such as -mabi=n64 or -mabi=purecap) to the compiler
for our test configurations

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: christof, mgorny, cfe-commits

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

llvm-svn: 325914

6 years agoSupport for the mno-stack-arg-probe flag
Hans Wennborg [Fri, 23 Feb 2018 13:47:36 +0000 (13:47 +0000)]
Support for the mno-stack-arg-probe flag

Adds support for this flag. There is also another piece for llvm
(separate review). More info:
https://bugs.llvm.org/show_bug.cgi?id=36221

By Ruslan Nikolaev!

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

llvm-svn: 325901

6 years agoSupport for the mno-stack-arg-probe flag
Hans Wennborg [Fri, 23 Feb 2018 13:46:25 +0000 (13:46 +0000)]
Support for the mno-stack-arg-probe flag

Adds support for this flag. There is also another piece for clang
(separate review). More info:
https://bugs.llvm.org/show_bug.cgi?id=36221

By Ruslan Nikolaev!

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

llvm-svn: 325900

6 years ago[mips] Revert r325872
Stefan Maksimovic [Fri, 23 Feb 2018 13:46:14 +0000 (13:46 +0000)]
[mips] Revert r325872

There are still outstanding issues with byVal arguments
that prevent this from being committed. Revert for now.

llvm-svn: 325899

6 years ago[SystemZ] Also update the CHECK line for VPDI
Jonas Paulsson [Fri, 23 Feb 2018 13:22:46 +0000 (13:22 +0000)]
[SystemZ]  Also update the CHECK line for VPDI

llvm-svn: 325898

6 years ago[SystemZ] Fix VPDI argument in test.
Jonas Paulsson [Fri, 23 Feb 2018 13:20:57 +0000 (13:20 +0000)]
[SystemZ] Fix VPDI argument in test.

To select element 1 from each half with VPDI, a constant of 5 should be used.

llvm-svn: 325897

6 years ago[X86][F16C] Regenerate half conversion tests
Simon Pilgrim [Fri, 23 Feb 2018 13:18:13 +0000 (13:18 +0000)]
[X86][F16C] Regenerate half conversion tests

llvm-svn: 325896

6 years agollvm-config: Add advapi32 to --system-libs on Windows (PR36372)
Hans Wennborg [Fri, 23 Feb 2018 12:20:26 +0000 (12:20 +0000)]
llvm-config: Add advapi32 to --system-libs on Windows (PR36372)

llvm-svn: 325894

6 years ago[WebAssembly] NDEBUG is spelled without a leading underscore.
Benjamin Kramer [Fri, 23 Feb 2018 12:20:18 +0000 (12:20 +0000)]
[WebAssembly] NDEBUG is spelled without a leading underscore.

llvm-svn: 325893

6 years ago[DAGCOmbine] Ensure that (brcond (setcc ...)) is handled in a canonical manner.
Amaury Sechet [Fri, 23 Feb 2018 11:50:42 +0000 (11:50 +0000)]
[DAGCOmbine] Ensure that (brcond (setcc ...)) is handled in a canonical manner.

Summary:
There are transformation that change setcc into other constructs, and transform that try to reconstruct a setcc from the brcond condition. Depending on what order these transform are done, the end result differs.

Most of the time, it is preferable to get a setcc as a brcond argument (and this is why brcond try to recreate the setcc in the first place) so we ensure this is done every time by also doing it at the setcc level when the only user is a brcond.

Reviewers: spatel, hfinkel, niravd, craig.topper

Subscribers: nhaehnle, llvm-commits

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

llvm-svn: 325892

6 years agoRevert "TableGen: Fix typeIsConvertibleTo for record types"
Nicolai Haehnle [Fri, 23 Feb 2018 11:31:49 +0000 (11:31 +0000)]
Revert "TableGen: Fix typeIsConvertibleTo for record types"

This reverts r325884.

Clang's TableGen has dependencies on the exact ordering of superclasses.
Revert this change fully for now to fix the build.

Change-Id: Ib297f5571cc7809f00838702ad7ab53d47335b26
llvm-svn: 325891

6 years ago[ELF][MIPS] Set EI_ABIVERSION flag accordingly to MIPS ABIs requirement
Simon Atanasyan [Fri, 23 Feb 2018 11:28:57 +0000 (11:28 +0000)]
[ELF][MIPS] Set EI_ABIVERSION flag accordingly to MIPS ABIs requirement

MIPS ABIs require that if an executable file uses non-PIC model, the
EI_ABIVERSION entry in the ELF header should be incremented from 0 to 1.
That allows obsoleted / limited dynamic linkers refuse to link them.

llvm-svn: 325890

6 years ago[MIPS GlobalISel] Adding GlobalISel
Petar Jovanovic [Fri, 23 Feb 2018 11:06:40 +0000 (11:06 +0000)]
[MIPS GlobalISel] Adding GlobalISel

Add GlobalISel infrastructure up to the point where we can select a ret
void.

Patch by Petar Avramovic.

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

llvm-svn: 325888

6 years ago[ELF] - Do not remove empty output sections that are explicitly assigned to phdr...
George Rimar [Fri, 23 Feb 2018 10:53:04 +0000 (10:53 +0000)]
[ELF] - Do not remove empty output sections that are explicitly assigned to phdr in script.

This continues direction started in D43069.

We can keep sections that are explicitly assigned to segment in script.
It helps to simplify code.

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

llvm-svn: 325887

6 years agoTableGen: Avoid using resolveListElementReference in TGParser
Nicolai Haehnle [Fri, 23 Feb 2018 10:46:21 +0000 (10:46 +0000)]
TableGen: Avoid using resolveListElementReference in TGParser

A subsequent change intends to remove resolveListElementReference
entirely. This part of the removal can be split out for better
bisectability.

Change-Id: Ibd762d88fd2d1e2cc116a259e2a27a5e9f9a8b10

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

Change-Id: Ifb695041cef1964ad8a3102f448249501a9243f0
llvm-svn: 325886

6 years agoTableGen: BitInit and VarBitInit are typed
Nicolai Haehnle [Fri, 23 Feb 2018 10:46:18 +0000 (10:46 +0000)]
TableGen: BitInit and VarBitInit are typed

Summary: Change-Id: I54e337a0b525e9649534bc5f90e5e07c0772e334

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

Change-Id: I07f78e793192974c2b90690ce644589fe4891e41
llvm-svn: 325885

6 years agoTableGen: Fix typeIsConvertibleTo for record types
Nicolai Haehnle [Fri, 23 Feb 2018 10:46:13 +0000 (10:46 +0000)]
TableGen: Fix typeIsConvertibleTo for record types

Summary:
Only check whether the left-hand side type is a subclass (or equal to)
the right-hand side type.

This requires a further fix in handling !if expressions and in type
resolution.

Furthermore, reverse the order of superclasses so that resolveTypes will
find a least common ancestor at least in simple cases.

Add a test that used to be accepted without flagging the obvious type
error.

Change-Id: Ib366db1a4e6a079f1a0851e469b402cddae76714

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 325884

6 years agoTableGen: Add !size operation
Nicolai Haehnle [Fri, 23 Feb 2018 10:46:07 +0000 (10:46 +0000)]
TableGen: Add !size operation

Summary:
Returns the size of a list. I have found this to be rather useful in some
development for the AMDGPU backend where we could simplify our .td files
by concatenating list<LLVMType> for complex intrinsics. Doing so requires
us to compute the position argument for LLVMMatchType.

Basically, the usage is in a pattern that looks somewhat like this:

    list<LLVMType> argtypes =
        !listconcat(base,
                    [llvm_any_ty, LLVMMatchType<!size(base)>]);

Change-Id: I360a0b000fd488d18bea412228230fd93722bd2c

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits, tpr

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

llvm-svn: 325883

6 years agoAMDGPU: Track physreg uses in SILoadStoreOptimizer
Nicolai Haehnle [Fri, 23 Feb 2018 10:45:56 +0000 (10:45 +0000)]
AMDGPU: Track physreg uses in SILoadStoreOptimizer

Summary:
This handles def-after-use of physregs, and allows us to merge loads and
stores even across some physreg defs (typically M0 defs).

Change-Id: I076484b2bda27c2cf46013c845a0380c5b89b67b

Reviewers: arsenm, mareko, rampitec

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

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

llvm-svn: 325882

6 years agoStructurizeCFG: Test for branch divergence correctly
Nicolai Haehnle [Fri, 23 Feb 2018 10:45:46 +0000 (10:45 +0000)]
StructurizeCFG: Test for branch divergence correctly

Summary:
This fixes cases like the new test @nonuniform. In that test, %cc itself
is a uniform value; however, when reading it after the end of the loop in
basic block %if, its value is effectively non-uniform.

This problem was encountered in
https://bugs.freedesktop.org/show_bug.cgi?id=103743; however, this change
in itself is not sufficient to fix that bug, as there is another issue
in the AMDGPU backend.

Change-Id: I32bbffece4a32f686fab54964dae1a5dd72949d4

Reviewers: arsenm, rampitec, jlebar

Subscribers: wdng, tpr, llvm-commits

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

llvm-svn: 325881

6 years agoMark MergedLoadStoreMotion as not preserving MemDep results
Bjorn Steinbrink [Fri, 23 Feb 2018 10:41:57 +0000 (10:41 +0000)]
Mark MergedLoadStoreMotion as not preserving MemDep results

Summary:
MemDep caches results that signify that a dependence is non-local, and
there is currently no way to invalidate such cache entries.
Unfortunately, when MLSM sinks a store that can result in a non-local
dependence becoming a local one, and then MemDep gives wrong answers.
The easiest way out here is to just say that MLSM does indeed not
preserve MemDep results.

Reviewers: davide, Gerolf

Subscribers: llvm-commits

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

llvm-svn: 325880

6 years agoRecommit "[ELF] - Do not crash with --emit-relocs and --icf=all together."
George Rimar [Fri, 23 Feb 2018 10:37:33 +0000 (10:37 +0000)]
Recommit "[ELF] - Do not crash with --emit-relocs and --icf=all together."

Latest patch version now.

Original commit message:

[ELF] - Do not crash with --emit-relocs and --icf=all together.

Previously we would crash because did not mark .rel[a] sections
as dead and they tried to access parent which was not live
after ICF and therefore was null.

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

llvm-svn: 325879

6 years ago[ELF] - Revert r325877 "[ELF] - Do not crash with --emit-relocs and --icf=all together."
George Rimar [Fri, 23 Feb 2018 10:30:31 +0000 (10:30 +0000)]
[ELF] - Revert r325877 "[ELF] - Do not crash with --emit-relocs and --icf=all together."

Not latest version of patch was committed by mistake.

llvm-svn: 325878

6 years ago[ELF] - Do not crash with --emit-relocs and --icf=all together.
George Rimar [Fri, 23 Feb 2018 10:27:13 +0000 (10:27 +0000)]
[ELF] - Do not crash with --emit-relocs and --icf=all together.

Previously we would crash because did not mark .rel[a] sections
as dead and they tried to access parent which was not live
after ICF and therefore was null.

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

llvm-svn: 325877

6 years ago[ELF] - Report error if removed empty output section declaration used undefined symbols.
George Rimar [Fri, 23 Feb 2018 10:15:54 +0000 (10:15 +0000)]
[ELF] - Report error if removed empty output section declaration used undefined symbols.

This is for fixing PR36297.

Issue itself is that if we have SECTIONS { .bar (a+b) : { *(.stub) } };
script and no section .stub, when LLD will remove .bar, but
produce output with undefined symbols a and b.

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

llvm-svn: 325875

6 years ago[ELF] - Added testcase for testing visibility of weak_odr symbols.
George Rimar [Fri, 23 Feb 2018 10:08:15 +0000 (10:08 +0000)]
[ELF] - Added testcase for testing visibility of weak_odr symbols.

This is relative to "Bug 36166 - tools/gold/X86/comdat.ll is failing only on Debian Unstable" (PR36166).
Something changed in newer versions of gold and now together with gold-plugin
there is an issue shown in PR, symbol may get wrong visibility.

LLD works fine, but we have no testcase for the same use case, patch adds it.

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

llvm-svn: 325874

6 years ago[ELF] - Add testcase documenting flags assigned when empty synthetic section is removed.
George Rimar [Fri, 23 Feb 2018 09:57:17 +0000 (09:57 +0000)]
[ELF] - Add testcase documenting flags assigned when empty synthetic section is removed.

This responds to PR36475,

r325763 led to unexprected layout change, though
new behavior seems to be more correct.

Previously we could have following script:

.foo : { *(.foo) }
.bar : { *(.synthetic_empty) BYTE(0x11) }}
where synthetic_empty is a synthetic section which is empty and
hence removed by linker.

Before r325763 .bar would receive section flags from .synthetic_empty,
but after this revision it receives flags the same as .foo section has.

It is the same as if there would not be any synthetic_empty section in a script,
so looks reasonable and consistent behavior:
.foo : { *(.foo) }
.bar : { BYTE(0x11) }}

Patch adds testcase to document it.

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

llvm-svn: 325873

6 years ago[mips] Reland r310704
Stefan Maksimovic [Fri, 23 Feb 2018 08:37:48 +0000 (08:37 +0000)]
[mips] Reland r310704

Recommit this change which was previously reverted
for the 5.0.0 release since the failures identified
were dealt with in r325782.

llvm-svn: 325872

6 years ago[Mips] Return true in enableMultipleCopyHints().
Jonas Paulsson [Fri, 23 Feb 2018 08:30:15 +0000 (08:30 +0000)]
[Mips]  Return true in enableMultipleCopyHints().

Enable multiple COPY hints to eliminate more COPYs during register allocation.

Note that this is something all targets should do, see
https://reviews.llvm.org/D38128.

Review: Simon Dardis
llvm-svn: 325870

6 years agoReleaseNotes: user lower-case for lld in the text
Hans Wennborg [Fri, 23 Feb 2018 08:27:38 +0000 (08:27 +0000)]
ReleaseNotes: user lower-case for lld in the text

llvm-svn: 325869

6 years ago[clangd] BindWithForward -> Bind. NFC
Sam McCall [Fri, 23 Feb 2018 07:54:17 +0000 (07:54 +0000)]
[clangd] BindWithForward -> Bind. NFC

llvm-svn: 325868

6 years agoutils: Adapt to llvm r325155
Jan Vesely [Fri, 23 Feb 2018 07:37:03 +0000 (07:37 +0000)]
utils: Adapt to llvm r325155

r325155 ("Pass a reference to a module to the bitcode writer.")
changed bit writer interface from pointer to reference

Reviewer: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 325867

6 years agoamdgcn: Fix build after GDS/const AS swap in r325030
Jan Vesely [Fri, 23 Feb 2018 07:37:01 +0000 (07:37 +0000)]
amdgcn: Fix build after GDS/const AS swap in r325030

Acked-by: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 325866

6 years agoamdgcn: Fix datalayout after addition of 32bit const AS in r324747
Jan Vesely [Fri, 23 Feb 2018 07:36:54 +0000 (07:36 +0000)]
amdgcn: Fix datalayout after addition of 32bit const AS in r324747

Acked-by: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 325865

6 years agor600: Fix datalayout after clang r324101
Jan Vesely [Fri, 23 Feb 2018 07:36:51 +0000 (07:36 +0000)]
r600: Fix datalayout after clang r324101

r324101 switched around AS numbering

Acked-by: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 325864

6 years agoamdgcn: Fix datalayout after clang r324101
Jan Vesely [Fri, 23 Feb 2018 07:36:39 +0000 (07:36 +0000)]
amdgcn: Fix datalayout after clang r324101

r324101 switched around AS numbering

Acked-by: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 325863

6 years agoFix TestMultithreaded when there's no debugserver specified
Frederic Riss [Fri, 23 Feb 2018 05:29:27 +0000 (05:29 +0000)]
Fix TestMultithreaded when there's no debugserver specified

r325858 was bogus and would error out with a KeyError when --server
was not passed to dotest.py.

llvm-svn: 325862

6 years ago[WebAssembly] Add explicit symbol table
Sam Clegg [Fri, 23 Feb 2018 05:08:53 +0000 (05:08 +0000)]
[WebAssembly] Add explicit symbol table

This change modified lld to in response the llvm change which
moved to a more explicit symbol table in the object format.

Based on patches by Nicholas Wilson:
 1. https://reviews.llvm.org/D41955
 2. https://reviews.llvm.org/D42585

The primary difference that we see in the test output is that
for relocatable (-r) output we now have symbol table which
replaces exports/imports and globals.

See: https://github.com/WebAssembly/tool-conventions/issues/38
Differential Revision: https://reviews.llvm.org/D43264

llvm-svn: 325861

6 years ago[WebAssembly] Add first claass symbol table to wasm objects
Sam Clegg [Fri, 23 Feb 2018 05:08:34 +0000 (05:08 +0000)]
[WebAssembly] Add first claass symbol table to wasm objects

This is combination of two patches by Nicholas Wilson:
  1. https://reviews.llvm.org/D41954
  2. https://reviews.llvm.org/D42495

Along with a few local modifications:
- One change I made was to add the UNDEFINED bit to the binary format
  to avoid the extra byte used when writing data symbols.  Although this
  bit is redundant for other symbols types (i.e. undefined can be
  implied if a function or global is a wasm import)
- I prefer to be explicit and consistent and not have derived flags.
- Some field renaming.
- Some reverting of unrelated minor changes.
- No test output differences.

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

llvm-svn: 325860

6 years agoFix TestUbsanBasic
Frederic Riss [Fri, 23 Feb 2018 05:03:10 +0000 (05:03 +0000)]
Fix TestUbsanBasic

Summary:
Potentially due to the recent testuite refactorings, this test now reports
a full absolute path but expect just the filename. For some reason this
test is skipped on GreenDragon so we've never seen the issue.

Reviewers: vsk

Subscribers: kubamracek, lldb-commits

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

llvm-svn: 325859

6 years agoFix TestMultithreaded when specifying an alternative debugserver.
Frederic Riss [Fri, 23 Feb 2018 05:03:09 +0000 (05:03 +0000)]
Fix TestMultithreaded when specifying an alternative debugserver.

Summary:
This test launches a helper that uses the debugserver. The environment
variable sepcifying the debug server wasn't passed to this helper, thus
it was using the default one.

Subscribers: lldb-commits

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

llvm-svn: 325858

6 years ago[WebAssembly] Move lambda declaration output of loop. NFC.
Sam Clegg [Fri, 23 Feb 2018 04:59:57 +0000 (04:59 +0000)]
[WebAssembly] Move lambda declaration output of loop. NFC.

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

llvm-svn: 325857

6 years agoremove FreeBSD xfail from lit TestCallStdStringFunction
Ed Maste [Fri, 23 Feb 2018 02:50:07 +0000 (02:50 +0000)]
remove FreeBSD xfail from lit TestCallStdStringFunction

This test is consistently reporting unexpected pass for me, and the
expectedFailure decorator was removed from the legacy test in r310626.
Apply the same change to the lit version of this test.

Will investigate further if this fails once the new buildbot is running
tests.

llvm.org/pr17807

llvm-svn: 325856

6 years ago[ELF] Add comment for preemptible and fix typo. NFC
Fangrui Song [Fri, 23 Feb 2018 02:05:48 +0000 (02:05 +0000)]
[ELF] Add comment for preemptible and fix typo. NFC

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 325855

6 years agoAdd a test to ensure we don't permit mutable access on temporaries outside the evalua...
Richard Smith [Fri, 23 Feb 2018 02:03:26 +0000 (02:03 +0000)]
Add a test to ensure we don't permit mutable access on temporaries outside the evaluation in which they were created.

llvm-svn: 325854

6 years agoRemove file missed by r325852 due to merge conflict.
Richard Smith [Fri, 23 Feb 2018 01:57:28 +0000 (01:57 +0000)]
Remove file missed by r325852 due to merge conflict.

llvm-svn: 325853

6 years agoRevert r325128 ("[X86] Reduce Store Forward Block issues in HW").
Richard Smith [Fri, 23 Feb 2018 01:43:46 +0000 (01:43 +0000)]
Revert r325128 ("[X86] Reduce Store Forward Block issues in HW").

This is causing miscompiles in some situations. See the llvm-commits thread for the commit for details.

llvm-svn: 325852

6 years ago[testsuite] Throw away test/debug_info/apple_types.
Davide Italiano [Fri, 23 Feb 2018 01:33:20 +0000 (01:33 +0000)]
[testsuite] Throw away test/debug_info/apple_types.

This test was only testing that clang produced the correct informations
for __apple accelerated tables. So, it's a clang test. Also, it
doesn't require any debugger intervention, the object file can
be analyzed statically with a dumper. Also, the input program
was highly verbose (unnecessarily).

r325850 commits a clang test instead, so it's time to retire this.

llvm-svn: 325851

6 years ago[Darwin] Add a test to check clang produces accelerator tables.
Davide Italiano [Fri, 23 Feb 2018 01:25:03 +0000 (01:25 +0000)]
[Darwin] Add a test to check clang produces accelerator tables.

This test was previously in lldb, and was only checking that clang
was emitting the correct section. So, it belongs here and not
in the debugger.

llvm-svn: 325850

6 years agoMake undefined symbol in DSO to pull out object files from archive files.
Rui Ueyama [Fri, 23 Feb 2018 01:16:57 +0000 (01:16 +0000)]
Make undefined symbol in DSO to pull out object files from archive files.

We have an internal program that does't link without this patch. I don't
know of any open-source program that needs this, but there might be.
Since this patch improves compatibility with GNU linkers with a few lines
of code, I think it's worth to be committed.

The problem is about undefined symbols in DSOs. Some programs depend on
the GNU linkers' behavior that they pull out object files from archive
files to resolve undefined symbols in DSOs. We already allow that kind of
"reverse" dependency (from DSOs to the main executable) for regular
symbols, in particular, for "__progname" symbol (which is usually in
crt0.o), but that doesn't work if the symbol is in an archive file.
This patch is to make it work.

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

llvm-svn: 325849

6 years ago[GISel]: Fix base case for m_any_of PatternMatcher.
Aditya Nandakumar [Fri, 23 Feb 2018 01:01:59 +0000 (01:01 +0000)]
[GISel]: Fix base case for m_any_of PatternMatcher.

The base case for any_of was incorrectly returning true. Also add test
case which uses m_any_of(preds...) where none of the predicates are
true.

llvm-svn: 325848

6 years agoDelete some unused #includes of CleanUp.h, NFC
Vedant Kumar [Fri, 23 Feb 2018 00:29:40 +0000 (00:29 +0000)]
Delete some unused #includes of CleanUp.h, NFC

llvm-svn: 325847