Commit Graph

376029 Commits

Author SHA1 Message Date
Florian Hahn e0905553b4
[ArgPromotion] Delay dead GEP removal until doPromotion.
Currently ArgPromotion removes dead GEPs as part of the legality check
in isSafeToPromoteArgument. If no promotion happens, this means the pass
claims no modifications happened, even though GEPs were removed.

This patch fixes the issue by delaying removal of dead GEPs until
doPromotion: isSafeToPromoteArgument can simply skips dead GEPs and
the code in doPromotion dealing with GEPs is updated to account for
dead GEPs. Once we committed to promotion, it should be safe to
remove dead GEPs.

Alternatively isSafeToPromoteArgument could return an additional boolean
to indicate whether it made changes, but this is quite cumbersome and
there should be no real benefit of weeding out some dead GEPs here if we
do not perform promotion.

I added a test for the case where dead GEPs need to be removed when
promotion happens in 578c5a0c6e.

Fixes PR47477.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D93991
2021-01-04 09:51:20 +00:00
Yang Fan e43b3d1f5e
Revert "[Sema] Fix deleted function problem in implicitly movable test"
This reverts commit 89b0972a
2021-01-04 17:21:19 +08:00
Kazushi (Jam) Marukawa 74e7cb26b9 [VE] Remove VA.needsCustom checks
Remove VA.needsCustom checks which are copied from Sparc implementation
at the very beginning of VE implementation.  Add assert to sanity-check
VA.needsCustom flag, also.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D93847
2021-01-04 18:19:18 +09:00
David Sherwood a65092040a [SVE] Fix inline assembly parsing crash
This patch fixes a crash encountered when compiling this code:

  ...
  float16_t a;
  __asm__("fminv %h[a], %[b], %[c].h"
          : [a] "=r" (a)
          : [b] "Upl" (b), [c] "w" (c))

The issue here is when using the 'h' modifier for a register
constraint 'r'.

Differential Revision: https://reviews.llvm.org/D93537
2021-01-04 09:11:05 +00:00
Craig Topper 94257d12cb [RISCV] Remove unused method isUImm5NonZero() from RISCVAsmParser.cpp. NFC
The operand predicate that used this has been gone for a while.
2021-01-04 00:17:39 -08:00
AnZhong Huang 09b3f3f22c
[benchmark] Fixed a build error when using CMake 3.15.1 + NDK-R20
std::decay_t used by llvm/utils/benchmark/include/benchmark/benchmark.h is a c++14 feature, but the CMakelist uses c++11, it's the root-cause of build error.

    There are two options to fix the error.
    1) change the CMakelist to support c++14.
    2) change std::decay_t to std::decay, it's what the patch done.

    This bug can only be reproduced by CMake 3.15, we didn't observer the bug with CMake 3.16. But based on the code's logic, it's an obvious bug of LLVM.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D93794
2021-01-04 11:00:57 +03:00
Kai Luo f6515b0520 [PowerPC] Do not fold `cmp(d|w)` and `subf` instruction to `subf.` if `nsw` is not present
In `PPCInstrInfo::optimizeCompareInstr` we seek opportunities to fold `cmp(d|w)` and `subf` as an `subf.`. However, if `subf.` gets overflow, `cr0` can't reflect the correct order, violating the semantics of `cmp(d|w)`.

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

Reviewed By: #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D90156
2021-01-04 07:54:15 +00:00
Andrew Litteken 5c951623bc [IROutliner] Refactoring errors in the cost model from past patches.
There were was the reuse of a variable that should not have been
occurred due to confusion during committing patches.
2021-01-04 00:11:18 -06:00
Andrew Litteken 05e6ac4eb8 [IROutliner] Removing a duplicate addition, causing overestimates in IROutliner.
There was an extra addition left over from a previous commit for the
cost model, this removes it.
2021-01-03 23:36:28 -06:00
sameeran joshi 6280bc1cc3 [Flang][openmp][5.0] Add task_reduction clause.
See OMP-5.0 2.19.5.5 task_reduction Clause.
To add a positive test case we need `taskgroup` directive which is not added hence skipping the test.
This is a dependency for `taskgroup` construct.

Reviewed By: clementval

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

Co-authored-by: Valentin Clement <clementval@gmail.com>
2021-01-04 08:48:11 +05:30
Jan Kratochvil 6988f7a6f4 [compiler-rt] [Sanitizers] Extend ThreadDescriptorSize() for glibc-2.32-2.fc33.x86_64+i686
before:
  $ echo 'int main(){}'|clang -g -fsanitize=leak -x c++ -;./a.out
  Tracer caught signal 11: addr=0x7f4f73da5f40 pc=0x4222c8 sp=0x7f4f72cffd40
  ==1164171==LeakSanitizer has encountered a fatal error.
  ==1164171==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
  ==1164171==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
  $ _

after:
  $ echo 'int main(){}'|clang -g -fsanitize=leak -x c++ -;./a.out)
  $ _

I haven't verified the size cannot be affected by Fedora patches of
upstream glibc-2.32 - but I do not expect upstream glibc-2.32 would have
the last sizes `(1216, 2304)` from 2013 around glibc-2.12.

Differential Revision: https://reviews.llvm.org/D93386
2021-01-04 03:21:04 +01:00
Nathan James 59810c51e7
[clang-tidy] Fix windows tests
Attempt to fix the 2 failing tests identifier in 48646.
Appears that python3 doesn't like nested double quotes in single quoted strings, hopefully nested single quotes in double quoted strings is a-ok.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D93979
2021-01-04 00:39:34 +00:00
Roman Lebedev 98cd1c33e3
[NFC][SimplifyCFG] Hoist 'original' DomTree verification from simplifyOnce() into run()
This is NFC since SimplifyCFG still currently defaults to not preserving DomTree.

SimplifyCFGOpt::simplifyOnce() is only be called from SimplifyCFGOpt::run(),
and can not be called externally, since SimplifyCFGOpt is defined in .cpp
This avoids some needless verifications, and is thus a bit faster
without sacrificing precision.
2021-01-04 01:02:02 +03:00
Roman Lebedev a7684940f0
[SimplifyCFG] SimplifyTerminatorOnSelect(): fix/tune DomTree updates
We only need to remove non-TrueBB/non-FalseBB successors,
and we only need to do that once. We don't need to insert
any new edges, because no new successors will be added.
2021-01-04 01:02:02 +03:00
Roman Lebedev 70935b9595
[NFC][SimplifyCFG] SimplifyTerminatorOnSelect(): pull out OldTerm->getParent() into a variable 2021-01-04 01:02:02 +03:00
Roman Lebedev 4fc908025f
[NFC][SimplifyCFG] Add a test where we fail to preserve DomTree validity 2021-01-04 01:02:01 +03:00
Nikita Popov 3715c99be9 [InstSimplify] Fold nnan/ninf violation to poison
As the comment already indicates, performing an operation with
nnan/ninf flags on a nan/inf or undef results in poison. Now that
we have a proper poison value, we no longer need to relax it to
undef.
2021-01-03 22:05:40 +01:00
Florian Hahn edb52c626b
[LoopUnswitch] Precommit initial partial unswitching test cases. 2021-01-03 20:34:32 +00:00
Nikita Popov 766cf7f32e [InstSimplify] Fold division by zero to poison
Div/rem by zero is immediate undefined behavior and anything goes.
Currently we fold it to undef, this patch changes it to fold to
poison instead, which is slightly stronger.

Differential Revision: https://reviews.llvm.org/D93995
2021-01-03 20:52:45 +01:00
Kazu Hirata ba82c0b315 [llvm] Call *(Set|Map)::erase directly (NFC)
We can erase an item in a set or map without checking its membership
first.
2021-01-03 09:57:47 -08:00
Kazu Hirata 0e219b6443 [Target] Construct SmallVector with iterator ranges (NFC) 2021-01-03 09:57:45 -08:00
Kazu Hirata 985f899bf2 [Target] Use llvm::append_range (NFC) 2021-01-03 09:57:43 -08:00
Nikita Popov f094d65bea [InstSimplify] Fix addo/subo with undef (PR43188)
We can't fold the first result to undef, because not all values
may be reachable under the constraint that no overflow occurred.
Use the same folds we do for saturated math instead.

Proofs:
uaddo: https://alive2.llvm.org/ce/z/zf55N_
saddo: https://alive2.llvm.org/ce/z/a_xPgS
usubo: https://alive2.llvm.org/ce/z/DmRqwt
ssubo: https://alive2.llvm.org/ce/z/8ag7U-
2021-01-03 18:51:49 +01:00
Nikita Popov c6ad00d709 [InstSimplify] Return poison for out of bounds extractelement
This is the same change as D93990, but for extractelement rather
than insertelement.

> If idx exceeds the length of val for a fixed-length vector, the
> result is a poison value. For a scalable vector, if the value of
> idx exceeds the runtime length of the vector, the result is a
> poison value.
2021-01-03 18:15:58 +01:00
Juneyoung Lee 49c2d703d3 [X86] Make deinterleave8bitStride3 use unary CreateShuffleVector
This patch makes X86InterleavedAccessGroup::deinterleave8bitStride3 use the unary CreateShuffleVector.

This is a continuation of D93923. There were a few missing replacements.

IIUC, this patch does not cause change in the generated programs' semantics because the
function inserts shufflevectors that only choose elements from the first vector.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93993
2021-01-04 02:10:51 +09:00
Nikita Popov 858b99d774 [InstSimplify] Regenerate test checks (NFC) 2021-01-03 18:09:58 +01:00
Juneyoung Lee 2139958b53 [InstSimplify] Return poison if insertelement touches out of bounds
This is a simple patch that updates InstSimplify to return poison if the index is/can be out-of-bounds

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93990
2021-01-04 00:43:02 +09:00
Florian Hahn 578c5a0c6e
[ArgPromotion] Add test with dead GEP when promoting.
This adds test coverage for the case where we do argument promotion and
there's a dead GEP that should be removed/ignored.
2021-01-03 15:39:06 +00:00
Juneyoung Lee 1fc992bd86 [Scalarizer] Use poison as insertelement's placeholder
This patch makes Scalarizer to use poison as insertelement's placeholder.

It contains two changes in Scalarizer.cpp, and the both changes does not change the semantics of the optimized program.
It is because the placeholder value (poison) is already completely hidden by following insertelement instructions.

The first change at visitBitCastInst() creates poison vector of MidTy and consecutively inserts FanIn times,
which is # of elems of MidTy.
The second change at ScalarizerVisitor::finish() creates poison with Op->getType(), and it is filled with
Count insertelements.

The test diffs show that the poison value is never exposed after insertelements.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93989
2021-01-04 00:35:28 +09:00
Juneyoung Lee c5a7e75eb6 Update *-inseltpoison.ll tests at Transforms/InstCombine/X86 by replacing undef with poison (NFC) 2021-01-03 22:40:05 +09:00
Gil Rapaport d9c0b128e3 [SCEV] Simplify trunc to zero based on known bits
Let getTruncateExpr() short-circuit to zero when the value being truncated is
known to have at least as many trailing zeros as the target type.

Differential Revision: https://reviews.llvm.org/D93973
2021-01-03 13:57:12 +02:00
Alexey Lapshin f5f7ff8d0f [dsymutil][DWARFLinker][NFC] Refactor usages of UniquingStringPool.
That refactoring is helpful since it reduces data inter-dependencies.
Which is good for current implementation and even more good for
fully multi-thread implementation. The idea of the refactoring
is to delete UniquingStringPool from the global DWARFLinker level.
It is used to unique type names while ODR deduplication is done.
Thus we move UniquingStringPool into the DeclContextTree which
matched to UniquingStringPool usage scope.

golden-dsymutil/dsymutil 23787992
clang MD5: 7d9873ff94f0246b6ab1ec3e8d0f3f06

build-Release/bin/dsymutil 23921272
clang MD5: 7d9873ff94f0246b6ab1ec3e8d0f3f06

Differential Revision: https://reviews.llvm.org/D93460
2021-01-03 14:44:51 +03:00
Nico Weber fe9976c02c Revert "[sanitizer] Define SANITIZER_GLIBC to refine SANITIZER_LINUX feature detection and support musl"
...and follow-ups. It still doesn't build on Android, see https://reviews.llvm.org/D93848#2476310

This reverts commit a92d01534f.
This reverts commit 52d7e183bf.
This reverts commit 34489da81b.
2021-01-02 18:59:26 -05:00
Lang Hames a554cd6ae5 [RuntimeDyld] Fix dangling reference in RuntimeDyldELF.
Patch by Moritz Sichert. Thanks Moritz!

Differential Revision: https://reviews.llvm.org/D89373
2021-01-03 10:20:36 +11:00
LLVM GN Syncbot 835bdd1776 [gn build] Port 5799fc79c3 2021-01-02 22:46:43 +00:00
Roman Lebedev 5fa241a657
[SimplifyCFG] FoldValueComparisonIntoPredecessors(): fine-tune/fix DomTree preservation, take 2 2021-01-03 01:45:48 +03:00
Roman Lebedev a0013934b6
[NFC][SimplifyCFG] Add another test for switch creation where we fail to maintain DomTree 2021-01-03 01:45:48 +03:00
Roman Lebedev 6a3a8d17eb
[SimplifyCFG] FoldValueComparisonIntoPredecessors(): fine-tune/fix DomTree preservation 2021-01-03 01:45:48 +03:00
Roman Lebedev eda50309f5
[NFC][SimplifyCFG] Add test for switch creation where we fail to maintain DomTree
Reduced from vanilla test-suite
2021-01-03 01:45:47 +03:00
Roman Lebedev 5799fc79c3
[llvm-reduce] Refactor global variable delta pass
The limitation of the current pass that it skips initializer-less GV's
seems arbitrary, in all the reduced cases i (personally) looked at,
the globals weren't needed, yet they were kept.

So let's do two things:
1. allow reducing initializer-less globals
2. before reducing globals, reduce their initializers, much like we do function bodies
2021-01-03 01:45:47 +03:00
Roman Lebedev 19ab1817b6
[llvm-reduce] Fix removal of unused llvm intrinsics declarations
ee6e25e439 changed
the delta pass to skip intrinsics, which means we may end up being
left with declarations of intrinsics, that aren't otherwise referenced
in the module. This is obviously unwanted, do drop them.
2021-01-03 01:45:47 +03:00
Roman Lebedev 7c8b8063b6
[SimplifyCFG][AMDGPU] AMDGPUUnifyDivergentExitNodes: SimplifyCFG isn't ready to preserve PostDomTree
There is a number of transforms in SimplifyCFG that take DomTree out of
DomTreeUpdater, and do updates manually. Until they are fixed,
user passes are unable to claim that PDT is preserved.

Note that the default for SimplifyCFG is still not to preserve DomTree,
so this is still effectively NFC.
2021-01-03 01:45:46 +03:00
Hongtao Yu 01f0d162d6 Moving UniqueInternalLinkageNamesPass to the start of IR pipelines.
`UniqueInternalLinkageNamesPass` is useful to CSSPGO, especially when pseudo probe is used. It solves naming conflict for static functions which otherwise will share a merged profile and likely have a profile quality issue with mismatched CFG checksums. Since the pseudo probe instrumentation happens very early in the pipeline, I'm moving `UniqueInternalLinkageNamesPass` right before it. This is being done only to the new pass manager.

Reviewed By: dblaikie, aeubanks

Differential Revision: https://reviews.llvm.org/D93656
2021-01-02 14:26:21 -08:00
Nathan James 7af6a13450
[NFC] Switch up some dyn_cast calls 2021-01-02 19:56:27 +00:00
Brandon Bergren 4c77a0f1ce [PowerPC] NFC: Apply minor clang-format fix 2021-01-02 12:21:28 -06:00
Brandon Bergren 2288319733 [PowerPC] Enable OpenMP for powerpcle target. [5/5]
Enable OpenMP for powerpcle to match the rest of powerpc*.

Update tests.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92445
2021-01-02 12:18:07 -06:00
Brandon Bergren 275eb8289c [PowerPC] Support powerpcle target in LLD [4/5]
Add support for linking powerpcle code in LLD.

Rewrite lld/test/ELF/emulation-ppc.s to use a shared check block and add powerpcle tests.

Update tests.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93917
2021-01-02 12:18:05 -06:00
Brandon Bergren 6cee9d0cf8 [PowerPC] Support powerpcle target in Clang [3/5]
Add powerpcle support to clang.

For FreeBSD, assume a freestanding environment for now, as we only need it in the first place to build loader, which runs in the OpenFirmware environment instead of the FreeBSD environment.

For Linux, recognize glibc and musl environments to match current usage in Void Linux PPC.

Adjust driver to match current binutils behavior regarding machine naming.

Adjust and expand tests.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93919
2021-01-02 12:17:58 -06:00
Brandon Bergren 696bd3073f [PowerPC] Support powerpcle target in LLVMObject [2/5]
Add object file handling for powerpcle-*-*.

Adjust tests.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93916
2021-01-02 12:17:39 -06:00
Brandon Bergren 8f004471c2 [PowerPC] Add the LLVM triple for powerpcle [1/5]
Add a triple for powerpcle-*-*.

This is a little-endian encoding of the 32-bit PowerPC ABI, useful in certain niche situations:

1) A loader such as the FreeBSD loader which will be loading a little endian kernel. This is required for PowerPC64LE to load properly in pseries VMs.
Such a loader is implemented as a freestanding ELF32 LSB binary.

2) Userspace emulation of a 32-bit LE architecture such as x86 on 64-bit hosts such as PowerPC64LE with tools like box86 requires having a 32-bit LE toolchain and library set, as they operate by translating only the main binary and switching to native code when making library calls.

3) The Void Linux for PowerPC project is experimenting with running an entire powerpcle userland.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93918
2021-01-02 12:17:22 -06:00