SuccessChanges

Summary

  1. adds more checks to -Wfree-nonheap-object (details)
  2. [mlir] Mark OpState::getAttrs() deprecated. (details)
  3. [libc++] Fix incorrect forwarding in tuple's assignment operator (details)
  4. [SanitizerCoverage] Drop !associated on metadata sections (details)
  5. Add a nullptr check. (details)
  6. [Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option. (details)
  7. [Clang][ASan] Teach Clang to not emit ASan module destructors when compiling with `-mkernel` or `-fapple-kext`. (details)
Commit 4f395db86b5cc11bb56853323d3cb1d4b6db5a0b by cjdb
adds more checks to -Wfree-nonheap-object

This commit adds checks for the following:

* labels
* block expressions
* random integers cast to `void*`
* function pointers cast to `void*`

Differential Revision: https://reviews.llvm.org/D94640
The file was modifiedclang/test/Analysis/weak-functions.c (diff)
The file was modifiedclang/test/Analysis/malloc-fnptr-plist.c (diff)
The file was modifiedclang/test/Analysis/malloc.c (diff)
The file was modifiedclang/include/clang/Basic/DiagnosticSemaKinds.td (diff)
The file was modifiedclang/lib/Sema/SemaChecking.cpp (diff)
The file was modifiedclang/test/Analysis/free.c (diff)
The file was addedclang/test/Analysis/free.cpp
Commit 8c074cb0b74e14ab1135d09cb53daf1a09602f73 by csigg
[mlir] Mark OpState::getAttrs() deprecated.

Fix call sites.

The method will be removed 2 weeks later.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D97464
The file was modifiedflang/include/flang/Optimizer/Dialect/FIROps.td (diff)
The file was modifiedmlir/lib/Dialect/Vector/VectorOps.cpp (diff)
The file was modifiedmlir/lib/Dialect/GPU/IR/GPUDialect.cpp (diff)
The file was modifiedmlir/examples/toy/Ch2/mlir/Dialect.cpp (diff)
The file was modifiedmlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp (diff)
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp (diff)
The file was modifiedmlir/lib/Dialect/SCF/SCF.cpp (diff)
The file was modifiedmlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (diff)
The file was modifiedmlir/lib/Dialect/Affine/IR/AffineOps.cpp (diff)
The file was modifiedmlir/examples/toy/Ch7/mlir/Dialect.cpp (diff)
The file was modifiedmlir/lib/Dialect/StandardOps/IR/Ops.cpp (diff)
The file was modifiedmlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp (diff)
The file was modifiedmlir/include/mlir/IR/OpDefinition.h (diff)
The file was modifiedmlir/lib/Dialect/Shape/IR/Shape.cpp (diff)
The file was modifiedmlir/lib/Dialect/OpenACC/IR/OpenACC.cpp (diff)
The file was modifiedmlir/lib/IR/BuiltinDialect.cpp (diff)
The file was modifiedmlir/lib/Dialect/Linalg/IR/LinalgOps.cpp (diff)
The file was modifiedmlir/lib/Dialect/PDL/IR/PDL.cpp (diff)
The file was modifiedmlir/lib/Dialect/Async/IR/Async.cpp (diff)
Commit 618862e89a022b2e8f73a62bed7c91654060dbab by Louis Dionne
[libc++] Fix incorrect forwarding in tuple's assignment operator

Also, add a bunch of tests for tuple and pair's assignment operators
involving reference types.

Differential Revision: https://reviews.llvm.org/D97419
The file was modifiedlibcxx/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp (diff)
The file was modifiedlibcxx/include/tuple (diff)
The file was modifiedlibcxx/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp (diff)
The file was modifiedlibcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp (diff)
The file was modifiedlibcxx/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp (diff)
The file was modifiedlibcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp (diff)
The file was modifiedlibcxx/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp (diff)
The file was modifiedlibcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp (diff)
Commit 4d63892acb17ba8ee5b146e83d38f244d8d92222 by i
[SanitizerCoverage] Drop !associated on metadata sections

In SanitizerCoverage, the metadata sections (`__sancov_guards`,
`__sancov_cntrs`, `__sancov_bools`) are referenced by functions.  After
inlining, such a `__sancov_*` section can be referenced by more than one
functions, but its sh_link still refers to the original function's section.
(Note: a SHF_LINK_ORDER section referenced by a section other than its linked-to
section violates the invariant.)

If the original function's section is discarded (e.g. LTO internalization +
`ld.lld --gc-sections`), ld.lld may report a `sh_link points to discarded section` error.

This above reasoning means that `!associated` is not appropriate to be called by
an inlinable function. Non-interposable functions are inline candidates, so we
have to drop `!associated`. A `__sancov_pcs` is not referenced by other sections
but is expected to parallel a metadata section, so we have to make sure the two
sections are retained or discarded at the same time. A section group does the
trick.  (Note: we have a module ctor, so `getUniqueModuleId` guarantees to
return a non-empty string, and `GetOrCreateFunctionComdat` guarantees to return
non-null.)

For interposable functions, we could keep using `!associated`, but
LTO can change the linkage to `internal` and allow such functions to be inlinable,
so we have to drop `!associated`, too. To not interfere with section
group resolution, we need to use the `noduplicates` variant (section group flag 0).
(This allows us to get rid of the ModuleID parameter.)
In -fno-pie and -fpie code (mostly dso_local), instrumented interposable
functions have WeakAny/LinkOnceAny linkages, which are rare. So the
section group header overload should be low.

This patch does not change the object file output for COFF (where `!associated` is ignored).

Reviewed By: morehouse, rnk, vitalybuka

Differential Revision: https://reviews.llvm.org/D97430
The file was modifiedllvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard.ll (diff)
The file was modifiedllvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll (diff)
The file was addedllvm/test/Instrumentation/SanitizerCoverage/interposable-symbol.ll
The file was modifiedllvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (diff)
The file was modifiedllvm/lib/Transforms/Instrumentation/Instrumentation.cpp (diff)
The file was removedllvm/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll
The file was modifiedllvm/include/llvm/Transforms/Instrumentation.h (diff)
The file was modifiedllvm/lib/Transforms/IPO/SampleProfileProbe.cpp (diff)
Commit 169318088406510ce6816e6b022502a532b86d4b by Adrian Prantl
Add a nullptr check.

This doesn't actually reproduce with a dbg.declare(i8* null, ...)
which produces a non-null null Value, but I have seen this show up in
crash logs. I'm suspecting that there may be another pass forcibly
setting the operand to a nullptr.
The file was modifiedllvm/lib/Transforms/Coroutines/CoroFrame.cpp (diff)
The file was modifiedllvm/test/Transforms/Coroutines/coro-debug.ll (diff)
Commit 5d64dd8e3c22e12e4f7b3d08ffe88fc41e727117 by Dan Liew
[Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option.

The new `-fsanitize-address-destructor-kind=` option allows control over how module
destructors are emitted by ASan.

The new option is consumed by both the driver and the frontend and is propagated into
codegen options by the frontend.

Both the legacy and new pass manager code have been updated to consume the new option
from the codegen options.

It would be nice if the new utility functions (`AsanDtorKindToString` and
`AsanDtorKindFromString`) could live in LLVM instead of Clang so they could be
consumed by other language frontends. Unfortunately that doesn't work because
the clang driver doesn't link against the LLVM instrumentation library.

rdar://71609176

Differential Revision: https://reviews.llvm.org/D96572
The file was modifiedclang/lib/Basic/Sanitizers.cpp (diff)
The file was modifiedclang/include/clang/Basic/CodeGenOptions.def (diff)
The file was modifiedclang/lib/Driver/SanitizerArgs.cpp (diff)
The file was modifiedclang/include/clang/Driver/Options.td (diff)
The file was modifiedclang/include/clang/Basic/CodeGenOptions.h (diff)
The file was modifiedclang/lib/Frontend/CompilerInvocation.cpp (diff)
The file was modifiedclang/include/clang/Driver/SanitizerArgs.h (diff)
The file was modifiedclang/docs/ClangCommandLineReference.rst (diff)
The file was modifiedclang/include/clang/Basic/Sanitizers.h (diff)
The file was modifiedclang/lib/CodeGen/BackendUtil.cpp (diff)
The file was addedclang/test/CodeGen/asan-destructor-kind.cpp
The file was addedclang/test/Driver/fsanitize-address-destructor-kind.c
Commit fdce098b49cb038996441741a7b2ab3652502aec by Dan Liew
[Clang][ASan] Teach Clang to not emit ASan module destructors when compiling with `-mkernel` or `-fapple-kext`.

rdar://71609176

Differential Revision: https://reviews.llvm.org/D96573
The file was modifiedclang/lib/Driver/SanitizerArgs.cpp (diff)
The file was addedclang/test/Driver/darwin-asan-mkernel-kext.c