Skip to content

Commit 02e41b1

Browse files
authored
Merge branch 'main' into hgh/libcxx/P2944R3-optional-constrained-equality
2 parents e17ef64 + d7c7c46 commit 02e41b1

File tree

17 files changed

+294
-128
lines changed

17 files changed

+294
-128
lines changed

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
104104
return builder.createBoolToInt(value, dstTy);
105105
if (mlir::isa<cir::BoolType>(dstTy))
106106
return value;
107+
llvm_unreachable("Can only promote integer or boolean types");
107108
}
108109

109110
//===--------------------------------------------------------------------===//
@@ -1857,9 +1858,6 @@ mlir::Value ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *e) {
18571858

18581859
// ZExt result to the expr type.
18591860
return maybePromoteBoolResult(boolVal, cgf.convertType(e->getType()));
1860-
1861-
cgf.cgm.errorNYI("destination type for logical-not unary operator is NYI");
1862-
return {};
18631861
}
18641862

18651863
/// Return the size or alignment of the type of argument of the sizeof

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,14 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
14831483
if (!Weights && CGM.getCodeGenOpts().OptimizationLevel)
14841484
BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
14851485
BoolCondVal, Stmt::getLikelihood(S.getBody()));
1486-
Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
1486+
auto *I = Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
1487+
// Key Instructions: Emit the condition and branch as separate atoms to
1488+
// match existing loop stepping behaviour. FIXME: We could have the branch as
1489+
// the backup location for the condition, which would probably be a better
1490+
// experience.
1491+
if (auto *CondI = dyn_cast<llvm::Instruction>(BoolCondVal))
1492+
addInstToNewSourceAtom(CondI, nullptr);
1493+
addInstToNewSourceAtom(I, nullptr);
14871494

14881495
if (ExitBlock != LoopExit.getBlock()) {
14891496
EmitBlock(ExitBlock);
@@ -1508,6 +1515,9 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
15081515
EmitStmt(S.getLoopVarStmt());
15091516
EmitStmt(S.getBody());
15101517
}
1518+
// The last block in the loop's body (which unconditionally branches to the
1519+
// `inc` block if there is one).
1520+
auto *FinalBodyBB = Builder.GetInsertBlock();
15111521

15121522
EmitStopPoint(&S);
15131523
// If there is an increment, emit it next.
@@ -1532,6 +1542,12 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
15321542

15331543
if (CGM.shouldEmitConvergenceTokens())
15341544
ConvergenceTokenStack.pop_back();
1545+
1546+
if (FinalBodyBB) {
1547+
// We want the for closing brace to be step-able on to match existing
1548+
// behaviour.
1549+
addInstToNewSourceAtom(FinalBodyBB->getTerminator(), nullptr);
1550+
}
15351551
}
15361552

15371553
void CodeGenFunction::EmitReturnOfRValue(RValue RV, QualType Ty) {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - \
2+
// RUN: | FileCheck %s
3+
4+
// Perennial question: should the inc be its own source atom or not
5+
// (currently it is).
6+
7+
// FIXME: See do.c and while.c regarding cmp and cond br groups.
8+
9+
// The stores in the setup (stores to __RANGE1, __BEGIN1, __END1) are all
10+
// marked as Key. Unclear whether that's desirable. Keep for now as that's
11+
// least risky (at worst it introduces an unnecessary step while debugging,
12+
// as opposed to potentially losing one we want).
13+
14+
// Check the conditional branch (and the condition) in FOR_COND and
15+
// unconditional branch in FOR_BODY are Key Instructions.
16+
17+
struct Range {
18+
int *begin();
19+
int *end();
20+
} r;
21+
22+
// CHECK-LABEL: define dso_local void @_Z1av(
23+
// CHECK-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG10:![0-9]+]] {
24+
// CHECK-NEXT: [[ENTRY:.*:]]
25+
// CHECK-NEXT: [[__RANGE1:%.*]] = alloca ptr, align 8
26+
// CHECK-NEXT: [[__BEGIN1:%.*]] = alloca ptr, align 8
27+
// CHECK-NEXT: [[__END1:%.*]] = alloca ptr, align 8
28+
// CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
29+
// CHECK-NEXT: store ptr @r, ptr [[__RANGE1]], align 8, !dbg [[DBG14:![0-9]+]]
30+
// CHECK-NEXT: [[CALL:%.*]] = call noundef ptr @_ZN5Range5beginEv(ptr noundef nonnull align 1 dereferenceable(1) @r), !dbg [[DBG15:![0-9]+]]
31+
// CHECK-NEXT: store ptr [[CALL]], ptr [[__BEGIN1]], align 8, !dbg [[DBG16:![0-9]+]]
32+
// CHECK-NEXT: [[CALL1:%.*]] = call noundef ptr @_ZN5Range3endEv(ptr noundef nonnull align 1 dereferenceable(1) @r), !dbg [[DBG17:![0-9]+]]
33+
// CHECK-NEXT: store ptr [[CALL1]], ptr [[__END1]], align 8, !dbg [[DBG18:![0-9]+]]
34+
// CHECK-NEXT: br label %[[FOR_COND:.*]], !dbg [[DBG19:![0-9]+]]
35+
// CHECK: [[FOR_COND]]:
36+
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[__BEGIN1]], align 8, !dbg [[DBG19]]
37+
// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[__END1]], align 8, !dbg [[DBG19]]
38+
// CHECK-NEXT: [[CMP:%.*]] = icmp ne ptr [[TMP0]], [[TMP1]], !dbg [[DBG20:![0-9]+]]
39+
// CHECK-NEXT: br i1 [[CMP]], label %[[FOR_BODY:.*]], label %[[FOR_END:.*]], !dbg [[DBG21:![0-9]+]]
40+
// CHECK: [[FOR_BODY]]:
41+
// CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[__BEGIN1]], align 8, !dbg [[DBG19]]
42+
// CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4, !dbg [[DBG22:![0-9]+]]
43+
// CHECK-NEXT: store i32 [[TMP3]], ptr [[I]], align 4, !dbg [[DBG23:![0-9]+]]
44+
// CHECK-NEXT: br label %[[FOR_INC:.*]], !dbg [[DBG24:![0-9]+]]
45+
// CHECK: [[FOR_INC]]:
46+
// CHECK-NEXT: [[TMP4:%.*]] = load ptr, ptr [[__BEGIN1]], align 8, !dbg [[DBG19]]
47+
// CHECK-NEXT: [[INCDEC_PTR:%.*]] = getelementptr inbounds nuw i32, ptr [[TMP4]], i32 1, !dbg [[DBG25:![0-9]+]]
48+
// CHECK-NEXT: store ptr [[INCDEC_PTR]], ptr [[__BEGIN1]], align 8, !dbg [[DBG26:![0-9]+]]
49+
// CHECK-NEXT: br label %[[FOR_COND]], !dbg [[DBG19]], !llvm.loop
50+
// CHECK: [[FOR_END]]:
51+
// CHECK-NEXT: ret void, !dbg [[DBG30:![0-9]+]]
52+
//
53+
void a() {
54+
for (int i: r)
55+
;
56+
}
57+
58+
// - Check the branch out of the body gets an atom group (and gets it correct
59+
// if there's ctrl-flow in the body).
60+
void b() {
61+
for (int i: r) {
62+
if (i)
63+
;
64+
// CHECK: entry:
65+
// CHECK: if.end:
66+
// CHECK-NEXT: br label %for.inc, !dbg [[b_br:!.*]]
67+
}
68+
}
69+
70+
// - Check an immediate loop exit (`break` in this case) gets an atom group and
71+
// - doesn't cause a crash.
72+
void c() {
73+
for (int i: r)
74+
// CHECK: entry:
75+
// CHECK: for.body:
76+
// CHECK: br label %for.end, !dbg [[c_br:!.*]]
77+
break;
78+
}
79+
80+
//.
81+
// CHECK: [[DBG14]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
82+
// CHECK: [[DBG15]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
83+
// CHECK: [[DBG16]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
84+
// CHECK: [[DBG17]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
85+
// CHECK: [[DBG18]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
86+
// CHECK: [[DBG19]] = !DILocation({{.*}})
87+
// CHECK: [[DBG20]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
88+
// CHECK: [[DBG21]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
89+
// CHECK: [[DBG22]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 2)
90+
// CHECK: [[DBG23]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 1)
91+
// CHECK: [[DBG24]] = !DILocation({{.*}} atomGroup: 8, atomRank: 1)
92+
// CHECK: [[DBG25]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 2)
93+
// CHECK: [[DBG26]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 1)
94+
// CHECK: [[DBG30]] = !DILocation({{.*}})
95+
//
96+
// CHECK: [[b_br]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
97+
//
98+
// CHECK: [[c_br]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
99+
//.

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed {
13031303
llvm_unreachable("Unimplemented option");
13041304
}
13051305

1306-
return {};
1306+
return error;
13071307
}
13081308

13091309
void OptionParsingStarting(ExecutionContext *execution_context) override {

lldb/source/Symbol/SaveCoreOptions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Status SaveCoreOptions::SetPluginName(const char *name) {
2424
if (!PluginManager::IsRegisteredObjectFilePluginName(name)) {
2525
return Status::FromErrorStringWithFormat(
2626
"plugin name '%s' is not a valid ObjectFile plugin name", name);
27-
return error;
2827
}
2928

3029
m_plugin_name = name;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This checks that lldb returns an error if process save-core is called
2+
# with a plugin that does not exist.
3+
4+
# RUN: %clang_host -g %S/Inputs/main.c -o %t
5+
# RUN: %lldb %t -s %s -o exit 2>&1 | FileCheck %s
6+
7+
b main
8+
# CHECK-LABEL: b main
9+
# CHECK: Breakpoint 1: where = {{.*}}`main
10+
11+
run
12+
# CHECK-LABEL: run
13+
# CHECK: Process {{.*}} stopped
14+
# CHECK: stop reason = breakpoint 1
15+
# CHECK: frame #0: {{.*}}`main at main.c
16+
17+
process save-core --plugin-name=notaplugin dump
18+
# CHECK-LABEL: process save-core --plugin-name=notaplugin dump
19+
# CHECK: error: plugin name 'notaplugin' is not a valid ObjectFile plugin name

llvm/docs/CommandGuide/lit.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ GENERAL OPTIONS
6363

6464
Show :program:`lit`'s version number and exit.
6565

66-
.. option:: -j N, --workers=N
66+
.. option:: -j N, --workers N
6767

6868
Run ``N`` tests in parallel. By default, this is automatically chosen to
6969
match the number of detected available CPUs.
7070

71-
.. option:: --config-prefix=NAME
71+
.. option:: --config-prefix NAME
7272

7373
Search for :file:`{NAME}.cfg` and :file:`{NAME}.site.cfg` when searching for
7474
test suites, instead of :file:`lit.cfg` and :file:`lit.site.cfg`.
@@ -157,7 +157,7 @@ EXECUTION OPTIONS
157157

158158
Disable sharding for GoogleTest format.
159159

160-
.. option:: --path=PATH
160+
.. option:: --path PATH
161161

162162
Specify an additional ``PATH`` to use when searching for executables in tests.
163163

@@ -178,7 +178,7 @@ EXECUTION OPTIONS
178178
feature that can be used to conditionally disable (or expect failure in)
179179
certain tests.
180180

181-
.. option:: --vg-arg=ARG
181+
.. option:: --vg-arg ARG
182182

183183
When :option:`--vg` is used, specify an additional argument to pass to
184184
:program:`valgrind` itself.
@@ -208,7 +208,7 @@ EXECUTION OPTIONS
208208
Maximum time to spend running a single test (in seconds). 0 means no time
209209
limit. [Default: 0]
210210

211-
.. option:: --timeout=N
211+
.. option:: --timeout N
212212

213213
Spend at most ``N`` seconds (approximately) running each individual test.
214214
``0`` means no time limit, and ``0`` is the default. Note that this is not an
@@ -268,17 +268,17 @@ The timing data is stored in the `test_exec_root` in a file named
268268
`.lit_test_times.txt`. If this file does not exist, then `lit` checks the
269269
`test_source_root` for the file to optionally accelerate clean builds.
270270

271-
.. option:: --max-tests=N
271+
.. option:: --max-tests N
272272

273273
Run at most ``N`` tests and then terminate.
274274

275-
.. option:: --max-time=N
275+
.. option:: --max-time N
276276

277277
Spend at most ``N`` seconds (approximately) running tests and then terminate.
278278
Note that this is not an alias for :option:`--timeout`; the two are
279279
different kinds of maximums.
280280

281-
.. option:: --order={lexical,random,smart}
281+
.. option:: --order {lexical,random,smart}
282282

283283
Define the order in which tests are run. The supported values are:
284284

@@ -300,21 +300,21 @@ The timing data is stored in the `test_exec_root` in a file named
300300

301301
Run failed tests first (DEPRECATED: use ``--order=smart``).
302302

303-
.. option:: --filter=REGEXP
303+
.. option:: --filter REGEXP
304304

305305
Run only those tests whose name matches the regular expression specified in
306306
``REGEXP``. The environment variable ``LIT_FILTER`` can be also used in place
307307
of this option, which is especially useful in environments where the call
308308
to ``lit`` is issued indirectly.
309309

310-
.. option:: --filter-out=REGEXP
310+
.. option:: --filter-out REGEXP
311311

312312
Filter out those tests whose name matches the regular expression specified in
313313
``REGEXP``. The environment variable ``LIT_FILTER_OUT`` can be also used in
314314
place of this option, which is especially useful in environments where the
315315
call to ``lit`` is issued indirectly.
316316

317-
.. option:: --xfail=LIST
317+
.. option:: --xfail LIST
318318

319319
Treat those tests whose name is in the semicolon separated list ``LIST`` as
320320
``XFAIL``. This can be helpful when one does not want to modify the test
@@ -346,7 +346,7 @@ The timing data is stored in the `test_exec_root` in a file named
346346
347347
LIT_XFAIL="affinity/kmp-hw-subset.c;libomptarget :: x86_64-pc-linux-gnu :: offloading/memory_manager.cpp"
348348
349-
.. option:: --xfail-not=LIST
349+
.. option:: --xfail-not LIST
350350

351351
Do not treat the specified tests as ``XFAIL``. The environment variable
352352
``LIT_XFAIL_NOT`` can also be used in place of this option. The syntax is the
@@ -356,7 +356,7 @@ The timing data is stored in the `test_exec_root` in a file named
356356
primary purpose is to suppress an ``XPASS`` result without modifying a test
357357
case that uses the ``XFAIL`` directive.
358358

359-
.. option:: --num-shards=M
359+
.. option:: --num-shards M
360360

361361
Divide the set of selected tests into ``M`` equal-sized subsets or
362362
"shards", and run only one of them. Must be used with the
@@ -366,7 +366,7 @@ The timing data is stored in the `test_exec_root` in a file named
366366
testsuites, for parallel execution on separate machines (say in a large
367367
testing farm).
368368

369-
.. option:: --run-shard=N
369+
.. option:: --run-shard N
370370

371371
Select which shard to run, assuming the ``--num-shards=M`` option was
372372
provided. The two options must be used together, and the value of ``N``

0 commit comments

Comments
 (0)