SuccessChanges

Summary

  1. [clang-tidy] Introduce misc No Integer To Pointer Cast check (details)
  2. [flang][openacc] Avoid use of init, shutdown and set in compute construct (details)
  3. [gn build] Port 1821265db68 (details)
  4. [gn build] Port 39431e479ff (details)
  5. [RISCV] Add isel patterns for SBCLRI/SBSETI/SBINVI(W) instruction (details)
  6. [AMDGPU] Add new pseudos for indirect addressing with VGPR Indexing (details)
  7. [clang-tidy] Add support for diagnostics with no location (details)
  8. [libc++] NFC: Indent feature-test macro script consistently (details)
  9. [libc++] Implement missing feature-test macro __cpp_lib_shared_ptr_arrays (details)
  10. Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, almost NFC (details)
  11. [X86] Handle localdynamic TLS model in x32 mode (details)
  12. [AArch64] Fix rottype use in complex instr defs. (details)
  13. [Driver] Don't make -gsplit-dwarf imply -g2 (details)
  14. Bitcode: add some convenience helpers for streaming bitcode (details)
  15. APINotes: add bitcode format schema definitions (details)
  16. [libc] Raise x87 exceptions by synchronizing with "fwait". (details)
  17. [Driver] Add -gno-split-dwarf which can disable debug fission (details)
  18. [VE] Correct LVLGen (LVL instruction insert pass) (details)
  19. [NFC] Rename IsCodeGenPass to ShouldPinPassToLegacyPM (details)
Commit 39431e479ffddc81120911f031921b2d637e967f by lebedev.ri
[clang-tidy] Introduce misc No Integer To Pointer Cast check

While casting an (integral) pointer to an integer is obvious - you just get
the integral value of the pointer, casting an integer to an (integral) pointer
is deceivingly different. While you will get a pointer with that integral value,
if you got that integral value via a pointer-to-integer cast originally,
the new pointer will lack the provenance information from the original pointer.

So while (integral) pointer to integer casts are effectively no-ops,
and are transparent to the optimizer, integer to (integral) pointer casts
are *NOT* transparent, and may conceal information from optimizer.

While that may be the intention, it is not always so. For example,
let's take a look at a routine to align the pointer up to the multiple of 16:
The obvious, naive implementation for that is:

```
  char* src(char* maybe_underbiased_ptr) {
    uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
    uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
    uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
    return (char*)aligned_intptr; // warning: avoid integer to pointer casts [misc-no-inttoptr]
  }
```

The check will rightfully diagnose that cast.

But when provenance concealment is not the goal of the code, but an accident,
this example can be rewritten as follows, without using integer to pointer cast:

```
  char*
  tgt(char* maybe_underbiased_ptr) {
      uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
      uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
      uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
      uintptr_t bias = aligned_intptr - maybe_underbiased_intptr;
      return maybe_underbiased_ptr + bias;
  }
```

See also:
* D71499
* [[ https://www.cs.utah.edu/~regehr/oopsla18.pdf | Juneyoung Lee, Chung-Kil Hur, Ralf Jung, Zhengyang Liu, John Regehr, and Nuno P. Lopes. 2018. Reconciling High-Level Optimizations and Low-Level Code in LLVM. Proc. ACM Program. Lang. 2, OOPSLA, Article 125 (November 2018), 28 pages. ]]

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D91055
The file was modifiedclang-tools-extra/docs/clang-tidy/checks/list.rst
The file was modifiedclang-tools-extra/docs/ReleaseNotes.rst
The file was addedclang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/performance/CMakeLists.txt
The file was modifiedclang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
The file was addedclang-tools-extra/test/clang-tidy/checkers/performance-no-int-to-ptr.cpp
The file was addedclang-tools-extra/docs/clang-tidy/checks/performance-no-int-to-ptr.rst
The file was addedclang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.h
The file was addedclang-tools-extra/test/clang-tidy/checkers/performance-no-int-to-ptr.c
Commit b53115b6c8aa9a107bb80e704b077b253037514f by clementval
[flang][openacc] Avoid use of init, shutdown and set in compute construct

init, shutdown and set directive are not allowed in compute construct.

Reviewed By: SouraVX

Differential Revision: https://reviews.llvm.org/D92443
The file was modifiedflang/lib/Semantics/check-acc-structure.h
The file was modifiedflang/test/Semantics/acc-clause-validity.f90
The file was modifiedflang/lib/Semantics/check-acc-structure.cpp
Commit bf14979e34bf8e855eb2cae19a971a4e77bf30b7 by llvmgnsyncbot
[gn build] Port 1821265db68
The file was modifiedllvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn
Commit abd80ac9b83c09b98b6b0bb3f2d4630d37e070ef by llvmgnsyncbot
[gn build] Port 39431e479ff
The file was modifiedllvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
Commit 98bca0a60574c4276cfc85833fe29d8f4beff7f6 by craig.topper
[RISCV] Add isel patterns for SBCLRI/SBSETI/SBINVI(W) instruction

We can use these instructions for single bit immediates that are too large for ANDI/ORI/CLRI.

The _10 test cases are to make sure that we still use ANDI/ORI/CLRI for small immediates.

Differential Revision: https://reviews.llvm.org/D92262
The file was modifiedllvm/lib/Target/RISCV/RISCVInstrInfoB.td
The file was modifiedllvm/test/CodeGen/RISCV/rv32Zbt.ll
The file was modifiedllvm/test/CodeGen/RISCV/rv32Zbs.ll
The file was modifiedllvm/test/CodeGen/RISCV/rv64Zbb.ll
The file was modifiedllvm/test/CodeGen/RISCV/rv64Zbs.ll
Commit 4aa842a800b53806a9e25f03b4e21f6879801a38 by Austin.Kerbow
[AMDGPU] Add new pseudos for indirect addressing with VGPR Indexing

It is possible for copies or spills to be inserted in the middle of indirect
addressing sequences which use VGPR indexing. Spills to accvgprs could be
effected by the indexing mode.

Add new pseudo instructions that are expanded after register allocation to avoid
the problematic spill or copy placement.

Differential Revision: https://reviews.llvm.org/D91048
The file was modifiedllvm/lib/Target/AMDGPU/SIInstrInfo.cpp
The file was modifiedllvm/test/CodeGen/AMDGPU/indirect-addressing-si-gfx9.ll
The file was modifiedllvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
The file was modifiedllvm/test/CodeGen/AMDGPU/indirect-addressing-si.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-extract-vector-elt.mir
The file was modifiedllvm/test/CodeGen/AMDGPU/indirect-addressing-term.ll
The file was modifiedllvm/lib/Target/AMDGPU/SIInstrInfo.h
The file was modifiedllvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
The file was modifiedllvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-insert-vector-elt.mir
The file was modifiedllvm/lib/Target/AMDGPU/SIISelLowering.cpp
The file was modifiedllvm/lib/Target/AMDGPU/SIInstructions.td
The file was modifiedllvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.i128.ll
The file was addedllvm/test/CodeGen/AMDGPU/expand-si-indirect.mir
Commit 27553933a8693d508eb7f7c24a14f66b3d006d2c by n.james93
[clang-tidy] Add support for diagnostics with no location

Add methods for emitting diagnostics with no location as well as a special diagnostic for configuration errors.
These show up in the errors as [clang-tidy-config].
The reason to use a custom name rather than the check name is to distinguish the error isn't the same category as the check that reported it.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D91885
The file was modifiedclang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
The file was modifiedclang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/ClangTidyCheck.h
The file was modifiedclang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/ClangTidyCheck.cpp
The file was modifiedclang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
The file was modifiedclang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
The file was modifiedclang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
The file was modifiedclang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
Commit 3e46b3a1880ce919dfafa012984fd3b44e978a2e by Louis Dionne
[libc++] NFC: Indent feature-test macro script consistently
The file was modifiedlibcxx/utils/generate_feature_test_macro_components.py
Commit a65dc08d105e147c98ef17a47b9504210f6058c5 by Louis Dionne
[libc++] Implement missing feature-test macro __cpp_lib_shared_ptr_arrays

This was forgotten when we implemented support for arrays in std::shared_ptr
in https://reviews.llvm.org/D62259.
The file was modifiedlibcxx/include/version
The file was modifiedlibcxx/utils/generate_feature_test_macro_components.py
The file was modifiedlibcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
The file was modifiedlibcxx/docs/FeatureTestMacroTable.rst
The file was modifiedlibcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
Commit 51f3432f4b5217b35dc2694c6e46d6cfc7defad6 by Duncan P. N. Exon Smith
Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, almost NFC

Clarify the logic for using the preamble (and overriding the main file
buffer) in `ASTUnit::CodeComplete` by factoring out a couple of lambdas
(`getUniqueID` and `hasSameUniqueID`).  While refactoring the logic,
hoist the check for `Line > 1` and locally check if the filenames are
equal (both to avoid unnecessary `stat` calls) and skip copying out the
filenames to `std::string`.

Besides fewer calls to `stat`, there's no functionality change here.

Differential Revision: https://reviews.llvm.org/D91296
The file was modifiedclang/lib/Frontend/ASTUnit.cpp
Commit 29c8ea6f1abd6606b65dafd3db8f15c8104c2593 by harald
[X86] Handle localdynamic TLS model in x32 mode

D92346 added TLS_(base_)addrX32 to handle TLS in x32 mode, but missed the
different TLS models. This diff fixes the logic for the local dynamic model
where `RAX` was used when `EAX` should be, and extends the tests to cover
all four TLS models.

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

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D92737
The file was modifiedllvm/lib/Target/X86/X86ISelLowering.cpp
The file was modifiedllvm/test/CodeGen/X86/pic.ll
Commit 4c69b1b98a9aeda363c7126a0cfa6e2e88e593c5 by flo
[AArch64] Fix rottype use in complex instr defs.

It seems like the order here is wrong. Types like i32 do not take any
arguments.

Currently this is not a problem, because the patterns are not actually
used with any nodes, but will fail once it is used with real ISD nodes.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D91345
The file was modifiedllvm/lib/Target/AArch64/AArch64InstrFormats.td
Commit 843f2dbf003f2a51d0d4ab8cf40647c99ded2e93 by i
[Driver] Don't make -gsplit-dwarf imply -g2

RFC: http://lists.llvm.org/pipermail/cfe-dev/2020-May/065430.html
Agreement from GCC: https://sourceware.org/pipermail/gcc-patches/2020-May/545688.html

g_flags_Group options generally don't affect the amount of debugging
information. -gsplit-dwarf is an exception. Its order dependency with
other gN_Group options make it inconvenient in a build system:

* -g0 -gsplit-dwarf -> level 2
   -gsplit-dwarf "upgrades" the amount of debugging information despite
   the previous intention (-g0) to drop debugging information
* -g1 -gsplit-dwarf -> level 2
  -gsplit-dwarf "upgrades" the amount of debugging information.
* If we have a higher-level -gN, -gN -gsplit-dwarf will supposedly decrease the
  amount of debugging information. This happens with GCC -g3.

The non-orthogonality has confused many users. GCC 11 will change the semantics
(-gsplit-dwarf no longer implies -g2) despite the backwards compatibility break.
This patch matches its behavior.

New semantics:

* If there is a g_Group, allow split DWARF if useful
  (none of: -g0, -gline-directives-only, -g1 -fno-split-dwarf-inlining)
* Otherwise, no-op.

To restore the original behavior, replace -gsplit-dwarf with -gsplit-dwarf -g.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D80391
The file was modifiedclang/docs/ReleaseNotes.rst
The file was modifiedclang/test/Driver/split-debug.c
The file was modifiedclang/lib/Driver/ToolChains/Clang.cpp
Commit 939c8f676c871682dba8bab25ee4c0c08faf98e1 by Saleem Abdulrasool
Bitcode: add some convenience helpers for streaming bitcode

This adds a set of metaprogramming helpers to help define records and
serialize them out.  This is motivated by API Notes which use the
bitcode format to serialize out a binary representation of the data.
These helpers are generically useful though and could help simplify some
of the existing bitcode consumers as well.

This is extracted from the code contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.

Differential Revision: https://reviews.llvm.org/D88582
The file was addedllvm/include/llvm/Bitcode/BitcodeConvenience.h
Commit b13f74151137f33327e0549adc9778aebf98a299 by Saleem Abdulrasool
APINotes: add bitcode format schema definitions

This adds the bitcode format schema required for serialization of the
YAML data to a binary format.  APINotes are pre-compiled and re-used in
the binary format from the frontend.  These definitions provide the data
layout representation enabling writing (and eventually) reading of the
data in bitcode format.

This is extracted from the code contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.

Differential Revision: https://reviews.llvm.org/D91997
Reviewed By: Gabor Marton
The file was addedclang/lib/APINotes/APINotesFormat.h
Commit ab3cbe4bc0d952ca58a3e2263629591ef898de3f by sivachandra
[libc] Raise x87 exceptions by synchronizing with "fwait".

Couple of helper functions enableExcept and disableExcept have been
added. In a later round, they will be used to implemented the GNU
extension functions feenableexcept and fedisableexcept.

Differential Revision: https://reviews.llvm.org/D92821
The file was modifiedlibc/test/src/fenv/CMakeLists.txt
The file was modifiedlibc/cmake/modules/LLVMLibCTestRules.cmake
The file was modifiedlibc/utils/FPUtil/x86_64/FEnv.h
The file was modifiedlibc/test/src/fenv/exception_status_test.cpp
The file was addedlibc/test/src/fenv/enabled_exceptions_test.cpp
Commit 85c18d3521e87a22c742be512245665d6bb5bfe2 by i
[Driver] Add -gno-split-dwarf which can disable debug fission

Currently when -gsplit-dwarf is specified (could be buried in a build system),
there is no convenient way to cancel debug fission without affecting the debug
information amount (all of -g0, -g1 -fsplit-dwarf-inlining and -gline-directives-only
can, but they affect the debug information amount).

Reviewed By: #debug-info, dblaikie

Differential Revision: https://reviews.llvm.org/D92809
The file was modifiedclang/include/clang/Driver/Options.td
The file was modifiedclang/test/Driver/split-debug.c
The file was modifiedclang/lib/Driver/ToolChains/Clang.cpp
Commit 95ea50e4adf76b75fcc0ad29cacd10642db091a6 by marukawa
[VE] Correct LVLGen (LVL instruction insert pass)

SX Aurora VE uses an intermediate representation similar to VP as its MIR.
VE itself uses invidiual VL register as its own vector length register at
the hardware level.  So, LLVM needs to insert load VL (LVL) instruction just
before vector instructions if the value of VL is changed.  This LVLGen pass
generates LVL instructions for such purpose.  Previously, a bug is pointed
out in D91416.  This patch correct this bug and add a regression test.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D92716
The file was modifiedllvm/lib/Target/VE/LVLGen.cpp
The file was modifiedllvm/test/CodeGen/VE/VELIntrinsics/lvlgen.ll
Commit eca13e995c6428e11f0d402641a74c9fe26f124c by aeubanks
[NFC] Rename IsCodeGenPass to ShouldPinPassToLegacyPM

Codegen-specific passes are being ported to the NPM. Rename for better
clarity and note that ported passes that fully work with the NPM should
be removed from these lists.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D92818
The file was modifiedllvm/tools/opt/opt.cpp