platform/upstream/llvm.git
2 years ago[Driver][NetBSD] -r: imply -nostdlib like GCC
Brad Smith [Tue, 15 Feb 2022 04:29:13 +0000 (23:29 -0500)]
[Driver][NetBSD] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

2 years ago[Driver][DragonFly] -r: imply -nostdlib like GCC
Brad Smith [Tue, 15 Feb 2022 04:24:26 +0000 (23:24 -0500)]
[Driver][DragonFly] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

2 years ago[BPF] Fix a bug in BTF_KIND_TYPE_TAG generation
Yonghong Song [Sun, 13 Feb 2022 00:56:17 +0000 (16:56 -0800)]
[BPF] Fix a bug in BTF_KIND_TYPE_TAG generation

Kumar Kartikeya Dwivedi reported a bug ([1]) where BTF_KIND_TYPE_TAG types
are not generated.

Currently, BPF backend only generates BTF types which are used by
the program, e.g., global variables, functions and some builtin functions.
For example, suppose we have
  struct task_struct {
    ...
    struct task_group               *sched_task_group;
    struct mm_struct                *mm;
    ...
    pid_t                           pid;
    pid_t                           tgid;
    ...
  }
If BPF program intends to access task_struct->pid and task_struct->tgid,
there really no need to generate BTF types for struct task_group
and mm_struct.

In BPF backend, during BTF generation, when generating BTF for struct
task_struct, if types for task_group and mm_struct have not been generated
yet, a Fixup structure will be created, which will be reexamined later
to instantiate into either a full type or a forward type.

In current implementation, if we have something like
  struct foo {
     struct bar  __tag1    *f;
  };
and when generating types for struct foo, struct bar type
has not been generated, the __tag1 will be lost during later
Fixup instantiation. This patch fixed this issue by properly
handling btf_type_tag's during Fixup instantiation stage.

  [1] https://lore.kernel.org/bpf/20220210232411.pmhzj7v5uptqby7r@apollo.legion/

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

2 years agoReland "[memprof] Introduce a wrapper around MemInfoBlock."
Snehasish Kumar [Mon, 14 Feb 2022 19:52:38 +0000 (11:52 -0800)]
Reland "[memprof] Introduce a wrapper around MemInfoBlock."

This reverts commit e6999040f5758f89a64b6232119b775b7bd1c85b.

Update test to fix signed int comparison warning, fix whitespace in
compiler-rt MIBEntryDef.inc file.

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

2 years ago[CSSPGO] Do not merge a context that is already duplicated into the base profile.
Hongtao Yu [Mon, 14 Feb 2022 17:33:54 +0000 (09:33 -0800)]
[CSSPGO] Do not merge a context that is already duplicated into the base profile.

Do not merge a context that is already duplicated into the base profile.

Also fixing a typo caused by previous refactoring.

Reviewed By: wenlei

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

2 years ago[Clang][Sema] Add a missing regression test about Wliteral-range
Jun Zhang [Fri, 11 Feb 2022 08:40:26 +0000 (16:40 +0800)]
[Clang][Sema] Add a missing regression test about Wliteral-range

This patch adds a missing test, covering the different kinds of floating-point
literals, like hexadecimal floats, and testing extreme cases & normal cases.

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

2 years agoThis test seems to pass on Linux, remove the x-fail.
Jim Ingham [Tue, 15 Feb 2022 00:57:20 +0000 (16:57 -0800)]
This test seems to pass on Linux, remove the x-fail.

One of the tests in this test setup was copied from a more complex test, and I didn't know
if the setup or the subsequent parts of the test were the ones that fail on Linux.  Looks
like it was the latter, so let's mark this succeeding.

2 years ago[OpenMP]Fix parsing of OpenMP directive nested in a metadirective
Mike Rice [Mon, 14 Feb 2022 19:36:12 +0000 (11:36 -0800)]
[OpenMP]Fix parsing of OpenMP directive nested in a metadirective

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

2 years ago[dsymutil] Add the ability to run the DWARF verifier on the input
Jonas Devlieghere [Mon, 14 Feb 2022 22:25:27 +0000 (14:25 -0800)]
[dsymutil] Add the ability to run the DWARF verifier on the input

Currently you can run the DWARF verifier on the linked dsymutil output.
This patch extends this functionality and makes it possible to
run the DWARF verifier on the input as well.

A new option --verify-dwarf allows you to specify input, output, all and
none. The existing --verify flag remains unchanged and acts and alias
for --verify-dwarf=output.

Input verification issues do not result in a non-zero exit code because
dsymutil is capable of taking invalid DWARF as input and producing valid
DWARF as output.

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

2 years agoReland "[memprof] Refactor out the MemInfoBlock into a macro based def."
Snehasish Kumar [Mon, 14 Feb 2022 19:52:34 +0000 (11:52 -0800)]
Reland "[memprof] Refactor out the MemInfoBlock into a macro based def."

This reverts commit 857ec0d01f8021ff0d9540fcbf6ff24e29868ba4.

Fixes -DLLVM_ENABLE_MODULES=On build by adding the new textual
header to the modulemap file.

Reviewed in https://reviews.llvm.org/D117722

2 years ago[modules] Add a flag for TagDecl if it was a definition demoted to a declaration.
Volodymyr Sapsai [Tue, 1 Feb 2022 23:03:59 +0000 (15:03 -0800)]
[modules] Add a flag for TagDecl if it was a definition demoted to a declaration.

For redeclaration chains we maintain an invariant of having only a
single definition in the chain. In a single translation unit we make
sure not to create duplicates. But modules are separate translation
units and they can contain definitions for the same symbol
independently. When we load such modules together, we need to demote
duplicate definitions to keep the AST invariants.

Some AST clients are interested in distinguishing
declaration-that-was-demoted-from-definition and
declaration-that-was-never-a-definition. For that purpose introducing
`IsThisDeclarationADemotedDefinition`. No functional change intended.

rdar://84677782

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

2 years ago[flang] Accept structure constructor value for polymorphic component
Peter Klausler [Tue, 8 Feb 2022 19:56:22 +0000 (11:56 -0800)]
[flang] Accept structure constructor value for polymorphic component

Semantic analysis was emitting a bogus error message when a structure
constructor contains a monomorphic value for a (limited) polymorphic
component of a derived type.  The type compatibility test was too
strict; this patch relaxes it a little to allow values that could
be assigned or passed to a variable or dummy argument with that type.
Also add some quotes to an error message that was sometimes confusing
without them, and remove a repeated space character from another.

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

2 years agoFix an incorrect assumption in "thread until": code with debug info is not always...
Jim Ingham [Mon, 14 Feb 2022 23:49:37 +0000 (15:49 -0800)]
Fix an incorrect assumption in "thread until": code with debug info is not always in a function.

Some dyld cross library stubs can have line information but no function.  Make sure you
check that you have a valid Function object before asking it questions.

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

2 years agoAdd a repeat command option for "thread backtrace --count N".
Jim Ingham [Fri, 4 Feb 2022 23:16:31 +0000 (15:16 -0800)]
Add a repeat command option for "thread backtrace --count N".

This way if you have a long stack, you can issue "thread backtrace --count 10"
and then subsequent <Return>-s will page you through the stack.

This took a little more effort than just adding the repeat command, since
the GetRepeatCommand API was returning a "const char *".  That meant the command
had to keep the repeat string alive, which is inconvenient.  The original
API returned either a nullptr, or a const char *, so I changed the private API to
return an llvm::Optional<std::string>.  Most of the patch is propagating that change.

Also, there was a little thinko in fetching the repeat command.  We don't
fetch repeat commands for commands that aren't being added to history, which
is in general reasonable.  And we don't add repeat commands to the history -
also reasonable.  But we do want the repeat command to be able to generate
the NEXT repeat command.  So I adjusted the logic in HandleCommand to work
that way.

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

2 years ago[libc++] Guard warning pragmas
Nikolas Klauser [Mon, 14 Feb 2022 17:52:28 +0000 (18:52 +0100)]
[libc++] Guard warning pragmas

This makes the GCC output even cleaner!

Reviewed By: ldionne, #libc

Spies: mstorsjo, Quuxplusone, Mordante, libcxx-commits

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

2 years ago[libc++] Replace _VSTD with std in __ranges/
Nikolas Klauser [Fri, 11 Feb 2022 00:01:17 +0000 (01:01 +0100)]
[libc++] Replace _VSTD with std in __ranges/

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[mlir][sparse][taco] Support true dense tensors and all dense sparse tensors.
Bixia Zheng [Fri, 11 Feb 2022 23:05:06 +0000 (15:05 -0800)]
[mlir][sparse][taco] Support true dense tensors and all dense sparse tensors.

The only method to create a true dense tensor (i.e un-annotated) in MLIR-PyTACO
is through the from_array method. However, the annotated all dense tensors are
also implemented as true dense tensor currently. The PR fixes the
implementation to support annotated all dense sparse tensors.

Extend the tensor init method to support the construction of a tensor without
any sparsity annotation.

Change the tensor to_file method to only support writing unpacked sparse
tensors to file through the MLIR sparse tensor dialect.

Add unit tests for true dense tensors and all dense sparse tensors.

Reviewed By: aartbik

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

2 years ago[flang] Ensure a characterized ENTRY in a PURE subprogram is also marked PURE
Peter Klausler [Tue, 8 Feb 2022 18:07:55 +0000 (10:07 -0800)]
[flang] Ensure a characterized ENTRY in a PURE subprogram is also marked PURE

ENTRY point symbols aren't marked PURE in the symbol table, but must
instead inherit the attribute from their containing subprograms.
There's a predicate in semantics that does this, but it wasn't being
used in the context of actual procedure argument characterization.

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

2 years ago[HWASAN] use common alignAndPadAlloca
Florian Mayer [Sat, 12 Feb 2022 01:41:56 +0000 (17:41 -0800)]
[HWASAN] use common alignAndPadAlloca

Reviewed By: eugenis

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

2 years ago[libc++][NFC] Fix typo in comment
Louis Dionne [Mon, 14 Feb 2022 23:25:57 +0000 (18:25 -0500)]
[libc++][NFC] Fix typo in comment

2 years ago[libcxx] [ci] Enable LIBCXX_ENABLE_WERROR where possible
Martin Storsjö [Thu, 10 Feb 2022 11:08:24 +0000 (13:08 +0200)]
[libcxx] [ci] Enable LIBCXX_ENABLE_WERROR where possible

Only opt out from it in the few configs (GCC based) where there still
are build warnings.

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

2 years ago[PowerPC] Remove the LDMX instruction.
Stefan Pintilie [Mon, 14 Feb 2022 21:38:54 +0000 (15:38 -0600)]
[PowerPC] Remove the LDMX instruction.

The LDMX instruction was to be potentially added in P9 but it was never added
in either ISA 3.0 or ISA 3.1. This patch removes that instruction as it is
currently still an invalid instruction.

Reviewed By: lei

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

2 years ago[NFC] [MTE] Move alignAndPadAlloca to MemoryTaggingSupport.
Florian Mayer [Sat, 12 Feb 2022 01:38:19 +0000 (17:38 -0800)]
[NFC] [MTE] Move alignAndPadAlloca to MemoryTaggingSupport.

Reviewed By: eugenis

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

2 years ago[flang] Accept NULL(mold=x) as constant component value in constant structure constructor
Peter Klausler [Mon, 7 Feb 2022 23:34:54 +0000 (15:34 -0800)]
[flang] Accept NULL(mold=x) as constant component value in constant structure constructor

The predicate IsInitialDataTarget() was failing to return a correct true
result in the case of a reference to the intrinsic function NULL() with a
MOLD= argument.  Fix, and improve tests for "NULL()" elsewhere in semantics,
checking for an attribute set by intrinsics.cpp rather than the actual name.

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

2 years ago[NVPTX] Fix NVPTXReplaceImageHandles for multiple uses of a texref
Dmitry Vassiliev [Mon, 14 Feb 2022 22:30:13 +0000 (01:30 +0300)]
[NVPTX] Fix NVPTXReplaceImageHandles for multiple uses of a texref

The texsurf_handle is removed by NVPTXReplaceImageHandles.cpp. There are more than one uses of the texsurf_handle, one of them is a regular function call, and one of them is a texture intrinsic.
The current hacky logic in NVPTXReplaceImageHandles.cpp for CUDA cannot handle such a mixed use. This patch fixes this issue.

Reviewed By: tra

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

2 years ago[NVPTX] Fix bug with int_nvvm_rotate_b64 when operand immediate
Dmitry Vassiliev [Mon, 14 Feb 2022 22:23:11 +0000 (01:23 +0300)]
[NVPTX] Fix bug with int_nvvm_rotate_b64 when operand immediate

Need to subract from 64, not 32.

Reviewed By: tra

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

2 years ago[WebAssembly] Use GeneralDynamic TLS for exception handling builtins.
Sam Clegg [Fri, 11 Feb 2022 23:53:28 +0000 (15:53 -0800)]
[WebAssembly] Use GeneralDynamic TLS for exception handling builtins.

These global TLS symbols are shared across all shared libraries and
therefor should not be assumed to be local to the current module.

Also add new error in the linker when TLS relocations are used against
undefined symbols.  TLS relocations are offsets into the current modules
tls data segment, and don't make sense for undefined symbols which are
modeled as global imports.

Fixes: https://github.com/emscripten-core/emscripten/issues/13398

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

2 years ago[funcattrs] check reachability to improve noreturn
Nick Desaulniers [Mon, 14 Feb 2022 21:47:00 +0000 (13:47 -0800)]
[funcattrs] check reachability to improve noreturn

There was a fixme in the code pertaining to attributing functions as
noreturn.  By using reachability, if none of the blocks that are
reachable from the entry return, then the function is noreturn.

Previously, the code only checked if any blocks returned. If they're
unreachable, then they don't matter.

This improves codegen for the Linux kernel.

Fixes: https://github.com/ClangBuiltLinux/linux/issues/1563

Reviewed By: nikic

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

2 years ago[libc++] Prepare string.nonmembers for constexpr
Nikolas Klauser [Thu, 10 Feb 2022 22:28:11 +0000 (23:28 +0100)]
[libc++] Prepare string.nonmembers for constexpr

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[gn build] Port 5d1c1a243c4d
LLVM GN Syncbot [Mon, 14 Feb 2022 21:39:38 +0000 (21:39 +0000)]
[gn build] Port 5d1c1a243c4d

2 years ago[libc++] [C++2b] [P0943] Add stdatomic.h header.
Marek Kurdej [Mon, 7 Feb 2022 21:04:31 +0000 (16:04 -0500)]
[libc++] [C++2b] [P0943] Add stdatomic.h header.

* https://wg21.link/P0943
* https://eel.is/c++draft/stdatomic.h.syn

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

2 years agoRevert D119669 "[NVPTX] Prefix "$L__" for branch label names"
Fangrui Song [Mon, 14 Feb 2022 21:23:22 +0000 (13:23 -0800)]
Revert D119669 "[NVPTX] Prefix "$L__" for branch label names"

This reverts commit cccef321096c20825fe8738045c1d91d3b9fd57d.

Broke clang-cuda-t4

```
/buildbot/cuda-t4-0/work/clang-cuda-t4/clang/bin/clang++  -DNDEBUG  -O3 -DNDEBUG   -w -Werror=date-time -UNDEBUG --cuda-path=/buildbot/cuda-t4-0/work/clang-cuda-t4/external/cuda/cuda-11.0 -I/buildbot/cuda-t4-0/work/clang-cuda-t4/external/cuda/cuda-11.0/include --cuda-gpu-arch=sm_75 -std=c++20 -stdlib=libstdc++ --gcc-toolchain=/buildbot/cuda-t4-0/work/clang-cuda-t4/external/cuda/gcc-8 -DSTDLIB_VERSION=2014 -MD -MT External/CUDA/CMakeFiles/complex-cuda-11.0-c++20-libstdc++-8.dir/complex.cu.o -MF External/CUDA/CMakeFiles/complex-cuda-11.0-c++20-libstdc++-8.dir/complex.cu.o.d -o External/CUDA/CMakeFiles/complex-cuda-11.0-c++20-libstdc++-8.dir/complex.cu.o -c /buildbot/cuda-t4-0/work/clang-cuda-t4/llvm-test-suite/External/CUDA/complex.cu
ptxas /tmp/complex-cfa050/complex-sm_75.s, line 250; fatal   : Parsing error near '$L__BB6_2': syntax error
ptxas fatal   : Ptx assembly aborted due to errors
```

2 years ago[clang][test] Add -fuse-ld= to test cases added in d238acd1131ec2670acf5cf47b89069ca6...
Alex Lorenz [Mon, 14 Feb 2022 21:21:39 +0000 (13:21 -0800)]
[clang][test] Add -fuse-ld= to test cases added in d238acd1131ec2670acf5cf47b89069ca6c2e86c to resolve test failure with CLANG_DEFAULT_LINKER=lld

2 years ago[release] Use a supported way of building libc++ when building the documentation
Louis Dionne [Tue, 8 Feb 2022 18:06:44 +0000 (13:06 -0500)]
[release] Use a supported way of building libc++ when building the documentation

Instead of using the deprecated LLVM_ENABLE_PROJECTS build, use the
default runtimes build. This is just as fast, but it's supported.

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

2 years ago[NVPTX] Prefix "$L__" for branch label names
Dmitry Vassiliev [Mon, 14 Feb 2022 20:51:36 +0000 (23:51 +0300)]
[NVPTX] Prefix "$L__" for branch label names

A global variable may have the same name as a label, and ptxas does not accept it.
Prefix labels with $L__ to fix this.

Reviewed By: MaskRay, tra

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

2 years ago[MC] Define and use MCRegisterInfo::regsOverlap
Jay Foad [Fri, 11 Feb 2022 10:39:46 +0000 (10:39 +0000)]
[MC] Define and use MCRegisterInfo::regsOverlap

Separate MCRegisterInfo::regsOverlap out from
TargetRegisterInfo::regsOverlap. This is useful in the AMDGPU AsmParser
where we only have access to MCRegisterInfo.

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

2 years ago[AMDGPU] Fix AGPR offset for waitcnt
Joe Nash [Mon, 14 Feb 2022 18:34:11 +0000 (13:34 -0500)]
[AMDGPU] Fix AGPR offset for waitcnt

An enum value stores the offset between AGPR ranges and VGPR
ranges in the internal storage of SIInsertWaitcnts. It said 226 when
it should say 256, causing some portion of the ranges to overlap. That
in turn causes 'aliasing' between the registers, potentially inserting
waitcnts that are not required.

Reviewed By: rampitec

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

2 years ago[libc++abi] Add a from-scratch testing config for Apple backdeployment
Louis Dionne [Thu, 10 Feb 2022 19:03:05 +0000 (14:03 -0500)]
[libc++abi] Add a from-scratch testing config for Apple backdeployment

We added one for libc++ recently, and this patch adds one for libc++abi.
Also, as a fly-by fix, include older libunwind dylibs in the testing of
libc++ and libc++abi, which fixes some issues related to running
back-deployment tests on newer systems.

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

2 years ago[Libomptarget][NFC] Remove constexpr to hide warnings
Joseph Huber [Mon, 14 Feb 2022 19:01:04 +0000 (14:01 -0500)]
[Libomptarget][NFC] Remove constexpr to hide warnings

Currently whenever we compile the device runtime we get the following
'Mapping.cpp:32:32: warning: inline function '_OMP::impl::getGridValue'
is not defined [-Wundefined-inline]' warning. This can be silenced by
removing the constexpr attribute for this function. Doing this doesn't
change the generated bitcode at all but prevents the screen from getting
filled with warnings whenver we build the runtime.

Reviewed By: jdoerfert

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

2 years ago[flang] Lower basic function with scalar integer/logical return value
Valentin Clement [Mon, 14 Feb 2022 20:31:46 +0000 (21:31 +0100)]
[flang] Lower basic function with scalar integer/logical return value

This patch allows the lowring of simple empty function with a
scalar integer or logical return value.
The code in ConvertType.cpp is cleaned up as well. This file was landed
together with the initial flang push and lowering was still a prototype
at that time. Some more cleaning will come with follow up patches.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[clang][driver] add clang driver support for emitting macho files with two build...
Alex Lorenz [Mon, 14 Feb 2022 20:24:43 +0000 (12:24 -0800)]
[clang][driver] add clang driver support for emitting macho files with two build version load commands

This patch extends clang driver to pass the right flags to the clang frontend, and ld64,
so that they can emit macho files with two build version load commands. It adds a new
0darwin-target-variant option which complements -target and also can be used to specify different
target variants when multi-arch compilations are invoked with multiple -arch commands.

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

2 years ago[libcxx] [test] Fix the get_weekday test on glibc
Martin Storsjö [Tue, 25 Jan 2022 09:24:45 +0000 (11:24 +0200)]
[libcxx] [test] Fix the get_weekday test on glibc

This test feeds in the expected utf8 form of weekdays in various
languages, trying to match what libc++ has gathered internally
from `strftime()`. On glibc, the ru_RU.UTF-8 representation of the
tested weekday is spelled with upper case, while the existing
test reference is lower case.

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

2 years ago[libcxx] [test] Simplify the handling of platform specific NAN formatting in put_long...
Martin Storsjö [Thu, 20 Jan 2022 12:47:05 +0000 (14:47 +0200)]
[libcxx] [test] Simplify the handling of platform specific NAN formatting in put_long_double

Also opt in to testing the hexadecimal float formatting for glibc; glibc
does matches the current test references there.

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

2 years ago[crashlog] Change heuristic to stripping the meta data from crashlogs
Jonas Devlieghere [Mon, 14 Feb 2022 20:12:54 +0000 (12:12 -0800)]
[crashlog] Change heuristic to stripping the meta data from crashlogs

Instead trying to pro-actively determine if the first line in a
crashlog contains meta data, change the heuristic to do the following:

 1. To trying to parse the whole file. If that fails, then:
 2. Strip the first line and try parsing the remainder of the file. If
    that fails, then:
 3. Fall back to the textual crashlog parser.

rdar://88580543

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

2 years ago[lldb] Stop forwarding LLDB_DEFAULT_PYTHON_VERSION in crashlog
Jonas Devlieghere [Mon, 14 Feb 2022 20:14:36 +0000 (12:14 -0800)]
[lldb] Stop forwarding LLDB_DEFAULT_PYTHON_VERSION in crashlog

Support for Python 2 was removed in Xcode 13.

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

2 years ago[libc++] [test] Uncomment std::ranges::min_element in niebloid.compile.pass.cpp.
Arthur O'Dwyer [Mon, 14 Feb 2022 20:12:10 +0000 (15:12 -0500)]
[libc++] [test] Uncomment std::ranges::min_element in niebloid.compile.pass.cpp.

This should have been part of 3b470d1ce.

2 years ago[libcxx] Fix setup of MSVC specific intrinsics in Ryu code
Martin Storsjö [Sat, 12 Feb 2022 20:00:46 +0000 (22:00 +0200)]
[libcxx] Fix setup of MSVC specific intrinsics in Ryu code

This fixes warnings about implicitly declared `_umul128` and
`__shiftright128` when building for x86_64 with clang-cl.

Use `_MSC_VER` instead of `_LIBCPP_COMPILER_MSVC` for enabling MSVC
specific code; `_MSC_VER` is defined both in clang-cl and MSVC,
while `_LIBCPP_COMPILER_MSVC` only is defined if building with the
actual MSVC compiler.

Include `ryu.h` at the head of `d2s_intrinsics.h`, as it uses
the `_LIBCPP_64_BIT` define, which is defined in `ryu.h`.

Now the Ryu files build without warnings with clang-cl for i386,
x86_64, arm and aarch64.

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

2 years ago[OpenMP][libomp] Introduce oneAPI compiler support
Jonathan Peyton [Mon, 31 Jan 2022 16:04:49 +0000 (10:04 -0600)]
[OpenMP][libomp] Introduce oneAPI compiler support

Introduce KMP_COMPILER_ICX macro to represent compilation with oneAPI
compiler.

Fixup flag detection and compiler ID detection in CMake. Older CMake's
detect IntelLLVM as Clang.

Fix compiler warnings.

Fixup many of the tests to have non-empty parallel regions as they are
elided by oneAPI compiler.

2 years ago[AMDGPU] Pre-commit test for wait between agpr & vgpr
Joe Nash [Mon, 14 Feb 2022 16:29:58 +0000 (11:29 -0500)]
[AMDGPU] Pre-commit test for wait between agpr & vgpr

Due to a typo of 256 to 226, the SIInsertWaitcnt pass thinks
several registers are aliased from a waitcnt PoV including vgpr226
and agpr0, vgpr227 and agpr1...

This is a test of the behavior.
NFC.

Reviewed By: rampitec

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

2 years ago[gn build] Port 85355a560a33
LLVM GN Syncbot [Mon, 14 Feb 2022 19:57:49 +0000 (19:57 +0000)]
[gn build] Port 85355a560a33

2 years ago[gn build] Port 2a8f9a5e95de
LLVM GN Syncbot [Mon, 14 Feb 2022 19:57:48 +0000 (19:57 +0000)]
[gn build] Port 2a8f9a5e95de

2 years ago[libc] [Obvious] Fix.
Raman Tenneti [Mon, 14 Feb 2022 19:53:59 +0000 (11:53 -0800)]
[libc] [Obvious] Fix.

Disable getenv_test.

Reviewed By: rtenneti

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

2 years ago[libc++] Implement P0627R6 (Function to mark unreachable code)
Nikolas Klauser [Mon, 14 Feb 2022 17:26:02 +0000 (18:26 +0100)]
[libc++] Implement P0627R6 (Function to mark unreachable code)

Reviewed By: ldionne, Quuxplusone, #libc

Spies: arichardson, mstorsjo, libcxx-commits, mgorny

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

2 years ago[libc] [Obvious] Fix.
Raman Tenneti [Mon, 14 Feb 2022 19:43:47 +0000 (11:43 -0800)]
[libc] [Obvious] Fix.

Removed getenv from entrypoints.

Reviewed By: rtenneti

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

2 years ago[InstCombine] add tests for min/max intrinsics with constant ops; NFC
Sanjay Patel [Mon, 14 Feb 2022 18:28:31 +0000 (13:28 -0500)]
[InstCombine] add tests for min/max intrinsics with constant ops; NFC

2 years agoRevert "[memprof] Refactor out the MemInfoBlock into a macro based def."
Snehasish Kumar [Mon, 14 Feb 2022 19:42:00 +0000 (11:42 -0800)]
Revert "[memprof] Refactor out the MemInfoBlock into a macro based def."

This reverts commit 9def83c6d02944b2931efd50cd2491953a772aab. [4/4]

2 years agoRevert "[memprof] Introduce a wrapper around MemInfoBlock."
Snehasish Kumar [Mon, 14 Feb 2022 19:41:37 +0000 (11:41 -0800)]
Revert "[memprof] Introduce a wrapper around MemInfoBlock."

This reverts commit 9b67165285c5e752fce3b554769f5a22e7b38da8. [3/4]

2 years agoRevert "[InstrProf] Make the IndexedInstrProf header backwards compatible."
Snehasish Kumar [Mon, 14 Feb 2022 19:41:03 +0000 (11:41 -0800)]
Revert "[InstrProf] Make the IndexedInstrProf header backwards compatible."

This reverts commit 14cc41a0206a85d350767f8aff6e02bd4e7dd5d6. [2/4]

2 years agoRevert "Reland "[memprof] Extend the index prof format to include memory profiles.""
Snehasish Kumar [Mon, 14 Feb 2022 19:40:22 +0000 (11:40 -0800)]
Revert "Reland "[memprof] Extend the index prof format to include memory profiles.""

This reverts commit de54e4ab78ef09b60f870e8df6f8a87e56d6bd94 [1/4]

2 years ago[libc++][NFC] Remove redundant comment about availability of std::format
Louis Dionne [Mon, 14 Feb 2022 19:28:23 +0000 (14:28 -0500)]
[libc++][NFC] Remove redundant comment about availability of std::format

2 years ago[IR] Define "ptrauth" operand bundle.
Ahmed Bougacha [Wed, 9 Feb 2022 03:04:47 +0000 (19:04 -0800)]
[IR] Define "ptrauth" operand bundle.

This introduces a new "ptrauth" operand bundle to be used in
call/invoke. At the IR level, it's semantically equivalent to an
@llvm.ptrauth.auth followed by an indirect call, but it additionally
provides additional hardening, by preventing the intermediate raw
pointer from being exposed.

This mostly adds the IR definition, verifier checks, and support in
a couple of general helper functions. Clang IRGen and backend support
will come separately.

Note that we'll eventually want to support this bundle in indirectbr as
well, for similar reasons.  indirectbr currently doesn't support bundles
at all, and the IR data structures need to be updated to allow that.

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

2 years ago[gn build] Port de54e4ab78ef
LLVM GN Syncbot [Mon, 14 Feb 2022 19:21:47 +0000 (19:21 +0000)]
[gn build] Port de54e4ab78ef

2 years ago[libc++][NFC] Remove trailing whitespace
Louis Dionne [Mon, 14 Feb 2022 19:16:50 +0000 (14:16 -0500)]
[libc++][NFC] Remove trailing whitespace

2 years agoAlt mechanism to find the first loadable seg in a Mach-O binary
Jason Molenda [Mon, 14 Feb 2022 19:09:34 +0000 (11:09 -0800)]
Alt mechanism to find the first loadable seg in a Mach-O binary

ObjectFileMachO, for a couple of special binaries at the initial
launch, needs to find segment load addresses before the Target's
SectionLoadList has been initialized. The calculation to find
the first segment, which is at the same address as the mach header,
was not correct if the binary was in the Darwin shared cache.
Update the logic to handle that case.

Differential Revision: https://reviews.llvm.org/D119602
rdar://88802629

2 years ago[OpenMP][IRBuilder] Change the default constructor for OpenMPIRBuilder::LocationDescr...
Shraiysh Vaishay [Mon, 14 Feb 2022 18:33:06 +0000 (00:03 +0530)]
[OpenMP][IRBuilder] Change the default constructor for OpenMPIRBuilder::LocationDescription

This patch changes the argument from template-IRBuilder to IRBuilderBase
thus allowing us to write less code while getting the location from a
builder.

Reviewed By: ftynse

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

2 years agoUpdate the diagnostic behavior of [[noreturn]] in C2x
Aaron Ballman [Mon, 14 Feb 2022 19:02:27 +0000 (14:02 -0500)]
Update the diagnostic behavior of [[noreturn]] in C2x

Post-commit review feedback suggested dropping the deprecated
diagnostic for the 'noreturn' macro (the diagnostic from the header
file suffices and the macro diagnostic could be confusing) and to only
issue the deprecated diagnostic for [[_Noreturn]] when the attribute
identifier is either directly written or not from a system macro.

Amends the commit made in 5029dce492b3cf3ac191eda0b5bf268c3acac2e0.

2 years ago[lldb] Fix use-after-move in SymbolFile/NativePDB
Fangrui Song [Mon, 14 Feb 2022 19:03:26 +0000 (11:03 -0800)]
[lldb] Fix use-after-move in SymbolFile/NativePDB

2 years ago[BitcodeReader] Fix use-after-move
Fangrui Song [Mon, 14 Feb 2022 18:54:37 +0000 (10:54 -0800)]
[BitcodeReader] Fix use-after-move

2 years agoReland "[memprof] Extend the index prof format to include memory profiles."
Snehasish Kumar [Mon, 14 Feb 2022 18:32:58 +0000 (10:32 -0800)]
Reland "[memprof] Extend the index prof format to include memory profiles."

This reverts commit 0f73fb18ca333e38cdb9ffa701a8db026c56041d.

Use llvm/Profile/MIBEntryDef.inc instead of relative path.

Generated the raw profile data with `-mllvm
-enable-name-compression=false` so that builbots where the reader is
built without zlib do not fail.

Also updated the test build instructions.

2 years ago[lldb] Enable test for `getelementptr` const args for Windows
Andy Yankovsky [Mon, 14 Feb 2022 18:48:51 +0000 (18:48 +0000)]
[lldb] Enable test for `getelementptr` const args for Windows

The test actually passes fine on Windows, since it doesn't use any
static members.

Follow-up to https://reviews.llvm.org/D113498

2 years ago[flang] Allow DATA initialization of derived types w/ allocatable components
Peter Klausler [Mon, 7 Feb 2022 16:44:50 +0000 (08:44 -0800)]
[flang] Allow DATA initialization of derived types w/ allocatable components

While one cannot of course statically initialize an allocatable component
of an instance of a derived type, its mere presence should not prevent
DATA initialization of the other nonallocatable components.  Semantics
was treating the existence of an allocatable component as a case of
"default initialization", which it is, but not one that should run
afoul of C877.  Add another Boolean argument to IsInitialized() to allow
for a more nuanced test.

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

2 years ago[llvm-profdata] Fix use-after-move
Fangrui Song [Mon, 14 Feb 2022 18:38:22 +0000 (10:38 -0800)]
[llvm-profdata] Fix use-after-move

2 years ago[BOLT] Make order of jump table successors deterministic
Maksim Panchenko [Mon, 14 Feb 2022 18:37:20 +0000 (10:37 -0800)]
[BOLT] Make order of jump table successors deterministic

When a jump table is recovered in postProcessIndirectBranches(),
successors for the containing basic block are added in random order.
Make the order deterministic.

Reviewed By: yota9

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

2 years ago[SystemZ/z/OS] Add XPLINK dynamic stack allocation
Kai Nacke [Mon, 14 Feb 2022 18:02:28 +0000 (13:02 -0500)]
[SystemZ/z/OS] Add XPLINK dynamic stack allocation

With XPLINK, dynamic stack allocations requires calling
a runtime function, which allocates the stack memory,
moves the register save area, and returns the new
stack pointer.

Reviewed By: uweigand

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

2 years ago[AMDGPU] Divergence-driven abs instruction selection
alex-t [Fri, 11 Feb 2022 21:08:32 +0000 (00:08 +0300)]
[AMDGPU] Divergence-driven abs instruction selection

This change enables "abs" SDNodes selection by the node divergence.

Reviewed By: rampitec

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

2 years ago[BOLT] Skip warning message if no functions were ignored
Maksim Panchenko [Mon, 14 Feb 2022 18:31:43 +0000 (10:31 -0800)]
[BOLT] Skip warning message if no functions were ignored

Reviewed By: yota9, Amir

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

2 years ago[gn build] Port 0f73fb18ca33
LLVM GN Syncbot [Mon, 14 Feb 2022 18:25:45 +0000 (18:25 +0000)]
[gn build] Port 0f73fb18ca33

2 years agoRevert "[memprof] Extend the index prof format to include memory profiles."
Snehasish Kumar [Mon, 14 Feb 2022 18:23:23 +0000 (10:23 -0800)]
Revert "[memprof] Extend the index prof format to include memory profiles."

This reverts commit 43c2348c5b926df6bdbc5b70efaa35ecdefe12d5.

Buildbots are failing with an error on reading memprof testdata.
"Inputs/basic.profraw: profile uses zlib
compression but the profile reader was built without zlib support"

https://lab.llvm.org/buildbot/#/builders/16/builds/24490

2 years ago[libc] Create cpp::IntegerSequence analogous to std::integer_sequence
Alex Brachet [Mon, 14 Feb 2022 18:13:00 +0000 (18:13 +0000)]
[libc] Create cpp::IntegerSequence analogous to std::integer_sequence

Reviewed By: sivachandra, lntue

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

2 years agoIntroduce getenv to LLVM libc
Raman Tenneti [Mon, 14 Feb 2022 01:57:28 +0000 (17:57 -0800)]
Introduce getenv to LLVM libc

Add support for getenv as defined by the Open Group's "System Interface &
 Header" in https://pubs.opengroup.org/onlinepubs/7908799/xsh/getenv.html

getenv requires a standard way of accessing the environment,
so a pointer to the environment is added to the startup in crt1.
Consquently, this function is not usable on top of other libcs.

Added starts_with method to StringView. getenv function uses it.

Co-authored-by: Jeff Bailey <jeffbailey@google.com>
Reviewed By: sivachandra, rtenneti

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

2 years ago[flang] Allow for deferred-length character in EstablishDescriptor
Peter Klausler [Fri, 11 Feb 2022 18:37:55 +0000 (10:37 -0800)]
[flang] Allow for deferred-length character in EstablishDescriptor

When the runtime is initializing an instance of a derived type,
don't crash if an allocatable character component has deferred length.

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

2 years ago[lldb] Add a positive test for `getelementptr` constant args
Andy Yankovsky [Mon, 14 Feb 2022 17:27:31 +0000 (17:27 +0000)]
[lldb] Add a positive test for `getelementptr` constant args

The IR interpreter supports const operands to the `GetElementPtr` IR
instruction, so it should be able to evaluate expression without JIT.

Follow up to https://reviews.llvm.org/D113498

Reviewed By: shafik

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

2 years ago[gn build] Port 43c2348c5b92
LLVM GN Syncbot [Mon, 14 Feb 2022 17:55:08 +0000 (17:55 +0000)]
[gn build] Port 43c2348c5b92

2 years ago[memprof] Extend the index prof format to include memory profiles.
Snehasish Kumar [Sat, 12 Feb 2022 00:28:33 +0000 (16:28 -0800)]
[memprof] Extend the index prof format to include memory profiles.

This patch adds support for optional memory profile information to be
included with and indexed profile. The indexed profile header adds a new
field which points to the offset of the memory profile section (if
present) in the indexed profile. For users who do not utilize this
feature the only overhead is a 64-bit offset in the header.

The memory profile section contains (1) profile metadata describing the
information recorded for each entry (2) an on-disk hashtable containing
the profile records indexed via llvm::md5(function_name). We chose to
introduce a separate hash table instead of the existing one since the
indexing for the instrumented fdo hash table is based on a CFG hash
which itself is perturbed by memprof instrumentation.

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

2 years ago[InstrProf] Make the IndexedInstrProf header backwards compatible.
Snehasish Kumar [Thu, 27 Jan 2022 03:35:17 +0000 (19:35 -0800)]
[InstrProf] Make the IndexedInstrProf header backwards compatible.

While the contents of the profile are backwards compatible the header
itself is not. For example, when adding new fields to the header results
in significant issues. This change adds allows for portable
instantiation of the header across indexed format versions.

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

2 years ago[memprof] Introduce a wrapper around MemInfoBlock.
Snehasish Kumar [Wed, 19 Jan 2022 21:26:37 +0000 (13:26 -0800)]
[memprof] Introduce a wrapper around MemInfoBlock.

Use the macro based format to add a wrapper around the MemInfoBlock
when stored in the MemProfRecord. This wrapped block can then be
serialized/deserialized based on a schema specified by a list of enums.

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

2 years ago[memprof] Refactor out the MemInfoBlock into a macro based def.
Snehasish Kumar [Wed, 19 Jan 2022 21:24:28 +0000 (13:24 -0800)]
[memprof] Refactor out the MemInfoBlock into a macro based def.

This patch refactors out the MemInfoBlock definition into a macro based
header which can be included to generate enums, structus and code for
each field recorded by the memprof profiling runtime.

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

2 years ago[ELF][docs] Document "Output section type"
Fangrui Song [Mon, 14 Feb 2022 17:52:20 +0000 (09:52 -0800)]
[ELF][docs] Document "Output section type"

2 years agoRevert "[analyzer] Add failing test case demonstrating buggy taint propagation"
Balazs Benics [Mon, 14 Feb 2022 17:44:30 +0000 (18:44 +0100)]
Revert "[analyzer] Add failing test case demonstrating buggy taint propagation"

This reverts commit 744745ae195f0997e5bfd5aa2de47b9ea156b6a6.

I'm reverting this since this patch caused a build breakage.

https://lab.llvm.org/buildbot/#/builders/91/builds/3818

2 years agoRevert "[analyzer] Fix taint propagation by remembering to the location context"
Balazs Benics [Mon, 14 Feb 2022 17:44:14 +0000 (18:44 +0100)]
Revert "[analyzer] Fix taint propagation by remembering to the location context"

This reverts commit b099e1e562555fbc67e2e0abbc15074e14a85ff1.

I'm reverting this since the head of the patch stack caused a build
breakage.

https://lab.llvm.org/buildbot/#/builders/91/builds/3818

2 years agoRevert "[analyzer] Fix taint rule of fgets and setproctitle_init"
Balazs Benics [Mon, 14 Feb 2022 17:42:50 +0000 (18:42 +0100)]
Revert "[analyzer] Fix taint rule of fgets and setproctitle_init"

This reverts commit bf5963bf19670ea58facdf57492e147c13bb650f.

I'm reverting this since the head of the patch stack caused a build
breakage.

https://lab.llvm.org/buildbot/#/builders/91/builds/3818

2 years ago[mlir][python] Directly implement sequence protocol on Sliceable.
Stella Laurenzo [Mon, 14 Feb 2022 06:49:28 +0000 (22:49 -0800)]
[mlir][python] Directly implement sequence protocol on Sliceable.

* While annoying, this is the only way to get C++ exception handling out of the happy path for normal iteration.
* Implements sq_length and sq_item for the sequence protocol (used for iteration, including list() construction).
* Implements mp_subscript for general use (i.e. foo[1] and foo[1:1]).
* For constructing a `list(op.results)`, this reduces the time from ~4-5us to ~1.5us on my machine (give or take measurement overhead) and eliminates C++ exceptions, which is a worthy goal in itself.
  * Compared to a baseline of similar construction of a three-integer list, which takes 450ns (might just be measuring function call overhead).
  * See issue discussed on the pybind side: https://github.com/pybind/pybind11/issues/2842

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

2 years ago[libc++][nfc] Add TEST_HAS_NO_FILESYSTEM_LIBRARY.
Mark de Wever [Fri, 11 Feb 2022 18:29:53 +0000 (19:29 +0100)]
[libc++][nfc] Add TEST_HAS_NO_FILESYSTEM_LIBRARY.

This avoids using an libc++ internal macro in our tests.

Reviewed By: #libc, philnik, ldionne

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

2 years ago[lldb] Skip TestIOHandlerPythonREPLSigint if *host* is linux
Jonas Devlieghere [Mon, 14 Feb 2022 17:36:21 +0000 (09:36 -0800)]
[lldb] Skip TestIOHandlerPythonREPLSigint if *host* is linux

The current dectorator (@skipIfLinux) will skip the test if the lldb
platform is the linux platform, but the issue is with the OS that lldb
is running on, not the OS that lldb is debugging. Update the decorator
to skip the test if the host is Linux.

Thank you Ted Woodward for pointing this out.

2 years ago[Inliner] Respect noinline call site attribute
Dávid Bolvanský [Mon, 14 Feb 2022 17:35:29 +0000 (18:35 +0100)]
[Inliner] Respect noinline call site attribute

```
always_inline foo() { }

bar () {

noinline foo();
}
```
We should prefer call site attribute over attribute on decl.

Related to https://reviews.llvm.org/D119061

Reviewed By: aeubanks

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

2 years ago[gn build] Port 00cd6c04202a
LLVM GN Syncbot [Mon, 14 Feb 2022 17:28:29 +0000 (17:28 +0000)]
[gn build] Port 00cd6c04202a

2 years ago[Preprocessor] Reduce the memory overhead of `#define` directives (Recommit)
Alex Lorenz [Fri, 11 Feb 2022 21:50:30 +0000 (13:50 -0800)]
[Preprocessor] Reduce the memory overhead of `#define` directives (Recommit)

Recently we observed high memory pressure caused by clang during some parallel builds.
We discovered that we have several projects that have a large number of #define directives
in their TUs (on the order of millions), which caused huge memory consumption in clang due
to a lot of allocations for MacroInfo. We would like to reduce the memory overhead of
clang for a single #define to reduce the memory overhead for these files, to allow us to
reduce the memory pressure on the system during highly parallel builds. This change achieves
that by removing the SmallVector in MacroInfo and instead storing the tokens in an array
allocated using the bump pointer allocator, after all tokens are lexed.

The added unit test with 1000000 #define directives illustrates the problem. Prior to this
change, on arm64 macOS, clang's PP bump pointer allocator allocated 272007616 bytes, and
used roughly 272 bytes per #define. After this change, clang's PP bump pointer allocator
allocates 120002016 bytes, and uses only roughly 120 bytes per #define.

For an example test file that we have internally with 7.8 million #define directives, this
change produces the following improvement on arm64 macOS: Persistent allocation footprint for
this test case file as it's being compiled to LLVM IR went down 22% from 5.28 GB to 4.07 GB
and the total allocations went down 14% from 8.26 GB to 7.05 GB. Furthermore, this change
reduced the total number of allocations made by the system for this clang invocation from
1454853 to 133663, an order of magnitude improvement.

The recommit fixes the LLDB build failure.

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

2 years ago[ELF] Fix dead initialization. NFC
Fangrui Song [Mon, 14 Feb 2022 17:27:42 +0000 (09:27 -0800)]
[ELF] Fix dead initialization. NFC

Reported by scan-build.

2 years ago[mlir][sparse] minor cleanup of include placement
Aart Bik [Sat, 12 Feb 2022 05:18:20 +0000 (21:18 -0800)]
[mlir][sparse] minor cleanup of include placement

Rationale:
empty line between main include for this file
moved include that actually defines code into right section

Note that this revision started as breaking up ops/attrs even more
(for bug https://github.com/llvm/llvm-project/issues/52748), but due
the the connection in Dialect.initalize(), this cannot be split further).
All heavy lifting refactoring was already done by River in previous cleanup.

Reviewed By: bixia

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

2 years ago[InstCombine] Add additional tests requested for D119715
Simon Pilgrim [Mon, 14 Feb 2022 17:12:39 +0000 (17:12 +0000)]
[InstCombine] Add additional tests requested for D119715