Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit a12fc48

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:0a68171b3c67503f7143856580f1b22a93ef566e into amd-gfx:cbff18bd3aba
Local branch amd-gfx cbff18b [AMDGPU] Rewrite GFX12 SGPR hazard handling to dedicated pass Remote branch main 0a68171 Revert "[MLIR,Python] Support converting boolean numpy arrays to and from mlir attributes (llvm#113064)"
2 parents cbff18b + 0a68171 commit a12fc48

File tree

144 files changed

+2148
-2901
lines changed

Some content is hidden

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

144 files changed

+2148
-2901
lines changed

clang-tools-extra/clang-query/Query.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
4444
" set bind-root (true|false) "
4545
"Set whether to bind the root matcher to \"root\".\n"
4646
" set print-matcher (true|false) "
47-
"Set whether to print the current matcher,\n"
47+
"Set whether to print the current matcher.\n"
48+
" set enable-profile (true|false) "
49+
"Set whether to enable matcher profiling.\n"
4850
" set traversal <kind> "
4951
"Set traversal kind of clang-query session. Available kinds are:\n"
5052
" AsIs "
@@ -82,27 +84,53 @@ namespace {
8284

8385
struct CollectBoundNodes : MatchFinder::MatchCallback {
8486
std::vector<BoundNodes> &Bindings;
85-
CollectBoundNodes(std::vector<BoundNodes> &Bindings) : Bindings(Bindings) {}
87+
StringRef Unit;
88+
CollectBoundNodes(std::vector<BoundNodes> &Bindings, StringRef Unit)
89+
: Bindings(Bindings), Unit(Unit) {}
8690
void run(const MatchFinder::MatchResult &Result) override {
8791
Bindings.push_back(Result.Nodes);
8892
}
93+
StringRef getID() const override { return Unit; }
94+
};
95+
96+
struct QueryProfiler {
97+
llvm::StringMap<llvm::TimeRecord> Records;
98+
99+
~QueryProfiler() {
100+
llvm::TimerGroup TG("clang-query", "clang-query matcher profiling",
101+
Records);
102+
TG.print(llvm::errs());
103+
llvm::errs().flush();
104+
}
89105
};
90106

91107
} // namespace
92108

93109
bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
94110
unsigned MatchCount = 0;
95111

112+
std::optional<QueryProfiler> Profiler;
113+
if (QS.EnableProfile)
114+
Profiler.emplace();
115+
96116
for (auto &AST : QS.ASTs) {
97-
MatchFinder Finder;
117+
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
118+
std::optional<llvm::StringMap<llvm::TimeRecord>> Records;
119+
if (QS.EnableProfile) {
120+
Records.emplace();
121+
FinderOptions.CheckProfiling.emplace(*Records);
122+
}
123+
124+
MatchFinder Finder(FinderOptions);
98125
std::vector<BoundNodes> Matches;
99126
DynTypedMatcher MaybeBoundMatcher = Matcher;
100127
if (QS.BindRoot) {
101128
std::optional<DynTypedMatcher> M = Matcher.tryBind("root");
102129
if (M)
103130
MaybeBoundMatcher = *M;
104131
}
105-
CollectBoundNodes Collect(Matches);
132+
StringRef OrigSrcName = AST->getOriginalSourceFileName();
133+
CollectBoundNodes Collect(Matches, OrigSrcName);
106134
if (!Finder.addDynamicMatcher(MaybeBoundMatcher, &Collect)) {
107135
OS << "Not a valid top-level matcher.\n";
108136
return false;
@@ -111,6 +139,8 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
111139
ASTContext &Ctx = AST->getASTContext();
112140
Ctx.getParentMapContext().setTraversalKind(QS.TK);
113141
Finder.matchAST(Ctx);
142+
if (QS.EnableProfile)
143+
Profiler->Records[OrigSrcName] += (*Records)[OrigSrcName];
114144

115145
if (QS.PrintMatcher) {
116146
SmallVector<StringRef, 4> Lines;

clang-tools-extra/clang-query/QueryParser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ enum ParsedQueryVariable {
182182
PQV_Output,
183183
PQV_BindRoot,
184184
PQV_PrintMatcher,
185+
PQV_EnableProfile,
185186
PQV_Traversal
186187
};
187188

@@ -285,6 +286,7 @@ QueryRef QueryParser::doParse() {
285286
.Case("output", PQV_Output)
286287
.Case("bind-root", PQV_BindRoot)
287288
.Case("print-matcher", PQV_PrintMatcher)
289+
.Case("enable-profile", PQV_EnableProfile)
288290
.Case("traversal", PQV_Traversal)
289291
.Default(PQV_Invalid);
290292
if (VarStr.empty())
@@ -303,6 +305,9 @@ QueryRef QueryParser::doParse() {
303305
case PQV_PrintMatcher:
304306
Q = parseSetBool(&QuerySession::PrintMatcher);
305307
break;
308+
case PQV_EnableProfile:
309+
Q = parseSetBool(&QuerySession::EnableProfile);
310+
break;
306311
case PQV_Traversal:
307312
Q = parseSetTraversalKind(&QuerySession::TK);
308313
break;

clang-tools-extra/clang-query/QuerySession.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class QuerySession {
2626
QuerySession(llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs)
2727
: ASTs(ASTs), PrintOutput(false), DiagOutput(true),
2828
DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
29-
Terminate(false), TK(TK_AsIs) {}
29+
EnableProfile(false), Terminate(false), TK(TK_AsIs) {}
3030

3131
llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs;
3232

@@ -36,6 +36,7 @@ class QuerySession {
3636

3737
bool BindRoot;
3838
bool PrintMatcher;
39+
bool EnableProfile;
3940
bool Terminate;
4041

4142
TraversalKind TK;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Improvements to clang-doc
9898
Improvements to clang-query
9999
---------------------------
100100

101-
The improvements are...
101+
- Added `set enable-profile true/false` command for basic matcher profiling.
102102

103103
Improvements to clang-tidy
104104
--------------------------

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class ObjCCommonTypesHelper {
365365
/// GcReadWeakFn -- LLVM objc_read_weak (id *src) function.
366366
llvm::FunctionCallee getGcReadWeakFn() {
367367
// id objc_read_weak (id *)
368-
llvm::Type *args[] = { ObjectPtrTy->getPointerTo() };
368+
llvm::Type *args[] = {CGM.UnqualPtrTy};
369369
llvm::FunctionType *FTy =
370370
llvm::FunctionType::get(ObjectPtrTy, args, false);
371371
return CGM.CreateRuntimeFunction(FTy, "objc_read_weak");
@@ -374,7 +374,7 @@ class ObjCCommonTypesHelper {
374374
/// GcAssignWeakFn -- LLVM objc_assign_weak function.
375375
llvm::FunctionCallee getGcAssignWeakFn() {
376376
// id objc_assign_weak (id, id *)
377-
llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
377+
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
378378
llvm::FunctionType *FTy =
379379
llvm::FunctionType::get(ObjectPtrTy, args, false);
380380
return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
@@ -383,7 +383,7 @@ class ObjCCommonTypesHelper {
383383
/// GcAssignGlobalFn -- LLVM objc_assign_global function.
384384
llvm::FunctionCallee getGcAssignGlobalFn() {
385385
// id objc_assign_global(id, id *)
386-
llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
386+
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
387387
llvm::FunctionType *FTy =
388388
llvm::FunctionType::get(ObjectPtrTy, args, false);
389389
return CGM.CreateRuntimeFunction(FTy, "objc_assign_global");
@@ -392,7 +392,7 @@ class ObjCCommonTypesHelper {
392392
/// GcAssignThreadLocalFn -- LLVM objc_assign_threadlocal function.
393393
llvm::FunctionCallee getGcAssignThreadLocalFn() {
394394
// id objc_assign_threadlocal(id src, id * dest)
395-
llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
395+
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
396396
llvm::FunctionType *FTy =
397397
llvm::FunctionType::get(ObjectPtrTy, args, false);
398398
return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal");
@@ -401,8 +401,7 @@ class ObjCCommonTypesHelper {
401401
/// GcAssignIvarFn -- LLVM objc_assign_ivar function.
402402
llvm::FunctionCallee getGcAssignIvarFn() {
403403
// id objc_assign_ivar(id, id *, ptrdiff_t)
404-
llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo(),
405-
CGM.PtrDiffTy };
404+
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy};
406405
llvm::FunctionType *FTy =
407406
llvm::FunctionType::get(ObjectPtrTy, args, false);
408407
return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar");
@@ -419,7 +418,7 @@ class ObjCCommonTypesHelper {
419418
/// GcAssignStrongCastFn -- LLVM objc_assign_strongCast function.
420419
llvm::FunctionCallee getGcAssignStrongCastFn() {
421420
// id objc_assign_strongCast(id, id *)
422-
llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
421+
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
423422
llvm::FunctionType *FTy =
424423
llvm::FunctionType::get(ObjectPtrTy, args, false);
425424
return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast");
@@ -554,23 +553,23 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
554553

555554
/// ExceptionTryEnterFn - LLVM objc_exception_try_enter function.
556555
llvm::FunctionCallee getExceptionTryEnterFn() {
557-
llvm::Type *params[] = { ExceptionDataTy->getPointerTo() };
556+
llvm::Type *params[] = {CGM.UnqualPtrTy};
558557
return CGM.CreateRuntimeFunction(
559558
llvm::FunctionType::get(CGM.VoidTy, params, false),
560559
"objc_exception_try_enter");
561560
}
562561

563562
/// ExceptionTryExitFn - LLVM objc_exception_try_exit function.
564563
llvm::FunctionCallee getExceptionTryExitFn() {
565-
llvm::Type *params[] = { ExceptionDataTy->getPointerTo() };
564+
llvm::Type *params[] = {CGM.UnqualPtrTy};
566565
return CGM.CreateRuntimeFunction(
567566
llvm::FunctionType::get(CGM.VoidTy, params, false),
568567
"objc_exception_try_exit");
569568
}
570569

571570
/// ExceptionExtractFn - LLVM objc_exception_extract function.
572571
llvm::FunctionCallee getExceptionExtractFn() {
573-
llvm::Type *params[] = { ExceptionDataTy->getPointerTo() };
572+
llvm::Type *params[] = {CGM.UnqualPtrTy};
574573
return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
575574
params, false),
576575
"objc_exception_extract");
@@ -587,7 +586,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
587586
/// SetJmpFn - LLVM _setjmp function.
588587
llvm::FunctionCallee getSetJmpFn() {
589588
// This is specifically the prototype for x86.
590-
llvm::Type *params[] = { CGM.Int32Ty->getPointerTo() };
589+
llvm::Type *params[] = {CGM.UnqualPtrTy};
591590
return CGM.CreateRuntimeFunction(
592591
llvm::FunctionType::get(CGM.Int32Ty, params, false), "_setjmp",
593592
llvm::AttributeList::get(CGM.getLLVMContext(),
@@ -6051,9 +6050,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
60516050
Int8PtrTy, PropertyListPtrTy);
60526051

60536052
// ImpnfABITy - LLVM for id (*)(id, SEL, ...)
6054-
llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };
6055-
ImpnfABITy = llvm::FunctionType::get(ObjectPtrTy, params, false)
6056-
->getPointerTo();
6053+
ImpnfABITy = CGM.UnqualPtrTy;
60576054

60586055
// struct _class_t {
60596056
// struct _class_t *isa;
@@ -6469,8 +6466,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
64696466
llvm::GlobalValue::ExternalLinkage, nullptr,
64706467
"_objc_empty_vtable");
64716468
else
6472-
ObjCEmptyVtableVar =
6473-
llvm::ConstantPointerNull::get(ObjCTypes.ImpnfABITy->getPointerTo());
6469+
ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.UnqualPtrTy);
64746470
}
64756471

64766472
// FIXME: Is this correct (that meta class size is never computed)?

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,7 +2727,8 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
27272727
}
27282728

27292729
if (Header)
2730-
OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n";
2730+
OS << "class CLANG_ABI " << R.getName() << "Attr : public " << SuperName
2731+
<< " {\n";
27312732
else
27322733
OS << "\n// " << R.getName() << "Attr implementation\n\n";
27332734

@@ -3185,7 +3186,8 @@ void clang::EmitClangAttrClass(const RecordKeeper &Records, raw_ostream &OS) {
31853186
emitSourceFileHeader("Attribute classes' definitions", OS, Records);
31863187

31873188
OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
3188-
OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n";
3189+
OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n";
3190+
OS << "#include \"clang/Support/Compiler.h\"\n\n";
31893191

31903192
emitAttributes(Records, OS, true);
31913193

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515

1616
#include "interception/interception.h"
1717
#include "sanitizer_common/sanitizer_allocator_dlsym.h"
18-
#include "sanitizer_common/sanitizer_allocator_internal.h"
1918
#include "sanitizer_common/sanitizer_platform_interceptors.h"
2019

2120
#include "interception/interception.h"
2221
#include "rtsan/rtsan.h"
23-
#include "rtsan/rtsan_context.h"
2422

2523
#if SANITIZER_APPLE
2624

@@ -33,11 +31,11 @@ extern "C" {
3331
typedef int32_t OSSpinLock;
3432
void OSSpinLockLock(volatile OSSpinLock *__lock);
3533
}
36-
#endif
34+
#endif // TARGET_OS_MAC
3735

3836
#include <libkern/OSAtomic.h>
3937
#include <os/lock.h>
40-
#endif
38+
#endif // SANITIZER_APPLE
4139

4240
#if SANITIZER_INTERCEPT_MEMALIGN || SANITIZER_INTERCEPT_PVALLOC
4341
#include <malloc.h>

0 commit comments

Comments
 (0)