Skip to content

[TableGen][InstrInfoEmitter] Count sub-operands on def operands #88837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
908c354
[𝘀𝗽𝗿] initial version
darkbuck Apr 16, 2024
891097e
rebase
darkbuck Apr 16, 2024
5a34ff1
fix Polynomial.td doc filename (#88900)
j2kun Apr 16, 2024
b03c1d4
add comment in the lit test and rebase
darkbuck Apr 16, 2024
b632476
[AST][RecoveryExpr] Fix a crash on c89/c90 invalid InitListExpr (#880…
danix800 Apr 16, 2024
d2d4a1b
Revert "[JumpThreading] Thread over BB with only an unconditional bra…
XChy Apr 16, 2024
22629bb
[libc++] Use availability to rely on key functions for bad_expected_a…
ldionne Apr 16, 2024
9ddedf0
[libc++] Deprecate the C++20 synchronization library before C++20 (#8…
ldionne Apr 16, 2024
bd28889
[RISCV] Add coverage for strength reduction of mul 2^N +/- 3/5/9
preames Apr 16, 2024
1334c03
[flang] Fix test after 4078afc6d23e25df6baedad61b224ef86a94d42f
kparzysz Apr 16, 2024
bf1ad1d
[VectorCombine][X86] Add initial shuffle-of-shuffles.ll test cover fo…
RKSimon Apr 16, 2024
f8e2ec1
Revert "Add asan tests for libsanitizers. (#88349)"
adrian-prantl Apr 16, 2024
8cee94e
[RISCV] Fix obvious copy paste error.
hvdijk Apr 16, 2024
51b42b7
Revert "[Sema] Mark alias/ifunc targets used and consider mangled nam…
joker-eph Apr 16, 2024
9d11128
[libclc] Improve clarity of CMake foreach. NFC.
frasercrmck Apr 16, 2024
2704eba
[flang][runtime] Create CUDA PTX OBJECT library target for F18 runtim…
vzakhari Apr 16, 2024
a79783d
[libc][fenv] Use proxy header (#88787)
robincaloudis Apr 16, 2024
38895e6
[libc][fenv] Remove unnecessary dependencies (#88788)
robincaloudis Apr 16, 2024
1c6b0f7
[RemoveDI] Add support for debug records to debugify (#87383)
SLTozer Apr 16, 2024
45eabd1
[flang,test] Add -resource-dir option to msvc-dependent-lib-flags.f90…
wzssyqa Apr 16, 2024
22e6bf7
[unused-includes][Serialization] Remove unused includes. NFC. (#88790)
vsapsai Apr 16, 2024
b566810
[unused-includes] PCHContainerOperations uses MemoryBufferRef, not Me…
vsapsai Apr 16, 2024
454d449
[OpenMP] Use a memory fence before incrementing the dispatch buffer i…
xingxue-ibm Apr 16, 2024
22bba85
[OpenMP][test][AIX] Make 64 the max number of threads for capacity te…
xingxue-ibm Apr 16, 2024
8137bd9
[memprof] Use CSId to construct MemProfRecord (#88362)
kazutakahirata Apr 16, 2024
8cd8ebe
[MLGO] Use double comparison facilities for reg alloc scoring tests (…
boomanaiden154 Apr 16, 2024
7505452
[clang][Interp] Implement VectorSplat casts
tbaederr Apr 16, 2024
184ba03
[RISCV] Avoid matching 3/5/9 * 2^N as 2^N + 2/4/8 (e.g. 24) (#88937)
preames Apr 16, 2024
4082a75
Improve stack usage to increase recursive initialization depth (#88546)
AaronBallman Apr 16, 2024
aefff77
[clang] Migrate DR tests to `static_assert` (#88611)
Endilll Apr 16, 2024
6b83fe5
[RISCV] Strength reduce mul by 2^n + 2/4/8 + 1 (#88911)
preames Apr 16, 2024
1c2afba
[CodeGen,test] Test llvm-libc style alias attribute with UsingShadowDecl
MaskRay Apr 16, 2024
5462b27
[NFC][libc++][TZDB] Refactors argument order. (#85781)
mordante Apr 16, 2024
a75c9d0
[NFC][libc++] Moves ios_base's forward declaration. (#88027)
mordante Apr 16, 2024
9cd3e92
[libc++][modules] Removes some validation quirks. (#88031)
mordante Apr 16, 2024
41a8305
[libc++] Removes deprecated _LIBCPP_ENABLE_<VERSION>_REMOVED_FEATURES…
mordante Apr 16, 2024
388da6a
[libc++][test] Removes Clang 16 validation. (#88558)
mordante Apr 16, 2024
8e0a4a8
[libc++][doc] Documents -DLIBCXX_INSTALL_MODULES=ON. (#88547)
mordante Apr 16, 2024
002297b
[gn] port 22629bb22a1b
nico Apr 16, 2024
8debcf0
[mlir][sparse] introduce sparse_tensor.iterate operation (#88807)
Apr 16, 2024
b955653
Revert "[mlir][sparse] introduce sparse_tensor.iterate operation" (#8…
Apr 16, 2024
481bd5d
[mlir][sparse] introduce `sparse_tensor.extract_iteration_space` oper…
Apr 16, 2024
edb711d
[InstCombine] Update `vector_reduce_and` tests to actually use `llvm.…
goldsteinn Apr 16, 2024
5c6af60
[Clang][Sema] placement new initializes typedef array with correct si…
mahtohappy Apr 16, 2024
b01879e
[MLIR][XeGPU] Add XeGPU scattered ops (#86594)
chencha3 Apr 16, 2024
9ec8c96
[clang][dataflow] Expose getReferencedDecls and relocate free functio…
bazuzi Apr 16, 2024
bbd64c4
[RISCV] Add coverage for strength reduction of mul as 2^N - 2^M
preames Apr 16, 2024
8885813
[libc++][chrono] Disables a test.
mordante Apr 16, 2024
0665669
[Sema] Mark alias/ifunc targets used and consider mangled names
MaskRay Apr 16, 2024
5422eb0
[memprof] Add another constructor to MemProfReader (#88952)
kazutakahirata Apr 16, 2024
c7657cf
[SLP]Keep externally used GEPs as GEPs, if possible instead of extrac…
alexey-bataev Apr 16, 2024
7d4e8c1
[SLP]Attempt to vectorize long stores, if short one failed.
alexey-bataev Apr 16, 2024
3eff86f
[gn build] Port 9ec8c961664d
llvmgnsyncbot Apr 16, 2024
b0ddbfb
[clang][SPIR-V] Set AS for the SPIR-V logical triple (#88939)
bogner Apr 16, 2024
c9731a3
[mlir] Fix a warning about an extraneous semicolon
kazutakahirata Apr 16, 2024
0a789ea
Fix test from #83124 and #88902
erichkeane Apr 16, 2024
9a0a28f
[Libomptarget] Rework Record & Replay to be a plugin member (#88928)
jhuber6 Apr 16, 2024
ed7038e
specify dialect in polynomial docs (#88933)
j2kun Apr 16, 2024
bfdeba4
[𝘀𝗽𝗿] changes introduced through rebase
darkbuck Apr 16, 2024
e9d5d78
split change into target-specific pre-commit and this tablegen change
darkbuck Apr 16, 2024
8bece5c
[𝘀𝗽𝗿] changes introduced through rebase
darkbuck Apr 16, 2024
3eb1b4c
split and rebase
darkbuck Apr 16, 2024
dbe87e2
[𝘀𝗽𝗿] changes introduced through rebase
darkbuck Apr 16, 2024
4a8e596
rebase
darkbuck Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ Non-comprehensive list of changes in this release
- ``__typeof_unqual__`` is available in all C modes as an extension, which behaves
like ``typeof_unqual`` from C23, similar to ``__typeof__`` and ``typeof``.

- Improved stack usage with C++ initialization code. This allows significantly
more levels of recursive initialization before reaching stack exhaustion
limits. This will positively impact recursive template instantiation code,
but should also reduce memory overhead for initializations in general.
Fixes #GH88330

New Compiler Flags
------------------
- ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
Expand Down Expand Up @@ -417,6 +423,8 @@ Bug Fixes in This Version
- Fixed a regression in CTAD that a friend declaration that befriends itself may cause
incorrect constraint substitution. (#GH86769).

- Fixed an assertion failure on invalid InitListExpr in C89 mode (#GH88008).

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions clang/docs/tools/clang-formatted-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
clang/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h
clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h
clang/include/clang/Analysis/FlowSensitive/ASTOps.h
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
Expand Down Expand Up @@ -307,6 +308,7 @@ clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/Analysis/CloneDetection.cpp
clang/lib/Analysis/CodeInjector.cpp
clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp
clang/lib/Analysis/FlowSensitive/ASTOps.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
Expand Down
98 changes: 98 additions & 0 deletions clang/include/clang/Analysis/FlowSensitive/ASTOps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//===-- ASTOps.h -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Operations on AST nodes that are used in flow-sensitive analysis.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ASTOPS_H
#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ASTOPS_H

#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/Type.h"
#include "clang/Analysis/FlowSensitive/StorageLocation.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SetVector.h"

namespace clang {
namespace dataflow {

/// Skip past nodes that the CFG does not emit. These nodes are invisible to
/// flow-sensitive analysis, and should be ignored as they will effectively not
/// exist.
///
/// * `ParenExpr` - The CFG takes the operator precedence into account, but
/// otherwise omits the node afterwards.
///
/// * `ExprWithCleanups` - The CFG will generate the appropriate calls to
/// destructors and then omit the node.
///
const Expr &ignoreCFGOmittedNodes(const Expr &E);
const Stmt &ignoreCFGOmittedNodes(const Stmt &S);

/// A set of `FieldDecl *`. Use `SmallSetVector` to guarantee deterministic
/// iteration order.
using FieldSet = llvm::SmallSetVector<const FieldDecl *, 4>;

/// Returns the set of all fields in the type.
FieldSet getObjectFields(QualType Type);

/// Returns whether `Fields` and `FieldLocs` contain the same fields.
bool containsSameFields(const FieldSet &Fields,
const RecordStorageLocation::FieldToLoc &FieldLocs);

/// Helper class for initialization of a record with an `InitListExpr`.
/// `InitListExpr::inits()` contains the initializers for both the base classes
/// and the fields of the record; this helper class separates these out into two
/// different lists. In addition, it deals with special cases associated with
/// unions.
class RecordInitListHelper {
public:
// `InitList` must have record type.
RecordInitListHelper(const InitListExpr *InitList);

// Base classes with their associated initializer expressions.
ArrayRef<std::pair<const CXXBaseSpecifier *, Expr *>> base_inits() const {
return BaseInits;
}

// Fields with their associated initializer expressions.
ArrayRef<std::pair<const FieldDecl *, Expr *>> field_inits() const {
return FieldInits;
}

private:
SmallVector<std::pair<const CXXBaseSpecifier *, Expr *>> BaseInits;
SmallVector<std::pair<const FieldDecl *, Expr *>> FieldInits;

// We potentially synthesize an `ImplicitValueInitExpr` for unions. It's a
// member variable because we store a pointer to it in `FieldInits`.
std::optional<ImplicitValueInitExpr> ImplicitValueInitForUnion;
};

/// A collection of several types of declarations, all referenced from the same
/// function.
struct ReferencedDecls {
/// Non-static member variables.
FieldSet Fields;
/// All variables with static storage duration, notably including static
/// member variables and static variables declared within a function.
llvm::DenseSet<const VarDecl *> Globals;
/// Free functions and member functions which are referenced (but not
/// necessarily called).
llvm::DenseSet<const FunctionDecl *> Functions;
};

/// Returns declarations that are declared in or referenced from `FD`.
ReferencedDecls getReferencedDecls(const FunctionDecl &FD);

} // namespace dataflow
} // namespace clang

#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ASTOPS_H
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/TypeOrdering.h"
#include "clang/Analysis/FlowSensitive/ASTOps.h"
#include "clang/Analysis/FlowSensitive/AdornedCFG.h"
#include "clang/Analysis/FlowSensitive/Arena.h"
#include "clang/Analysis/FlowSensitive/Solver.h"
Expand All @@ -30,38 +31,11 @@
#include <cassert>
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>

namespace clang {
namespace dataflow {
class Logger;

/// Skip past nodes that the CFG does not emit. These nodes are invisible to
/// flow-sensitive analysis, and should be ignored as they will effectively not
/// exist.
///
/// * `ParenExpr` - The CFG takes the operator precedence into account, but
/// otherwise omits the node afterwards.
///
/// * `ExprWithCleanups` - The CFG will generate the appropriate calls to
/// destructors and then omit the node.
///
const Expr &ignoreCFGOmittedNodes(const Expr &E);
const Stmt &ignoreCFGOmittedNodes(const Stmt &S);

/// A set of `FieldDecl *`. Use `SmallSetVector` to guarantee deterministic
/// iteration order.
using FieldSet = llvm::SmallSetVector<const FieldDecl *, 4>;

/// Returns the set of all fields in the type.
FieldSet getObjectFields(QualType Type);

/// Returns whether `Fields` and `FieldLocs` contain the same fields.
bool containsSameFields(const FieldSet &Fields,
const RecordStorageLocation::FieldToLoc &FieldLocs);

struct ContextSensitiveOptions {
/// The maximum depth to analyze. A value of zero is equivalent to disabling
/// context-sensitive analysis entirely.
Expand Down
36 changes: 0 additions & 36 deletions clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,42 +775,6 @@ RecordStorageLocation *getImplicitObjectLocation(const CXXMemberCallExpr &MCE,
RecordStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
const Environment &Env);

/// Returns the fields of a `RecordDecl` that are initialized by an
/// `InitListExpr`, in the order in which they appear in
/// `InitListExpr::inits()`.
/// `Init->getType()` must be a record type.
std::vector<const FieldDecl *>
getFieldsForInitListExpr(const InitListExpr *InitList);

/// Helper class for initialization of a record with an `InitListExpr`.
/// `InitListExpr::inits()` contains the initializers for both the base classes
/// and the fields of the record; this helper class separates these out into two
/// different lists. In addition, it deals with special cases associated with
/// unions.
class RecordInitListHelper {
public:
// `InitList` must have record type.
RecordInitListHelper(const InitListExpr *InitList);

// Base classes with their associated initializer expressions.
ArrayRef<std::pair<const CXXBaseSpecifier *, Expr *>> base_inits() const {
return BaseInits;
}

// Fields with their associated initializer expressions.
ArrayRef<std::pair<const FieldDecl *, Expr *>> field_inits() const {
return FieldInits;
}

private:
SmallVector<std::pair<const CXXBaseSpecifier *, Expr *>> BaseInits;
SmallVector<std::pair<const FieldDecl *, Expr *>> FieldInits;

// We potentially synthesize an `ImplicitValueInitExpr` for unions. It's a
// member variable because we store a pointer to it in `FieldInits`.
std::optional<ImplicitValueInitExpr> ImplicitValueInitForUnion;
};

/// Associates a new `RecordValue` with `Loc` and returns the new value.
RecordValue &refreshRecordValue(RecordStorageLocation &Loc, Environment &Env);

Expand Down
6 changes: 4 additions & 2 deletions clang/include/clang/Sema/Initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ class InitializationSequence {
OverloadingResult FailedOverloadResult;

/// The candidate set created when initialization failed.
OverloadCandidateSet FailedCandidateSet;
std::unique_ptr<OverloadCandidateSet> FailedCandidateSet;

/// The incomplete type that caused a failure.
QualType FailedIncompleteType;
Expand Down Expand Up @@ -1403,7 +1403,9 @@ class InitializationSequence {
/// Retrieve a reference to the candidate set when overload
/// resolution fails.
OverloadCandidateSet &getFailedCandidateSet() {
return FailedCandidateSet;
assert(FailedCandidateSet &&
"this should have been allocated in the constructor!");
return *FailedCandidateSet;
}

/// Get the overloading result, for when the initialization
Expand Down
70 changes: 19 additions & 51 deletions clang/include/clang/Sema/Overload.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <utility>

namespace clang {
Expand Down Expand Up @@ -874,7 +875,8 @@ class Sema;
ConversionFixItGenerator Fix;

/// Viable - True to indicate that this overload candidate is viable.
bool Viable : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned Viable : 1;

/// Whether this candidate is the best viable function, or tied for being
/// the best viable function.
Expand All @@ -883,12 +885,14 @@ class Sema;
/// was part of the ambiguity kernel: the minimal non-empty set of viable
/// candidates such that all elements of the ambiguity kernel are better
/// than all viable candidates not in the ambiguity kernel.
bool Best : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned Best : 1;

/// IsSurrogate - True to indicate that this candidate is a
/// surrogate for a conversion to a function pointer or reference
/// (C++ [over.call.object]).
bool IsSurrogate : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned IsSurrogate : 1;

/// IgnoreObjectArgument - True to indicate that the first
/// argument's conversion, which for this function represents the
Expand All @@ -897,18 +901,20 @@ class Sema;
/// implicit object argument is just a placeholder) or a
/// non-static member function when the call doesn't have an
/// object argument.
bool IgnoreObjectArgument : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned IgnoreObjectArgument : 1;

/// True if the candidate was found using ADL.
CallExpr::ADLCallKind IsADLCandidate : 1;
LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
unsigned IsADLCandidate : 1;

/// Whether this is a rewritten candidate, and if so, of what kind?
LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
unsigned RewriteKind : 2;

/// FailureKind - The reason why this candidate is not viable.
/// Actually an OverloadFailureKind.
unsigned char FailureKind;
LLVM_PREFERRED_TYPE(OverloadFailureKind)
unsigned FailureKind : 5;

/// The number of call arguments that were explicitly provided,
/// to be used while performing partial ordering of function templates.
Expand Down Expand Up @@ -972,7 +978,9 @@ class Sema;
private:
friend class OverloadCandidateSet;
OverloadCandidate()
: IsSurrogate(false), IsADLCandidate(CallExpr::NotADL), RewriteKind(CRK_None) {}
: IsSurrogate(false),
IsADLCandidate(static_cast<unsigned>(CallExpr::NotADL)),
RewriteKind(CRK_None) {}
};

/// OverloadCandidateSet - A set of overload candidates, used in C++
Expand Down Expand Up @@ -1070,51 +1078,16 @@ class Sema;
};

private:
SmallVector<OverloadCandidate, 16> Candidates;
llvm::SmallPtrSet<uintptr_t, 16> Functions;

// Allocator for ConversionSequenceLists. We store the first few of these
// inline to avoid allocation for small sets.
llvm::BumpPtrAllocator SlabAllocator;
SmallVector<OverloadCandidate, 4> Candidates;
llvm::SmallPtrSet<uintptr_t, 4> Functions;

SourceLocation Loc;
CandidateSetKind Kind;
OperatorRewriteInfo RewriteInfo;

constexpr static unsigned NumInlineBytes =
24 * sizeof(ImplicitConversionSequence);
unsigned NumInlineBytesUsed = 0;
alignas(void *) char InlineSpace[NumInlineBytes];

// Address space of the object being constructed.
LangAS DestAS = LangAS::Default;

/// If we have space, allocates from inline storage. Otherwise, allocates
/// from the slab allocator.
/// FIXME: It would probably be nice to have a SmallBumpPtrAllocator
/// instead.
/// FIXME: Now that this only allocates ImplicitConversionSequences, do we
/// want to un-generalize this?
template <typename T>
T *slabAllocate(unsigned N) {
// It's simpler if this doesn't need to consider alignment.
static_assert(alignof(T) == alignof(void *),
"Only works for pointer-aligned types.");
static_assert(std::is_trivial<T>::value ||
std::is_same<ImplicitConversionSequence, T>::value,
"Add destruction logic to OverloadCandidateSet::clear().");

unsigned NBytes = sizeof(T) * N;
if (NBytes > NumInlineBytes - NumInlineBytesUsed)
return SlabAllocator.Allocate<T>(N);
char *FreeSpaceStart = InlineSpace + NumInlineBytesUsed;
assert(uintptr_t(FreeSpaceStart) % alignof(void *) == 0 &&
"Misaligned storage!");

NumInlineBytesUsed += NBytes;
return reinterpret_cast<T *>(FreeSpaceStart);
}

void destroyCandidates();

public:
Expand Down Expand Up @@ -1163,12 +1136,7 @@ class Sema;
ConversionSequenceList
allocateConversionSequences(unsigned NumConversions) {
ImplicitConversionSequence *Conversions =
slabAllocate<ImplicitConversionSequence>(NumConversions);

// Construct the new objects.
for (unsigned I = 0; I != NumConversions; ++I)
new (&Conversions[I]) ImplicitConversionSequence();

new ImplicitConversionSequence[NumConversions];
return ConversionSequenceList(Conversions, NumConversions);
}

Expand Down
Loading
Loading