platform/upstream/llvm.git
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

2 years ago[libc][cpp] Add a constructor to ArrayRef to construct from void * data.
Siva Chandra Reddy [Sat, 12 Feb 2022 05:51:06 +0000 (05:51 +0000)]
[libc][cpp] Add a constructor to ArrayRef to construct from void * data.

Also modified operator[] to return a reference to the array element.

Reviewed By: lntue

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

2 years ago[Systemz/z/OS] Centralize emitting the call type information
Kai Nacke [Mon, 14 Feb 2022 16:17:56 +0000 (11:17 -0500)]
[Systemz/z/OS] Centralize emitting the call type information

With XPLINK, a no-op with information about the call type is emitted
after each call instruction. Centralizing it has the advantage that it is
easy to document all cases, and it makes it easier to extend it later
(e.g. dynamic stack allocation, 32 bit mode).
Also add a test checking the call types emitted so far.

Reviewed By: uweigand

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

2 years ago[FPEnv][InstSimplify] Fold fsub X, +0 ==> X
Kevin P. Neal [Mon, 14 Feb 2022 16:54:54 +0000 (11:54 -0500)]
[FPEnv][InstSimplify] Fold fsub X, +0 ==> X

Currently the fsub optimizations in InstSimplify don't know how to fold X
- +0.0 to X when using the constrained intrinsics. This adds the support.

This review is split out from D107285.

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

2 years ago[mlir][emitc] Add a pointer type
Marius Brehler [Wed, 9 Feb 2022 14:31:39 +0000 (14:31 +0000)]
[mlir][emitc] Add a pointer type

Adds a pointer type to EmitC. The emission of pointers is so far only
possible by using the `emitc.opaque` type

Co-authored-by: Simon Camphausen <simon.camphausen@iml.fraunhofer.de>
Reviewed By: jpienaar

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

2 years ago[lldb] Replace asserts on .Success() with assertSuccess()
Dave Lee [Sat, 12 Feb 2022 05:23:16 +0000 (21:23 -0800)]
[lldb] Replace asserts on .Success() with assertSuccess()

Replace forms of `assertTrue(err.Success())` with `assertSuccess(err)` (added in D82759).

* `assertSuccess` prints out the error's message
* `assertSuccess` expresses explicit higher level semantics, both to the reader and for test failure output
* `assertSuccess` seems not to be well known, using it where possible will help spread knowledge
* `assertSuccess` statements are more succinct

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

2 years ago[clang] Don't emit redundant warnings for 'return;'
Arthur O'Dwyer [Sun, 6 Feb 2022 21:40:28 +0000 (16:40 -0500)]
[clang] Don't emit redundant warnings for 'return;'

when the function declaration's return type is already invalid for
some reason. This is relevant to https://github.com/llvm/llvm-project/issues/49188
because another way that the declaration's return type could become
invalid is that it might be `C auto` where `C<void>` is false.

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

2 years ago[clang] [test] Fix an apparent typo in SemaCXX/consteval-return-void.cpp.
Arthur O'Dwyer [Mon, 7 Feb 2022 17:12:39 +0000 (12:12 -0500)]
[clang] [test] Fix an apparent typo in SemaCXX/consteval-return-void.cpp.

Reviewed as part of D119094.

2 years ago[libc++] [NFC] s/geenrally/generally/
Arthur O'Dwyer [Mon, 14 Feb 2022 16:27:06 +0000 (11:27 -0500)]
[libc++] [NFC] s/geenrally/generally/

2 years agoFix test failure for targets with varying uwtable defaults
Momchil Velikov [Mon, 14 Feb 2022 15:50:53 +0000 (15:50 +0000)]
Fix test failure for targets with varying uwtable defaults

Depending on toolchain and ABI, a target might not output DWARF unwind tables by default.
Run the test for a target with a known behaviour, test coverage is not reduced.

Reviewed By: dmgreen

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

2 years ago[libc++] [NFC] Fix a typo in Cxx2bIssues.csv
Igor Zhukov [Mon, 14 Feb 2022 15:57:45 +0000 (10:57 -0500)]
[libc++] [NFC] Fix a typo in Cxx2bIssues.csv

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

2 years ago[analyzer] Fix taint rule of fgets and setproctitle_init
Balazs Benics [Mon, 14 Feb 2022 15:55:55 +0000 (16:55 +0100)]
[analyzer] Fix taint rule of fgets and setproctitle_init

There was a typo in the rule.
`{{0}, ReturnValueIndex}` meant that the discrete index is `0` and the
variadic index is `-1`.
What we wanted instead is that both `0` and `-1` are in the discrete index
list.

Instead of this, we wanted to express that both `0` and the
`ReturnValueIndex` is in the discrete arg list.

The manual inspection revealed that `setproctitle_init` also suffered a
probably incomplete propagation rule.

Reviewed By: Szelethus, gamesh411

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

2 years ago[analyzer] Fix taint propagation by remembering to the location context
Balazs Benics [Mon, 14 Feb 2022 15:55:55 +0000 (16:55 +0100)]
[analyzer] Fix taint propagation by remembering to the location context

Fixes the issue D118987 by mapping the propagation to the callsite's
LocationContext.
This way we can keep track of the in-flight propagations.

Note that empty propagation sets won't be inserted.

Reviewed By: NoQ, Szelethus

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

2 years ago[analyzer] Add failing test case demonstrating buggy taint propagation
Balazs Benics [Mon, 14 Feb 2022 15:55:55 +0000 (16:55 +0100)]
[analyzer] Add failing test case demonstrating buggy taint propagation

Recently we uncovered a serious bug in the `GenericTaintChecker`.
It was already flawed before D116025, but that was the patch that turned
this silent bug into a crash.

It happens if the `GenericTaintChecker` has a rule for a function, which
also has a definition.

  char *fgets(char *s, int n, FILE *fp) {
    nested_call();   // no parameters!
    return (char *)0;
  }

  // Within some function:
  fgets(..., tainted_fd);

When the engine inlines the definition and finds a function call within
that, the `PostCall` event for the call will get triggered sooner than the
`PostCall` for the original function.
This mismatch violates the assumption of the `GenericTaintChecker` which
wants to propagate taint information from the `PreCall` event to the
`PostCall` event, where it can actually bind taint to the return value
**of the same call**.

Let's get back to the example and go through step-by-step.
The `GenericTaintChecker` will see the `PreCall<fgets(..., tainted_fd)>`
event, so it would 'remember' that it needs to taint the return value
and the buffer, from the `PostCall` handler, where it has access to the
return value symbol.
However, the engine will inline fgets and the `nested_call()` gets
evaluated subsequently, which produces an unimportant
`PreCall<nested_call()>`, then a `PostCall<nested_call()>` event, which is
observed by the `GenericTaintChecker`, which will unconditionally mark
tainted the 'remembered' arg indexes, trying to access a non-existing
argument, resulting in a crash.
If it doesn't crash, it will behave completely unintuitively, by marking
completely unrelated memory regions tainted, which is even worse.

The resulting assertion is something like this:
  Expr.h: const Expr *CallExpr::getArg(unsigned int) const: Assertion
          `Arg < getNumArgs() && "Arg access out of range!"' failed.

The gist of the backtrace:
  CallExpr::getArg(unsigned int) const
  SimpleFunctionCall::getArgExpr(unsigned int)
  CallEvent::getArgSVal(unsigned int) const
  GenericTaintChecker::checkPostCall(const CallEvent &, CheckerContext&) const

Prior to D116025, there was a check for the argument count before it
applied taint, however, it still suffered from the same underlying
issue/bug regarding propagation.

This path does not intend to fix the bug, rather start a discussion on
how to fix this.

---

Let me elaborate on how I see this problem.

This pre-call, post-call juggling is just a workaround.
The engine should by itself propagate taint where necessary right where
it invalidates regions.
For the tracked values, which potentially escape, we need to erase the
information we know about them; and this is exactly what is done by
invalidation.
However, in the case of taint, we basically want to approximate from the
opposite side of the spectrum.
We want to preserve taint in most cases, rather than cleansing them.

Now, we basically sanitize all escaping tainted regions implicitly,
since invalidation binds a fresh conjured symbol for the given region,
and that has not been associated with taint.

IMO this is a bad default behavior, we should be more aggressive about
preserving taint if not further spreading taint to the reachable
regions.

We have a couple of options for dealing with it (let's call it //tainting
policy//):
  1) Taint only the parameters which were tainted prior to the call.
  2) Taint the return value of the call, since it likely depends on the
     tainted input - if any arguments were tainted.
  3) Taint all escaped regions - (maybe transitively using the cluster
     algorithm) - if any arguments were tainted.
  4) Not taint anything - this is what we do right now :D

The `ExprEngine` should not deal with taint on its own. It should be done
by a checker, such as the `GenericTaintChecker`.
However, the `Pre`-`PostCall` checker callbacks are not designed for this.
`RegionChanges` would be a much better fit for modeling taint propagation.
What we would need in the `RegionChanges` callback is the `State` prior
invalidation, the `State` after the invalidation, and a `CheckerContext` in
which the checker can create transitions, where it would place `NoteTags`
for the modeled taint propagations and report errors if a taint sink
rule gets violated.
In this callback, we could query from the prior State, if the given
value was tainted; then act and taint if necessary according to the
checker's tainting policy.

By using RegionChanges for this, we would 'fix' the mentioned
propagation bug 'by-design'.

Reviewed By: Szelethus

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

2 years ago[libc][benchmark] Fix change in JSon API
Guillaume Chatelet [Mon, 14 Feb 2022 15:55:27 +0000 (15:55 +0000)]
[libc][benchmark] Fix change in JSon API