platform/upstream/llvm.git
5 years agoFix uninitialized variable warnings. NFCI.
Simon Pilgrim [Wed, 3 Jul 2019 10:22:08 +0000 (10:22 +0000)]
Fix uninitialized variable warnings. NFCI.

Both MSVC and cppcheck don't like the fact that the variables are initialized via references.

llvm-svn: 365018

5 years ago[clang-tidy] Fix the YAML created for checks like modernize-pass-by-value
Ivan Donchevskii [Wed, 3 Jul 2019 10:21:50 +0000 (10:21 +0000)]
[clang-tidy] Fix the YAML created for checks like modernize-pass-by-value

Currently this check generates the replacement with the newline in the end.
The proper way to export it to YAML is to have two \n\n instead of one.
Without this fix clients should reinterpret the replacement as
"#include <utility> " instead of "#include <utility>\n"

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

llvm-svn: 365017

5 years ago[X86] LowerFunnelShift - use modulo constant shift amount.
Simon Pilgrim [Wed, 3 Jul 2019 10:04:16 +0000 (10:04 +0000)]
[X86] LowerFunnelShift - use modulo constant shift amount.

This avoids the use of getZExtValue and uses the modulo shift amount which is whats expected for funnel shifts anyhow.

llvm-svn: 365016

5 years ago[ELF] Allow placing SHF_MERGE sections with different alignments into the same MergeS...
Fangrui Song [Wed, 3 Jul 2019 10:03:49 +0000 (10:03 +0000)]
[ELF] Allow placing SHF_MERGE sections with different alignments into the same MergeSyntheticSection

This should fix PR42289: the Linux kernel has a use case that input
files have .rodata.cst32 sections with different alignments. The
expectation (and what ld.bfd and gold do) is that in the -r link, there
is only one .rodata.cst32 (SHF_MERGE sections with different alignments
can be combined), but lld currently creates one for each different
alignment.

The current merging strategy:

1) Group SHF_MERGE sections by (name, sh_flags, sh_entsize and
   sh_addralign). String merging is performed among a group, even if -O0 is specified.
2) Create one output section for each group. This is a special case in
   addInputSec().

This patch changes 1) to:

1) Group SHF_MERGE sections by (name, sh_flags, sh_entsize).
   String merging is performed among a group, even if -O0 is specified.

We will thus create just one .rodata.cst32 . This also improves merging
efficiency when sections with the same name but different alignments are
combined.

Reviewed By: ruiu

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

llvm-svn: 365015

5 years ago[ARM] Thumb2: favor R4-R7 over R12/LR in allocation order when opt for minsize
Oliver Stannard [Wed, 3 Jul 2019 09:58:52 +0000 (09:58 +0000)]
[ARM] Thumb2: favor R4-R7 over R12/LR in allocation order when opt for minsize

For Thumb2, we prefer low regs (costPerUse = 0) to allow narrow
encoding. However, current allocation order is like:
  R0-R3, R12, LR, R4-R11

As a result, a lot of instructs that use R12/LR will be wide instrs.

This patch changes the allocation order to:
  R0-R7, R12, LR, R8-R11
for thumb2 and -Osize.

In most cases, there is no extra push/pop instrs as they will be folded
into existing ones. There might be slight performance impact due to more
stack usage, so we only enable it when opt for min size.

https://reviews.llvm.org/D30324

llvm-svn: 365014

5 years agoRemove some autoconf references from docs and comments
Sven van Haastregt [Wed, 3 Jul 2019 09:57:59 +0000 (09:57 +0000)]
Remove some autoconf references from docs and comments

The autoconf build system support has been removed a while ago, remove
some outdated references.

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

llvm-svn: 365013

5 years agoFix MSVC "not all control paths return a value" warnings. NFCI.
Simon Pilgrim [Wed, 3 Jul 2019 09:54:25 +0000 (09:54 +0000)]
Fix MSVC "not all control paths return a value" warnings. NFCI.

llvm-svn: 365012

5 years ago[InstCombine] Y - ~X --> X + Y + 1 fold (PR42457)
Roman Lebedev [Wed, 3 Jul 2019 09:41:50 +0000 (09:41 +0000)]
[InstCombine] Y - ~X --> X + Y + 1 fold (PR42457)

Summary:
I *think* we'd want this new variant, because we obviously
have better handling for `add` as compared to `sub`/`not`.

https://rise4fun.com/Alive/WMn

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42457 | PR42457 ]]

Reviewers: spatel, nikic, huihuiz, efriedma

Reviewed By: spatel

Subscribers: RKSimon, llvm-commits

Tags: #llvm

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

llvm-svn: 365011

5 years ago[Codegen][X86][AArch64][ARM][PowerPC] Inc-of-add vs sub-of-not (PR42457)
Roman Lebedev [Wed, 3 Jul 2019 09:41:35 +0000 (09:41 +0000)]
[Codegen][X86][AArch64][ARM][PowerPC] Inc-of-add vs sub-of-not (PR42457)

Summary:
This is the backend part of [[ https://bugs.llvm.org/show_bug.cgi?id=42457 | PR42457 ]].
In middle-end, we'd want to prefer the form with two adds - D63992,
but as this diff shows, not every target will prefer that pattern.

Out of 4 targets for which i added tests all seem to be ok with inc-of-add for scalars,
but only X86 prefer that same pattern for vectors.

Here i'm adding a new TLI hook, always defaulting to the inc-of-add,
but adding AArch64,ARM,PowerPC overrides to prefer inc-of-add only for scalars.

Reviewers: spatel, RKSimon, efriedma, t.p.northover, hfinkel

Reviewed By: efriedma

Subscribers: nemanjai, javed.absar, kristof.beyls, kbarton, jsji, llvm-commits

Tags: #llvm

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

llvm-svn: 365010

5 years ago[SCEV][LSR] Prevent using undefined value in binops
Eugene Leviant [Wed, 3 Jul 2019 09:36:32 +0000 (09:36 +0000)]
[SCEV][LSR] Prevent using undefined value in binops

On some occasions ReuseOrCreateCast may convert previously
expanded value to undefined. That value may be passed by
SCEVExpander as an argument to InsertBinop making IV chain
undefined.

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

llvm-svn: 365009

5 years agoMSan: handle callbr instructions
Alexander Potapenko [Wed, 3 Jul 2019 09:28:50 +0000 (09:28 +0000)]
MSan: handle callbr instructions

Summary:
Handling callbr is very similar to handling an inline assembly call:
MSan must checks the instruction's inputs.
callbr doesn't (yet) have outputs, so there's nothing to unpoison,
and conservative assembly handling doesn't apply either.

Fixes PR42479.

Reviewers: eugenis

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 365008

5 years ago[clang-tidy] new check: bugprone-posix-return
Dmitri Gribenko [Wed, 3 Jul 2019 09:20:18 +0000 (09:20 +0000)]
[clang-tidy] new check: bugprone-posix-return

Summary:
Checks if any calls to posix functions (except posix_openpt) expect negative return values.
These functions return either 0 on success or an errno on failure, which is positive only.

Reviewers: JonasToth, gribozavr, alexfh, hokein

Reviewed By: gribozavr

Subscribers: Eugene.Zelenko, lebedev.ri, llozano, george.burgess.iv, xazax.hun, srhines, mgorny, cfe-commits

Tags: #clang

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

Patch by Jian Cai.

llvm-svn: 365007

5 years agoChange std::{lower,upper}_bound to llvm::{lower,upper}_bound or llvm::partition_point...
Fangrui Song [Wed, 3 Jul 2019 08:13:17 +0000 (08:13 +0000)]
Change std::{lower,upper}_bound to llvm::{lower,upper}_bound or llvm::partition_point. NFC

llvm-svn: 365006

5 years ago[clang][HeaderSearch] Shorten paths for includes in mainfile's directory
Kadir Cetinkaya [Wed, 3 Jul 2019 07:47:19 +0000 (07:47 +0000)]
[clang][HeaderSearch] Shorten paths for includes in mainfile's directory

Summary:
Currently HeaderSearch only looks at SearchDir's passed into it, but in
addition to those paths headers can be relative to including file's directory.

This patch makes sure that is taken into account.

Reviewers: gribozavr

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 365005

5 years agoAvoid identifiers that are different only in case. NFC.
Rui Ueyama [Wed, 3 Jul 2019 07:08:27 +0000 (07:08 +0000)]
Avoid identifiers that are different only in case. NFC.

llvm-svn: 365004

5 years agoAvoid identifiers that are different only in case. NFC.
Rui Ueyama [Wed, 3 Jul 2019 06:11:50 +0000 (06:11 +0000)]
Avoid identifiers that are different only in case. NFC.

Some variables in lld have the same name as functions ignoring case.
This patch gives them different names, so that my next patch is easier
to read.

llvm-svn: 365003

5 years ago[LoopPeel] Re-factor llvm::peelLoop method. NFC.
Serguei Katkov [Wed, 3 Jul 2019 05:59:23 +0000 (05:59 +0000)]
[LoopPeel] Re-factor llvm::peelLoop method. NFC.

Extract code dealing with branch weights in separate functions.

Reviewers: reames, mkuper, iajbar, fhahn
Reviewed By: reames, fhahn
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D63917

llvm-svn: 365002

5 years agoRevert r364999: [lld] Use -o /dev/null in test when output is not needed.
Rui Ueyama [Wed, 3 Jul 2019 05:52:35 +0000 (05:52 +0000)]
Revert r364999: [lld] Use -o /dev/null in test when output is not needed.

This reverts commit r364999 as it broke a build. Looks like `%t.archive.o`
is used two lines below where it was created.

llvm-svn: 365001

5 years agoRevert [InlineCost] cleanup calculations of Cost and Threshold
Jordan Rupprecht [Wed, 3 Jul 2019 04:01:51 +0000 (04:01 +0000)]
Revert [InlineCost] cleanup calculations of Cost and Threshold

This reverts r364422 (git commit 1a3dc761860d620ac8ed7e32a4285952142f780b)

The inlining cost calculation is incorrect, leading to stack overflow due to large stack frames from heavy inlining.

llvm-svn: 365000

5 years ago[lld] Use -o /dev/null in test when output is not needed.
Sam Clegg [Wed, 3 Jul 2019 02:41:00 +0000 (02:41 +0000)]
[lld] Use -o /dev/null in test when output is not needed.

Feedback nit from rL364998

llvm-svn: 364999

5 years ago[ELF] Error on archive with missing index
Sam Clegg [Wed, 3 Jul 2019 02:29:02 +0000 (02:29 +0000)]
[ELF] Error on archive with missing index

This matches the wasm lld and GNU ld behavior.

The ELF linker has special handling for bitcode archives but if that
doesn't kick in we probably want to error out rather than silently
ignore the library.

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

llvm-svn: 364998

5 years ago[ThinLTO] Reenable test with workaround for known failure
Teresa Johnson [Wed, 3 Jul 2019 02:14:47 +0000 (02:14 +0000)]
[ThinLTO] Reenable test with workaround for known failure

Reenable the testing disabled in r364978 with the same workaround used
for this failure in the cfi-devirt.ll test. The known issue is PR39436,
and the workaround is to add -verify-machineinstrs=0.

llvm-svn: 364997

5 years ago[ELF][RISCV] Support RISC-V in getBitcodeMachineKind
Kito Cheng [Wed, 3 Jul 2019 02:13:11 +0000 (02:13 +0000)]
[ELF][RISCV] Support RISC-V in getBitcodeMachineKind

Add Triple::riscv64 and Triple::riscv32 to getBitcodeMachineKind for get right
e_machine during LTO.

Reviewed By: ruiu, MaskRay

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

llvm-svn: 364996

5 years ago[AMDGPU] Enable serializing of argument info.
Michael Liao [Wed, 3 Jul 2019 02:00:21 +0000 (02:00 +0000)]
[AMDGPU] Enable serializing of argument info.

Summary:
- Support serialization of all arguments in machine function info. This
  enables fabricating MIR tests depending on argument info.

Reviewers: arsenm, rampitec

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

Tags: #llvm

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

llvm-svn: 364995

5 years ago[AArch64][GlobalISel] Overhaul legalization & isel or shifts to select immediate...
Amara Emerson [Wed, 3 Jul 2019 01:49:06 +0000 (01:49 +0000)]
[AArch64][GlobalISel] Overhaul legalization & isel or shifts to select immediate forms.

There are two main issues preventing us from generating immediate form shifts:
1) We have partial SelectionDAG imported support for G_ASHR and G_LSHR shift
immediate forms, but they currently don't work because the amount type is
expected to be an s64 constant, but we only legalize them to have homogenous
types.

To deal with this, first we introduce a custom legalizer to *only* custom legalize
s32 shifts which have a constant operand into a s64.

There is also an additional artifact combiner to fold zexts(g_constant) to a
larger G_CONSTANT if it's legal, a counterpart to the anyext version committed
in an earlier patch.

2) For G_SHL the importer can't cope with the pattern. For this I introduced an
early selection phase in the arm64 selector to select these forms manually
before the tablegen selector pessimizes it to a register-register variant.

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

llvm-svn: 364994

5 years ago[PowerPC] exclude ICmpZero in LSR if icmp can be replaced in later hardware loop.
Chen Zheng [Wed, 3 Jul 2019 01:49:03 +0000 (01:49 +0000)]
[PowerPC] exclude ICmpZero in LSR if icmp can be replaced in later hardware loop.

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

llvm-svn: 364993

5 years ago[analyzer] exploded-graph-rewriter: Implement bug nodes and sink nodes.
Artem Dergachev [Wed, 3 Jul 2019 01:26:41 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: Implement bug nodes and sink nodes.

Add a label to nodes that have a bug report attached or on which
the analysis was generally interrupted.

Fix printing has_report and implement printing is_sink in the graph dumper.

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

llvm-svn: 364992

5 years ago[analyzer] exploded-graph-rewriter: NFC: Add more comments.
Artem Dergachev [Wed, 3 Jul 2019 01:26:38 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: NFC: Add more comments.

llvm-svn: 364991

5 years ago[analyzer] exploded-graph-rewriter: Collapse very long statement pretty-prints.
Artem Dergachev [Wed, 3 Jul 2019 01:26:35 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: Collapse very long statement pretty-prints.

When printing various statements that include braces (compound
statements, lambda expressions, statement-expressions, etc.),
replace the code between braces with '...'.

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

llvm-svn: 364990

5 years ago[analyzer] exploded-graph-rewriter: Implement checker messages.
Artem Dergachev [Wed, 3 Jul 2019 01:26:32 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: Implement checker messages.

They are displayed as raw lines and diffed via difflib on a per-checker basis.

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

llvm-svn: 364989

5 years ago[triple] Use 'macabi' environment name for the Mac Catalyst triples
Alex Lorenz [Wed, 3 Jul 2019 01:02:43 +0000 (01:02 +0000)]
[triple] Use 'macabi' environment name for the Mac Catalyst triples

The 'macabi' environment name is preferred instead of 'maccatalyst'.

llvm-svn: 364988

5 years agoRevert Changing CodeView debug info type record representation in assembly files...
Nilanjana Basu [Wed, 3 Jul 2019 00:51:49 +0000 (00:51 +0000)]
Revert Changing CodeView debug info type record representation in assembly files to make it more human-readable & editable

This reverts r364982 (git commit 2082bf28ebea76cc187b508f801122866420d9ff)

llvm-svn: 364987

5 years ago[VFS] Add reverse iterator to OverlayFileSystem
Jonas Devlieghere [Wed, 3 Jul 2019 00:45:53 +0000 (00:45 +0000)]
[VFS] Add reverse iterator to OverlayFileSystem

Add a reverse iterator to the overlay file system. This makes it
possible to take overlays from one OverlayFileSystem, and add them to
another.

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

llvm-svn: 364986

5 years ago[WebAssembly] Prevent inline assembly from being mangled by SjLj
Guanzhong Chen [Wed, 3 Jul 2019 00:37:49 +0000 (00:37 +0000)]
[WebAssembly] Prevent inline assembly from being mangled by SjLj

Summary:
Before, inline assembly gets mangled by the SjLj transformation.

For example, in a function with setjmp/longjmp, this LLVM IR code

    call void asm sideeffect "", ""()

would be transformed into

    call void @__invoke_void(void ()* asm sideeffect "", "")

This is invalid, and results in the error:

    Cannot take the address of an inline asm!

In this diff, we skip the transformation for inline assembly.

Reviewers: aheejin, tlively

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

Tags: #llvm

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

llvm-svn: 364985

5 years agoCodeGen: Set hasSideEffects = 0 on BUNDLE
Matt Arsenault [Wed, 3 Jul 2019 00:30:47 +0000 (00:30 +0000)]
CodeGen: Set hasSideEffects = 0 on BUNDLE

The BUNDLE itself should not have side effects, and this is a property
of instructions inside the bundle. The hasProperty check already
searches for any member instructions, which was pointless since it was
overridden by this bit.

Allows me to distinguish bundles that have side effects vs. do not in
a future patch. Also fixes an unnecessary scheduling barrier in the
bundle AMDGPU uses to get PC relative addresses.

llvm-svn: 364984

5 years agoAMDGPU: Look through bundles for existing waitcnts
Matt Arsenault [Wed, 3 Jul 2019 00:30:44 +0000 (00:30 +0000)]
AMDGPU: Look through bundles for existing waitcnts

These aren't produced now, but will be in a future patch.

llvm-svn: 364983

5 years agoChanging CodeView debug info type record representation in assembly files to make...
Nilanjana Basu [Wed, 3 Jul 2019 00:26:23 +0000 (00:26 +0000)]
Changing CodeView debug info type record representation in assembly files to make it more human-readable & editable

llvm-svn: 364982

5 years agoAdd support for the 'macCatalyst' MachO platform
Alex Lorenz [Tue, 2 Jul 2019 23:47:11 +0000 (23:47 +0000)]
Add support for the 'macCatalyst' MachO platform

Mac Catalyst is a new MachO platform in macOS Catalina.
It always uses the build_version MachO load command.

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

llvm-svn: 364981

5 years agoFix for r364686 - actually set symbol_is_missing_weak...
Jim Ingham [Tue, 2 Jul 2019 23:38:07 +0000 (23:38 +0000)]
Fix for r364686 - actually set symbol_is_missing_weak...

This was set in a std::function, but I was shadowing a
variable that I thought I was capturing.  Even with this bug
we were correctly not raising an error and returning an address
of 0x0.  We were not marking the symbol as weak, but apparently
the JIT didn't need that, so the test still passed.

llvm-svn: 364980

5 years agoUpdate cmake build setup so lldb doesn't link against the DebugSymbols
Jason Molenda [Tue, 2 Jul 2019 23:36:39 +0000 (23:36 +0000)]
Update cmake build setup so lldb doesn't link against the DebugSymbols
framework on macOS, in line with the source/xcode project changes in
r364243.
<rdar://problem/49458356>

llvm-svn: 364979

5 years ago[ThinLTO] Work around existing failure exposed by new test
Teresa Johnson [Tue, 2 Jul 2019 23:28:28 +0000 (23:28 +0000)]
[ThinLTO] Work around existing failure exposed by new test

When adding summary entries for index-based WPD (r364960), an added
test also included some additional testing of the existing hybrid
Thin/Regular LTO WPD (test/ThinLTO/X86/devirt.ll). That part of the
test is producing a failure on the llvm-clang-x86_64-expensive-checks-win
bot:

*** Bad machine code: Explicit definition marked as use ***
- function:    __typeid__ZTS1A_0_branch_funnel
- basic block: %bb.0  (0x81d4c58)
- instruction: ICALL_BRANCH_FUNNEL %0:gr64, @0, 16, @_ZN1B1fEi, 48, @_ZN1C1fEi
- operand 0:   %0:gr64
LLVM ERROR: Found 1 machine code errors.

This is functionality unrelated to the summary entries added with my
patch, so I am disabling this part of the new test until it is
addressed. I'll continue to investigate the failure.

llvm-svn: 364978

5 years ago[X86] Add a DAG combine for turning *_extend_vector_inreg+load into an appropriate...
Craig Topper [Tue, 2 Jul 2019 23:20:03 +0000 (23:20 +0000)]
[X86] Add a DAG combine for turning *_extend_vector_inreg+load into an appropriate extload if the load isn't volatile.

Remove the corresponding isel patterns that did the same thing without checking for volatile.

This fixes another variation of PR42079

llvm-svn: 364977

5 years agoadd symbols/declvendor.cpp.
Jason Molenda [Tue, 2 Jul 2019 23:06:13 +0000 (23:06 +0000)]
add symbols/declvendor.cpp.

llvm-svn: 364976

5 years agoAttempt #2 to fix gcc builds. This time check
Mitch Phillips [Tue, 2 Jul 2019 22:36:45 +0000 (22:36 +0000)]
Attempt #2 to fix gcc builds. This time check
against CXX compiler ID instead of CRT test ID.

llvm-svn: 364975

5 years ago[swig] Don't mess with swig internals.
Jonas Devlieghere [Tue, 2 Jul 2019 22:18:35 +0000 (22:18 +0000)]
[swig] Don't mess with swig internals.

As of SWIG 4.0, __swig_getmethods__ and __swig_setmethods__ are no
longer defined. It appears that there's no need to mess with these
internals, we can simplify define the corresponding properties inline.

Originally I wanted to use the swig extension %attribute and
%attributeref to define properties. However, I couldn't find a way to
add documentation to these attributes. Since we already had the
properties defined inline, we might as well keep them.

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

llvm-svn: 364974

5 years ago[ThinLTO] Dump input on failure in devirt test
Teresa Johnson [Tue, 2 Jul 2019 22:06:02 +0000 (22:06 +0000)]
[ThinLTO] Dump input on failure in devirt test

To help track down bug exposed by llvm-clang-x86_64-expensive-checks-win
bot.

llvm-svn: 364973

5 years agoOnly use -mno-omit-leaf-frame-pointer with clang builds.
Mitch Phillips [Tue, 2 Jul 2019 21:58:19 +0000 (21:58 +0000)]
Only use -mno-omit-leaf-frame-pointer with clang builds.
Fix build breakage caused by D64085

llvm-svn: 364972

5 years ago[triple] add 'macCatalyst' environment type
Alex Lorenz [Tue, 2 Jul 2019 21:37:00 +0000 (21:37 +0000)]
[triple] add 'macCatalyst' environment type

Mac Catalyst is a new deployment platform in macOS Catalina.

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

llvm-svn: 364971

5 years ago[ARM] Fix unwind info for Thumb1 functions that save high registers.
Eli Friedman [Tue, 2 Jul 2019 21:35:15 +0000 (21:35 +0000)]
[ARM] Fix unwind info for Thumb1 functions that save high registers.

There were two issues here: one, some of the relevant instructions were
missing the expected "FrameSetup" flag, and two,
ARMAsmPrinter::EmitUnwindingInstruction wasn't expecting "mov"
instructions in the prologue.

I'm sticking the additional state into ARMFunctionInfo so it's obvious
it only applies to the current function.

I considered a few alternative approaches where we would compute the
correct unwind information as part of the prologue/epilogue lowering,
but it seems like a lot of work to introduce pseudo-instructions, and
the current code seems to be reliable enough.

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

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

llvm-svn: 364970

5 years ago[NFC] Strenghten isInteger condition for rL364940
David Bolvansky [Tue, 2 Jul 2019 21:16:34 +0000 (21:16 +0000)]
[NFC] Strenghten isInteger condition for rL364940

llvm-svn: 364969

5 years ago[ThinLTO] Address post-review suggestions for index-based WPD summary
Teresa Johnson [Tue, 2 Jul 2019 21:07:45 +0000 (21:07 +0000)]
[ThinLTO] Address post-review suggestions for index-based WPD summary

Removes a couple of unnecessary and/or redundant checks introduced by
r364960.

llvm-svn: 364968

5 years ago[lldb] Mention automatic codesign setup script [NFC]
Raphael Isemann [Tue, 2 Jul 2019 21:07:25 +0000 (21:07 +0000)]
[lldb] Mention automatic codesign setup script [NFC]

The script is the modern way of getting the certificate, so we should mention it in
the documentation.

Patch idea by Davidino Italiano!

llvm-svn: 364967

5 years ago[GWP-ASan] [Scudo] Add GWP-ASan backtrace for alloc/free to Scudo.
Mitch Phillips [Tue, 2 Jul 2019 20:33:19 +0000 (20:33 +0000)]
[GWP-ASan] [Scudo] Add GWP-ASan backtrace for alloc/free to Scudo.

Summary:
Adds allocation and deallocation stack trace support to Scudo. The
default provided backtrace library for GWP-ASan is supplied by the libc
unwinder, and is suitable for production variants of Scudo. If Scudo in future
has its own unwinder, it may choose to use its own over the generic unwinder
instead.

Reviewers: cryptoad

Reviewed By: cryptoad

Subscribers: kubamracek, mgorny, #sanitizers, llvm-commits, morehouse, vlad.tsyrklevich, eugenis

Tags: #sanitizers, #llvm

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

llvm-svn: 364966

5 years ago[gold] Fix test after BitStream reader error changes
Teresa Johnson [Tue, 2 Jul 2019 20:24:00 +0000 (20:24 +0000)]
[gold] Fix test after BitStream reader error changes

The recent change to the BitStream reader error handling in r364464
changed the error message format (from "LLVM ERROR:" to just "error"),
leading to a failure in this test which is only executed for very recent
versions of gold. Fix this by removing that part of the error message
check, leaving only the interesting part of the message to be checked.

llvm-svn: 364965

5 years ago[SLP] Recommit: Look-ahead operand reordering heuristic.
Vasileios Porpodas [Tue, 2 Jul 2019 20:20:28 +0000 (20:20 +0000)]
[SLP] Recommit: Look-ahead operand reordering heuristic.

Summary: This patch introduces a new heuristic for guiding operand reordering. The new "look-ahead" heuristic can look beyond the immediate predecessors. This helps break ties when the immediate predecessors have identical opcodes (see lit test for an example).

Reviewers: RKSimon, ABataev, dtemirbulatov, Ayal, hfinkel, rnk

Reviewed By: RKSimon, dtemirbulatov

Subscribers: hiraditya, phosek, rnk, rcorcs, llvm-commits

Tags: #llvm

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

llvm-svn: 364964

5 years ago[clang-doc] Serialize child namespaces and records
Julie Hockett [Tue, 2 Jul 2019 19:59:56 +0000 (19:59 +0000)]
[clang-doc] Serialize child namespaces and records

Serialization of child namespaces and records is now handled.
Namespaces can have child records and child namespaces.
Records can only have child records.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

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

llvm-svn: 364963

5 years ago[Symbol] Add DeclVendor::FindTypes
Alex Langford [Tue, 2 Jul 2019 19:53:07 +0000 (19:53 +0000)]
[Symbol] Add DeclVendor::FindTypes

Summary:
Following up on the plan I outlined in D63622, we can remove the
dependence on clang in all the places where we only want to find the
types from the DeclVendor. This means that currently DeclVendor depends
on clang, but centralizing the dependency makes it easier to refactor
cleanly.

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

llvm-svn: 364962

5 years ago[AArch64][GlobalISel] Teach tryOptSelect to handle G_ICMP
Jessica Paquette [Tue, 2 Jul 2019 19:44:16 +0000 (19:44 +0000)]
[AArch64][GlobalISel] Teach tryOptSelect to handle G_ICMP

This teaches `tryOptSelect` to handle folding G_ICMP, and removes the
requirement that the G_SELECT we're dealing with is floating point.

Some refactoring to make this work nicely as well:

- Factor out the scalar case from the selection code for G_ICMP into
  `emitIntegerCompare`.
- Make `tryOptCMN` return a MachineInstr* instead of a bool.
- Make `tryOptCMN` not modify the instruction being selected.
- Factor out the CMN emission into `emitCMN` for readability.

By doing this this way, we can get all of the compare selection optimizations
in select emission.

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

llvm-svn: 364961

5 years ago[ThinLTO] Add summary entries for index-based WPD
Teresa Johnson [Tue, 2 Jul 2019 19:38:02 +0000 (19:38 +0000)]
[ThinLTO] Add summary entries for index-based WPD

Summary:
If LTOUnit splitting is disabled, the module summary analysis computes
the summary information necessary to perform single implementation
devirtualization during the thin link with the index and no IR. The
information collected from the regular LTO IR in the current hybrid WPD
algorithm is summarized, including:
1) For vtable definitions, record the function pointers and their offset
within the vtable initializer (subsumes the information collected from
IR by tryFindVirtualCallTargets).
2) A record for each type metadata summarizing the vtable definitions
decorated with that metadata (subsumes the TypeIdentiferMap collected
from IR).

Also added are the necessary bitcode records, and the corresponding
assembly support.

The follow-on index-based WPD patch is D55153.

Depends on D53890.

Reviewers: pcc

Subscribers: mehdi_amini, Prazek, inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits

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

llvm-svn: 364960

5 years agoAMDGPU: Custom lower vector_shuffle for v4i16/v4f16
Matt Arsenault [Tue, 2 Jul 2019 19:15:45 +0000 (19:15 +0000)]
AMDGPU: Custom lower vector_shuffle for v4i16/v4f16

Ordinarily it is lowered as a build_vector of each extract_vector_elt,
which in turn get lowered to bitcasts and bit shifts. Very little
understand the lowered extract pattern, resulting in much worse
code. We treat concat_vectors of v2i16 as legal, so prefer that.

llvm-svn: 364959

5 years ago[RA] Fix spelling of Greedy register allocator internal option
Teresa Johnson [Tue, 2 Jul 2019 18:54:03 +0000 (18:54 +0000)]
[RA] Fix spelling of Greedy register allocator internal option

The internal option added with r323870 has a typo. It isn't being used
by any tests, but I decided to fix the spelling and leave it in for use
in debugging the changes added in that patch.

llvm-svn: 364958

5 years ago[X86] Copy test cases from vector-zext.ll to vector-zext-widen.ll. Same for vector...
Craig Topper [Tue, 2 Jul 2019 18:39:59 +0000 (18:39 +0000)]
[X86] Copy test cases from vector-zext.ll to vector-zext-widen.ll. Same for vector-sext.ll. NFC

llvm-svn: 364957

5 years ago[lli] Fix a typo in a header.
Lang Hames [Tue, 2 Jul 2019 18:39:32 +0000 (18:39 +0000)]
[lli] Fix a typo in a header.

llvm-svn: 364956

5 years ago[llvm-objdump] Warn if no user specified sections (-j) are not found.
Yuanfang Chen [Tue, 2 Jul 2019 18:38:17 +0000 (18:38 +0000)]
[llvm-objdump] Warn if no user specified sections (-j) are not found.

Match GNU objdump.

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

Reviewers: jhenderson, grimar, MaskRay, rupprecht

Reviewed by: jhenderson, grimar, MaskRay

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

llvm-svn: 364955

5 years ago[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast
Erik Pilkington [Tue, 2 Jul 2019 18:28:13 +0000 (18:28 +0000)]
[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast

This commit adds a new builtin, __builtin_bit_cast(T, v), which performs a
bit_cast from a value v to a type T. This expression can be evaluated at
compile time under specific circumstances.

The compile time evaluation currently doesn't support bit-fields, but I'm
planning on fixing this in a follow up (some of the logic for figuring this out
is in CodeGen). I'm also planning follow-ups for supporting some more esoteric
types that the constexpr evaluator supports, as well as extending
__builtin_memcpy constexpr evaluation to use the same infrastructure.

rdar://44987528

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

llvm-svn: 364954

5 years ago[X86] getTargetConstantBitsFromNode - remove unnecessary getZExtValue() (PR42486)
Simon Pilgrim [Tue, 2 Jul 2019 18:20:38 +0000 (18:20 +0000)]
[X86] getTargetConstantBitsFromNode - remove unnecessary getZExtValue() (PR42486)

Don't use APInt::getZExtValue() if you can avoid it - eventually someone will call it with i128 or something that doesn't fit into 64-bits.

In this case it was completely superfluous as we'd moved the rest of the code to always use APInt.

Fixes the <1 x i128> addition bug in PR42486

llvm-svn: 364953

5 years ago[AMDGPU] LCSSA pass added in preISel. Fixing typo in previous commit
Alexander Timofeev [Tue, 2 Jul 2019 18:16:42 +0000 (18:16 +0000)]
[AMDGPU] LCSSA pass added in preISel. Fixing typo in previous commit

llvm-svn: 364952

5 years agoRevert "[swig] Define attribute(ref) instead of accessing swig internals."
Jonas Devlieghere [Tue, 2 Jul 2019 18:04:55 +0000 (18:04 +0000)]
Revert "[swig] Define attribute(ref) instead of accessing swig internals."

This reverts commit f9b91a52797325ccaaee229e414beae7c03f1948.

llvm-svn: 364951

5 years ago[AMDGPU] LCSSA pass added in preISel. Uniform values defined in the divergent loop...
Alexander Timofeev [Tue, 2 Jul 2019 17:59:44 +0000 (17:59 +0000)]
[AMDGPU] LCSSA pass added in preISel. Uniform values defined in the divergent loop and used outside

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

Reviewers: rampitec, nhaehnle, arsenm
llvm-svn: 364950

5 years ago[clang-doc] Fix segfault in comment sorting
Julie Hockett [Tue, 2 Jul 2019 17:57:11 +0000 (17:57 +0000)]
[clang-doc] Fix segfault in comment sorting

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

llvm-svn: 364949

5 years ago[X86] Add patterns to select (scalar_to_vector (loadf32)) as (V)MOVSSrm instead of...
Craig Topper [Tue, 2 Jul 2019 17:51:02 +0000 (17:51 +0000)]
[X86] Add patterns to select (scalar_to_vector (loadf32)) as (V)MOVSSrm instead of COPY_TO_REGCLASS + (V)MOVSSrm_alt.

Similar for (V)MOVSD. Ultimately, I'd like to see about folding
scalar_to_vector+load to vzload. Which would select as (V)MOVSSrm
so this is closer to that.

llvm-svn: 364948

5 years ago[TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.7
Julian Lettner [Tue, 2 Jul 2019 17:32:04 +0000 (17:32 +0000)]
[TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.7

Factor out `ExtractLongJmpSp` helper function and move platform-specific
code to tsan_platform_{linux,mac}.cc.

Reviewed By: dvyukov

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

llvm-svn: 364947

5 years ago[swig] Define attribute(ref) instead of accessing swig internals.
Jonas Devlieghere [Tue, 2 Jul 2019 17:25:20 +0000 (17:25 +0000)]
[swig] Define attribute(ref) instead of accessing swig internals.

As of SWIG 4.0, __swig_getmethods__ and __swig_setmethods__ are no
longer defined. The solution is to stop using these internal swig
dictionaries and use %attribute and %attributeref instead. I plan on
doing this incrementally, with this differential serving as an example.

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

llvm-svn: 364946

5 years ago[NFC][Codegen][X86][AArch64][ARM][PowerPC] Recommit: Add test coverage for "add-of...
Roman Lebedev [Tue, 2 Jul 2019 16:48:49 +0000 (16:48 +0000)]
[NFC][Codegen][X86][AArch64][ARM][PowerPC] Recommit: Add test coverage for "add-of-inc" vs "sub-of-not"

I initially committed it with --check-prefix instead of --check-prefixes
(again, shame on me, and utils/update_*.py not complaining!)
and did not have a moment to understand the failure,
so i reverted it initially in rL64939.

llvm-svn: 364945

5 years agoFix GN build
Vitaly Buka [Tue, 2 Jul 2019 16:08:10 +0000 (16:08 +0000)]
Fix GN build

llvm-svn: 364942

5 years ago[GWP-ASan] Add generic unwinders and structure backtrace output.
Mitch Phillips [Tue, 2 Jul 2019 16:04:52 +0000 (16:04 +0000)]
[GWP-ASan] Add generic unwinders and structure backtrace output.

Summary:
Adds two flavours of generic unwinder and all the supporting cruft. If the
supporting allocator is okay with bringing in sanitizer_common, they can use
the fast frame-pointer based unwinder from sanitizer_common. Otherwise, we also
provide the backtrace() libc-based unwinder as well. Of course, the allocator
can always specify its own unwinder and unwinder-symbolizer.

The slightly changed output format is exemplified in the first comment on this
patch. It now better incorporates backtrace information, and displays
allocation details on the second line.

Reviewers: eugenis, vlad.tsyrklevich

Reviewed By: eugenis, vlad.tsyrklevich

Subscribers: srhines, kubamracek, mgorny, cryptoad, #sanitizers, llvm-commits, morehouse

Tags: #sanitizers, #llvm

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

llvm-svn: 364941

5 years ago[SimplifyLibCalls] powf(x, sitofp(n)) -> powi(x, n)
David Bolvansky [Tue, 2 Jul 2019 15:58:45 +0000 (15:58 +0000)]
[SimplifyLibCalls] powf(x, sitofp(n)) -> powi(x, n)

Summary:
Partially solves https://bugs.llvm.org/show_bug.cgi?id=42190

Reviewers: spatel, nikic, efriedma

Reviewed By: efriedma

Subscribers: efriedma, nikic, llvm-commits

Tags: #llvm

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

llvm-svn: 364940

5 years agoRevert "[NFC][Codegen][X86][AArch64][ARM][PowerPC] Add test coverage for "add-of...
Roman Lebedev [Tue, 2 Jul 2019 15:54:24 +0000 (15:54 +0000)]
Revert "[NFC][Codegen][X86][AArch64][ARM][PowerPC] Add test coverage for "add-of-inc" vs "sub-of-not""

Some test failures i don't have a moment to investigate.

This reverts commit r364930.

llvm-svn: 364939

5 years agoclang-format: Add new style option AlignConsecutiveMacros
Sam McCall [Tue, 2 Jul 2019 15:53:14 +0000 (15:53 +0000)]
clang-format: Add new style option AlignConsecutiveMacros

This option behaves similarly to AlignConsecutiveDeclarations and
AlignConsecutiveAssignments, aligning the assignment of C/C++
preprocessor macros on consecutive lines.

I've worked in many projects (embedded, mostly) where header files full
of large, well-aligned "#define" blocks are a common pattern. We
normally avoid using clang-format on these files, since it ruins any
existing alignment in said blocks. This style option will align "simple"
PP macros (no parameters) and PP macros with parameter lists on
consecutive lines.

Related Bugzilla entry (thanks mcuddie):
https://llvm.org/bugs/show_bug.cgi?id=20637

Patch by Nick Renieris (VelocityRa)!

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

llvm-svn: 364938

5 years agoProvide basic Full LTO extension points
Serge Guelton [Tue, 2 Jul 2019 15:52:39 +0000 (15:52 +0000)]
Provide basic Full LTO extension points

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

llvm-svn: 364937

5 years agogetMainExecutable: handle realpath() failure, falling back to getprogpath().
Sam McCall [Tue, 2 Jul 2019 15:42:37 +0000 (15:42 +0000)]
getMainExecutable: handle realpath() failure, falling back to getprogpath().

Summary:
Previously, we'd pass a nullptr to std::string and crash().

This case happens when the binary is deleted while being used (e.g. rebuilding clangd).

Reviewers: kadircet

Subscribers: ilya-biryukov, kristina, llvm-commits

Tags: #llvm

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

llvm-svn: 364936

5 years agoAMDGPU: Fix broken test
Matt Arsenault [Tue, 2 Jul 2019 15:34:40 +0000 (15:34 +0000)]
AMDGPU: Fix broken test

llvm-svn: 364935

5 years agoCreate a runtime option to disable task throttling.
Andrey Churbanov [Tue, 2 Jul 2019 15:10:20 +0000 (15:10 +0000)]
Create a runtime option to disable task throttling.

Patch by viroulep (Philippe Virouleau)

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

llvm-svn: 364934

5 years agoAMDGPU/GlobalISel: Try generated matcher with intrinsics
Matt Arsenault [Tue, 2 Jul 2019 14:52:16 +0000 (14:52 +0000)]
AMDGPU/GlobalISel: Try generated matcher with intrinsics

llvm-svn: 364933

5 years agoAMDGPU/GlobalISel: Select mul
Matt Arsenault [Tue, 2 Jul 2019 14:52:14 +0000 (14:52 +0000)]
AMDGPU/GlobalISel: Select mul

llvm-svn: 364932

5 years agoGlobalISel: Define GINodeEquiv for G_UMULH/G_SMULH
Matt Arsenault [Tue, 2 Jul 2019 14:49:29 +0000 (14:49 +0000)]
GlobalISel: Define GINodeEquiv for G_UMULH/G_SMULH

llvm-svn: 364931

5 years ago[NFC][Codegen][X86][AArch64][ARM][PowerPC] Add test coverage for "add-of-inc" vs...
Roman Lebedev [Tue, 2 Jul 2019 14:48:52 +0000 (14:48 +0000)]
[NFC][Codegen][X86][AArch64][ARM][PowerPC] Add test coverage for "add-of-inc" vs "sub-of-not"

As it is pointed out in https://reviews.llvm.org/D63992,
before we get to pick canonical variant in middle-end
we should ensure best codegen in backend.

llvm-svn: 364930

5 years agoUse --defsym instead of sed in a test. NFC
Paul Robinson [Tue, 2 Jul 2019 14:47:49 +0000 (14:47 +0000)]
Use --defsym instead of sed in a test. NFC

llvm-svn: 364929

5 years agoAMDGPU/GlobalISel: Fix G_GEP with mixed SGPR/VGPR operands
Matt Arsenault [Tue, 2 Jul 2019 14:40:22 +0000 (14:40 +0000)]
AMDGPU/GlobalISel: Fix G_GEP with mixed SGPR/VGPR operands

The register bank for the destination of the sample argument copy was
wrong. We shouldn't be constraining each source to the result register
bank. Allow constraining the original register to the right size.

llvm-svn: 364928

5 years agoAMDGPU/GlobalISel: Select G_FENCE
Matt Arsenault [Tue, 2 Jul 2019 14:17:38 +0000 (14:17 +0000)]
AMDGPU/GlobalISel: Select G_FENCE

Manually select to workaround tablegen emitter emitting checks for
G_CONSTANT.

llvm-svn: 364927

5 years agoGlobalISel: Add G_FENCE
Matt Arsenault [Tue, 2 Jul 2019 14:16:39 +0000 (14:16 +0000)]
GlobalISel: Add G_FENCE

The pattern importer is for some reason emitting checks for G_CONSTANT
for the immediate operands.

llvm-svn: 364926

5 years agoCleanup of unused code
Andrey Churbanov [Tue, 2 Jul 2019 13:45:40 +0000 (13:45 +0000)]
Cleanup of unused code

Patch by Terry Wilmarth

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

llvm-svn: 364925

5 years ago[X86][AVX] combineX86ShuffleChain - pull out CombineShuffleWithExtract lambda. NFCI.
Simon Pilgrim [Tue, 2 Jul 2019 13:30:04 +0000 (13:30 +0000)]
[X86][AVX] combineX86ShuffleChain - pull out CombineShuffleWithExtract lambda. NFCI.

Pull out CombineShuffleWithExtract lambda to new combineX86ShuffleChainWithExtract wrapper and refactored it to handle more than 2 shuffle inputs - this will allow combineX86ShufflesRecursively to call this in a future patch.

llvm-svn: 364924

5 years agoRemoved extra ; after function definition
Kristof Umann [Tue, 2 Jul 2019 13:25:41 +0000 (13:25 +0000)]
Removed extra ; after function definition

llvm-svn: 364923

5 years ago[clang-tidy] Extend TransformerClangTidyCheck to support adding includes.
Yitzhak Mandelbaum [Tue, 2 Jul 2019 13:25:07 +0000 (13:25 +0000)]
[clang-tidy] Extend TransformerClangTidyCheck to support adding includes.

Summary:
This revision implements support for the `AddedIncludes` field in
RewriteRule cases; that is, it supports specifying the addition of include
directives in files modified by the clang tidy check.

Reviewers: ilya-biryukov, gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364922

5 years ago[NFC][TargetLowering] Some preparatory cleanups around 'prepareUREMEqFold()' from...
Roman Lebedev [Tue, 2 Jul 2019 13:21:23 +0000 (13:21 +0000)]
[NFC][TargetLowering] Some preparatory cleanups around 'prepareUREMEqFold()' from D63963

llvm-svn: 364921

5 years ago[APIntTest] multiplicativeInverse(): clarify test
Roman Lebedev [Tue, 2 Jul 2019 13:21:17 +0000 (13:21 +0000)]
[APIntTest] multiplicativeInverse(): clarify test

Clarify that multiplicative inverse exists for all odd numbers,
and does not exist for all even numbers (including 0).

llvm-svn: 364920

5 years agoFix line endings (NFC)
Paul Robinson [Tue, 2 Jul 2019 13:13:36 +0000 (13:13 +0000)]
Fix line endings (NFC)

llvm-svn: 364919

5 years ago[docs][llvm-readelf] Delete old llvm-readelf.md
James Henderson [Tue, 2 Jul 2019 13:11:34 +0000 (13:11 +0000)]
[docs][llvm-readelf] Delete old llvm-readelf.md

This was accidentally missed when committing r364800.

llvm-svn: 364918

5 years ago[LibTooling] Extend `RewriteRule` with support for adding includes.
Yitzhak Mandelbaum [Tue, 2 Jul 2019 13:11:04 +0000 (13:11 +0000)]
[LibTooling] Extend `RewriteRule` with support for adding includes.

Summary:
This revision allows users to specify the insertion of an included directive (at
the top of the file being rewritten) as part of a rewrite rule.  These
directives are bundled with `RewriteRule` cases, so that different cases can
potentially result in different include actions.

Reviewers: ilya-biryukov, gribozavr

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 364917