Skip to content

Commit a509d1d

Browse files
authored
Merge branch 'main' into main
2 parents 78a4749 + 74275a1 commit a509d1d

File tree

836 files changed

+24443
-9044
lines changed

Some content is hidden

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

836 files changed

+24443
-9044
lines changed

bolt/test/link_fdata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# Regexes to extract FDATA lines from input and parse FDATA and pre-aggregated
3434
# profile data
35-
prefix_pat = re.compile(f"^# {args.prefix}: (.*)")
35+
prefix_pat = re.compile(f"^(#|//) {args.prefix}: (.*)")
3636

3737
# FDATA records:
3838
# <is symbol?> <closest elf symbol or DSO name> <relative FROM address>
@@ -61,7 +61,7 @@
6161
prefix_match = prefix_pat.match(line)
6262
if not prefix_match:
6363
continue
64-
profile_line = prefix_match.group(1)
64+
profile_line = prefix_match.group(2)
6565
fdata_match = fdata_pat.match(profile_line)
6666
preagg_match = preagg_pat.match(profile_line)
6767
nolbr_match = nolbr_pat.match(profile_line)

bolt/test/runtime/copy_file.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
import shutil
3+
4+
with open(sys.argv[1] + ".output") as log_file:
5+
lines = log_file.readlines()
6+
for line in lines:
7+
if line.startswith(sys.argv[2]):
8+
pid = line.split(" ")[1].strip()
9+
shutil.copy(
10+
sys.argv[1] + "." + pid + ".fdata",
11+
sys.argv[1] + "." + sys.argv[3] + ".fdata",
12+
)
13+
sys.exit(0)
14+
15+
sys.exit(1)

bolt/test/runtime/instrumentation-indirect-2.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int main() {
5050
return 0;
5151
}
5252
/*
53-
REQUIRES: system-linux,shell,fuser
53+
REQUIRES: system-linux,fuser
5454
5555
RUN: %clang %cflags %s -o %t.exe -Wl,-q -pie -fpie
5656
@@ -61,10 +61,14 @@ RUN: --instrumentation-wait-forks
6161
6262
# Instrumented program needs to finish returning zero
6363
# Both output and profile must contain all 16 functions
64-
RUN: %t.instrumented_conservative > %t.output
65-
# Wait for profile and output to be fully written
66-
RUN: bash %S/wait_file.sh %t.output
67-
RUN: bash %S/wait_file.sh %t.fdata
64+
# We need to use bash to invoke this as otherwise we hang inside a
65+
# popen.communicate call in lit's internal shell. Eventually we should not
66+
# need this.
67+
# TODO(boomanaiden154): Remove once
68+
# https://github.com/llvm/llvm-project/issues/156484 is fixed.
69+
RUN: bash -c "%t.instrumented_conservative; wait" > %t.output
70+
# We can just read because we ensure the profile will be fully written by
71+
# calling wait inside the bash invocation.
6872
RUN: cat %t.output | FileCheck %s --check-prefix=CHECK-OUTPUT
6973
RUN: cat %t.fdata | FileCheck %s --check-prefix=CHECK-COMMON-PROF
7074
@@ -112,14 +116,8 @@ RUN: bash %S/wait_file.sh %t.output
112116
# Make sure all functions were called
113117
RUN: cat %t.output | FileCheck %s --check-prefix=CHECK-OUTPUT
114118
115-
RUN: child_pid=$(cat %t.output | grep funcA | awk '{print $2;}')
116-
RUN: par_pid=$(cat %t.output | grep funcB | awk '{print $2;}')
117-
118-
RUN: bash %S/wait_file.sh %t.$child_pid.fdata
119-
RUN: bash %S/wait_file.sh %t.$par_pid.fdata
120-
121-
RUN: mv %t.$child_pid.fdata %t.child.fdata
122-
RUN: mv %t.$par_pid.fdata %t.parent.fdata
119+
RUN: %python %S/copy_file.py %t funcA child
120+
RUN: %python %S/copy_file.py %t funcB parent
123121
124122
# Instrumented binary must produce two profiles with only local calls
125123
# recorded. Functions called only in child should not appear in parent's

bolt/test/timers.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
/* This test checks timers for metadata manager phases.
2-
# RUN: %clang %cflags %s -o %t.exe
3-
# RUN: link_fdata %s %t.exe %t.fdata
4-
# RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5-
# RUN: 2>&1 | FileCheck %s
6-
# RUN: link_fdata %s %t.exe %t.preagg PREAGG
7-
# RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8-
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
1+
// This test checks timers for metadata manager phases.
2+
// RUN: %clang %cflags %s -o %t.exe
3+
// RUN: link_fdata %s %t.exe %t.fdata
4+
// RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5+
// RUN: 2>&1 | FileCheck %s
6+
// RUN: link_fdata %s %t.exe %t.preagg PREAGG
7+
// RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
99

10-
# CHECK-DAG: update metadata post-emit
11-
# CHECK-DAG: process section metadata
12-
# CHECK-DAG: process metadata pre-CFG
13-
# CHECK-DAG: process metadata post-CFG
14-
# CHECK-DAG: finalize metadata pre-emit
10+
// CHECK-DAG: update metadata post-emit
11+
// CHECK-DAG: process section metadata
12+
// CHECK-DAG: process metadata pre-CFG
13+
// CHECK-DAG: process metadata post-CFG
14+
// CHECK-DAG: finalize metadata pre-emit
1515

16-
# CHECK-P2B-DAG: process section metadata
17-
# CHECK-P2B-DAG: process metadata pre-CFG
16+
// CHECK-P2B-DAG: process section metadata
17+
// CHECK-P2B-DAG: process metadata pre-CFG
1818

19-
# FDATA: 0 [unknown] 0 1 main 0 1 0
20-
# PREAGG: B X:0 #main# 1 0
21-
*/
19+
// FDATA: 0 [unknown] 0 1 main 0 1 0
20+
// PREAGG: B X:0 #main# 1 0
2221
int main() { return 0; }

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,11 +1106,11 @@ class FindControlFlow : public RecursiveASTVisitor<FindControlFlow> {
11061106
return true;
11071107
}
11081108
bool VisitBreakStmt(BreakStmt *B) {
1109-
found(Break, B->getBreakLoc());
1109+
found(Break, B->getKwLoc());
11101110
return true;
11111111
}
11121112
bool VisitContinueStmt(ContinueStmt *C) {
1113-
found(Continue, C->getContinueLoc());
1113+
found(Continue, C->getKwLoc());
11141114
return true;
11151115
}
11161116
bool VisitSwitchCase(SwitchCase *C) {

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ C Language Changes
134134

135135
C2y Feature Support
136136
^^^^^^^^^^^^^^^^^^^
137+
- Clang now supports `N3355 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm>`_ Named Loops.
137138

138139
C23 Feature Support
139140
^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/JSONNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class JSONNodeDumper
333333
void VisitStringLiteral(const StringLiteral *SL);
334334
void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *BLE);
335335

336+
void VisitLoopControlStmt(const LoopControlStmt *LS);
336337
void VisitIfStmt(const IfStmt *IS);
337338
void VisitSwitchStmt(const SwitchStmt *SS);
338339
void VisitCaseStmt(const CaseStmt *CS);

clang/include/clang/AST/Stmt.h

Lines changed: 80 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -277,24 +277,14 @@ class alignas(void *) Stmt {
277277
SourceLocation GotoLoc;
278278
};
279279

280-
class ContinueStmtBitfields {
281-
friend class ContinueStmt;
280+
class LoopControlStmtBitfields {
281+
friend class LoopControlStmt;
282282

283283
LLVM_PREFERRED_TYPE(StmtBitfields)
284284
unsigned : NumStmtBits;
285285

286-
/// The location of the "continue".
287-
SourceLocation ContinueLoc;
288-
};
289-
290-
class BreakStmtBitfields {
291-
friend class BreakStmt;
292-
293-
LLVM_PREFERRED_TYPE(StmtBitfields)
294-
unsigned : NumStmtBits;
295-
296-
/// The location of the "break".
297-
SourceLocation BreakLoc;
286+
/// The location of the "continue"/"break".
287+
SourceLocation KwLoc;
298288
};
299289

300290
class ReturnStmtBitfields {
@@ -1325,8 +1315,7 @@ class alignas(void *) Stmt {
13251315
DoStmtBitfields DoStmtBits;
13261316
ForStmtBitfields ForStmtBits;
13271317
GotoStmtBitfields GotoStmtBits;
1328-
ContinueStmtBitfields ContinueStmtBits;
1329-
BreakStmtBitfields BreakStmtBits;
1318+
LoopControlStmtBitfields LoopControlStmtBits;
13301319
ReturnStmtBitfields ReturnStmtBits;
13311320
SwitchCaseBitfields SwitchCaseBits;
13321321

@@ -2184,6 +2173,14 @@ class LabelStmt : public ValueStmt {
21842173
SourceLocation getBeginLoc() const { return getIdentLoc(); }
21852174
SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();}
21862175

2176+
/// Look through nested labels and return the first non-label statement; e.g.
2177+
/// if this is 'a:' in 'a: b: c: for(;;)', this returns the for loop.
2178+
const Stmt *getInnermostLabeledStmt() const;
2179+
Stmt *getInnermostLabeledStmt() {
2180+
return const_cast<Stmt *>(
2181+
const_cast<const LabelStmt *>(this)->getInnermostLabeledStmt());
2182+
}
2183+
21872184
child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
21882185

21892186
const_child_range children() const {
@@ -3056,26 +3053,53 @@ class IndirectGotoStmt : public Stmt {
30563053
}
30573054
};
30583055

3059-
/// ContinueStmt - This represents a continue.
3060-
class ContinueStmt : public Stmt {
3061-
public:
3062-
ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass) {
3063-
setContinueLoc(CL);
3056+
/// Base class for BreakStmt and ContinueStmt.
3057+
class LoopControlStmt : public Stmt {
3058+
/// If this is a named break/continue, the label whose statement we're
3059+
/// targeting, as well as the source location of the label after the
3060+
/// keyword; for example:
3061+
///
3062+
/// a: // <-- TargetLabel
3063+
/// for (;;)
3064+
/// break a; // <-- LabelLoc
3065+
///
3066+
LabelDecl *TargetLabel = nullptr;
3067+
SourceLocation LabelLoc;
3068+
3069+
protected:
3070+
LoopControlStmt(StmtClass Class, SourceLocation Loc, SourceLocation LabelLoc,
3071+
LabelDecl *Target)
3072+
: Stmt(Class), TargetLabel(Target), LabelLoc(LabelLoc) {
3073+
setKwLoc(Loc);
30643074
}
30653075

3066-
/// Build an empty continue statement.
3067-
explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {}
3076+
LoopControlStmt(StmtClass Class, SourceLocation Loc)
3077+
: LoopControlStmt(Class, Loc, SourceLocation(), nullptr) {}
30683078

3069-
SourceLocation getContinueLoc() const { return ContinueStmtBits.ContinueLoc; }
3070-
void setContinueLoc(SourceLocation L) { ContinueStmtBits.ContinueLoc = L; }
3079+
LoopControlStmt(StmtClass Class, EmptyShell ES) : Stmt(Class, ES) {}
30713080

3072-
SourceLocation getBeginLoc() const { return getContinueLoc(); }
3073-
SourceLocation getEndLoc() const { return getContinueLoc(); }
3081+
public:
3082+
SourceLocation getKwLoc() const { return LoopControlStmtBits.KwLoc; }
3083+
void setKwLoc(SourceLocation L) { LoopControlStmtBits.KwLoc = L; }
30743084

3075-
static bool classof(const Stmt *T) {
3076-
return T->getStmtClass() == ContinueStmtClass;
3085+
SourceLocation getBeginLoc() const { return getKwLoc(); }
3086+
SourceLocation getEndLoc() const {
3087+
return hasLabelTarget() ? getLabelLoc() : getKwLoc();
30773088
}
30783089

3090+
bool hasLabelTarget() const { return TargetLabel != nullptr; }
3091+
3092+
SourceLocation getLabelLoc() const { return LabelLoc; }
3093+
void setLabelLoc(SourceLocation L) { LabelLoc = L; }
3094+
3095+
LabelDecl *getLabelDecl() { return TargetLabel; }
3096+
const LabelDecl *getLabelDecl() const { return TargetLabel; }
3097+
void setLabelDecl(LabelDecl *S) { TargetLabel = S; }
3098+
3099+
/// If this is a named break/continue, get the loop or switch statement
3100+
/// that this targets.
3101+
const Stmt *getNamedLoopOrSwitch() const;
3102+
30793103
// Iterators
30803104
child_range children() {
30813105
return child_range(child_iterator(), child_iterator());
@@ -3084,35 +3108,42 @@ class ContinueStmt : public Stmt {
30843108
const_child_range children() const {
30853109
return const_child_range(const_child_iterator(), const_child_iterator());
30863110
}
3087-
};
30883111

3089-
/// BreakStmt - This represents a break.
3090-
class BreakStmt : public Stmt {
3091-
public:
3092-
BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass) {
3093-
setBreakLoc(BL);
3112+
static bool classof(const Stmt *T) {
3113+
StmtClass Class = T->getStmtClass();
3114+
return Class == ContinueStmtClass || Class == BreakStmtClass;
30943115
}
3116+
};
30953117

3096-
/// Build an empty break statement.
3097-
explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) {}
3098-
3099-
SourceLocation getBreakLoc() const { return BreakStmtBits.BreakLoc; }
3100-
void setBreakLoc(SourceLocation L) { BreakStmtBits.BreakLoc = L; }
3118+
/// ContinueStmt - This represents a continue.
3119+
class ContinueStmt : public LoopControlStmt {
3120+
public:
3121+
ContinueStmt(SourceLocation CL) : LoopControlStmt(ContinueStmtClass, CL) {}
3122+
ContinueStmt(SourceLocation CL, SourceLocation LabelLoc, LabelDecl *Target)
3123+
: LoopControlStmt(ContinueStmtClass, CL, LabelLoc, Target) {}
31013124

3102-
SourceLocation getBeginLoc() const { return getBreakLoc(); }
3103-
SourceLocation getEndLoc() const { return getBreakLoc(); }
3125+
/// Build an empty continue statement.
3126+
explicit ContinueStmt(EmptyShell Empty)
3127+
: LoopControlStmt(ContinueStmtClass, Empty) {}
31043128

31053129
static bool classof(const Stmt *T) {
3106-
return T->getStmtClass() == BreakStmtClass;
3130+
return T->getStmtClass() == ContinueStmtClass;
31073131
}
3132+
};
31083133

3109-
// Iterators
3110-
child_range children() {
3111-
return child_range(child_iterator(), child_iterator());
3112-
}
3134+
/// BreakStmt - This represents a break.
3135+
class BreakStmt : public LoopControlStmt {
3136+
public:
3137+
BreakStmt(SourceLocation BL) : LoopControlStmt(BreakStmtClass, BL) {}
3138+
BreakStmt(SourceLocation CL, SourceLocation LabelLoc, LabelDecl *Target)
3139+
: LoopControlStmt(BreakStmtClass, CL, LabelLoc, Target) {}
31133140

3114-
const_child_range children() const {
3115-
return const_child_range(const_child_iterator(), const_child_iterator());
3141+
/// Build an empty break statement.
3142+
explicit BreakStmt(EmptyShell Empty)
3143+
: LoopControlStmt(BreakStmtClass, Empty) {}
3144+
3145+
static bool classof(const Stmt *T) {
3146+
return T->getStmtClass() == BreakStmtClass;
31163147
}
31173148
};
31183149

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ class TextNodeDumper
255255
void VisitExpressionTemplateArgument(const TemplateArgument &TA);
256256
void VisitPackTemplateArgument(const TemplateArgument &TA);
257257

258+
void VisitLoopControlStmt(const LoopControlStmt *L);
258259
void VisitIfStmt(const IfStmt *Node);
259260
void VisitSwitchStmt(const SwitchStmt *Node);
260261
void VisitWhileStmt(const WhileStmt *Node);

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ TARGET_BUILTIN(__builtin_amdgcn_global_load_monitor_b128, "V4iV4i*1Ii", "nc", "g
667667
TARGET_BUILTIN(__builtin_amdgcn_flat_load_monitor_b32, "ii*0Ii", "nc", "gfx1250-insts")
668668
TARGET_BUILTIN(__builtin_amdgcn_flat_load_monitor_b64, "V2iV2i*0Ii", "nc", "gfx1250-insts")
669669
TARGET_BUILTIN(__builtin_amdgcn_flat_load_monitor_b128, "V4iV4i*0Ii", "nc", "gfx1250-insts")
670+
TARGET_BUILTIN(__builtin_amdgcn_cluster_load_b32, "ii*1Iii", "nc", "gfx1250-insts,wavefrontsize32")
671+
TARGET_BUILTIN(__builtin_amdgcn_cluster_load_b64, "V2iV2i*1Iii", "nc", "gfx1250-insts,wavefrontsize32")
672+
TARGET_BUILTIN(__builtin_amdgcn_cluster_load_b128, "V4iV4i*1Iii", "nc", "gfx1250-insts,wavefrontsize32")
670673
TARGET_BUILTIN(__builtin_amdgcn_global_load_async_to_lds_b8, "vc*1c*3IiIi", "nc", "gfx1250-insts")
671674
TARGET_BUILTIN(__builtin_amdgcn_global_load_async_to_lds_b32, "vi*1i*3IiIi", "nc", "gfx1250-insts")
672675
TARGET_BUILTIN(__builtin_amdgcn_global_load_async_to_lds_b64, "vV2i*1V2i*3IiIi", "nc", "gfx1250-insts")

0 commit comments

Comments
 (0)