SuccessChanges

Summary

  1. [flang] Better C_LOC and C_ASSOCIATED in flang/module (details)
  2. [CUDA] Normalize handling of defauled dtor. (details)
  3. [OpenMP] Fix failing test due to change in offloading flags (details)
  4. X86: Fix use-after-realloc in X86AsmParser::ParseIntelExpression (details)
  5. [FunctionAttrs] Infer willreturn for functions without loops (details)
  6. [ELF] report section sizes when output file too large (details)
  7. [SLP] simplify reduction matching (details)
  8. Recommit "[RISCV] Legalize select when Zbt extension available" (details)
  9. ADT: Fix reference invalidation in SmallVector::emplace_back and assign(N,V) (details)
Commit a75840a09c65582e3ec4eb1654bd17386b71397d by pklausler
[flang] Better C_LOC and C_ASSOCIATED in flang/module

The place-holding implementation of C_LOC just didn't work
when used with our more complete semantic checking, specifically
in the case of a polymorphic argument; convert it to an external
function with an implicit interface.  C_ASSOCIATED needs to be
a generic interface with specific implementations for C_PTR and
C_FUNPTR.

Differential Revision: https://reviews.llvm.org/D94714
The file was modifiedflang/module/iso_c_binding.f90
The file was modifiedflang/module/__fortran_builtins.f90
Commit 127091bfd5edf10495fee4724fd21c666e5d79c1 by tra
[CUDA] Normalize handling of defauled dtor.

Defaulted destructor was treated inconsistently, compared to other
compiler-generated functions.

When Sema::IdentifyCUDATarget() got called on just-created dtor which didn't
have implicit __host__ __device__ attributes applied yet, it would treat it as a
host function.  That happened to (sometimes) hide the error when dtor referred
to a host-only functions.

Even when we had identified defaulted dtor as a HD function, we still treated it
inconsistently during selection of usual deallocators, where we did not allow
referring to wrong-side functions, while it is allowed for other HD functions.

This change brings handling of defaulted dtors in line with other HD functions.

Differential Revision: https://reviews.llvm.org/D94732
The file was modifiedclang/lib/Sema/SemaExprCXX.cpp
The file was modifiedclang/test/SemaCUDA/usual-deallocators.cu
The file was modifiedclang/test/CodeGenCUDA/usual-deallocators.cu
The file was modifiedclang/lib/Sema/SemaCUDA.cpp
Commit 119a9ea13f9f2e5fe78125bc3f9a76ebf85d3270 by huberjn
[OpenMP] Fix failing test due to change in offloading flags

Summary:
Prior to D91261 the information checked the OMP_MAP_TARGET_PARAM flag, change this as it has been removed. The INFO macro was changed to accept a flag as input to make conditionally printing information easier.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D95133
The file was modifiedopenmp/libomptarget/include/Debug.h
The file was modifiedopenmp/libomptarget/src/device.cpp
The file was modifiedopenmp/libomptarget/src/private.h
The file was modifiedopenmp/libomptarget/plugins/cuda/src/rtl.cpp
Commit f2fd41d7897e1cc8fc6e9fb2ea46e5b6527852e4 by Duncan P. N. Exon Smith
X86: Fix use-after-realloc in X86AsmParser::ParseIntelExpression

`X86AsmParser::ParseIntelExpression` has a while loop. In the body,
calls to MCAsmLexer::UnLex can force a reallocation in the MCAsmLexer's
`CurToken` SmallVector, invalidating saved references to
`MCAsmLexer::getTok()`.

`const MCAsmToken &Tok` is such a saved reference, and this moves it
from outside the while loop to inside the body, fixing a
use-after-realloc.

`Tok` will still be reused across calls to `Lex()`, each of which
effectively destroys and constructs the pointed-to token. I'm a bit
skeptical of this usage pattern, but it seems broadly used in the
X86AsmParser (and others) so I'm leaving it alone (for now).

Somehow this bug was exposed by https://reviews.llvm.org/D94739,
resulting in test failures in dot-operator related tests in
llvm/test/tools/llvm-ml. I suspect the exposure path is related to
optimizer changes from splitting up the grow operation, but I haven't
dug all the way in. Regardless, there are already tests in tree that
cover this; they might fail consistently if we added ASan
instrumentation to SmallVector.

Differential Revision: https://reviews.llvm.org/D95112
The file was modifiedllvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Commit 65fd034b95d69fa0e634861ee165b502ceb92a12 by nikita.ppv
[FunctionAttrs] Infer willreturn for functions without loops

If a function doesn't contain loops and does not call non-willreturn
functions, then it is willreturn. Loops are detected by checking
for backedges in the function. We don't attempt to handle finite
loops at this point.

Differential Revision: https://reviews.llvm.org/D94633
The file was modifiedclang/test/CodeGenOpenCL/convergent.cl
The file was modifiedllvm/test/CodeGen/AMDGPU/inline-attr.ll
The file was modifiedllvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
The file was modifiedllvm/test/Transforms/FunctionAttrs/optnone.ll
The file was modifiedllvm/test/Transforms/FunctionAttrs/nofree.ll
The file was modifiedllvm/lib/Transforms/IPO/FunctionAttrs.cpp
The file was modifiedllvm/test/Transforms/FunctionAttrs/atomic.ll
The file was modifiedllvm/test/Transforms/FunctionAttrs/willreturn.ll
The file was modifiedllvm/test/Transforms/FunctionAttrs/incompatible_fn_attrs.ll
The file was modifiedllvm/test/Transforms/FunctionAttrs/writeonly.ll
The file was modifiedllvm/test/Transforms/InferFunctionAttrs/norecurse_debug.ll
Commit 8e0b17931530e84f45586e31b58b031d6d68ee6c by llvm
[ELF] report section sizes when output file too large

Fixes PR48523. When the linker errors with "output file too large",
one question that comes to mind is how the section sizes differ from
what they were previously. Unfortunately, this information is lost
when the linker exits without writing the output file. This change
makes it so that the error message includes the sizes of the largest
sections.

Reviewed By: MaskRay, grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D94560
The file was modifiedlld/test/ELF/linkerscript/output-too-large.s
The file was modifiedlld/ELF/Writer.cpp
Commit d77753381fe024434ae8ffaaacfe4b9ed9d4d760 by spatel
[SLP] simplify reduction matching

This is NFC-intended and removes the "OperationData"
class which had become nothing more than a recurrence
(reduction) type.

I adjusted the matching logic to distinguish
instructions from non-instructions - that's all that
the "IsLeafValue" member was keeping track of.
The file was modifiedllvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Commit 4ab0f51a7518332b8b7691915b5fdad4c1ed045f by craig.topper
Recommit "[RISCV] Legalize select when Zbt extension available"

This recommits 71ed4b6ce57d8843ef705af8f98305976a8f107a with
the polarity of some of the pattern corrected.

Original commit message:
The custom expansion of select operations in the RISC-V backend
interferes with the matching of cmov instructions. Legalizing
select when the Zbt extension is available solves that problem.

Reviewed By: luismarques, craig.topper

Differential Revision: https://reviews.llvm.org/D93767
The file was modifiedllvm/test/CodeGen/RISCV/rv64Zbt.ll
The file was modifiedllvm/test/CodeGen/RISCV/select-cc.ll
The file was modifiedllvm/test/CodeGen/RISCV/select-optimize-multiple.ll
The file was modifiedllvm/test/CodeGen/RISCV/rv32Zbbp.ll
The file was modifiedllvm/test/CodeGen/RISCV/select-or.ll
The file was modifiedllvm/test/CodeGen/RISCV/rv32Zbb.ll
The file was modifiedllvm/lib/Target/RISCV/RISCVInstrInfoB.td
The file was modifiedllvm/lib/Target/RISCV/RISCVISelLowering.cpp
The file was modifiedllvm/test/CodeGen/RISCV/rv32Zbt.ll
The file was modifiedllvm/test/CodeGen/RISCV/select-bare.ll
The file was modifiedllvm/test/CodeGen/RISCV/select-const.ll
The file was modifiedllvm/test/CodeGen/RISCV/rv32Zbs.ll
The file was modifiedllvm/test/CodeGen/RISCV/select-and.ll
Commit d7ff0036463fbf049a240fe3792fcfcd8081c41e by Duncan P. N. Exon Smith
ADT: Fix reference invalidation in SmallVector::emplace_back and assign(N,V)

This fixes the final (I think?) reference invalidation in `SmallVector`
that we need to fix to align with `std::vector`. (There is still some
left in the range insert / append / assign, but the standard calls that
UB for `std::vector` so I think we don't care?)

For POD-like types, reimplement `emplace_back()` in terms of
`push_back()`, taking a copy even for large `T` rather than lose the
realloc optimization in `grow_pod()`.

For other types, split the grow operation in three and construct the new
element in the middle.

- `mallocForGrow()` calculates the new capacity and returns the result
  of `safe_malloc()`. We only need a single definition per
  `SmallVectorBase` so this is defined in SmallVector.cpp to avoid code
  size bloat. Moving this part of non-POD grow to the source file also
  allows the logic to be easily shared with `grow_pod`, and
  `report_size_overflow()` and `report_at_maximum_capacity()` can move
  there too.
- `moveElementsForGrow()` moves elements from the old to the new
  allocation.
- `takeAllocationForGrow()` frees the old allocation and saves the
  new allocation and capacity .

`SmallVector:assign(size_type, const T&)` also uses the split-grow
operations for non-POD, but it also has a semantic change when not
growing. Previously, assign would start with `clear()`, and so the old
elements were destructed and all elements of the new vector were
copy-constructed (potentially invalidating references). The new
implementation skips destruction and uses copy-assignment for the prefix
of the new vector that fits. The new semantics match what libc++ does
for `std::vector::assign()`.

Note that the following is another possible implementation:
```
  void assign(size_type NumElts, ValueParamT Elt) {
    std::fill_n(this->begin(), std::min(NumElts, this->size()), Elt);
    this->resize(NumElts, Elt);
  }
```
The downside of this simpler implementation is that if the vector has to
grow there will be `size()` redundant copy operations.

(I had planned on splitting this patch up into three for committing
(after getting performance numbers / initial review), but I've realized
that if this does for some reason need to be reverted we'll probably
want to revert the whole package...)

Differential Revision: https://reviews.llvm.org/D94739
The file was modifiedllvm/lib/Support/SmallVector.cpp
The file was modifiedllvm/unittests/ADT/SmallVectorTest.cpp
The file was modifiedllvm/include/llvm/ADT/SmallVector.h