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
|
 | clang-tools-extra/docs/clang-tidy/checks/list.rst |
 | clang-tools-extra/docs/ReleaseNotes.rst |
 | clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.cpp |
 | clang-tools-extra/clang-tidy/performance/CMakeLists.txt |
 | clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp |
 | clang-tools-extra/test/clang-tidy/checkers/performance-no-int-to-ptr.cpp |
 | clang-tools-extra/docs/clang-tidy/checks/performance-no-int-to-ptr.rst |
 | clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.h |
 | clang-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
|
 | flang/lib/Semantics/check-acc-structure.h |
 | flang/test/Semantics/acc-clause-validity.f90 |
 | flang/lib/Semantics/check-acc-structure.cpp |
Commit
bf14979e34bf8e855eb2cae19a971a4e77bf30b7
by llvmgnsyncbot[gn build] Port 1821265db68
|
 | llvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn |
Commit
abd80ac9b83c09b98b6b0bb3f2d4630d37e070ef
by llvmgnsyncbot[gn build] Port 39431e479ff
|
 | llvm/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
|
 | llvm/lib/Target/RISCV/RISCVInstrInfoB.td |
 | llvm/test/CodeGen/RISCV/rv32Zbt.ll |
 | llvm/test/CodeGen/RISCV/rv32Zbs.ll |
 | llvm/test/CodeGen/RISCV/rv64Zbb.ll |
 | llvm/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
|
 | llvm/lib/Target/AMDGPU/SIInstrInfo.cpp |
 | llvm/test/CodeGen/AMDGPU/indirect-addressing-si-gfx9.ll |
 | llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp |
 | llvm/test/CodeGen/AMDGPU/indirect-addressing-si.ll |
 | llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-extract-vector-elt.mir |
 | llvm/test/CodeGen/AMDGPU/indirect-addressing-term.ll |
 | llvm/lib/Target/AMDGPU/SIInstrInfo.h |
 | llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp |
 | llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-insert-vector-elt.mir |
 | llvm/lib/Target/AMDGPU/SIISelLowering.cpp |
 | llvm/lib/Target/AMDGPU/SIInstructions.td |
 | llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.i128.ll |
 | llvm/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
|
 | clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp |
 | clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp |
 | clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp |
 | clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp |
 | clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp |
 | clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp |
 | clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp |
 | clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp |
 | clang-tools-extra/clang-tidy/ClangTidyCheck.h |
 | clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp |
 | clang-tools-extra/clang-tidy/ClangTidyCheck.cpp |
 | clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h |
 | clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp |
 | clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp |
 | clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp |
Commit
3e46b3a1880ce919dfafa012984fd3b44e978a2e
by Louis Dionne[libc++] NFC: Indent feature-test macro script consistently
|
 | libcxx/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.
|
 | libcxx/include/version |
 | libcxx/utils/generate_feature_test_macro_components.py |
 | libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp |
 | libcxx/docs/FeatureTestMacroTable.rst |
 | libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp |
Commit
51f3432f4b5217b35dc2694c6e46d6cfc7defad6
by Duncan P. N. Exon SmithFrontend: 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
|
 | clang/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
|
 | llvm/lib/Target/X86/X86ISelLowering.cpp |
 | llvm/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
|
 | llvm/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
|
 | clang/docs/ReleaseNotes.rst |
 | clang/test/Driver/split-debug.c |
 | clang/lib/Driver/ToolChains/Clang.cpp |
Commit
939c8f676c871682dba8bab25ee4c0c08faf98e1
by Saleem AbdulrasoolBitcode: 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
|
 | llvm/include/llvm/Bitcode/BitcodeConvenience.h |
Commit
b13f74151137f33327e0549adc9778aebf98a299
by Saleem AbdulrasoolAPINotes: 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
|
 | clang/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
|
 | libc/test/src/fenv/CMakeLists.txt |
 | libc/cmake/modules/LLVMLibCTestRules.cmake |
 | libc/utils/FPUtil/x86_64/FEnv.h |
 | libc/test/src/fenv/exception_status_test.cpp |
 | libc/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
|
 | clang/include/clang/Driver/Options.td |
 | clang/test/Driver/split-debug.c |
 | clang/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
|
 | llvm/lib/Target/VE/LVLGen.cpp |
 | llvm/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
|
 | llvm/tools/opt/opt.cpp |