Skip to content

Commit 66b9427

Browse files
committed
Merge branch 'main' into users/ahmedbougacha/ptrauth-instcombine-intrin-callee-safe
Conflicts: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/lib/Transforms/InstCombine/InstCombineInternal.h
2 parents a27020b + 42d2ae1 commit 66b9427

File tree

273 files changed

+4668
-4236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+4668
-4236
lines changed

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,
219219

220220
IntrusiveRefCntPtr<ModuleCache> ModCache = createCrossProcessModuleCache();
221221
PCHContainerOperations PCHOperations;
222+
CodeGenOptions CodeGenOpts;
222223
ASTReader Reader(PP, *ModCache, /*ASTContext=*/nullptr,
223-
PCHOperations.getRawReader(), {});
224+
PCHOperations.getRawReader(), CodeGenOpts, {});
224225

225226
// We don't need any listener here. By default it will use a validator
226227
// listener.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ Improvements to clang-doc
8888
Improvements to clang-query
8989
---------------------------
9090

91+
- Matcher queries interpreted by clang-query are now support trailing comma (,)
92+
in matcher arguments. Note that C++ still doesn't allow this in function
93+
arguments. So when porting a query to C++, remove all instances of trailing
94+
comma (otherwise C++ compiler will just complain about "expected expression").
95+
9196
Improvements to include-cleaner
9297
-------------------------------
9398
- Deprecated the ``-insert`` and ``-remove`` command line options, and added
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
void foo(void) {}
2+
// CHECK-OK: trailing-comma.c:1:1: note: "root" binds here
3+
// CHECK-ERR-COMMA: Invalid token <,> found when looking for a value.
4+
5+
// RUN: clang-query -c "match \
6+
// RUN: functionDecl( \
7+
// RUN: hasName( \
8+
// RUN: \"foo\", \
9+
// RUN: ), \
10+
// RUN: ) \
11+
// RUN: " %s | FileCheck --check-prefix=CHECK-OK %s
12+
13+
// Same with \n tokens
14+
// RUN: echo "match functionDecl( hasName( \"foo\" , ) , )" | sed "s/ /\n/g" >%t
15+
// RUN: clang-query -f %t %s | FileCheck --check-prefix=CHECK-OK %s
16+
17+
// RUN: not clang-query -c "match functionDecl(hasName(\"foo\"),,)" %s \
18+
// RUN: | FileCheck --check-prefix=CHECK-ERR-COMMA %s
19+
20+
// RUN: not clang-query -c "match functionDecl(,)" %s \
21+
// RUN: | FileCheck --check-prefix=CHECK-ERR-COMMA %s

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,8 @@ Bug Fixes in This Version
800800
declaration statements. Clang now emits a warning for these patterns. (#GH141659)
801801
- Fixed false positives for redeclaration errors of using enum in
802802
nested scopes. (#GH147495)
803+
- Fixed a failed assertion with an operator call expression which comes from a
804+
macro expansion when performing analysis for nullability attributes. (#GH138371)
803805

804806
Bug Fixes to Compiler Builtins
805807
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -967,6 +969,7 @@ Bug Fixes to C++ Support
967969
- Fix a crash with NTTP when instantiating local class.
968970
- Fixed a crash involving list-initialization of an empty class with a
969971
non-empty initializer list. (#GH147949)
972+
- Fixed constant evaluation of equality comparisons of constexpr-unknown references. (#GH147663)
970973

971974
Bug Fixes to AST Handling
972975
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1143,6 +1146,8 @@ Fixed Point Support in Clang
11431146
AST Matchers
11441147
------------
11451148

1149+
- Ensure ``hasBitWidth`` doesn't crash on bit widths that are dependent on template
1150+
parameters.
11461151
- Ensure ``isDerivedFrom`` matches the correct base in case more than one alias exists.
11471152
- Extend ``templateArgumentCountIs`` to support function and variable template
11481153
specialization.

clang/include/clang/AST/Decl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,6 +3252,11 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
32523252
return hasInClassInitializer() ? InitAndBitWidth->BitWidth : BitWidth;
32533253
}
32543254

3255+
/// Determines whether the bit width of this field is a constant integer.
3256+
/// This may not always be the case, such as inside template-dependent
3257+
/// expressions.
3258+
bool hasConstantIntegerBitWidth() const;
3259+
32553260
/// Computes the bit width of this field, if this is a bit field.
32563261
/// May not be called on non-bitfields.
32573262
/// Note that in order to successfully use this function, the bitwidth

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ AST_MATCHER(FieldDecl, isBitField) {
710710
/// fieldDecl(hasBitWidth(2))
711711
/// matches 'int a;' and 'int c;' but not 'int b;'.
712712
AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width) {
713-
return Node.isBitField() && Node.getBitWidthValue() == Width;
713+
return Node.isBitField() && Node.hasConstantIntegerBitWidth() &&
714+
Node.getBitWidthValue() == Width;
714715
}
715716

716717
/// Matches non-static data members that have an in-class initializer.

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ TARGET_BUILTIN(__builtin_amdgcn_s_wait_asynccnt, "vIUs", "n", "gfx1250-insts")
669669
TARGET_BUILTIN(__builtin_amdgcn_s_wait_tensorcnt, "vIUs", "n", "gfx1250-insts")
670670

671671
TARGET_BUILTIN(__builtin_amdgcn_tanh_bf16, "yy", "nc", "bf16-trans-insts")
672+
TARGET_BUILTIN(__builtin_amdgcn_rcp_bf16, "yy", "nc", "bf16-trans-insts")
672673

673674
TARGET_BUILTIN(__builtin_amdgcn_cvt_f16_fp8, "hiIi", "nc", "gfx1250-insts")
674675
TARGET_BUILTIN(__builtin_amdgcn_cvt_f16_bf8, "hiIi", "nc", "gfx1250-insts")

clang/include/clang/Basic/BuiltinsPPC.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,12 @@ UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
10921092
"mma,paired-vector-memops")
10931093
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
10941094
"mma,paired-vector-memops")
1095+
UNALIASED_CUSTOM_BUILTIN(mma_dmsetdmrz, "vW1024*", false,
1096+
"mma,isa-future-instructions")
1097+
UNALIASED_CUSTOM_BUILTIN(mma_dmmr, "vW1024*W1024*", false,
1098+
"mma,isa-future-instructions")
1099+
UNALIASED_CUSTOM_BUILTIN(mma_dmxor, "vW1024*W1024*", true,
1100+
"mma,isa-future-instructions")
10951101

10961102
// MMA builtins with positive/negative multiply/accumulate.
10971103
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,17 @@ CODEGENOPT(ObjCAvoidHeapifyLocalBlocks, 1, 0, Benign)
209209

210210

211211
// The optimization options affect frontend options, which in turn do affect the AST.
212-
VALUE_CODEGENOPT(OptimizationLevel, 2, 0, Affecting) ///< The -O[0-3] option specified.
213-
VALUE_CODEGENOPT(OptimizeSize, 2, 0, Affecting) ///< If -Os (==1, Benign) or -Oz (==2, Benign) is specified.
212+
VALUE_CODEGENOPT(OptimizationLevel, 2, 0, Compatible) ///< The -O[0-3] option specified.
213+
VALUE_CODEGENOPT(OptimizeSize, 2, 0, Compatible) ///< If -Os (==1, Benign) or -Oz (==2, Benign) is specified.
214214

215215
CODEGENOPT(AtomicProfileUpdate , 1, 0, Benign) ///< Set -fprofile-update=atomic
216216
CODEGENOPT(ContinuousProfileSync, 1, 0, Benign) ///< Enable continuous instrumentation profiling
217217
/// Choose profile instrumenation kind or no instrumentation.
218218

219-
ENUM_CODEGENOPT(ProfileInstr, llvm::driver::ProfileInstrKind, 4, llvm::driver::ProfileInstrKind::ProfileNone, Benign)
219+
ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 4, ProfileInstrKind::ProfileNone, Benign)
220220

221221
/// Choose profile kind for PGO use compilation.
222-
ENUM_CODEGENOPT(ProfileUse, llvm::driver::ProfileInstrKind, 2, llvm::driver::ProfileInstrKind::ProfileNone, Benign)
222+
ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileInstrKind::ProfileNone, Benign)
223223
/// Partition functions into N groups and select only functions in group i to be
224224
/// instrumented. Selected group numbers can be 0 to N-1 inclusive.
225225
VALUE_CODEGENOPT(ProfileTotalFunctionGroups, 32, 1, Benign)
@@ -244,8 +244,8 @@ CODEGENOPT(SaveTempLabels , 1, 0, Benign) ///< Save temporary labels.
244244
CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0, Benign) ///< Enable use-after-scope detection
245245
///< in AddressSanitizer
246246
ENUM_CODEGENOPT(SanitizeAddressUseAfterReturn,
247-
llvm::AsanDetectStackUseAfterReturnMode, 2,
248-
llvm::AsanDetectStackUseAfterReturnMode::Runtime,
247+
AsanDetectStackUseAfterReturnMode, 2,
248+
AsanDetectStackUseAfterReturnMode::Runtime,
249249
Benign
250250
) ///< Set detection mode for stack-use-after-return.
251251
CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1, 0, Benign) ///< Enable poisoning operator new[] which is not a replaceable
@@ -255,9 +255,9 @@ CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0, Benign) ///< Enable linker
255255
CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0, Benign) ///< Enable ODR indicator globals
256256
CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0, Benign) ///< Enable tracking origins in
257257
///< MemorySanitizer
258-
ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
259-
llvm::AsanDtorKind::Global, Benign) ///< Set how ASan global
260-
///< destructors are emitted.
258+
ENUM_CODEGENOPT(SanitizeAddressDtor, AsanDtorKind, 2,
259+
AsanDtorKind::Global, Benign) ///< Set how ASan global
260+
///< destructors are emitted.
261261
CODEGENOPT(SanitizeMemoryParamRetval, 1, 0, Benign) ///< Enable detection of uninitialized
262262
///< parameters and return values
263263
///< in MemorySanitizer
@@ -375,13 +375,13 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0, Benign)
375375
VALUE_CODEGENOPT(SSPBufferSize, 32, 0, Benign)
376376

377377
/// The kind of inlining to perform.
378-
ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining, Benign)
378+
ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining, Compatible)
379379

380380
/// The maximum stack size a function can have to be considered for inlining.
381381
VALUE_CODEGENOPT(InlineMaxStackSize, 32, UINT_MAX, Benign)
382382

383383
// Vector functions library to use.
384-
ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, llvm::driver::VectorLibrary::NoLibrary, Benign)
384+
ENUM_CODEGENOPT(VecLib, VectorLibrary, 4, VectorLibrary::NoLibrary, Benign)
385385

386386
/// The default TLS model to use.
387387
ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel, Benign)
@@ -457,8 +457,8 @@ ENUM_CODEGENOPT(SwiftAsyncFramePointer, SwiftAsyncFramePointerKind, 2,
457457
CODEGENOPT(SkipRaxSetup, 1, 0, Benign)
458458

459459
/// Whether to zero out caller-used registers before returning.
460-
ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
461-
5, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip, Benign)
460+
ENUM_CODEGENOPT(ZeroCallUsedRegs, ZeroCallUsedRegsKind,
461+
5, ZeroCallUsedRegsKind::Skip, Benign)
462462

463463
/// Modify C++ ABI to returning `this` pointer from constructors and
464464
/// non-deleting destructors. (No effect on Microsoft ABI.)
@@ -477,8 +477,8 @@ CODEGENOPT(ResMayAlias, 1, 0, Benign)
477477

478478
/// Controls how unwind v2 (epilog) information should be generated for x64
479479
/// Windows.
480-
ENUM_CODEGENOPT(WinX64EHUnwindV2, llvm::WinX64EHUnwindV2Mode,
481-
2, llvm::WinX64EHUnwindV2Mode::Disabled, Benign)
480+
ENUM_CODEGENOPT(WinX64EHUnwindV2, WinX64EHUnwindV2Mode,
481+
2, WinX64EHUnwindV2Mode::Disabled, Benign)
482482

483483
/// FIXME: Make DebugOptions its own top-level .def file.
484484
#include "DebugOptions.def"

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,32 @@ class CodeGenOptionsBase {
4646
enum class CompatibilityKind {
4747
/// Does affect the construction of the AST in a way that does prevent
4848
/// module interoperability.
49-
Affecting,
49+
NotCompatible,
50+
/// Does affect the construction of the AST in a way that doesn't prevent
51+
/// interoperability (that is, the value can be different between an
52+
/// explicit module and the user of that module).
53+
Compatible,
5054
/// Does not affect the construction of the AST in any way (that is, the
5155
/// value can be different between an implicit module and the user of that
5256
/// module).
5357
Benign,
5458
};
5559

60+
using CFBranchLabelSchemeKind = clang::CFBranchLabelSchemeKind;
61+
using ProfileInstrKind = llvm::driver::ProfileInstrKind;
62+
using AsanDetectStackUseAfterReturnMode =
63+
llvm::AsanDetectStackUseAfterReturnMode;
64+
using AsanDtorKind = llvm::AsanDtorKind;
65+
using VectorLibrary = llvm::driver::VectorLibrary;
66+
using ZeroCallUsedRegsKind = llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind;
67+
using WinX64EHUnwindV2Mode = llvm::WinX64EHUnwindV2Mode;
68+
69+
using DebugCompressionType = llvm::DebugCompressionType;
70+
using EmitDwarfUnwindType = llvm::EmitDwarfUnwindType;
71+
using DebugTemplateNamesKind = llvm::codegenoptions::DebugTemplateNamesKind;
72+
using DebugInfoKind = llvm::codegenoptions::DebugInfoKind;
73+
using DebuggerKind = llvm::DebuggerKind;
74+
5675
#define CODEGENOPT(Name, Bits, Default, Compatibility) unsigned Name : Bits;
5776
#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)
5877
#include "clang/Basic/CodeGenOptions.def"

0 commit comments

Comments
 (0)