Skip to content

Make AMDGPUCombinerHelper methods const #121740

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
49 commits
Select commit Hold shift + click to select a range
d98c994
[NFC] Make AMDGPUCombinerHelper methods const
paulhuggett Jan 6, 2025
0494c8d
[llvm] Remove `br i1 undef` from CodeGen/X86 tests (#121733)
leewei05 Jan 6, 2025
8524581
[libclc] Add Maintainers.md for libclc (#118309)
DavidSpickett Jan 6, 2025
3a0b306
[lldb][Docs] Add equivalents of GDB's "skip" to command map (#120740)
DavidSpickett Jan 6, 2025
a3d1239
[LLVM] Fix formatting mistakes in Maintainers.md (NFC)
nikic Jan 6, 2025
5c7e77f
[LLVM] Update AliasAnalysis maintainers (#120447)
nikic Jan 6, 2025
2bd18fb
[clang][NFC] Stop testing CWG2917 in C++98 mode
Endilll Jan 6, 2025
d1d5403
[clang][NFC] Fix expected directives in C++ DRs
Endilll Jan 6, 2025
c4b8f7a
[AArch64][SME] Fix broken compiler check for SME2 support in compiler…
aemerson Jan 6, 2025
3ce85be
[AArch64] Correct position of CFI Instruction for Pointer Authenticat…
Stylie777 Jan 6, 2025
2496985
[clang-format] Add LT_RequiresExpression and LT_SimpleRequirement (#1…
owenca Jan 6, 2025
2934ba8
[mlir] flush output in transform.print (#121382)
ftynse Jan 6, 2025
63c6fed
[clang][NFC] Stop using atypical compiler arguments in C++ DR tests
Endilll Jan 6, 2025
3bb2a6f
Complex deinterleaving/single reductions build fix Reapply "Add suppo…
NickGuy-Arm Jan 6, 2025
7de8dd8
[LoopVectorize][NFC] Fix arith-fp-frem-costs.ll test to use new vplan…
david-arm Jan 6, 2025
cd356ff
[lldb][AIX] HostInfoAIX Support (#117906)
DhruvSrivastavaX Jan 6, 2025
67055a7
[gn build] Port 3a7a9c928671
llvmgnsyncbot Jan 6, 2025
6bee566
[LoopVectorize][NFC] Move "LV: Selecting VF" debug output (#120744)
david-arm Jan 6, 2025
d3bd54b
[AArch64][SVE] Add dot product codegen for partial reductions with no…
JamesChesterman Jan 6, 2025
5436414
[clang] Do not serialize function definitions without a body (#121550)
alejandro-alvarez-sonarsource Jan 6, 2025
86d9040
[mlir][GPU] Add NVVM-specific `cf.assert` lowering (#120431)
matthias-springer Jan 6, 2025
07b2d30
[FLANG][OpenMP]Add support for ALIGN clause on OMP ALLOCATE (#120791)
Leporacanthicus Jan 6, 2025
c35d382
[clang] Add sincos builtin using `llvm.sincos` intrinsic (#114086)
MacDue Jan 6, 2025
06d3d81
[libc++] Simplify unwrap_ref_decay a bit (#121623)
philnik777 Jan 6, 2025
97a04ec
[RISCV] Don't commute with shift if it would break sh{1,2,3}add patte…
lukel97 Jan 6, 2025
d691d30
[lldb][POSIX] Replace bzero with memset in domain socket code (#121747)
DhruvSrivastavaX Jan 6, 2025
30498da
[docs] fix grammar mistake (#121695)
alyanser Jan 6, 2025
f17c586
Reapply "[clang][analyzer] Stable order for SymbolRef-keyed container…
necto Jan 6, 2025
a5f64c1
[AArch64][SME] Disable inlining of callees with new ZT0 state (#121338)
kmclaughlin-arm Jan 6, 2025
92ae976
[mlir] DCE `friend Dialect::registerDialect` (#121728)
makslevental Jan 6, 2025
a002bef
[AMDGPU] [GlobalIsel] Combine Fmul with Select into ldexp instruction…
vg0204 Jan 6, 2025
ccc8ef6
[mlir] DCE `RegisteredOperationName::parseAssembly` decl (#121730)
makslevental Jan 6, 2025
9173ed2
[PhaseOrdering][X86] Add horizontal-sub test coverage for #34072
RKSimon Jan 6, 2025
4bb2ce3
[clang] Fix missing check for nullptr in CallExpr::getUnusedResultAtt…
Mick235711 Jan 6, 2025
70507db
[clang] Expose -f(no-)wrapv as clang-cl option (#120787)
nico Jan 6, 2025
52a8fec
[AArch64] Improve codegen of vectorised early exit loops (#119534)
david-arm Jan 6, 2025
0bc561c
Fix after #121482 (#121764)
JoelWee Jan 6, 2025
ef1ba52
[X86] Support lowering of FMINIMUMNUM/FMAXIMUMNUM (#121464)
phoebewang Jan 6, 2025
632e6c8
[CostModel][X86] getShuffleCost - use processShuffleMasks for all shu…
RKSimon Jan 6, 2025
5374a3d
[InstSimplify] Simplify both operands of select before comparing (#12…
nikic Jan 6, 2025
c316730
[InstCombine] Handle commuted pattern for `((X s/ C1) << C2) + X` (#1…
dtcxzyw Jan 6, 2025
a3a14a5
[Clang] Make passing incomplete types to builtin type-traits a non-sf…
cor3ntin Jan 6, 2025
ba8755d
[Clang][AMDGPU] Stop defaulting to `one-as` for all atomic scopes (#1…
jhuber6 Jan 6, 2025
b4559c7
[clang][NFC] Move CWG273 test into its own file
Endilll Jan 6, 2025
ab16ce4
[InstCombine] Add additional tests for icmp of phi of zext (NFC)
nikic Jan 6, 2025
4b9b115
[clang][NFC] Fill in historical data for C++ DRs with 'yes' availability
Endilll Jan 6, 2025
21378d4
[MLIR] Fix triple mismatch warning for embedded libdevice (#121447)
arthurqiu Jan 6, 2025
4d0b60e
[libc] Fix sort test failing on NVPTX
jhuber6 Jan 6, 2025
d5cf401
[NFC] Make AMDGPUCombinerHelper methods const
paulhuggett Jan 6, 2025
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
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ Bug Fixes to C++ Support
out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218)
- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
- Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081)
- Passing incomplete types to ``__is_base_of`` and other builtin type traits for which the corresponding
standard type trait mandates a complete type is now a hard (non-sfinae-friendly) error
(`LWG3929 <https://wg21.link/LWG3929>`__.) (#GH121278)
- Clang now identifies unexpanded parameter packs within the type constraint on a non-type template parameter. (#GH88866)
- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242)

Expand Down
13 changes: 13 additions & 0 deletions clang/include/clang/Basic/Builtins.td
Original file line number Diff line number Diff line change
Expand Up @@ -3568,6 +3568,19 @@ def Frexp : FPMathTemplate, LibBuiltin<"math.h"> {
let AddBuiltinPrefixedAlias = 1;
}

def Sincos : FPMathTemplate, GNULibBuiltin<"math.h"> {
let Spellings = ["sincos"];
let Attributes = [NoThrow];
let Prototype = "void(T, T*, T*)";
let AddBuiltinPrefixedAlias = 1;
}

def SincosF16F128 : F16F128MathTemplate, Builtin {
let Spellings = ["__builtin_sincos"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void(T, T*, T*)";
}

def Ldexp : FPMathTemplate, LibBuiltin<"math.h"> {
let Spellings = ["ldexp"];
let Attributes = [NoThrow, ConstIgnoringErrnoAndExceptions];
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticFrontendKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ def warn_function_always_inline_attribute_mismatch : Warning<
"inlining may change runtime behaviour">, InGroup<AArch64SMEAttributes>;
def err_function_always_inline_new_za : Error<
"always_inline function %0 has new za state">;
def err_function_always_inline_new_zt0
: Error<"always_inline function %0 has new zt0 state">;

def warn_avx_calling_convention
: Warning<"AVX vector %select{return|argument}0 of type %1 without '%2' "
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -9361,7 +9361,7 @@ def note_inequality_comparison_to_or_assign : Note<
"use '|=' to turn this inequality comparison into an or-assignment">;

def err_incomplete_type_used_in_type_trait_expr : Error<
"incomplete type %0 used in type trait expression">;
"incomplete type %0 used in type trait expression">, NoSFINAE;

// C++20 constinit and require_constant_initialization attribute
def warn_cxx20_compat_constinit : Warning<
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3508,8 +3508,6 @@ def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Group<f_Group>,
Visibility<[ClangOption, CC1Option]>,
MarshallingInfoNegativeFlag<CodeGenOpts<"AsmVerbose">>;
def fno_working_directory : Flag<["-"], "fno-working-directory">, Group<f_Group>;
def fno_wrapv : Flag<["-"], "fno-wrapv">, Group<f_Group>,
Visibility<[ClangOption, FlangOption]>;
def fobjc_arc : Flag<["-"], "fobjc-arc">, Group<f_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Synthesize retain and release calls for Objective-C pointers">;
Expand Down Expand Up @@ -4280,8 +4278,10 @@ defm virtual_function_elimination : BoolFOption<"virtual-function-elimination",
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption]>>;

def fwrapv : Flag<["-"], "fwrapv">, Group<f_Group>,
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
Visibility<[ClangOption, CLOption, CC1Option, FlangOption, FC1Option]>,
HelpText<"Treat signed integer overflow as two's complement">;
def fno_wrapv : Flag<["-"], "fno-wrapv">, Group<f_Group>,
Visibility<[ClangOption, CLOption, FlangOption]>;
def fwritable_strings : Flag<["-"], "fwritable-strings">, Group<f_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Store string literals as writable data">,
Expand Down
31 changes: 22 additions & 9 deletions clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace ento {

class MemRegion;

using SymbolID = unsigned;

/// Symbolic value. These values used to capture symbolic execution of
/// the program.
class SymExpr : public llvm::FoldingSetNode {
Expand All @@ -39,9 +41,19 @@ class SymExpr : public llvm::FoldingSetNode {

private:
Kind K;
/// A unique identifier for this symbol.
///
/// It is useful for SymbolData to easily differentiate multiple symbols, but
/// also for "ephemeral" symbols, such as binary operations, because this id
/// can be used for arranging constraints or equivalence classes instead of
/// unstable pointer values.
///
/// Note, however, that it can't be used in Profile because SymbolManager
/// needs to compute Profile before allocating SymExpr.
const SymbolID Sym;

protected:
SymExpr(Kind k) : K(k) {}
SymExpr(Kind k, SymbolID Sym) : K(k), Sym(Sym) {}

static bool isValidTypeForSymbol(QualType T) {
// FIXME: Depending on whether we choose to deprecate structural symbols,
Expand All @@ -56,6 +68,14 @@ class SymExpr : public llvm::FoldingSetNode {

Kind getKind() const { return K; }

/// Get a unique identifier for this symbol.
/// The ID is unique across all SymExprs in a SymbolManager.
/// They reflect the allocation order of these SymExprs,
/// and are likely stable across runs.
/// Used as a key in SymbolRef containers and as part of identity
/// for SymbolData, e.g. SymbolConjured with ID = 7 is "conj_$7".
SymbolID getSymbolID() const { return Sym; }

virtual void dump() const;

virtual void dumpToStream(raw_ostream &os) const {}
Expand Down Expand Up @@ -112,28 +132,21 @@ inline raw_ostream &operator<<(raw_ostream &os,

using SymbolRef = const SymExpr *;
using SymbolRefSmallVectorTy = SmallVector<SymbolRef, 2>;
using SymbolID = unsigned;

/// A symbol representing data which can be stored in a memory location
/// (region).
class SymbolData : public SymExpr {
const SymbolID Sym;

void anchor() override;

protected:
SymbolData(Kind k, SymbolID sym) : SymExpr(k), Sym(sym) {
assert(classof(this));
}
SymbolData(Kind k, SymbolID sym) : SymExpr(k, sym) { assert(classof(this)); }

public:
~SymbolData() override = default;

/// Get a string representation of the kind of the region.
virtual StringRef getKindStr() const = 0;

SymbolID getSymbolID() const { return Sym; }

unsigned computeComplexity() const override {
return 1;
};
Expand Down
100 changes: 78 additions & 22 deletions clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/ImmutableSet.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Allocator.h"
#include <cassert>
Expand All @@ -43,15 +44,16 @@ class StoreManager;
class SymbolRegionValue : public SymbolData {
const TypedValueRegion *R;

public:
friend class SymExprAllocator;
SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
: SymbolData(SymbolRegionValueKind, sym), R(r) {
assert(r);
assert(isValidTypeForSymbol(r->getValueType()));
}

public:
LLVM_ATTRIBUTE_RETURNS_NONNULL
const TypedValueRegion* getRegion() const { return R; }
const TypedValueRegion *getRegion() const { return R; }

static void Profile(llvm::FoldingSetNodeID& profile, const TypedValueRegion* R) {
profile.AddInteger((unsigned) SymbolRegionValueKind);
Expand Down Expand Up @@ -84,7 +86,7 @@ class SymbolConjured : public SymbolData {
const LocationContext *LCtx;
const void *SymbolTag;

public:
friend class SymExprAllocator;
SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx,
QualType t, unsigned count, const void *symbolTag)
: SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
Expand All @@ -98,6 +100,7 @@ class SymbolConjured : public SymbolData {
assert(isValidTypeForSymbol(t));
}

public:
/// It might return null.
const Stmt *getStmt() const { return S; }
unsigned getCount() const { return Count; }
Expand Down Expand Up @@ -137,14 +140,15 @@ class SymbolDerived : public SymbolData {
SymbolRef parentSymbol;
const TypedValueRegion *R;

public:
friend class SymExprAllocator;
SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r)
: SymbolData(SymbolDerivedKind, sym), parentSymbol(parent), R(r) {
assert(parent);
assert(r);
assert(isValidTypeForSymbol(r->getValueType()));
}

public:
LLVM_ATTRIBUTE_RETURNS_NONNULL
SymbolRef getParentSymbol() const { return parentSymbol; }
LLVM_ATTRIBUTE_RETURNS_NONNULL
Expand Down Expand Up @@ -180,12 +184,13 @@ class SymbolDerived : public SymbolData {
class SymbolExtent : public SymbolData {
const SubRegion *R;

public:
friend class SymExprAllocator;
SymbolExtent(SymbolID sym, const SubRegion *r)
: SymbolData(SymbolExtentKind, sym), R(r) {
assert(r);
}

public:
LLVM_ATTRIBUTE_RETURNS_NONNULL
const SubRegion *getRegion() const { return R; }

Expand Down Expand Up @@ -222,7 +227,7 @@ class SymbolMetadata : public SymbolData {
unsigned Count;
const void *Tag;

public:
friend class SymExprAllocator;
SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t,
const LocationContext *LCtx, unsigned count, const void *tag)
: SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), LCtx(LCtx),
Expand All @@ -234,6 +239,7 @@ class SymbolMetadata : public SymbolData {
assert(tag);
}

public:
LLVM_ATTRIBUTE_RETURNS_NONNULL
const MemRegion *getRegion() const { return R; }

Expand Down Expand Up @@ -286,15 +292,16 @@ class SymbolCast : public SymExpr {
/// The type of the result.
QualType ToTy;

public:
SymbolCast(const SymExpr *In, QualType From, QualType To)
: SymExpr(SymbolCastKind), Operand(In), FromTy(From), ToTy(To) {
friend class SymExprAllocator;
SymbolCast(SymbolID Sym, const SymExpr *In, QualType From, QualType To)
: SymExpr(SymbolCastKind, Sym), Operand(In), FromTy(From), ToTy(To) {
assert(In);
assert(isValidTypeForSymbol(From));
// FIXME: GenericTaintChecker creates symbols of void type.
// Otherwise, 'To' should also be a valid type.
}

public:
unsigned computeComplexity() const override {
if (Complexity == 0)
Complexity = 1 + Operand->computeComplexity();
Expand Down Expand Up @@ -332,9 +339,10 @@ class UnarySymExpr : public SymExpr {
UnaryOperator::Opcode Op;
QualType T;

public:
UnarySymExpr(const SymExpr *In, UnaryOperator::Opcode Op, QualType T)
: SymExpr(UnarySymExprKind), Operand(In), Op(Op), T(T) {
friend class SymExprAllocator;
UnarySymExpr(SymbolID Sym, const SymExpr *In, UnaryOperator::Opcode Op,
QualType T)
: SymExpr(UnarySymExprKind, Sym), Operand(In), Op(Op), T(T) {
// Note, some unary operators are modeled as a binary operator. E.g. ++x is
// modeled as x + 1.
assert((Op == UO_Minus || Op == UO_Not) && "non-supported unary expression");
Expand All @@ -345,6 +353,7 @@ class UnarySymExpr : public SymExpr {
assert(!Loc::isLocType(T) && "unary symbol should be nonloc");
}

public:
unsigned computeComplexity() const override {
if (Complexity == 0)
Complexity = 1 + Operand->computeComplexity();
Expand Down Expand Up @@ -381,8 +390,8 @@ class BinarySymExpr : public SymExpr {
QualType T;

protected:
BinarySymExpr(Kind k, BinaryOperator::Opcode op, QualType t)
: SymExpr(k), Op(op), T(t) {
BinarySymExpr(SymbolID Sym, Kind k, BinaryOperator::Opcode op, QualType t)
: SymExpr(k, Sym), Op(op), T(t) {
assert(classof(this));
// Binary expressions are results of arithmetic. Pointer arithmetic is not
// handled by binary expressions, but it is instead handled by applying
Expand Down Expand Up @@ -425,14 +434,15 @@ class BinarySymExprImpl : public BinarySymExpr {
LHSTYPE LHS;
RHSTYPE RHS;

public:
BinarySymExprImpl(LHSTYPE lhs, BinaryOperator::Opcode op, RHSTYPE rhs,
QualType t)
: BinarySymExpr(ClassKind, op, t), LHS(lhs), RHS(rhs) {
friend class SymExprAllocator;
BinarySymExprImpl(SymbolID Sym, LHSTYPE lhs, BinaryOperator::Opcode op,
RHSTYPE rhs, QualType t)
: BinarySymExpr(Sym, ClassKind, op, t), LHS(lhs), RHS(rhs) {
assert(getPointer(lhs));
assert(getPointer(rhs));
}

public:
void dumpToStream(raw_ostream &os) const override {
dumpToStreamImpl(os, LHS);
dumpToStreamImpl(os, getOpcode());
Expand Down Expand Up @@ -478,6 +488,21 @@ using IntSymExpr = BinarySymExprImpl<APSIntPtr, const SymExpr *,
using SymSymExpr = BinarySymExprImpl<const SymExpr *, const SymExpr *,
SymExpr::Kind::SymSymExprKind>;

class SymExprAllocator {
SymbolID NextSymbolID = 0;
llvm::BumpPtrAllocator &Alloc;

public:
explicit SymExprAllocator(llvm::BumpPtrAllocator &Alloc) : Alloc(Alloc) {}

template <class SymT, typename... ArgsT> SymT *make(ArgsT &&...Args) {
return new (Alloc) SymT(nextID(), std::forward<ArgsT>(Args)...);
}

private:
SymbolID nextID() { return NextSymbolID++; }
};

class SymbolManager {
using DataSetTy = llvm::FoldingSet<SymExpr>;
using SymbolDependTy =
Expand All @@ -489,15 +514,14 @@ class SymbolManager {
/// alive as long as the key is live.
SymbolDependTy SymbolDependencies;

unsigned SymbolCounter = 0;
llvm::BumpPtrAllocator& BPAlloc;
SymExprAllocator Alloc;
BasicValueFactory &BV;
ASTContext &Ctx;

public:
SymbolManager(ASTContext &ctx, BasicValueFactory &bv,
llvm::BumpPtrAllocator& bpalloc)
: SymbolDependencies(16), BPAlloc(bpalloc), BV(bv), Ctx(ctx) {}
llvm::BumpPtrAllocator &bpalloc)
: SymbolDependencies(16), Alloc(bpalloc), BV(bv), Ctx(ctx) {}

static bool canSymbolicate(QualType T);

Expand Down Expand Up @@ -687,4 +711,36 @@ class SymbolVisitor {

} // namespace clang

// Override the default definition that would use pointer values of SymbolRefs
// to order them, which is unstable due to ASLR.
// Use the SymbolID instead which reflect the order in which the symbols were
// allocated. This is usually stable across runs leading to the stability of
// ConstraintMap and other containers using SymbolRef as keys.
template <>
struct llvm::ImutContainerInfo<clang::ento::SymbolRef>
: public ImutProfileInfo<clang::ento::SymbolRef> {
using value_type = clang::ento::SymbolRef;
using value_type_ref = clang::ento::SymbolRef;
using key_type = value_type;
using key_type_ref = value_type_ref;
using data_type = bool;
using data_type_ref = bool;

static key_type_ref KeyOfValue(value_type_ref D) { return D; }
static data_type_ref DataOfValue(value_type_ref) { return true; }

static bool isEqual(clang::ento::SymbolRef LHS, clang::ento::SymbolRef RHS) {
return LHS->getSymbolID() == RHS->getSymbolID();
}

static bool isLess(clang::ento::SymbolRef LHS, clang::ento::SymbolRef RHS) {
return LHS->getSymbolID() < RHS->getSymbolID();
}

// This might seem redundant, but it is required because of the way
// ImmutableSet is implemented through AVLTree:
// same as ImmutableMap, but with a non-informative "data".
static bool isDataEqual(data_type_ref, data_type_ref) { return true; }
};

#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
Loading