platform/upstream/llvm.git
4 years ago[NewPM][Sancov] Create the Sancov Pass after building the pipelines
Leonard Chan [Sun, 8 Sep 2019 07:30:17 +0000 (07:30 +0000)]
[NewPM][Sancov] Create the Sancov Pass after building the pipelines

We're running into linker errors from missing sancov sections:

```
ld.lld: error: relocation refers to a discarded section: __sancov_guards
>>> defined in user-arm64-ubsan-sancov-full.shlib/obj/third_party/ulib/scudo/scudo.wrappers_c.cc.o
>>> referenced by common.h:26 (../../zircon/third_party/ulib/scudo/common.h:26)
... many other references
```

I believe this is due to a pass in the default pipeline that somehow discards
these sections. The ModuleSanitizerCoveragePass was initially added at the
start of the pipeline. This now adds it to the end of the pipeline for
optimized and unoptimized builds.

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

llvm-svn: 371326

4 years ago[X86] Make getZeroVector return floating point vectors in their native type on SSE2...
Craig Topper [Sun, 8 Sep 2019 00:43:52 +0000 (00:43 +0000)]
[X86] Make getZeroVector return floating point vectors in their native type on SSE2 and later.

isel used to require zero vectors to be canonicalized to a single
type to minimize the number of patterns needed to match. This is
 no longer required.

I plan to do this to integers too, but floating point was simpler
to start with. Integer has a complication where v32i16/v64i8 aren't
legal when the other 512-bit integer types are.

llvm-svn: 371325

4 years agoRemove ::gets for FreeBSD 13 and later
Dimitry Andric [Sat, 7 Sep 2019 22:18:20 +0000 (22:18 +0000)]
Remove ::gets for FreeBSD 13 and later

Summary:
In https://svnweb.freebsd.org/changeset/base/351659 @emaste removed gets() from
FreeBSD 13's libc, and our copies of libc++ and libstdc++.  In that change, the
declarations were simply deleted, but I would like to propose this conditional
test instead.

Reviewers: EricWF, mclow.lists, emaste

Reviewed By: mclow.lists

Subscribers: krytarowski, christof, ldionne, emaste, libcxx-commits

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

llvm-svn: 371324

4 years ago[X86] Add support for unfold broadcast loads from FMA instructions.
Craig Topper [Sat, 7 Sep 2019 21:54:40 +0000 (21:54 +0000)]
[X86] Add support for unfold broadcast loads from FMA instructions.

llvm-svn: 371323

4 years ago[X86] Add broadcast load unfolding tests for FMA instructions.
Craig Topper [Sat, 7 Sep 2019 21:54:36 +0000 (21:54 +0000)]
[X86] Add broadcast load unfolding tests for FMA instructions.

llvm-svn: 371322

4 years ago[aarch64] Add combine patterns for fp16 fmla
Sebastian Pop [Sat, 7 Sep 2019 20:24:51 +0000 (20:24 +0000)]
[aarch64] Add combine patterns for fp16 fmla

This patch enables generation of fused multiply add/sub for instructions operating on fp16.
Tested on aarch64-linux.

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

llvm-svn: 371321

4 years agoFixes an assertion while instantiating a template with an incomplete typo-corrected...
Aaron Ballman [Sat, 7 Sep 2019 20:14:09 +0000 (20:14 +0000)]
Fixes an assertion while instantiating a template with an incomplete typo-corrected type.

Fixes PR35682. When a template in instantiated with an incomplete typo corrected type an assertion can trigger if the -ferror-limit is used to reduce the number of errors.

Patch by Mark de Wever.

llvm-svn: 371320

4 years ago[X86] Add prefer-128-bit subtarget feature.
Craig Topper [Sat, 7 Sep 2019 19:54:22 +0000 (19:54 +0000)]
[X86] Add prefer-128-bit subtarget feature.

Summary:
Similar to the previous prefer-256-bit flag. We might want to
enable this by default some CPUs. This just starts the initial
work to implement and prove that it effects TTI's vector width.

Reviewers: RKSimon, echristo, spatel, atdt

Reviewed By: RKSimon

Subscribers: lebedev.ri, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 371319

4 years ago[llvm-nm] - Fix a bug and unbreak ASan BB.
George Rimar [Sat, 7 Sep 2019 19:45:27 +0000 (19:45 +0000)]
[llvm-nm] - Fix a bug and unbreak ASan BB.

BB: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/13820/steps/check-llvm%20asan/logs/stdio

rL371074 revealed a bug in llvm-nm.

This patch fixes it.

llvm-svn: 371318

4 years agoFix typo. NFCI
Simon Pilgrim [Sat, 7 Sep 2019 18:09:09 +0000 (18:09 +0000)]
Fix typo. NFCI

llvm-svn: 371317

4 years ago[mips] Follow-up to r371313 - fix failed test case. NFC
Simon Atanasyan [Sat, 7 Sep 2019 16:31:37 +0000 (16:31 +0000)]
[mips] Follow-up to r371313 - fix failed test case. NFC

llvm-svn: 371316

4 years ago[X86] Avoid uses of getZextValue(). NFCI.
Simon Pilgrim [Sat, 7 Sep 2019 16:13:57 +0000 (16:13 +0000)]
[X86] Avoid uses of getZextValue(). NFCI.

Use getAPIntValue() directly - this is mainly a best practice style issue to help prevent fuzz tests blowing up when a i12345 (or whatever) is generated.

Use getConstantOperandVal/getConstantOperandAPInt wrappers where possible.

llvm-svn: 371315

4 years ago[X86][AVX] Add 'f5' v4f64 shuffle test mentioned in D66004
Simon Pilgrim [Sat, 7 Sep 2019 16:13:48 +0000 (16:13 +0000)]
[X86][AVX] Add 'f5' v4f64 shuffle test mentioned in D66004

llvm-svn: 371314

4 years ago[mips] Make another set of test cases more tolerant to exact symbol addresses. NFC
Simon Atanasyan [Sat, 7 Sep 2019 15:44:40 +0000 (15:44 +0000)]
[mips] Make another set of test cases more tolerant to exact symbol addresses. NFC

llvm-svn: 371313

4 years ago[ELF][MC] Set types of aliases of IFunc to STT_GNU_IFUNC
Fangrui Song [Sat, 7 Sep 2019 14:58:47 +0000 (14:58 +0000)]
[ELF][MC] Set types of aliases of IFunc to STT_GNU_IFUNC

```
.type  foo,@gnu_indirect_function
.set   foo,foo_resolver

.set foo2,foo
.set foo3,foo2
```

The types of foo2 and foo3 should be STT_GNU_IFUNC, but we currently
resolve them to the type of foo_resolver. This patch fixes it.

Differential Revision: https://reviews.llvm.org/D67206
Patch by Senran Zhang

llvm-svn: 371312

4 years ago[SimplifyCFG][NFC] Autogenerate PhiEliminate3.ll
Roman Lebedev [Sat, 7 Sep 2019 13:53:14 +0000 (13:53 +0000)]
[SimplifyCFG][NFC] Autogenerate PhiEliminate3.ll

llvm-svn: 371311

4 years ago[SimplifyCFG][NFC] Autogenerate two tests
Roman Lebedev [Sat, 7 Sep 2019 13:35:54 +0000 (13:35 +0000)]
[SimplifyCFG][NFC] Autogenerate two tests

llvm-svn: 371310

4 years ago[CodeGen] Handle SMULFIXSAT with scale zero in TargetLowering::expandFixedPointMul
Bjorn Pettersson [Sat, 7 Sep 2019 12:16:23 +0000 (12:16 +0000)]
[CodeGen] Handle SMULFIXSAT with scale zero in TargetLowering::expandFixedPointMul

Summary:
Normally TargetLowering::expandFixedPointMul would handle
SMULFIXSAT with scale zero by using an SMULO to compute the
product and determine if saturation is needed (if overflow
happened). But if SMULO isn't custom/legal it falls through
and uses the same technique, using MULHS/SMUL_LOHI, as used
for non-zero scales.

Problem was that when checking for overflow (handling saturation)
when not using MULO we did not expect to find a zero scale. So
we ended up in an assertion when doing
  APInt::getLowBitsSet(VTSize, Scale - 1)

This patch fixes the problem by adding a new special case for
how saturation is computed when scale is zero.

Reviewers: RKSimon, bevinh, leonardchan, spatel

Reviewed By: RKSimon

Subscribers: wuzish, nemanjai, hiraditya, MaskRay, jsji, llvm-commits

Tags: #llvm

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

llvm-svn: 371309

4 years ago[Intrinsic] Add the llvm.umul.fix.sat intrinsic
Bjorn Pettersson [Sat, 7 Sep 2019 12:16:14 +0000 (12:16 +0000)]
[Intrinsic] Add the llvm.umul.fix.sat intrinsic

Summary:
Add an intrinsic that takes 2 unsigned integers with
the scale of them provided as the third argument and
performs fixed point multiplication on them. The
result is saturated and clamped between the largest and
smallest representable values of the first 2 operands.

This is a part of implementing fixed point arithmetic
in clang where some of the more complex operations
will be implemented as intrinsics.

Patch by: leonardchan, bjope

Reviewers: RKSimon, craig.topper, bevinh, leonardchan, lebedev.ri, spatel

Reviewed By: leonardchan

Subscribers: ychen, wuzish, nemanjai, MaskRay, jsji, jdoerfert, Ka-Ka, hiraditya, rjmccall, llvm-commits

Tags: #llvm

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

llvm-svn: 371308

4 years ago[X86] Fix pshuflw formation from repeated shuffle mask (PR43230)
Nikita Popov [Sat, 7 Sep 2019 12:13:44 +0000 (12:13 +0000)]
[X86] Fix pshuflw formation from repeated shuffle mask (PR43230)

Fix for https://bugs.llvm.org/show_bug.cgi?id=43230.

When creating PSHUFLW from a repeated shuffle mask, we have to apply
the checks to the repeated mask, not the original one. For the test
case from PR43230 the inspected part of the original mask is all undef.

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

llvm-svn: 371307

4 years ago[LVI] Look through extractvalue of insertvalue
Nikita Popov [Sat, 7 Sep 2019 12:03:59 +0000 (12:03 +0000)]
[LVI] Look through extractvalue of insertvalue

This addresses the issue mentioned on D19867. When we simplify
with.overflow instructions in CVP, we leave behind extractvalue
of insertvalue sequences that LVI no longer understands. This
means that we can not simplify any instructions based on the
with.overflow anymore (until some over pass like InstCombine
cleans them up).

This patch extends LVI extractvalue handling by calling
SimplifyExtractValueInst (which doesn't do anything more than
constant folding + looking through insertvalue) and using the block
value of the simplification.

A possible alternative would be to do something similar to
SimplifyIndVars, where we instead directly try to replace
extractvalue users of the with.overflow. This would need some
additional structural changes to CVP, as it's currently not legal
to remove anything but the current instruction -- we'd have to
introduce a worklist with instructions scheduled for deletion or similar.

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

llvm-svn: 371306

4 years ago[X86] Add test for PR43230; NFC
Nikita Popov [Sat, 7 Sep 2019 12:03:48 +0000 (12:03 +0000)]
[X86] Add test for PR43230; NFC

llvm-svn: 371305

4 years ago[DwarfExpression] Disallow some rewrites to avoid undefined behavior
Bjorn Pettersson [Sat, 7 Sep 2019 11:40:10 +0000 (11:40 +0000)]
[DwarfExpression] Disallow some rewrites to avoid undefined behavior

Summary:
The value operand in DW_OP_plus_uconst/DW_OP_constu value can be
large (it uses uint64_t as representation internally in LLVM).
This means that in the uint64_t to int conversions, previously done
by DwarfExpression::addMachineRegExpression, could lose information.
Also, the negation done in "-Offset" was undefined behavior in case
Offset was exactly INT_MIN.

To avoid the above problems, we now avoid transformation like
 [Reg, DW_OP_plus_uconst, Offset] --> [DW_OP_breg, Offset]
and
 [Reg, DW_OP_constu, Offset, DW_OP_plus]  --> [DW_OP_breg, Offset]
when Offset > INT_MAX.

And we avoid to transform
 [Reg, DW_OP_constu, Offset, DW_OP_minus] --> [DW_OP_breg,-Offset]
when Offset > INT_MAX+1.

The patch also adjusts DwarfCompileUnit::constructVariableDIEImpl
to make sure that "DW_OP_constu, Offset, DW_OP_minus" is used
instead of "DW_OP_plus_uconst, Offset" when creating DIExpressions
with negative frame index offsets.

Notice that this might just be the tip of the iceberg. There
are lots of fishy handling related to these constants. I think both
DIExpression::appendOffset and DIExpression::extractIfOffset may
trigger undefined behavior for certain values.

Reviewers: sdesmalen, rnk, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: jholewinski, aprantl, hiraditya, ychen, uabelho, llvm-commits

Tags: #debug-info, #llvm

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

llvm-svn: 371304

4 years ago[DebugInfo] Pre-commit of test case for DW_OP_breg/DW_OP_fbreg folds
Bjorn Pettersson [Sat, 7 Sep 2019 11:39:57 +0000 (11:39 +0000)]
[DebugInfo] Pre-commit of test case for DW_OP_breg/DW_OP_fbreg folds

This currently triggers undefined behavior if executed with an
ubsan build. It is just a precommit of the test case to show that
we got a problem.

Fix is proposed in https://reviews.llvm.org/D67263 and plan is to
commit the fix directly after this patch.

llvm-svn: 371303

4 years agoFix MSVC "32-bit shift implicitly converted to 64 bits" warnings. NFCI.
Simon Pilgrim [Sat, 7 Sep 2019 11:04:04 +0000 (11:04 +0000)]
Fix MSVC "32-bit shift implicitly converted to 64 bits" warnings. NFCI.

llvm-svn: 371302

4 years ago[SimplifyCFG][NFC] Make merge-cond-stores-cost.ll X86-specific, and rewrite it
Roman Lebedev [Sat, 7 Sep 2019 10:55:04 +0000 (10:55 +0000)]
[SimplifyCFG][NFC] Make merge-cond-stores-cost.ll X86-specific, and rewrite it

We clearly perform store-merging, even though div is really costly.

llvm-svn: 371300

4 years ago[ELF][test] Improve tests
Fangrui Song [Sat, 7 Sep 2019 10:42:11 +0000 (10:42 +0000)]
[ELF][test] Improve tests

Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output

Delete weak-undef-val.s - covered by relocation-undefined-weak.s
Delete weak-undef-export.s - covered by additional test added to weak-undef.s
Delete version-undef-sym.s - covered by undefined-versioned-symbol.s => version-symbol-undef.s
Delete symbol-ordering-file2.s - covered by symbol-ordering-file.s
Delete gotpcrelx.s - covered by gotpc-relax-und-dso.s => x86-64-gotpc-relax-und-dso.s

llvm-svn: 371299

4 years ago[Attributor] Make unimplemented method pure virtual.
Benjamin Kramer [Sat, 7 Sep 2019 10:27:13 +0000 (10:27 +0000)]
[Attributor] Make unimplemented method pure virtual.

Otherwise the compiler mistakes it for a vtable anchor.

llvm-svn: 371298

4 years ago[SimplifyCFG][NFC] Show that we don't consider the cost when merging cond stores
Roman Lebedev [Sat, 7 Sep 2019 09:25:26 +0000 (09:25 +0000)]
[SimplifyCFG][NFC] Show that we don't consider the cost when merging cond stores

We count instruction count in each BB's separately, not their cost.

llvm-svn: 371297

4 years ago[SimplifyCFG][NFC] Regenerate merge-cond-stores* tests
Roman Lebedev [Sat, 7 Sep 2019 09:25:18 +0000 (09:25 +0000)]
[SimplifyCFG][NFC] Regenerate merge-cond-stores* tests

llvm-svn: 371296

4 years ago[SimplifyCFG] SpeculativelyExecuteBB(): It's SpeculatedInstructions, not SpeculationCost
Roman Lebedev [Sat, 7 Sep 2019 09:06:06 +0000 (09:06 +0000)]
[SimplifyCFG] SpeculativelyExecuteBB(): It's SpeculatedInstructions, not SpeculationCost

It counts the number of instructions we are ok speculating
(at most 1 there), not their cost, so rename accordingly.

llvm-svn: 371294

4 years agoReplicate the change "[Alignment][NFC] Use Align with TargetLowering::setMinFunctionA...
Sylvestre Ledru [Sat, 7 Sep 2019 08:38:46 +0000 (08:38 +0000)]
Replicate the change "[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment"
on AVR to avoid a breakage.
See r371200 / https://reviews.llvm.org/D67229

llvm-svn: 371293

4 years ago[ELF][test] Improve LTO tests
Fangrui Song [Sat, 7 Sep 2019 08:20:09 +0000 (08:20 +0000)]
[ELF][test] Improve LTO tests

Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output

llvm-svn: 371292

4 years ago[Attributor] ValueSimplify Abstract Attribute
Hideto Ueno [Sat, 7 Sep 2019 07:03:05 +0000 (07:03 +0000)]
[Attributor] ValueSimplify Abstract Attribute

Summary:
This patch introduces initial `AAValueSimplify` which simplifies a value in a context.

example
- (for function returned) If all the return values are the same and constant, then we can replace callsite returned with the constant.
- If an internal function takes the same value(constant) as an argument in the callsite, then we can replace the argument with that constant.

Reviewers: jdoerfert, sstefan1

Reviewed By: jdoerfert

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 371291

4 years ago[git-llvm] Do not reinvent `@{upstream}`
David Zarzycki [Sat, 7 Sep 2019 06:44:52 +0000 (06:44 +0000)]
[git-llvm] Do not reinvent `@{upstream}`

Make `git-llvm` more robust when used with a nontrivial repository.

https://reviews.llvm.org/D67262

llvm-svn: 371290

4 years agoRevert [CodeGen] Fix typos to run tests. NFC.
Xing GUO [Sat, 7 Sep 2019 05:14:47 +0000 (05:14 +0000)]
Revert [CodeGen] Fix typos to run tests. NFC.

This reverts r371286 (git commit b38105bbd0f7dfef424a4f096aa6a6b7b467fe99)

r371286 caused build bots' failure. I'll check it.

llvm-svn: 371289

4 years ago[CodeGen] Fix typos to run tests. NFC.
Xing GUO [Sat, 7 Sep 2019 04:57:53 +0000 (04:57 +0000)]
[CodeGen] Fix typos to run tests. NFC.

llvm-svn: 371286

4 years agoRemove stale TLI Module level pass registration
Teresa Johnson [Sat, 7 Sep 2019 03:09:46 +0000 (03:09 +0000)]
Remove stale TLI Module level pass registration

Clang patch to adapt to LLVM changes in D66428 that make the TLI
require a Function. There is no longer a module-level
TargetLibraryAnalysis, so remove its registration

llvm-svn: 371285

4 years agoChange TargetLibraryInfo analysis passes to always require Function
Teresa Johnson [Sat, 7 Sep 2019 03:09:36 +0000 (03:09 +0000)]
Change TargetLibraryInfo analysis passes to always require Function

Summary:
This is the first change to enable the TLI to be built per-function so
that -fno-builtin* handling can be migrated to use function attributes.
See discussion on D61634 for background. This is an enabler for fixing
handling of these options for LTO, for example.

This change should not affect behavior, as the provided function is not
yet used to build a specifically per-function TLI, but rather enables
that migration.

Most of the changes were very mechanical, e.g. passing a Function to the
legacy analysis pass's getTLI interface, or in Module level cases,
adding a callback. This is similar to the way the per-function TTI
analysis works.

There was one place where we were looking for builtins but not in the
context of a specific function. See FindCXAAtExit in
lib/Transforms/IPO/GlobalOpt.cpp. I'm somewhat concerned my workaround
could provide the wrong behavior in some corner cases. Suggestions
welcome.

Reviewers: chandlerc, hfinkel

Subscribers: arsenm, dschuff, jvesely, nhaehnle, mehdi_amini, javed.absar, sbc100, jgravelle-google, eraman, aheejin, steven_wu, george.burgess.iv, dexonsmith, jfb, asbirlea, gchatelet, llvm-commits

Tags: #llvm

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

llvm-svn: 371284

4 years ago[X86] Add tests for fp128 frem, sqrt, sin, and cos.
Craig Topper [Sat, 7 Sep 2019 01:39:21 +0000 (01:39 +0000)]
[X86] Add tests for fp128 frem, sqrt, sin, and cos.

llvm-svn: 371283

4 years ago[X86] Autogenerate fp128-libcalls.ll
Craig Topper [Sat, 7 Sep 2019 01:39:12 +0000 (01:39 +0000)]
[X86] Autogenerate fp128-libcalls.ll

llvm-svn: 371282

4 years ago[llvm-objcopy] Rename SHOffset (e_shoff) field to SHOff. NFC
Fangrui Song [Sat, 7 Sep 2019 01:38:56 +0000 (01:38 +0000)]
[llvm-objcopy] Rename SHOffset (e_shoff) field to SHOff. NFC

Similar to D67254.

`struct Elf*_Shdr` has a field `sh_offset`. Rename SHOffset to SHOff to
avoid confusion.

llvm-svn: 371281

4 years agoLong timeouts for the MacOSX SystemRuntime plugins under ASAN; else quick.
Jason Molenda [Sat, 7 Sep 2019 01:38:37 +0000 (01:38 +0000)]
Long timeouts for the MacOSX SystemRuntime plugins under ASAN; else quick.

In April via r357829, Adrian unified timeouts across lldb and set the
default value high so that we wouldn't get timeouts on ASAN bots that
were running under load.

The library that the MacOSX SystemRuntime has functions that need
to take a lock, and if that lock is held already, those functions
will never complete; we're seeing the 15 second timeout being hit
with inferiors that are doing a lot of enqueuing and dequeuing of
libdispatch work items causing this deadlocking behavior.

This patch reverts to a very short timeout for these SystemRuntime
function calls, given the behavior of this library that they are
calling into.  When lldb is built with AddressSanitizer enabled,
they will use the default 15 second timeout.

tl;dr: this reverts to the previous timeouts for these SystemRuntime
inf func calls.

<rdar://problem/54538149>

llvm-svn: 371280

4 years ago[clang][DependencyFileGenerator] Fix missing -MT option handling
Jan Korous [Sat, 7 Sep 2019 00:59:13 +0000 (00:59 +0000)]
[clang][DependencyFileGenerator] Fix missing -MT option handling

Targets in DependencyFileGenerator don't necessarily come from -MT option.

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

llvm-svn: 371279

4 years agoFix thunks.cpp test, don't FileCheck for anon namespace id
Reid Kleckner [Sat, 7 Sep 2019 00:41:08 +0000 (00:41 +0000)]
Fix thunks.cpp test, don't FileCheck for anon namespace id

The anon namespace id is a hash of the main input path to the compiler,
which varies in the test suite because the input path is absolute.

llvm-svn: 371277

4 years ago[Sema][ObjC] Mark C union fields that have non-trivial ObjC ownership
Akira Hatanaka [Sat, 7 Sep 2019 00:34:47 +0000 (00:34 +0000)]
[Sema][ObjC] Mark C union fields that have non-trivial ObjC ownership
qualifications as unavailable if the union is declared in a system
header

r365985 stopped marking those fields as unavailable, which caused the
union's NonTrivialToPrimitive* bits to be set to true. This patch
restores the behavior prior to r365985, except that users can explicitly
specify the ownership qualification of the field to instruct the
compiler not to mark it as unavailable.

rdar://problem/53420753

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

llvm-svn: 371276

4 years ago[Sema] Diagnose default-initialization, destruction, and copying of
Akira Hatanaka [Sat, 7 Sep 2019 00:34:43 +0000 (00:34 +0000)]
[Sema] Diagnose default-initialization, destruction, and copying of
non-trivial C union types

This recommits r365985, which was reverted because it broke a few
projects using unions containing non-trivial ObjC pointer fields in
system headers. We now have a patch to fix the problem (see
https://reviews.llvm.org/D65256).

Original commit message:

This patch diagnoses uses of non-trivial C unions and structs/unions
containing non-trivial C unions in the following contexts, which require
default-initialization, destruction, or copying of the union objects,
instead of disallowing fields of non-trivial types in C unions, which is
what we currently do:

- function parameters.
- function returns.
- assignments.
- compound literals.
- block captures except capturing of `__block` variables by non-escaping blocks.
- local and global variable definitions.
- lvalue-to-rvalue conversions of volatile types.

See the discussion in https://reviews.llvm.org/D62988 for more background.

rdar://problem/50679094

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

llvm-svn: 371275

4 years agoSynchronize LLVM's copy of libc++abi's demangler with the libc++abi
Richard Smith [Sat, 7 Sep 2019 00:11:53 +0000 (00:11 +0000)]
Synchronize LLVM's copy of libc++abi's demangler with the libc++abi
version after r371273.

Also fix a minor issue in r371273 that only surfaced after template
instantiation from LLVM's use of the demangler.

llvm-svn: 371274

4 years agoImplement demangling support for C++20 lambda expression extensions.
Richard Smith [Fri, 6 Sep 2019 23:53:21 +0000 (23:53 +0000)]
Implement demangling support for C++20 lambda expression extensions.

This implements demangling support for the mangling extensions specified
in https://github.com/itanium-cxx-abi/cxx-abi/pull/85, much of which is
implemented in Clang r359967 and r371004.

Specifically, this provides demangling for:

 * <template-param-decl> in <lambda-sig>
 * <template-param> with non-zero level
 * lambda-expression literals (not emitted by Clang yet)
 * nullptr literals
 * string literals

(The final two seem unrelated, but handling them was necessary in order
to disambiguate between lambda expressions and the other forms of
literal for which we have a type but no value.)

When demangling a <lambda-sig>, we form template parameters with no
corresponding argument, so we cannot substitute in the argument in the
demangling. Instead we invent synthetic names for the template
parameters (eg, '[]<typename $T>($T *x)').

llvm-svn: 371273

4 years agoUse musttail for variadic method thunks when possible
Reid Kleckner [Fri, 6 Sep 2019 22:55:26 +0000 (22:55 +0000)]
Use musttail for variadic method thunks when possible

This avoids cloning variadic virtual methods when the target supports
musttail and the return type is not covariant. I think we never
implemented this previously because it doesn't handle the covariant
case. But, in the MS ABI, there are some cases where vtable thunks must
be emitted even when the variadic method defintion is not available, so
it looks like we need to implement this. Do it for both ABIs, since it's
a nice size improvement and simplification for Itanium.

Emit an error when emitting thunks for variadic methods with a covariant
return type. This case is essentially not implementable unless the ABI
provides a way to perfectly forward variadic arguments without a tail
call.

Fixes PR43173.

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

llvm-svn: 371269

4 years agoUpdate lld tests dynamic-list.s and symbol-override.s to use llvm-nm
Matthew Voss [Fri, 6 Sep 2019 22:51:46 +0000 (22:51 +0000)]
Update lld tests dynamic-list.s and symbol-override.s to use llvm-nm

The following tests failed on Windows bots due to nm not being
available:

  lld/test/ELF/dynamic-list.s
  lld/test/ELF/symbol-override.s

llvm-svn: 371267

4 years ago[AArch64][GlobalISel] Enable the localizer for optimized builds.
Amara Emerson [Fri, 6 Sep 2019 22:27:09 +0000 (22:27 +0000)]
[AArch64][GlobalISel] Enable the localizer for optimized builds.

Despite the fact that the localizer's original motivation was to fix horrendous
constant spilling at -O0, shortening live ranges still has net benefits even
with optimizations enabled.

On an -Os build of CTMark, doing this improves code size by 0.5% geomean.

There are a few regressions, bullet increasing in size by 0.5%. One example from
bullet where code size increased slightly was due to GlobalISel actually now
generating the same code as SelectionDAG. So we actually have an opportunity
in future to implement better heuristics for localization and therefore be
*better* than SDAG in some cases. In relation to other optimizations though that
one is relatively minor.

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

llvm-svn: 371266

4 years ago[InstCombine] Refactor substitution of instruction in the parent BB (NFC)
Evandro Menezes [Fri, 6 Sep 2019 22:07:11 +0000 (22:07 +0000)]
[InstCombine] Refactor substitution of instruction in the parent BB (NFC)

Add the new method `LibCallSimplifier::substituteInParent()` that calls
`LibCallSimplifier::replaceAllUsesWith()' and
`LibCallSimplifier::eraseFromParent()` back to back, simplifying the
resulting code.

llvm-svn: 371264

4 years ago[ORC][RPC] Join server thread before checking condition in unit test.
Lang Hames [Fri, 6 Sep 2019 21:55:43 +0000 (21:55 +0000)]
[ORC][RPC] Join server thread before checking condition in unit test.

Otherwise we have a race on the sent-messages count.

llvm-svn: 371263

4 years ago[IR] CallBrInst: scan+update arg list when indirect dest list changes
Nick Desaulniers [Fri, 6 Sep 2019 21:50:11 +0000 (21:50 +0000)]
[IR] CallBrInst: scan+update arg list when indirect dest list changes

Summary:
There's an unspoken invariant of callbr that the list of BlockAddress
Constants in the "function args" list match the BasicBlocks in the
"other labels" list. (This invariant is being added to the LangRef in
https://reviews.llvm.org/D67196).

When modifying the any of the indirect destinations of a callbr
instruction (possible jump targets), we need to update the function
arguments if the argument is a BlockAddress whose BasicBlock refers to
the indirect destination BasicBlock being replaced.  Otherwise, many
transforms that modify successors will end up violating that invariant.
A recent change to the arm64 Linux kernel exposed this bug, which
prevents the kernel from booting.

I considered maintaining a mapping from indirect destination BasicBlock
to argument operand BlockAddress, but this ends up being a one to
potentially many (though usually one) mapping.  Also, the list of
arguments to a function (or more typically inline assembly) ends up
being less than 10.  The implementation is significantly simpler to just
rescan the full list of arguments. Because of the one to potentially
many relationship, the full arg list must be scanned (we can't stop at
the first instance).

Thanks to the following folks that reported the issue and helped debug
it:
* Nathan Chancellor
* Will Deacon
* Andrew Murray
* Craig Topper

Link: https://bugs.llvm.org/show_bug.cgi?id=43222
Link: https://github.com/ClangBuiltLinux/linux/issues/649
Link: https://lists.infradead.org/pipermail/linux-arm-kernel/2019-September/678330.html
Reviewers: craig.topper, chandlerc

Reviewed By: craig.topper

Subscribers: void, javed.absar, kristof.beyls, hiraditya, llvm-commits, nathanchance, srhines

Tags: #llvm

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

llvm-svn: 371262

4 years ago[X86] Add a AVX512VBMI command line to min-legal-vector-width.ll. Always enable fast...
Craig Topper [Fri, 6 Sep 2019 21:49:01 +0000 (21:49 +0000)]
[X86] Add a AVX512VBMI command line to min-legal-vector-width.ll. Always enable fast-variable-shuffle

Trying to minimize the features we need to manipulate when this
is updated for D67259.

The VBMI is interesting because it enables some improved combining
for truncates.

I enabled fast-variable-shuffle because all the CPUs we're going
to add implicitly enable it. So they can share check lines.

llvm-svn: 371261

4 years ago[X86] Replace -mcpu with -mattr on some tests.
Craig Topper [Fri, 6 Sep 2019 21:48:44 +0000 (21:48 +0000)]
[X86] Replace -mcpu with -mattr on some tests.

llvm-svn: 371260

4 years ago[test] Add a FIXME test for stop-command-source-on-error
Jonas Devlieghere [Fri, 6 Sep 2019 21:43:33 +0000 (21:43 +0000)]
[test] Add a FIXME test for stop-command-source-on-error

Modifying the interpreter settings is tricky because they don't take
effect until we create a new command interpreter, which should be merely
an implementation detail. This leads to confusing and unexpected
scenarios.

This adds a test cases with FIXMEs for some of the odd scenarios I
encountered. I didn't XFAIL the test because I don't think there's a way
to get an unexpected PASS if any of the commands succeeds and splitting
up the file in multiple tests seems excessive.

llvm-svn: 371259

4 years ago[Core] Remove use of ClangASTContext in DumpDataExtractor
Alex Langford [Fri, 6 Sep 2019 21:05:21 +0000 (21:05 +0000)]
[Core] Remove use of ClangASTContext in DumpDataExtractor

Summary:
DumpDataExtractor uses ClangASTContext in order to get the proper llvm
fltSemantics for the type it needs so that it can dump floats in a more
precise way. However, there's no reason that this behavior needs to be
specific ClangASTContext. Instead, I think it makes sense to ask
TypeSystems for the float semantics for a type of a given size.

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

llvm-svn: 371258

4 years ago[analyzer] Add minimal support for fix-it hints.
Artem Dergachev [Fri, 6 Sep 2019 20:55:29 +0000 (20:55 +0000)]
[analyzer] Add minimal support for fix-it hints.

Allow attaching fixit hints to Static Analyzer BugReports.

Fixits are attached either to the bug report itself or to its notes
(path-sensitive event notes or path-insensitive extra notes).

Add support for fixits in text output (including the default text output that
goes without notes, as long as the fixit "belongs" to the warning).

Add support for fixits in the plist output mode.

Implement a fixit for the path-insensitive DeadStores checker. Only dead
initialization warning is currently covered.

Implement a fixit for the path-sensitive VirtualCall checker when the virtual
method is not pure virtual (in this case the "fix" is to suppress the warning
by qualifying the call).

Both fixits are under an off-by-default flag for now, because they
require more careful testing.

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

llvm-svn: 371257

4 years ago[analyzer] pr43179: Make CallDescription defensive against C variadic functions.
Artem Dergachev [Fri, 6 Sep 2019 20:55:24 +0000 (20:55 +0000)]
[analyzer] pr43179: Make CallDescription defensive against C variadic functions.

Most functions that our checkers react upon are not C-style variadic functions,
and therefore they have as many actual arguments as they have formal parameters.

However, it's not impossible to define a variadic function with the same name.
This will crash any checker that relies on CallDescription to check the number
of arguments but silently assumes that the number of parameters is the same.

Change CallDescription to check both the number of arguments and the number of
parameters by default.

If we're intentionally trying to match variadic functions, allow specifying
arguments and parameters separately (possibly omitting any of them).
For now we only have one CallDescription which would make use of those,
namely __builtin_va_start itself.

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

llvm-svn: 371256

4 years ago[ORC] Add a missing #include atomic.
Lang Hames [Fri, 6 Sep 2019 20:50:00 +0000 (20:50 +0000)]
[ORC] Add a missing #include atomic.

Hopefully this will fix the bot build failures from r371245.

llvm-svn: 371255

4 years agoGlobalISel: Add G_FMAD instruction
Matt Arsenault [Fri, 6 Sep 2019 20:49:10 +0000 (20:49 +0000)]
GlobalISel: Add G_FMAD instruction

llvm-svn: 371254

4 years agoGlobalISel: Support physical register inputs in patterns
Matt Arsenault [Fri, 6 Sep 2019 20:32:37 +0000 (20:32 +0000)]
GlobalISel: Support physical register inputs in patterns

llvm-svn: 371253

4 years agoUpdate comment for <template-param-decl> mangling to match extended mangling rule...
Richard Smith [Fri, 6 Sep 2019 20:32:01 +0000 (20:32 +0000)]
Update comment for <template-param-decl> mangling to match extended mangling rule in r371004.

llvm-svn: 371252

4 years agoRemove dead .seh_stackalloc parsing method in X86AsmParser
Reid Kleckner [Fri, 6 Sep 2019 20:12:44 +0000 (20:12 +0000)]
Remove dead .seh_stackalloc parsing method in X86AsmParser

The shared COFF asm parser code handles this directive, since it is
shared with AArch64. Spotted by Alexandre Ganea in review.

llvm-svn: 371251

4 years ago[clang][Index][NFC] Put IndexingOptions to a separate header
Jan Korous [Fri, 6 Sep 2019 20:08:32 +0000 (20:08 +0000)]
[clang][Index][NFC] Put IndexingOptions to a separate header

llvm-svn: 371250

4 years agoAMDGPU: Fix typo
Matt Arsenault [Fri, 6 Sep 2019 20:00:22 +0000 (20:00 +0000)]
AMDGPU: Fix typo

llvm-svn: 371249

4 years ago[llvm-ifs] Improving detection of PlatformKind from triple for TBD generation.
Puyan Lotfi [Fri, 6 Sep 2019 19:59:59 +0000 (19:59 +0000)]
[llvm-ifs] Improving detection of PlatformKind from triple for TBD generation.

It was pointed out that I had hard-coded PlatformKind. This is rectifying that.

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

llvm-svn: 371248

4 years ago[PowerPC][XCOFF] Remove basic test. [NFC]
Sean Fertile [Fri, 6 Sep 2019 19:55:44 +0000 (19:55 +0000)]
[PowerPC][XCOFF] Remove basic test. [NFC]

Test verified that we could compile an empty module and produce an XCOFF
object file. Newer tests superssed this coverage, its safe to remove.

llvm-svn: 371247

4 years ago[ConstantFolding] Add new test cases for transcendentals (NFC)
Evandro Menezes [Fri, 6 Sep 2019 19:41:49 +0000 (19:41 +0000)]
[ConstantFolding] Add new test cases for transcendentals (NFC)

llvm-svn: 371246

4 years ago[ORC] Make sure RPC channel-send is called in blocking calls and responses.
Lang Hames [Fri, 6 Sep 2019 19:21:59 +0000 (19:21 +0000)]
[ORC] Make sure RPC channel-send is called in blocking calls and responses.

ORC-RPC batches calls by default, and the channel's send method must be called
to transfer any buffered calls to the remote. The call to send was missing on
responses and blocking calls in the SingleThreadedRPCEndpoint. This patch adds
the necessary calls and modifies the RPC unit test to check for them.

llvm-svn: 371245

4 years ago[llvm-jitlink] Add optional slab allocator for testing locality optimizations.
Lang Hames [Fri, 6 Sep 2019 19:21:55 +0000 (19:21 +0000)]
[llvm-jitlink] Add optional slab allocator for testing locality optimizations.

The llvm-jitlink utility now accepts a '-slab-allocate <size>' option. If given,
llvm-jitlink will use a slab-based memory manager rather than the default
InProcessMemoryManager. Using a slab allocator will allow reliable testing of
future locality based optimizations (e.g. PLT and GOT elimination) in JITLink.

The <size> argument is a number, optionally followed by a units specifier (Kb,
Mb, or Gb). If the units are not given then the number is assumed to be in Kb.

llvm-svn: 371244

4 years ago[X86] Use MOVSX by default instead of CBW to extend i8 to AX for i8 sdivrem.
Craig Topper [Fri, 6 Sep 2019 19:17:02 +0000 (19:17 +0000)]
[X86] Use MOVSX by default instead of CBW to extend i8 to AX for i8 sdivrem.

We can use a MOVSX16 here then rely on FixupBWInst to change to
MOVSX32 if the upper bits are dead. With a special case to
not promote if it could be turned into CBW.

Then we can rely on X86MCInstLower to turn the MOVSX into CBW
very late if register allocation worked out.

Using MOVSX gives an opportunity to use the MOVSX as a both a
copy and a sign extend since the input and output register aren't
tied together.

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

llvm-svn: 371243

4 years ago[X86] Use MOVZX16rr8/MOVZXrm8 when extending input for i8 udivrem.
Craig Topper [Fri, 6 Sep 2019 19:15:04 +0000 (19:15 +0000)]
[X86] Use MOVZX16rr8/MOVZXrm8 when extending input for i8 udivrem.

We can rely on X86FixupBWInsts to turn these into MOVZX32. This
simplifies a follow up commit to use MOVSX for i8 sdivrem with
a late optimization to use CBW when register allocation works out.

llvm-svn: 371242

4 years ago[LifetimeAnalysis] don't use raw string literals in macros
Matthias Gehre [Fri, 6 Sep 2019 19:15:02 +0000 (19:15 +0000)]
[LifetimeAnalysis] don't use raw string literals in macros

They broke the AArch64 bots (gcc does not support it)

llvm-svn: 371241

4 years ago[X86] Teach FixupBWInsts to turn MOVSX16rr8/MOVZX16rr8/MOVSX16rm8/MOVZX16rm8 into...
Craig Topper [Fri, 6 Sep 2019 19:14:49 +0000 (19:14 +0000)]
[X86] Teach FixupBWInsts to turn MOVSX16rr8/MOVZX16rr8/MOVSX16rm8/MOVZX16rm8 into their 32-bit dest equivalents when the upper part of the register is dead.

llvm-svn: 371240

4 years ago[PowerPC][XCOFF] Verify symbol table in xcoff object files. [NFC]
Sean Fertile [Fri, 6 Sep 2019 18:56:14 +0000 (18:56 +0000)]
[PowerPC][XCOFF] Verify symbol table in xcoff object files. [NFC]

Extend the common/local-common testing for object files to also verify the
symbol table now that the needed functionality has landed in llvm-readobj.

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

llvm-svn: 371237

4 years ago[ConstantFolding] Refactor functions not available before C99 (NFC)
Evandro Menezes [Fri, 6 Sep 2019 18:24:21 +0000 (18:24 +0000)]
[ConstantFolding] Refactor functions not available before C99 (NFC)

Note the cases when calling a function at compile time may fail if the host
does not support the C99 run time library.

llvm-svn: 371236

4 years ago[FPEnv] Teach the IRBuilder about constrained FPToSI and FPToUI.
Kevin P. Neal [Fri, 6 Sep 2019 18:04:34 +0000 (18:04 +0000)]
[FPEnv] Teach the IRBuilder about constrained FPToSI and FPToUI.

The IRBuilder doesn't know that the two floating point to integer instructions
have constrained equivalents. This patch adds the support by building on
the strict FP mode now present in the IRBuilder.

Reviewed by: John McCall
Approved by: John McCall
Differential Revision: https://reviews.llvm.org/D67291

llvm-svn: 371235

4 years ago[lldb] Small optimization of FormatMap::Delete and FormatMap::Get
Jan Kratochvil [Fri, 6 Sep 2019 17:52:27 +0000 (17:52 +0000)]
[lldb] Small optimization of FormatMap::Delete and FormatMap::Get

llvm-svn: 371234

4 years ago[Remarks] Add support for internalizing a remark in a string table
Francis Visoiu Mistrih [Fri, 6 Sep 2019 17:22:51 +0000 (17:22 +0000)]
[Remarks] Add support for internalizing a remark in a string table

In order to keep remarks around, we need to make them tied to a string
table.

Users then can delete the parser and rely on the string table to keep
the memory of the strings alive and deduplicated.

llvm-svn: 371233

4 years ago[ARM] Add patterns for VSUB with q and r registers
Oliver Cruickshank [Fri, 6 Sep 2019 17:02:42 +0000 (17:02 +0000)]
[ARM] Add patterns for VSUB with q and r registers

Added patterns for VSUB to support q and r registers, which reduces
pressure on q registers.

llvm-svn: 371231

4 years ago[ARM] Add patterns for VADD with q and r registers
Oliver Cruickshank [Fri, 6 Sep 2019 17:02:35 +0000 (17:02 +0000)]
[ARM] Add patterns for VADD with q and r registers

Added support for VADD to use q and r registers, which reduces pressure
on q registers.

llvm-svn: 371230

4 years ago[ARM] Add patterns for VMUL with q and r registers
Oliver Cruickshank [Fri, 6 Sep 2019 17:02:21 +0000 (17:02 +0000)]
[ARM] Add patterns for VMUL with q and r registers

Added support for VMUL to use an r register, this reduces pressure on
the q registers.

llvm-svn: 371229

4 years ago[ConstantFolding] Refactor function match for better speed (NFC)
Evandro Menezes [Fri, 6 Sep 2019 16:49:49 +0000 (16:49 +0000)]
[ConstantFolding] Refactor function match for better speed (NFC)

Use an `enum` instead of string comparison to match the candidate function.

llvm-svn: 371228

4 years ago[AArch64][GlobalISel] Always fall back on tail calls with -tailcallopt
Jessica Paquette [Fri, 6 Sep 2019 16:49:13 +0000 (16:49 +0000)]
[AArch64][GlobalISel] Always fall back on tail calls with -tailcallopt

-tailcallopt requires that we perform different stack adjustments than with
sibling calls. For example, the `@caller_to0_from8` function in
test/CodeGen/AArch64/tail-call.ll requires that we adjust SP. Without
-tailcallopt, this adjustment does not happen. With it, however, it is expected.

So, to ensure that adding sibling call support doesn't break -tailcallopt,
make CallLowering always fall back on possible tail calls when -tailcallopt
is passed in.

Update test/CodeGen/AArch64/tail-call.ll with a GlobalISel line to make sure
that we don't differ from the SDAG implementation at any point.

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

llvm-svn: 371227

4 years ago[NFCI] Unbreak buildbots
David Bolvansky [Fri, 6 Sep 2019 16:30:44 +0000 (16:30 +0000)]
[NFCI] Unbreak buildbots

llvm-svn: 371226

4 years ago[ELF] Replace error() with errorOrWarn() for the ASSERT command
Fangrui Song [Fri, 6 Sep 2019 16:30:22 +0000 (16:30 +0000)]
[ELF] Replace error() with errorOrWarn() for the ASSERT command

Summary:
ld.bfd produces an output with --noinhibit-exec when an ASSERT fails.
Use errorOrWarn() so that we can produce an output as well.

An interesting case is that symbol assignments may execute multiple
times, so we probably want to suppress errors for non-final runs.

Reviewed By: peter.smith

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

llvm-svn: 371225

4 years ago[InstCombine] pow(x, +/- 0.0) -> 1.0
JF Bastien [Fri, 6 Sep 2019 16:26:59 +0000 (16:26 +0000)]
[InstCombine] pow(x, +/- 0.0) -> 1.0

Summary:
This isn't an important optimization at all... We're already doing:
  pow(x, 0.0) -> 1.0
My patch merely teaches instcombine that -0.0 does the same.

However, doing this fixes an AMAZING bug! Compile this program:

  extern "C" double pow(double, double);
  double boom(double base) {
    return pow(base, -0.0);
  }

With:
  clang++ ~/Desktop/fast-math.cpp -ffast-math -O2 -S

And clang will crash with a signal. Wow, fast math is so fast it ICEs the
compiler! Arguably, the generated math is infinitely fast.

What's actually happening is that we recurse infinitely in getPow. In debug we
hit its assertion:
  assert(Exp != 0 && "Incorrect exponent 0 not handled");

We avoid this entire mess if we instead recognize that an exponent of positive
and negative zero yield 1.0.

A separate commit, r371221, fixed the same problem. This only contains the added
tests.

<rdar://problem/54598300>

Reviewers: scanon

Subscribers: hiraditya, jkorous, dexonsmith, ributzka, llvm-commits

Tags: #llvm

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

llvm-svn: 371224

4 years ago[NFC] Added new tests for r371222
David Bolvansky [Fri, 6 Sep 2019 16:18:18 +0000 (16:18 +0000)]
[NFC] Added new tests for r371222

llvm-svn: 371223

4 years ago[Diagnostics] Refactor code for -Wsizeof-pointer-div, catch more cases; also add...
David Bolvansky [Fri, 6 Sep 2019 16:12:48 +0000 (16:12 +0000)]
[Diagnostics] Refactor code for -Wsizeof-pointer-div, catch more cases; also add -Wsizeof-array-div

Previously, -Wsizeof-pointer-div failed to catch:
const int *r;
sizeof(r) / sizeof(int);

Now fixed.
Also introduced -Wsizeof-array-div which catches bugs like:
sizeof(r) / sizeof(short);

(Array element type does not match type of sizeof operand).

llvm-svn: 371222

4 years ago[SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233)
Sanjay Patel [Fri, 6 Sep 2019 16:10:18 +0000 (16:10 +0000)]
[SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233)

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

llvm-svn: 371221

4 years ago[ARM] Sink add/mul(shufflevector(insertelement())) for MVE instruction selection
Sam Tebbs [Fri, 6 Sep 2019 16:01:32 +0000 (16:01 +0000)]
[ARM] Sink add/mul(shufflevector(insertelement())) for MVE instruction selection

This patch sinks add/mul(shufflevector(insertelement())) into the basic block in which they are used so that they can then be selected together.

This is useful for various MVE instructions, such as vmla and others that take R registers.

Loop tests have been added to the vmla test file to make sure vmlas are generated in loops.

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

llvm-svn: 371218

4 years agoReland D66717 [ELF] Do not ICF two sections with different output sections (by SECTIO...
Fangrui Song [Fri, 6 Sep 2019 15:57:44 +0000 (15:57 +0000)]
Reland D66717 [ELF] Do not ICF two sections with different output sections (by SECTIONS commands)

Recommit r370635 (reverted by r371202), with one change: move addOrphanSections() before ICF.

Before, orphan sections in two different partitions may be folded and
moved to the main partition.

Now, InputSection->OutputSection assignment for orphans happens before
ICF. ICF does not fold input sections with different output sections.

With the PR43241 reproduce,
`llvm-objcopy --extract-partition libvr.so libchrome__combined.so libvr.so` => no error

Updated description:

Fixes PR39418. Complements D47241 (the non-linker-script case).

processSectionCommands() assigns input sections to output sections.
ICF is called before it, so .text.foo and .text.bar may be folded even if
their output sections are made different by SECTIONS commands.

```
markLive<ELFT>()
doIcf<ELFT>()                      // During ICF, we don't know the output sections
writeResult()
  combineEhSections<ELFT>()
  script->processSectionCommands() // InputSection -> OutputSection assignment
```

This patch splits processSectionCommands() into processSectionCommands()
and processSymbolAssignments(), and moves
processSectionCommands()/addOrphanSections() before ICF:

```
markLive<ELFT>()
combineEhSections<ELFT>()
script->processSectionCommands()
script->addOrphanSections();
doIcf<ELFT>()                      // should remove folded input sections
writeResult()
  script->processSymbolAssignments()
```

An alternative approach is to unfold a section `sec` in
processSectionCommands() when we find `sec` and `sec->repl` belong to
different output sections. I feel this patch is superior because this
can fold more sections and the decouple of
SectionCommand/SymbolAssignment gives flexibility:

* An ExprValue can't be evaluated before its section is assigned to an
  output section -> we can delete getOutputSectionVA and simplify
  another place where we had to check if the output section is null.
  Moreover, a case in linkerscript/early-assign-symbol.s can be handled
  now.
* processSectionCommands/processSymbolAssignments can be freely moved
  around.

llvm-svn: 371216

4 years agoRevert "Revert r370635, it caused PR43241."
Fangrui Song [Fri, 6 Sep 2019 15:57:24 +0000 (15:57 +0000)]
Revert "Revert r370635, it caused PR43241."

This reverts commit 50d2dca22b3b05d0ee4883b0cbf93d7d15f241fc.

llvm-svn: 371215

4 years ago[AMDGPU] Enable constant offset promotion to immediate operand for VMEM stores
Valery Pykhtin [Fri, 6 Sep 2019 15:33:53 +0000 (15:33 +0000)]
[AMDGPU] Enable constant offset promotion to immediate operand for VMEM stores

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

llvm-svn: 371214

4 years ago[ELF][test] Simplify and reorganize tests
Fangrui Song [Fri, 6 Sep 2019 15:10:31 +0000 (15:10 +0000)]
[ELF][test] Simplify and reorganize tests

Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output
Delete simple Inputs/*.s files

Delete version-script-copy-rel.s - covered by verdef-defaultver.s
Delete version-wildcard.test - covered by version-script-glob.s

llvm-svn: 371213

4 years ago[Alignment][NFC] Use Align with TargetLowering::setPrefFunctionAlignment
Guillaume Chatelet [Fri, 6 Sep 2019 15:03:49 +0000 (15:03 +0000)]
[Alignment][NFC] Use Align with TargetLowering::setPrefFunctionAlignment

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: nemanjai, javed.absar, hiraditya, kbarton, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, s.egerton, pzheng, ychen, llvm-commits

Tags: #llvm

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

llvm-svn: 371212

4 years ago[Object] remove struct constructor, NFC
Cyndy Ishida [Fri, 6 Sep 2019 15:02:22 +0000 (15:02 +0000)]
[Object] remove struct constructor, NFC

Summary: make POD struct by removing ctors

Reviewers: avl, dblaikie

Reviewed By: dblaikie

Subscribers: ributzka, llvm-commits

Tags: #llvm

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

llvm-svn: 371211