platform/upstream/llvm.git
6 years ago[hwasan] Add -hwasan-with-ifunc flag.
Evgeniy Stepanov [Fri, 10 Aug 2018 16:21:37 +0000 (16:21 +0000)]
[hwasan] Add -hwasan-with-ifunc flag.

Summary: Similar to asan's flag, it can be used to disable the use of ifunc to access hwasan shadow address.

Reviewers: vitalybuka, kcc

Subscribers: srhines, hiraditya, llvm-commits

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

llvm-svn: 339447

6 years ago[InstCombine] revert r339439 - rearrange code for foldSelectBinOpIdentity
Sanjay Patel [Fri, 10 Aug 2018 16:12:19 +0000 (16:12 +0000)]
[InstCombine] revert r339439 - rearrange code for foldSelectBinOpIdentity

That was supposed to be NFC, but it exposed a logic hole somewhere that
caused bots to fail.

llvm-svn: 339446

6 years ago[InstCombine][NFC] Added tests for select with binop fold
David Bolvansky [Fri, 10 Aug 2018 15:29:09 +0000 (15:29 +0000)]
[InstCombine][NFC] Added tests for select with binop fold

llvm-svn: 339441

6 years agoRichManglingContext: Make m_ipd_str_len a local variable and simplify processIPDStrRe...
Stefan Granitz [Fri, 10 Aug 2018 15:21:33 +0000 (15:21 +0000)]
RichManglingContext: Make m_ipd_str_len a local variable and simplify processIPDStrResult + polishing in test and Mangled

llvm-svn: 339440

6 years ago[InstCombine] rearrange code for foldSelectBinOpIdentity; NFCI
Sanjay Patel [Fri, 10 Aug 2018 15:11:26 +0000 (15:11 +0000)]
[InstCombine] rearrange code for foldSelectBinOpIdentity; NFCI

This should make it easier to folow and to add the planned enhancements
such as D50190.

llvm-svn: 339439

6 years ago[CodeGen] Merge equivalent block copy/helper functions.
Akira Hatanaka [Fri, 10 Aug 2018 15:09:24 +0000 (15:09 +0000)]
[CodeGen] Merge equivalent block copy/helper functions.

Clang generates copy and dispose helper functions for each block literal
on the stack. Often these functions are equivalent for different blocks.
This commit makes changes to merge equivalent copy and dispose helper
functions and reduce code size.

To enable merging equivalent copy/dispose functions, the captured object
infomation is encoded into the helper function name. This allows IRGen
to check whether an equivalent helper function has already been emitted
and reuse the function instead of generating a new helper function
whenever a block is defined. In addition, the helper functions are
marked as linkonce_odr to enable merging helper functions that have the
same name across translation units and marked as unnamed_addr to enable
the linker's deduplication pass to merge functions that have different
names but the same content.

rdar://problem/42640608

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

llvm-svn: 339438

6 years ago[clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
Roman Lebedev [Fri, 10 Aug 2018 15:05:46 +0000 (15:05 +0000)]
[clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

Summary:
Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with `warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to be checked.
This was useful for me when developing D36836.

Reviewers: alexfh, klimek, aaron.ballman, hokein

Reviewed By: alexfh, aaron.ballman

Subscribers: JonasToth, JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 339437

6 years ago[MS Demangler] Properly demangle conversion operators.
Zachary Turner [Fri, 10 Aug 2018 15:04:56 +0000 (15:04 +0000)]
[MS Demangler] Properly demangle conversion operators.

These were completely broken before.  We need to handle
the 'B' operator tag.

llvm-svn: 339436

6 years ago[MS Demangler] Disable a couple of tests.
Zachary Turner [Fri, 10 Aug 2018 14:53:33 +0000 (14:53 +0000)]
[MS Demangler] Disable a couple of tests.

The check lines are marked FIXME but not the mangled names.
This is causing an error.

llvm-svn: 339435

6 years ago[MS Demangler] Fix several issues related to templates.
Zachary Turner [Fri, 10 Aug 2018 14:31:04 +0000 (14:31 +0000)]
[MS Demangler] Fix several issues related to templates.

These were uncovered when porting the mangling tests in
ms-templates.cpp from clang/CodeGenCXX over to demangling
tests.  The main issues fixed here are surrounding integer
literal signed and unsignedness, empty array dimensions,
and pointer and reference non-type template parameters.

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

llvm-svn: 339434

6 years ago[clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body...
Alexander Kornienko [Fri, 10 Aug 2018 13:59:33 +0000 (13:59 +0000)]
[clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body is in a macro

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

Patch by IdrissRio.

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

llvm-svn: 339433

6 years ago[ARM] Disallow zexts in ARMCodeGenPrepare
Sam Parker [Fri, 10 Aug 2018 13:57:13 +0000 (13:57 +0000)]
[ARM] Disallow zexts in ARMCodeGenPrepare

Enabling ARMCodeGenPrepare by default caused a whole load of
failures. This is due to zexts and truncs not being handled properly.
ZExts are messy so it's just easier to disable for now and truncs
are allowed only as 'sinks'. I still need to figure out why allowing
them as 'sources' causes so many failures. The other main changes are
that we are explicit in the types that we converting to, it's now
always 'TypeSize'. Type support is also now performed while checking
for valid opcodes as it unnecessarily complicated having the checks
are different stages.

I've moved the tests around too, so we have the zext and truncs in
their own file as well as the overflowing opcode tests.

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

llvm-svn: 339432

6 years ago[libc++] Enable aligned allocation based on feature test macro, irrespective of standard
Louis Dionne [Fri, 10 Aug 2018 13:24:56 +0000 (13:24 +0000)]
[libc++] Enable aligned allocation based on feature test macro, irrespective of standard

Summary:
The current code enables aligned allocation functions when compiling in C++17
and later. This is a problem because aligned allocation functions might not
be supported on the target platform, which leads to an error at link time.

Since r338934, Clang knows not to define __cpp_aligned_new when it's not
available on the target platform -- this commit takes advantage of that to
only use aligned allocation functions when they are available.

Reviewers: vsapsai, EricWF

Subscribers: christof, dexonsmith, cfe-commits, EricWF, mclow.lists

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

llvm-svn: 339431

6 years agoAmend "Remove unused type Either from Utility library".
Tatyana Krasnukha [Fri, 10 Aug 2018 13:01:26 +0000 (13:01 +0000)]
Amend "Remove unused type Either from Utility library".

llvm-svn: 339430

6 years agoFix a deprecated warning in the last commit.
David Chisnall [Fri, 10 Aug 2018 12:53:18 +0000 (12:53 +0000)]
Fix a deprecated warning in the last commit.

Done as a separate commit to make it easier to cherry pick the changes
to the release branch.

llvm-svn: 339429

6 years agoAdd Windows support for the GNUstep Objective-C ABI V2.
David Chisnall [Fri, 10 Aug 2018 12:53:13 +0000 (12:53 +0000)]
Add Windows support for the GNUstep Objective-C ABI V2.

Summary:
Introduces funclet-based unwinding for Objective-C and fixes an issue
where global blocks can't have their isa pointers initialised on
Windows.

After discussion with Dustin, this changes the name mangling of
Objective-C types to prevent a C++ catch statement of type struct X*
from catching an Objective-C object of type X*.

Reviewers: rjmccall, DHowett-MSFT

Reviewed By: rjmccall, DHowett-MSFT

Subscribers: mgrang, mstorsjo, smeenai, cfe-commits

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

llvm-svn: 339428

6 years ago[clang-tidy] run-clang-tidy.py - add synchronisation to the output
Andi-Bogdan Postelnicu [Fri, 10 Aug 2018 11:50:47 +0000 (11:50 +0000)]
[clang-tidy]  run-clang-tidy.py - add synchronisation to the output
Differential Revision: https://reviews.llvm.org/D49851

llvm-svn: 339427

6 years ago[clangd] Allow consuming limited number of items
Kirill Bobyrev [Fri, 10 Aug 2018 11:50:44 +0000 (11:50 +0000)]
[clangd] Allow consuming limited number of items

This patch modifies `consume` function to allow retrieval of limited
number of symbols. This is the "cheap" implementation of top-level
limiting iterator. In the future we would like to have a complete limit
iterator implementation to insert it into the query subtrees, but in the
meantime this version would be enough for a fully-functional
proof-of-concept Dex implementation.

Reviewers: ioeric, ilya-biryukov

Reviewed by: ioeric

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

llvm-svn: 339426

6 years ago[X86][SSE] Pull out repeated shift getOpcode() calls. NFCI.
Simon Pilgrim [Fri, 10 Aug 2018 11:42:42 +0000 (11:42 +0000)]
[X86][SSE] Pull out repeated shift getOpcode() calls. NFCI.

llvm-svn: 339425

6 years agoclang-cl: accept -fcrash-diagnostics-dir=
Hans Wennborg [Fri, 10 Aug 2018 11:40:50 +0000 (11:40 +0000)]
clang-cl: accept -fcrash-diagnostics-dir=

llvm-svn: 339424

6 years agoFix a wrong type bug in ParsedAttr::TypeTagForDatatypeData
Bruno Ricci [Fri, 10 Aug 2018 11:20:20 +0000 (11:20 +0000)]
Fix a wrong type bug in ParsedAttr::TypeTagForDatatypeData

This patch fixes a wrong type bug inside ParsedAttr::TypeTagForDatatypeData.
The details to the best of my knowledge are as follow. The incredible thing
is that everything works out just fine by chance due to a sequence of lucky
coincidences in the layout of various types.

The struct ParsedAttr::TypeTagForDatatypeData contains among other things
a ParsedType *MatchingCType, where ParsedType is just OpaquePtr<QualType>.

However the member MatchingCType is initialized in the constructor for
type_tag_for_datatype attribute as follows:

new (&ExtraData.MatchingCType) ParsedType(matchingCType);

This results in the ParsedType being constructed in the location of the
ParsedType * Later ParsedAttr::getMatchingCType do return
*getTypeTagForDatatypeDataSlot().MatchingCType; which instead of
dereferencing the ParsedType * will dereference the QualType inside
the ParsedType. Now this QualType in this case contains no qualifiers
and therefore is a valid Type *. Therefore getMatchingCType returns a
Type or at least the stuff that is in the first sizeof(void*) bytes of it,
But it turns out that Type inherits from ExtQualsCommonBase and that the
first member of ExtQualsCommonBase is a const Type *const BaseType. This
Type * in this case points to the original Type pointed to by the
QualType and so everything works fine even though all the types were wrong.

This bug was only found because I changed the layout of Type,
which obviously broke all of this long chain of improbable events.

Reviewed By: erichkeane

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

llvm-svn: 339423

6 years agoFix -Wimplicit-fallthrough warning introduced in rL339397.
Simon Pilgrim [Fri, 10 Aug 2018 11:02:44 +0000 (11:02 +0000)]
Fix -Wimplicit-fallthrough warning introduced in rL339397.

llvm-svn: 339422

6 years ago[Tablegen][SubtargetEmitter] refactor method `emitSchedModelHelpersImpl()`. NFCI
Andrea Di Biagio [Fri, 10 Aug 2018 10:43:43 +0000 (10:43 +0000)]
[Tablegen][SubtargetEmitter] refactor method `emitSchedModelHelpersImpl()`. NFCI

Part of the logic has been moved to helper functions to (hopefully) improve
readability.
Added a few code comments to better describe how the algorithm works.

No functional change intended.

llvm-svn: 339421

6 years agoclang-cl: Support /guard:cf,nochecks
Hans Wennborg [Fri, 10 Aug 2018 09:49:21 +0000 (09:49 +0000)]
clang-cl: Support /guard:cf,nochecks

This extension emits the guard cf table without inserting the
instrumentation. Currently that's what clang-cl does with /guard:cf
anyway, but this allows a user to request that explicitly.

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

llvm-svn: 339420

6 years agoRename the cfguard module flag to cfguardtable
Hans Wennborg [Fri, 10 Aug 2018 09:48:53 +0000 (09:48 +0000)]
Rename the cfguard module flag to cfguardtable

The previous name sounds like it inserts cfguard implementation, but it
really just emits the table of address-taken functions. Change the name
to better reflect that.

Clang will be updated in the next commit.

llvm-svn: 339419

6 years ago[NFC] Add tests that demonstrate that MustExecute is fundamentally broken
Max Kazantsev [Fri, 10 Aug 2018 09:20:46 +0000 (09:20 +0000)]
[NFC] Add tests that demonstrate that MustExecute is fundamentally broken

llvm-svn: 339417

6 years ago[clangd] Fix a "-Wdangling-else" compiler warning in the test.
Haojian Wu [Fri, 10 Aug 2018 08:34:16 +0000 (08:34 +0000)]
[clangd] Fix a "-Wdangling-else" compiler warning in the test.

llvm-svn: 339416

6 years ago[clang-tidy] Omit cases where loop variable is not used in loop body in
Haojian Wu [Fri, 10 Aug 2018 08:25:51 +0000 (08:25 +0000)]
[clang-tidy] Omit cases where loop variable is not used in loop body in
performance-for-range-copy check.

Summary:
The upstream change r336737 make the check too smart to fix the case
where loop variable could be used as `const auto&`.

But for the case below, changing to `const auto _` will introduce
an unused complier warning.

```
for (auto _ : state) {
  // no references for _.
}
```

This patch omit this case, and it is safe to do it as the case is very rare.

Reviewers: ilya-biryukov, alexfh

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 339415

6 years ago[MSan] Shrink the register save area for non-SSE builds
Alexander Potapenko [Fri, 10 Aug 2018 08:06:43 +0000 (08:06 +0000)]
[MSan] Shrink the register save area for non-SSE builds

If code is compiled for X86 without SSE support, the register save area
doesn't contain FPU registers, so `AMD64FpEndOffset` should be equal to
`AMD64GpEndOffset`.

llvm-svn: 339414

6 years ago[ELF] - Get rid of SyntheticSection::postThunkContents(). NFCI.
George Rimar [Fri, 10 Aug 2018 07:24:18 +0000 (07:24 +0000)]
[ELF] - Get rid of SyntheticSection::postThunkContents(). NFCI.

It turns out that postThunkContents() is only used for
sorting symbols in .symtab.

Though we can instead move the logic to SymbolTableBaseSection::finalizeContents(),
postpone calling it and then get rid of postThunkContents completely.

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

llvm-svn: 339413

6 years ago[LLD][ELF] - Fix crash when using empty --defsym.
George Rimar [Fri, 10 Aug 2018 06:32:39 +0000 (06:32 +0000)]
[LLD][ELF] - Fix crash when using empty --defsym.

We have a crash issue when handling the empty -defsym.

For parsing this option we are using ScriptParser class which is used
generally for reading the linker script. For empty defsym case, we
pass the empty memory buffer and crash in the place removed in https://reviews.llvm.org/rL336436.

But reverting of the above patch would not help here (we would still crash but a bit later). And
even after fixing the crash we would report something like
"lld.exe: error: -defsym:1: unexpected EOF"
It is probably not the appropriate message because mentions EOF.

I think the issue should be handled on a higher level like this patch does.
So we do not want to pass the empty memory buffer first of all I believe.

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

llvm-svn: 339412

6 years ago[MemorySSA] "Fix" lifetime intrinsic handling
George Burgess IV [Fri, 10 Aug 2018 05:14:43 +0000 (05:14 +0000)]
[MemorySSA] "Fix" lifetime intrinsic handling

MemorySSA currently creates MemoryAccesses for lifetime intrinsics, and
sometimes treats them as clobbers. This may/may not be the best way
forward, but while we're doing it, we should consider
MayAlias/PartialAlias to be clobbers.

The ideal fix here is probably to remove all of this reasoning about
lifetimes from MemorySSA + put it into the passes that need to care. But
that's a wayyy broader fix that needs some consensus, and we have
miscompiles + a release branch today, and this should solve the
miscompiles just as well.

differential revision is D43269. Landing without an explicit LGTM (and
without using the special please-autoclose-this syntax) so we can still
use that revision as a place to decide what the right fix here is.

llvm-svn: 339411

6 years ago[InstCombine] Transform str(n)cmp to memcmp
David Bolvansky [Fri, 10 Aug 2018 04:32:54 +0000 (04:32 +0000)]
[InstCombine] Transform str(n)cmp to memcmp

Summary:
Motivation examples:
int strcmp_memcmp() {
    char buf[12];
    return strcmp(buf, "key") == 0;
}

int strcmp_memcmp2() {
    char buf[12];
    return strcmp(buf, "key") != 0;
}

int strncmp_memcmp() {
    char buf[12];
    return strncmp(buf, "key", 3) == 0;
}

can be turned to memcmp.

See test file for more cases.

Reviewers: efriedma

Reviewed By: efriedma

Subscribers: spatel, llvm-commits

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

llvm-svn: 339410

6 years agoFix size calculation from r339380
Richard Trieu [Fri, 10 Aug 2018 01:30:10 +0000 (01:30 +0000)]
Fix size calculation from r339380

r339380 changed the trailing types of ParsedAttr to use llvm::TrailingObjects.
However, it did not copy over one of the size attributes, causing a too
small allocation for this object.  The error was detected with
AddressSanitizer use-after-poison

llvm-svn: 339409

6 years agoRevert "SafeStack: Delay thread stack clean-up"
Vlad Tsyrklevich [Fri, 10 Aug 2018 00:36:04 +0000 (00:36 +0000)]
Revert "SafeStack: Delay thread stack clean-up"

This reverts commit r339405, it's failing on Darwin buildbots because
it doesn't seem to have a tgkill/thr_kill2 interface. It has a
__pthread_kill() syscall, but that relies on having a handle to the
thread's port which is not equivalent to it's tid.

llvm-svn: 339408

6 years ago[WebAssembly] Gate i64x2 and f64x2 on -wasm-enable-unimplemented
Heejin Ahn [Thu, 9 Aug 2018 23:58:51 +0000 (23:58 +0000)]
[WebAssembly] Gate i64x2 and f64x2 on -wasm-enable-unimplemented

Summary:
i64x2 and f64x2 operations are not implemented in V8, so we normally
do not want to emit them. However, they are in the SIMD spec proposal,
so we still want to be able to test them in the toolchain. This patch
adds a flag to enable their emission.

Reviewers: aheejin, dschuff

Subscribers: sunfish, jgravelle-google, sbc100, llvm-commits

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

Patch by Thomas Lively (tlively)

llvm-svn: 339407

6 years ago[X86] Qualify one of the heuristics in combineMul to only apply to positive multiply...
Craig Topper [Thu, 9 Aug 2018 23:27:42 +0000 (23:27 +0000)]
[X86] Qualify one of the heuristics in combineMul to only apply to positive multiply amounts.

This seems to slightly help the performance of one of our internal benchmarks. We probably need better heuristics here.

llvm-svn: 339406

6 years agoSafeStack: Delay thread stack clean-up
Vlad Tsyrklevich [Thu, 9 Aug 2018 22:56:41 +0000 (22:56 +0000)]
SafeStack: Delay thread stack clean-up

Summary:
glibc can call SafeStack instrumented code even after the last pthread
data destructor has run. Delay cleaning-up unsafe stacks for threads
until the thread is dead by having future threads clean-up prior threads
stacks.

Reviewers: pcc, eugenis

Reviewed By: eugenis

Subscribers: cryptoad, eugenis, kubamracek, delcypher, llvm-commits, #sanitizers, kcc

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

llvm-svn: 339405

6 years ago[llvm-objcopy] NFC: Add some color to error()
Jordan Rupprecht [Thu, 9 Aug 2018 22:52:03 +0000 (22:52 +0000)]
[llvm-objcopy] NFC: Add some color to error()

llvm-svn: 339404

6 years agoMark up deprecated methods as such
Stephen Kelly [Thu, 9 Aug 2018 22:45:38 +0000 (22:45 +0000)]
Mark up deprecated methods as such

Reviewers: teemperor!

Subscribers: cfe-commits

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

llvm-svn: 339403

6 years agoRemove obsolete set call
Stephen Kelly [Thu, 9 Aug 2018 22:44:03 +0000 (22:44 +0000)]
Remove obsolete set call

Summary:
Case case of the switch statement here makes the same call, but it is
already done at the start of the function.

Reviewers: rsmith, dblaikie

Subscribers: cfe-commits

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

llvm-svn: 339402

6 years agoPort getLocEnd -> getEndLoc
Stephen Kelly [Thu, 9 Aug 2018 22:43:02 +0000 (22:43 +0000)]
Port getLocEnd -> getEndLoc

Subscribers: nemanjai, ioeric, kbarton, cfe-commits

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

llvm-svn: 339401

6 years agoPort getLocStart -> getBeginLoc
Stephen Kelly [Thu, 9 Aug 2018 22:42:26 +0000 (22:42 +0000)]
Port getLocStart -> getBeginLoc

Reviewers: javed.absar

Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits

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

llvm-svn: 339400

6 years agoValueTracking: Start enhancing isKnownNeverNaN
Matt Arsenault [Thu, 9 Aug 2018 22:40:08 +0000 (22:40 +0000)]
ValueTracking: Start enhancing isKnownNeverNaN

llvm-svn: 339399

6 years ago[WebAssembly] Fix wasm backend compilation on gcc 5.4: variable name cannot match...
Heejin Ahn [Thu, 9 Aug 2018 22:35:23 +0000 (22:35 +0000)]
[WebAssembly] Fix wasm backend compilation on gcc 5.4: variable name cannot match class

Summary:
gcc does not like

const Region *Region;

It wants a different name for the variable.

Is there a better convention for what name to use in such a case?

Reviewers: sbc100, aheejin

Subscribers: aheejin, jgravelle-google, dschuff, llvm-commits

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

Patch by Alon Zakai (kripken)

llvm-svn: 339398

6 years ago[MC] Move EH DWARF encodings from MC to CodeGen, NFC
Reid Kleckner [Thu, 9 Aug 2018 22:24:04 +0000 (22:24 +0000)]
[MC] Move EH DWARF encodings from MC to CodeGen, NFC

Summary:
The TType encoding, LSDA encoding, and personality encoding are all
passed explicitly by CodeGen to the assembler through .cfi_* directives,
so only the AsmPrinter needs to know about them.

The FDE CFI encoding however, controls the encoding of the label
implicitly created by the .cfi_startproc directive. That directive seems
to be special in that it doesn't take an encoding, so the assembler just
has to know how to encode one DSO-local label reference from .eh_frame
to .text.

As a result, it looks like MC will continue to have to know when the
large code model is in use. Perhaps we could invent a '.cfi_startproc
[large]' flag so that this knowledge doesn't need to pollute the
assembler.

Reviewers: davide, lliu0, JDevlieghere

Subscribers: hiraditya, fedor.sergeev, llvm-commits

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

llvm-svn: 339397

6 years ago[InstSimplify] move minnum/maxnum with Inf folds from instcombine
Sanjay Patel [Thu, 9 Aug 2018 22:20:44 +0000 (22:20 +0000)]
[InstSimplify] move minnum/maxnum with Inf folds from instcombine

llvm-svn: 339396

6 years agoAMDGPU: Add another missing builtin
Matt Arsenault [Thu, 9 Aug 2018 22:18:37 +0000 (22:18 +0000)]
AMDGPU: Add another missing builtin

llvm-svn: 339395

6 years agoAdd owner for llvm-objcopy
Jake Ehrlich [Thu, 9 Aug 2018 22:05:19 +0000 (22:05 +0000)]
Add owner for llvm-objcopy

llvm-svn: 339394

6 years ago[OpenMP] Cleanup code
Jonathan Peyton [Thu, 9 Aug 2018 22:04:30 +0000 (22:04 +0000)]
[OpenMP] Cleanup code

This patch cleans up unused functions, variables, sign compare issues, and
addresses some -Warning flags which are now enabled including -Wcast-qual.
Not all the warning flags in LibompHandleFlags.cmake are enabled, but some
are with this patch.

Some __kmp_gtid_from_* macros in kmp.h are switched to static inline functions
which allows us to remove the awkward definition of KMP_DEBUG_ASSERT() and
KMP_ASSERT() macros which used the comma operator. This had to be done for the
innumerable -Wunused-value warnings related to KMP_DEBUG_ASSERT()

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

llvm-svn: 339393

6 years agoAdded LLVM metadata to generated IR to increase vectorization width
Emmett Neyman [Thu, 9 Aug 2018 21:59:01 +0000 (21:59 +0000)]
Added LLVM metadata to generated IR to increase vectorization width

Summary: Edited `loop_proto_to_llvm` to emit metadata at the end of the generated IR. This metadata will increase the vector width when the IR is optimized.

Reviewers: morehouse, kcc

Reviewed By: morehouse

Subscribers: cfe-commits, llvm-commits

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

llvm-svn: 339392

6 years ago[NFC] ConstantMerge: factor out some functions
JF Bastien [Thu, 9 Aug 2018 21:56:09 +0000 (21:56 +0000)]
[NFC] ConstantMerge: factor out some functions

This makes the code easier to read and will make an upcoming patch I have easier to review because that patch needed this refactoring to reuse some of the functions.

llvm-svn: 339391

6 years agoConstantMerge: update MadeChange when change is made
JF Bastien [Thu, 9 Aug 2018 21:36:57 +0000 (21:36 +0000)]
ConstantMerge: update MadeChange when change is made

It was always false, which is obviously wrong.

llvm-svn: 339390

6 years agoFix and recommit r339382 based on solution from RSmith:
Erich Keane [Thu, 9 Aug 2018 21:18:13 +0000 (21:18 +0000)]
Fix and recommit r339382 based on solution from RSmith:

As sent on cfe-commits:
 "You need to use "friend TrailingObjects;" here, not
 "friend class TrailingObjects;", to avoid breaking MSVC
 (which doesn't implement injected-class-names quite according to spec)."

llvm-svn: 339389

6 years ago[LICM] Suppress a compiler warning noticed by one of the bots
Philip Reames [Thu, 9 Aug 2018 21:15:33 +0000 (21:15 +0000)]
[LICM] Suppress a compiler warning noticed by one of the bots

llvm-svn: 339388

6 years agoRevert -r339382, which apparently breaks the Windows build.
Erich Keane [Thu, 9 Aug 2018 21:13:46 +0000 (21:13 +0000)]
Revert -r339382, which apparently breaks the Windows build.

llvm-svn: 339387

6 years agoPort getLocEnd -> getEndLoc
Stephen Kelly [Thu, 9 Aug 2018 21:09:38 +0000 (21:09 +0000)]
Port getLocEnd -> getEndLoc

Reviewers: teemperor!

Subscribers: cfe-commits

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

llvm-svn: 339386

6 years agoPort getLocStart -> getBeginLoc
Stephen Kelly [Thu, 9 Aug 2018 21:08:08 +0000 (21:08 +0000)]
Port getLocStart -> getBeginLoc

Reviewers: teemperor!

Subscribers: jholewinski, whisperity, jfb, cfe-commits

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

llvm-svn: 339385

6 years agoPort getStartLoc -> getBeginLoc
Stephen Kelly [Thu, 9 Aug 2018 21:05:56 +0000 (21:05 +0000)]
Port getStartLoc -> getBeginLoc

Reviewers: teemperor!

Subscribers: cfe-commits

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

llvm-svn: 339384

6 years ago[NFC] Complete the rule-of-5 for ParsedAttr
Erich Keane [Thu, 9 Aug 2018 21:04:34 +0000 (21:04 +0000)]
[NFC] Complete the rule-of-5 for ParsedAttr

Add move assign/construct as 'deleted' to ParsedAttr
to complete the rule-of-5.

llvm-svn: 339383

6 years ago[NFC] Simplify 'friend' declaration in ParsedAttr
Erich Keane [Thu, 9 Aug 2018 21:03:39 +0000 (21:03 +0000)]
[NFC] Simplify 'friend' declaration in ParsedAttr

As suggested in the post-commit review for D50531,
change from the templatized TrailingObjects friend declaration
to a version referring to the base.

llvm-svn: 339382

6 years ago[RISC-V] Fixed alias for addi x2, x2, 0
Ana Pazos [Thu, 9 Aug 2018 20:51:53 +0000 (20:51 +0000)]
[RISC-V] Fixed alias for addi x2, x2, 0

A missing check for non-zero immediate in MCOperandPredicate
caused c.addi16sp sp, 0 to be selected which is not a valid
instruction.

llvm-svn: 339381

6 years ago[NFC] Convert ParsedAttr to use llvm::TrailingObjects
Erich Keane [Thu, 9 Aug 2018 20:25:12 +0000 (20:25 +0000)]
[NFC] Convert ParsedAttr to use llvm::TrailingObjects

ParsedAttr is using a hand-rolled trailing-objects
implementation that gets cleaned up quite a bit by
just using llvm::TrailingObjects. This is a large
TrailingObjects list, but most things are length '0'.

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

llvm-svn: 339380

6 years agoFix build
Stephen Kelly [Thu, 9 Aug 2018 20:21:09 +0000 (20:21 +0000)]
Fix build

llvm-svn: 339379

6 years ago[LICM] hoist fences out of loops w/o memory operations
Philip Reames [Thu, 9 Aug 2018 20:18:42 +0000 (20:18 +0000)]
[LICM] hoist fences out of loops w/o memory operations

The motivating case is an otherwise dead loop with a fence in it. At the moment, this goes all the way through the optimizer and we end up emitting an entirely pointless loop on x86. This case may seem a bit contrived, but we've seen it in real code as the result of otherwise reasonable lowering strategies combined w/thread local memory optimizations (such as escape analysis).

To handle this simple case, we can teach LICM to hoist must execute fences when there is no other memory operation within the loop.

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

llvm-svn: 339378

6 years agoFix typo
Stephen Kelly [Thu, 9 Aug 2018 20:15:13 +0000 (20:15 +0000)]
Fix typo

llvm-svn: 339377

6 years agoRemove obsolete policy settings
Stephen Kelly [Thu, 9 Aug 2018 20:15:08 +0000 (20:15 +0000)]
Remove obsolete policy settings

Summary:
The line

 cmake_minimum_required(VERSION 3.4.3)

already has the effect of setting to NEW all policies present in that
release:

 https://cmake.org/cmake/help/v3.4/manual/cmake-policies.7.html

Subscribers: mgorny, llvm-commits

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

llvm-svn: 339376

6 years ago[Sema] P0961R1: Relaxing the structured bindings customization point finding rules
Erik Pilkington [Thu, 9 Aug 2018 20:11:13 +0000 (20:11 +0000)]
[Sema] P0961R1: Relaxing the structured bindings customization point finding rules

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

llvm-svn: 339375

6 years agoAdd getEndLoc API to replace getLocEnd
Stephen Kelly [Thu, 9 Aug 2018 20:05:47 +0000 (20:05 +0000)]
Add getEndLoc API to replace getLocEnd

Subscribers: cfe-commits

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

llvm-svn: 339374

6 years agoAdd getBeginLoc API to replace getStartLoc
Stephen Kelly [Thu, 9 Aug 2018 20:05:18 +0000 (20:05 +0000)]
Add getBeginLoc API to replace getStartLoc

Reviewers: teemperor!

Subscribers: cfe-commits

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

llvm-svn: 339373

6 years agoAdd getBeginLoc API to replace getLocStart
Stephen Kelly [Thu, 9 Aug 2018 20:05:03 +0000 (20:05 +0000)]
Add getBeginLoc API to replace getLocStart

Subscribers: cfe-commits

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

llvm-svn: 339372

6 years ago[ELF][HEXAGON] Add R_HEX_HI16/R_HEX_LO16 relocations
Sid Manning [Thu, 9 Aug 2018 20:04:53 +0000 (20:04 +0000)]
[ELF][HEXAGON] Add R_HEX_HI16/R_HEX_LO16 relocations

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

llvm-svn: 339371

6 years ago[sanitizer] Remove rsp from the clobber list in internal_clone
Kostya Kortchinsky [Thu, 9 Aug 2018 20:01:11 +0000 (20:01 +0000)]
[sanitizer] Remove rsp from the clobber list in internal_clone

Summary:
When compiling with WERROR=ON, a new fatal warning started popping up recently
(due to -Werror,-Winline-asm):
```
.../lib/sanitizer_common/sanitizer_linux.cc:1214:24: error: inline asm clobber list contains reserved registers: RSP [-Werror,-Winline-asm]
                       "syscall\n"
                       ^
<inline asm>:1:1: note: instantiated into assembly here
        syscall
^
.../lib/sanitizer_common/sanitizer_linux.cc:1214:24: note: Reserved registers on the clobber list may not be preserved across the asm statement, and clobbering them may lead to undefined behaviour.
                       "syscall\n"
                       ^
<inline asm>:1:1: note: instantiated into assembly here
        syscall
^
```

Removing `rsp` from the clobber list makes the warning go away, and does not
appear to have a functional impact. If there is another way to solve this, let
me know.

Reviewers: eugenis, vitalybuka

Reviewed By: eugenis

Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 339370

6 years ago[analyzer] Fix the bug in UninitializedObjectChecker caused by not handling block...
George Karpenkov [Thu, 9 Aug 2018 19:03:12 +0000 (19:03 +0000)]
[analyzer] Fix the bug in UninitializedObjectChecker caused by not handling block pointers

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

llvm-svn: 339369

6 years ago[InstCombine] allow fsub+fmul FMF folds for vectors
Sanjay Patel [Thu, 9 Aug 2018 18:42:12 +0000 (18:42 +0000)]
[InstCombine] allow fsub+fmul FMF folds for vectors

llvm-svn: 339368

6 years agoFix few g++ 8 warning with non obvious copy object operations
David Carlier [Thu, 9 Aug 2018 18:29:07 +0000 (18:29 +0000)]
Fix few g++ 8 warning with non obvious copy object operations

Reviewers: dblaikie, dexonsmith

Reviewed By: dblaikie

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

llvm-svn: 339367

6 years ago[NFC] Remove magic bool param in RAUW
JF Bastien [Thu, 9 Aug 2018 18:28:54 +0000 (18:28 +0000)]
[NFC] Remove magic bool param in RAUW

Use an enum class instead.

llvm-svn: 339366

6 years ago[Hexagon] Map ISD::TRAP to J2_trap0(#0)
Krzysztof Parzyszek [Thu, 9 Aug 2018 18:03:45 +0000 (18:03 +0000)]
[Hexagon] Map ISD::TRAP to J2_trap0(#0)

llvm-svn: 339365

6 years agoSupport RISC-V
Rui Ueyama [Thu, 9 Aug 2018 17:59:56 +0000 (17:59 +0000)]
Support RISC-V

Patch by PkmX.

This patch makes lld recognize RISC-V target and implements basic
relocation for RV32/RV64 (and RVC). This should be necessary for static
linking ELF applications.

The ABI documentation for RISC-V can be found at:
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md.
Note that the documentation is far from complete so we had to figure out
some details from bfd.

The patch should be pretty straightforward. Some highlights:

 - A new relocation Expr R_RISCV_PC_INDIRECT is added. This is needed as
   the low part of a PC-relative relocation is linked to the corresponding
   high part (auipc), see:
   https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#pc-relative-symbol-addresses

 - LLVM's MC support for RISC-V is very incomplete (we are working on
   this), so tests are given in objectyaml format with the original
   assembly included in the comments. Once we have complete support for
   RISC-V in MC, we can switch to llvm-as/llvm-objdump.

 - We don't support linker relaxation for now as it requires greater
   changes to lld that is beyond the scope of this patch. Once this is
   accepted we can start to work on adding relaxation to lld.

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

llvm-svn: 339364

6 years agoSCEV should forget all loops containing a deleted block.
Alina Sbirlea [Thu, 9 Aug 2018 17:53:26 +0000 (17:53 +0000)]
SCEV should forget all loops containing a deleted block.

Summary:
LoopSimplifyCFG should update ScEv for all loops after a block is deleted.
If the deleted block "Succ" is part of L, then it is part of all parent loops, so forget topmost loop.

Reviewers: greened, mkazantsev, sanjoy

Subscribers: jlebar, javed.absar, uabelho, llvm-commits

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

llvm-svn: 339363

6 years ago[llvm-objcopy] Add --prefix-symbols option
Paul Semel [Thu, 9 Aug 2018 17:49:04 +0000 (17:49 +0000)]
[llvm-objcopy] Add --prefix-symbols option

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

llvm-svn: 339362

6 years ago[InstCombine] add vector tests for fsub+fmul; NFC
Sanjay Patel [Thu, 9 Aug 2018 17:40:27 +0000 (17:40 +0000)]
[InstCombine] add vector tests for fsub+fmul; NFC

llvm-svn: 339361

6 years ago[GlobalOpt] Don't apply fastcc if it would break inalloca invariants
Reid Kleckner [Thu, 9 Aug 2018 17:29:26 +0000 (17:29 +0000)]
[GlobalOpt] Don't apply fastcc if it would break inalloca invariants

The inalloca parameter has to be the only parameter passed in memory.
Changing the convention to fastcc can break that.

At some point we should teach global opt how to optimize ABI attributes
like inalloca and maybe byval. These attributes are mainly used to match
C ABIs. They are harder for LLVM to optimize and they don't always
generate the best code.

Fixes PR38487

llvm-svn: 339360

6 years ago[SelectionDAG] try harder to convert funnel shift to rotate
Sanjay Patel [Thu, 9 Aug 2018 17:26:22 +0000 (17:26 +0000)]
[SelectionDAG] try harder to convert funnel shift to rotate

Similar to rL337966 - if the DAGCombiner's rotate matching was
working as expected, I don't think we'd see any test diffs here.

AArch only goes right, and PPC only goes left.
x86 has both, so no diffs there.

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

llvm-svn: 339359

6 years ago[llvm-objcopy] Add --dump-section
Paul Semel [Thu, 9 Aug 2018 17:05:21 +0000 (17:05 +0000)]
[llvm-objcopy] Add --dump-section

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

llvm-svn: 339358

6 years agoextend folding fsub/fadd to fneg for FMF
Michael Berg [Thu, 9 Aug 2018 17:00:03 +0000 (17:00 +0000)]
extend folding fsub/fadd to fneg for FMF

Summary: This change provides a common optimization path for both Unsafe and FMF driven optimization for this fsub fold adding reassociation, as it the flag that most closely represents the translation

Reviewers: spatel, wristow, arsenm

Reviewed By: spatel

Subscribers: wdng

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

llvm-svn: 339357

6 years ago[ARM] Adjust the feature set for Exynos
Evandro Menezes [Thu, 9 Aug 2018 16:34:38 +0000 (16:34 +0000)]
[ARM] Adjust the feature set for Exynos

Enable `FeatureZCZeroing`, `FeatureHasSlowFPVMLx`, `FeatureExpandMLx`,
`FeatureProfUnpredicate`, `FeatureSlowVDUP32`, `FeatureSlowVGETLNi32`,
`FeatureSplatVFPToNeon`, `FeatureHasRetAddrStack`, `FeatureSlowFPBrcc` for
all Exynos processors.

llvm-svn: 339356

6 years ago[ARM] Replace processor check with feature
Evandro Menezes [Thu, 9 Aug 2018 16:13:24 +0000 (16:13 +0000)]
[ARM] Replace processor check with feature

Add new feature, `FeatureUseWideStrideVFP`, that replaces the need for a
processor check.  Otherwise, NFC.

llvm-svn: 339354

6 years agoAdded missing null checks to fix r339351
Raphael Isemann [Thu, 9 Aug 2018 15:57:43 +0000 (15:57 +0000)]
Added missing null checks to fix r339351

llvm-svn: 339353

6 years ago[MC][PredicateExpander] Extend the grammar to support simple switch and return statem...
Andrea Di Biagio [Thu, 9 Aug 2018 15:32:48 +0000 (15:32 +0000)]
[MC][PredicateExpander] Extend the grammar to support simple switch and return statements.

This patch introduces tablegen class MCStatement.

Currently, an MCStatement can be either a return statement, or a switch
statement.

```
MCStatement:
   MCReturnStatement
   MCOpcodeSwitchStatement
```

A MCReturnStatement expands to a return statement, and the boolean expression
associated with the return statement is described by a MCInstPredicate.

An MCOpcodeSwitchStatement is a switch statement where the condition is a check
on the machine opcode. It allows the definition of multiple checks, as well as a
default case. More details on the grammar implemented by these two new
constructs can be found in the diff for TargetInstrPredicates.td.

This patch makes it easier to read the body of auto-generated TargetInstrInfo
predicates.

In future, I plan to reuse/extend the MCStatement grammar to describe more
complex target hooks. For now, this is just a first step (mostly a minor
cosmetic change to polish the new predicates framework).

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

llvm-svn: 339352

6 years agoAlso display the output and error output of a failed command
Raphael Isemann [Thu, 9 Aug 2018 15:29:32 +0000 (15:29 +0000)]
Also display the output and error output of a failed command

Summary:
Instead of just printing the current "False is not True, ..." message when we
fail to run a certain command, this patch also adds the actual command output or
error output that we received to the assertion message.

Reviewers: davide

Reviewed By: davide

Subscribers: lldb-commits

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

llvm-svn: 339351

6 years ago[MC] Remove PhysRegSize from MCRegisterClass
Bjorn Pettersson [Thu, 9 Aug 2018 15:19:07 +0000 (15:19 +0000)]
[MC] Remove PhysRegSize from MCRegisterClass

Summary:
The interface to get size and spill size of a register
was moved from MCRegisterInfo to TargetRegisterInfo over
a year ago. Afaik the old interface has bee around
to give out-of-tree targets a chance to adapt to the
new interface.

One problem with the old MCRegisterClass::PhysRegSize was that
it represented the size of a register as "size in bits" / 8.
So a register had to be a multiple of eight bits wide for the
size to be correct (and the byte size for the target needed to
be eight bits).

Reviewers: kparzysz, qcolombet

Reviewed By: kparzysz

Subscribers: llvm-commits

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

llvm-svn: 339350

6 years ago[InstCombine] reduce code duplication; NFC
Sanjay Patel [Thu, 9 Aug 2018 15:07:13 +0000 (15:07 +0000)]
[InstCombine] reduce code duplication; NFC

llvm-svn: 339349

6 years ago[LLD][ELF] - Add a test for elf::getPriority(StringRef S)
George Rimar [Thu, 9 Aug 2018 15:05:25 +0000 (15:05 +0000)]
[LLD][ELF] - Add a test for elf::getPriority(StringRef S)

It covers the following line with a test:
https://github.com/llvm-mirror/lld/blob/master/ELF/OutputSections.cpp#L383

llvm-svn: 339348

6 years ago[AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests
Sjoerd Meijer [Thu, 9 Aug 2018 14:07:27 +0000 (14:07 +0000)]
[AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests

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

llvm-svn: 339347

6 years ago[TargetLowering] Add BuildSDIVPattern helper to BuildExactSDIV (NFCI).
Simon Pilgrim [Thu, 9 Aug 2018 13:56:04 +0000 (13:56 +0000)]
[TargetLowering] Add BuildSDIVPattern helper to BuildExactSDIV (NFCI).

As requested in D50392, pull the magic constant calculations out into a helper function.

llvm-svn: 339346

6 years ago[COFF] Make the relocation scanning for CFG more discriminating
Hans Wennborg [Thu, 9 Aug 2018 13:43:22 +0000 (13:43 +0000)]
[COFF] Make the relocation scanning for CFG more discriminating

link.exe ignores REL32 relocations on 32-bit x86, as well as relocations
against non-function symbols such as labels. This makes lld do the same.

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

llvm-svn: 339345

6 years agoImplement diagnostic stream operator for ParsedAttr.
Erich Keane [Thu, 9 Aug 2018 13:21:32 +0000 (13:21 +0000)]
Implement diagnostic stream operator for ParsedAttr.

As a part of attempting to clean up the way attributes are
printed, this patch adds an operator << to the diagnostics/
partialdiagnostics so that ParsedAttr can be sent directly.

This patch also rewrites a large amount* of the times when
ParsedAttr was printed using its IdentifierInfo object instead
of being printed itself.
*"a large amount" == "All I could find".

llvm-svn: 339344

6 years agoDarwin: mark test unsupported while we sort out how to make it generic.
Tim Northover [Thu, 9 Aug 2018 13:21:05 +0000 (13:21 +0000)]
Darwin: mark test unsupported while we sort out how to make it generic.

This test relies on communicating with debugserver via an unnamed (pre-opened)
pipe, but macOS's version of debugserver doesn't seem to support that mode of
operation. So disable the test for now.

llvm-svn: 339343

6 years ago[LLD][ELF] - Add a test for ScriptParser::readPhdrType().
George Rimar [Thu, 9 Aug 2018 13:19:10 +0000 (13:19 +0000)]
[LLD][ELF] - Add a test for ScriptParser::readPhdrType().

This adds a test for https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L1289.

llvm-svn: 339342