Skip to content

Commit 17760ee

Browse files
committed
rebase
Created using spr 1.3.4
2 parents 0e58030 + 3121da5 commit 17760ee

File tree

64 files changed

+668
-218
lines changed

Some content is hidden

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

64 files changed

+668
-218
lines changed

clang/test/CodeGenCXX/wasm-eh.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct Cleanup {
1717
};
1818

1919
// Multiple catch clauses w/o catch-all
20-
void test0() {
20+
void multiple_catches_wo_catch_all() {
2121
try {
2222
may_throw();
2323
} catch (int) {
@@ -27,7 +27,7 @@ void test0() {
2727
}
2828
}
2929

30-
// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality ptr @__gxx_wasm_personality_v0
30+
// CHECK-LABEL: define void @_Z29multiple_catches_wo_catch_allv() {{.*}} personality ptr @__gxx_wasm_personality_v0
3131

3232
// CHECK: %[[INT_ALLOCA:.*]] = alloca i32
3333
// CHECK: invoke void @_Z9may_throwv()
@@ -73,15 +73,15 @@ void test0() {
7373
// CHECK-NEXT: unreachable
7474

7575
// Single catch-all
76-
void test1() {
76+
void single_catch_all() {
7777
try {
7878
may_throw();
7979
} catch (...) {
8080
dont_throw();
8181
}
8282
}
8383

84-
// CATCH-LABEL: @_Z5test1v()
84+
// CATCH-LABEL: @_Z16single_catch_allv()
8585

8686
// CHECK: %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
8787

@@ -93,7 +93,7 @@ void test1() {
9393
// CHECK: catchret from %[[CATCHPAD]] to label
9494

9595
// Multiple catch clauses w/ catch-all
96-
void test2() {
96+
void multiple_catches_w_catch_all() {
9797
try {
9898
may_throw();
9999
} catch (int) {
@@ -103,7 +103,7 @@ void test2() {
103103
}
104104
}
105105

106-
// CHECK-LABEL: @_Z5test2v()
106+
// CHECK-LABEL: @_Z28multiple_catches_w_catch_allv()
107107

108108
// CHECK: %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
109109

@@ -118,12 +118,12 @@ void test2() {
118118
// CHECK: catchret from %[[CATCHPAD]] to label
119119

120120
// Cleanup
121-
void test3() {
121+
void cleanup() {
122122
Cleanup c;
123123
may_throw();
124124
}
125125

126-
// CHECK-LABEL: @_Z5test3v()
126+
// CHECK-LABEL: @_Z7cleanupv()
127127

128128
// CHECK: invoke void @_Z9may_throwv()
129129
// CHECK-NEXT: to label {{.*}} unwind label %[[EHCLEANUP_BB:.*]]
@@ -134,15 +134,15 @@ void test3() {
134134
// CHECK-NEXT: cleanupret from %[[CLEANUPPAD]] unwind to caller
135135

136136
// Possibly throwing function call within a catch
137-
void test4() {
137+
void catch_int() {
138138
try {
139139
may_throw();
140140
} catch (int) {
141141
may_throw();
142142
}
143143
}
144144

145-
// CHECK-LABEL: @_Z5test4v()
145+
// CHECK-LABEL: @_Z9catch_intv()
146146

147147
// CHECK: %[[CATCHSWITCH]] = catchswitch within none [label %[[CATCHSTART_BB]]] unwind to caller
148148

@@ -162,15 +162,15 @@ void test4() {
162162
// CHECK-NEXT: cleanupret from %[[CLEANUPPAD]] unwind to caller
163163

164164
// Possibly throwing function call within a catch-all
165-
void test5() {
165+
void catch_all() {
166166
try {
167167
may_throw();
168168
} catch (...) {
169169
may_throw();
170170
}
171171
}
172172

173-
// CHECK-LABEL: @_Z5test5v()
173+
// CHECK-LABEL: @_Z9catch_allv()
174174

175175
// CHECK: %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB]]] unwind to caller
176176

@@ -198,7 +198,7 @@ void test5() {
198198
// CHECK-NEXT: unreachable
199199

200200
// Try-catch with cleanups
201-
void test6() {
201+
void try_catch_w_cleanups() {
202202
Cleanup c1;
203203
try {
204204
Cleanup c2;
@@ -209,7 +209,7 @@ void test6() {
209209
}
210210
}
211211

212-
// CHECK-LABEL: @_Z5test6v()
212+
// CHECK-LABEL: @_Z20try_catch_w_cleanupsv()
213213
// CHECK: invoke void @_Z9may_throwv()
214214
// CHECK-NEXT: to label %{{.*}} unwind label %[[EHCLEANUP_BB0:.*]]
215215

@@ -254,7 +254,7 @@ void test6() {
254254
// CHECK-NEXT: unreachable
255255

256256
// Nested try-catches within a try with cleanups
257-
void test7() {
257+
void nested_try_catches_with_cleanups() {
258258
Cleanup c1;
259259
may_throw();
260260
try {
@@ -275,7 +275,7 @@ void test7() {
275275
}
276276
}
277277

278-
// CHECK-LABEL: @_Z5test7v()
278+
// CHECK-LABEL: @_Z32nested_try_catches_with_cleanupsv()
279279
// CHECK: invoke void @_Z9may_throwv()
280280

281281
// CHECK: invoke void @_Z9may_throwv()
@@ -340,7 +340,7 @@ void test7() {
340340
// CHECK: unreachable
341341

342342
// Nested try-catches within a catch
343-
void test8() {
343+
void nested_try_catch_within_catch() {
344344
try {
345345
may_throw();
346346
} catch (int) {
@@ -352,7 +352,7 @@ void test8() {
352352
}
353353
}
354354

355-
// CHECK-LABEL: @_Z5test8v()
355+
// CHECK-LABEL: @_Z29nested_try_catch_within_catchv()
356356
// CHECK: invoke void @_Z9may_throwv()
357357

358358
// CHECK: %[[CATCHSWITCH0:.*]] = catchswitch within none
@@ -402,19 +402,19 @@ void noexcept_throw() noexcept {
402402
// This is controlled by -Wwasm-exception-spec, which is on by default. This
403403
// warning can be suppressed with -Wno-wasm-exception-spec. Checks if a warning
404404
// message is correctly printed or not printed depending on the options.
405-
void test9() throw(int) {
405+
void exception_spec_warning() throw(int) {
406406
}
407407
// WARNING-DEFAULT: warning: dynamic exception specifications with types are currently ignored in wasm
408408
// WARNING-ON: warning: dynamic exception specifications with types are currently ignored in wasm
409409
// WARNING-OFF-NOT: warning: dynamic exception specifications with types are currently ignored in wasm
410410
// EM-EH-WARNING: warning: dynamic exception specifications with types are currently ignored in wasm
411411

412-
// Wasm curremtly treats 'throw()' in the same way as 'noexept'. Check if the
412+
// Wasm currently treats 'throw()' in the same way as 'noexcept'. Check if the
413413
// same warning message is printed as if when a 'noexcept' function throws.
414-
void test10() throw() {
414+
void exception_spec_throw_empty() throw() {
415415
throw 3;
416416
}
417-
// WARNING-DEFAULT: warning: 'test10' has a non-throwing exception specification but can still throw
417+
// WARNING-DEFAULT: warning: 'exception_spec_throw_empty' has a non-throwing exception specification but can still throw
418418
// WARNING-DEFAULT: function declared non-throwing here
419419

420420
// Here we only check if the command enables wasm exception handling in the

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ set(TARGET_LIBC_ENTRYPOINTS
9393
libc.src.strings.bcmp
9494
libc.src.strings.bcopy
9595
libc.src.strings.bzero
96+
libc.src.strings.ffs
97+
libc.src.strings.ffsl
98+
libc.src.strings.ffsll
9699
libc.src.strings.index
97100
libc.src.strings.rindex
98101
libc.src.strings.strcasecmp

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ set(TARGET_LIBC_ENTRYPOINTS
9393
libc.src.strings.bcmp
9494
libc.src.strings.bcopy
9595
libc.src.strings.bzero
96+
libc.src.strings.ffs
97+
libc.src.strings.ffsl
98+
libc.src.strings.ffsll
9699
libc.src.strings.index
97100
libc.src.strings.rindex
98101
libc.src.strings.strcasecmp

libc/include/strings.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ functions:
2929
arguments:
3030
- type: void *
3131
- type: size_t
32+
- name: ffs
33+
standards:
34+
- POSIX
35+
return_type: int
36+
arguments:
37+
- type: int
38+
- name: ffsl
39+
standards:
40+
- POSIX
41+
return_type: int
42+
arguments:
43+
- type: long
44+
- name: ffsll
45+
standards:
46+
- POSIX
47+
return_type: int
48+
arguments:
49+
- type: long long
3250
- name: index
3351
standards:
3452
- BSDExtensions

libc/src/strings/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,36 @@ add_entrypoint_object(
5454
bcopy.h
5555
)
5656

57+
add_entrypoint_object(
58+
ffs
59+
SRCS
60+
ffs.cpp
61+
HDRS
62+
ffs.h
63+
DEPENDS
64+
libc.src.__support.math_extras
65+
)
66+
67+
add_entrypoint_object(
68+
ffsl
69+
SRCS
70+
ffsl.cpp
71+
HDRS
72+
ffsl.h
73+
DEPENDS
74+
libc.src.__support.math_extras
75+
)
76+
77+
add_entrypoint_object(
78+
ffsll
79+
SRCS
80+
ffsll.cpp
81+
HDRS
82+
ffsll.h
83+
DEPENDS
84+
libc.src.__support.math_extras
85+
)
86+
5787
add_entrypoint_object(
5888
index
5989
SRCS

libc/src/strings/ffs.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of ffs ---------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/strings/ffs.h"
10+
#include "src/__support/common.h"
11+
#include "src/__support/macros/config.h"
12+
#include "src/__support/math_extras.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(int, ffs, (int i)) {
17+
return first_trailing_one(static_cast<unsigned>(i));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL

libc/src/strings/ffs.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for ffs ---------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_STRINGS_FFS_H
10+
#define LLVM_LIBC_SRC_STRINGS_FFS_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
int ffs(int i);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_STRINGS_FFS_H

libc/src/strings/ffsl.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of ffsl --------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/strings/ffsl.h"
10+
#include "src/__support/common.h"
11+
#include "src/__support/macros/config.h"
12+
#include "src/__support/math_extras.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(int, ffsl, (long i)) {
17+
return first_trailing_one(static_cast<unsigned long>(i));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL

libc/src/strings/ffsl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for ffsl --------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_STRINGS_FFSL_H
10+
#define LLVM_LIBC_SRC_STRINGS_FFSL_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
int ffsl(long i);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_STRINGS_FFSL_H

libc/src/strings/ffsll.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of ffsll -------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/strings/ffsll.h"
10+
#include "src/__support/common.h"
11+
#include "src/__support/macros/config.h"
12+
#include "src/__support/math_extras.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(int, ffsll, (long long i)) {
17+
return first_trailing_one(static_cast<unsigned long long>(i));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)