Skip to content

Commit a78a7c8

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3843)
2 parents 9b9b6cc + f87c942 commit a78a7c8

File tree

358 files changed

+7254
-2371
lines changed

Some content is hidden

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

358 files changed

+7254
-2371
lines changed

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

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
@@ -132,6 +132,7 @@ C Language Changes
132132

133133
C2y Feature Support
134134
^^^^^^^^^^^^^^^^^^^
135+
- Clang now supports `N3355 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm>`_ Named Loops.
135136

136137
C23 Feature Support
137138
^^^^^^^^^^^^^^^^^^^

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/DiagnosticDriverKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,6 @@ def err_drv_optimization_remark_format : Error<
374374
def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, please use [no]simd instead">;
375375
def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
376376
def err_drv_incompatible_omp_arch : Error<"OpenMP target architecture '%0' pointer size is incompatible with host '%1'">;
377-
def err_drv_omp_host_ir_file_not_found : Error<
378-
"provided host compiler IR file '%0' is required to generate code for OpenMP "
379-
"target regions but cannot be found">;
380377
def err_drv_omp_host_target_not_supported : Error<
381378
"target '%0' is not a supported OpenMP host target">;
382379
def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<

clang/include/clang/Basic/DiagnosticFrontendKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ def err_target_unsupported_type_for_abi
312312
: Error<"%0 requires %1 type support, but ABI '%2' does not support it">;
313313
}
314314

315+
def err_omp_host_ir_file_not_found : Error<
316+
"provided host compiler IR file '%0' is required to generate code for OpenMP "
317+
"target regions but cannot be found">;
315318
def err_alias_to_undefined : Error<
316319
"%select{alias|ifunc}0 must point to a defined "
317320
"%select{variable or |}1function">;

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ def warn_c23_compat_case_range : Warning<
215215
DefaultIgnore, InGroup<CPre2yCompat>;
216216
def ext_c2y_case_range : Extension<
217217
"case ranges are a C2y extension">, InGroup<C2y>;
218+
def err_c2y_labeled_break_continue : Error<
219+
"named %select{'break'|'continue'}0 is only supported in C2y">;
218220

219221
// Generic errors.
220222
def err_expected_expression : Error<"expected expression">;

0 commit comments

Comments
 (0)