Skip to content

Commit 38dc2e1

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:64735ad63975 into amd-gfx:0ea05753df73
Local branch amd-gfx 0ea0575 Manual merge main:2cd8207b26ea into amd-gfx:6f68ba52734c Remote branch main 64735ad [libclc] Move sign to the CLC builtins library (llvm#115699)
2 parents 0ea0575 + 64735ad commit 38dc2e1

File tree

63 files changed

+1288
-984
lines changed

Some content is hidden

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

63 files changed

+1288
-984
lines changed

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CallDescription {
3535
/// Match calls to functions from the C standard library. This also
3636
/// recognizes builtin variants whose name is derived by adding
3737
/// "__builtin", "__inline" or similar prefixes or suffixes; but only
38-
/// matches functions than are externally visible and are declared either
38+
/// matches functions that are externally visible and are declared either
3939
/// directly within a TU or in the namespace 'std'.
4040
/// For the exact heuristics, see CheckerContext::isCLibraryFunction().
4141
CLibrary,
@@ -152,7 +152,7 @@ class CallDescription {
152152
/// exists only when that is not available, for example, when _only_
153153
/// syntactic check is done on a piece of code.
154154
///
155-
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade
155+
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate
156156
/// for syntactic only matching if you are writing a new checker. This is
157157
/// handy if a CallDescriptionMap is already there.
158158
///
@@ -233,7 +233,7 @@ template <typename T> class CallDescriptionMap {
233233
/// exists only when that is not available, for example, when _only_
234234
/// syntactic check is done on a piece of code.
235235
///
236-
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade
236+
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate
237237
/// for syntactic only matching if you are writing a new checker. This is
238238
/// handy if a CallDescriptionMap is already there.
239239
///
@@ -274,7 +274,7 @@ class CallDescriptionSet {
274274
/// exists only when that is not available, for example, when _only_
275275
/// syntactic check is done on a piece of code.
276276
///
277-
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade
277+
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate
278278
/// for syntactic only matching if you are writing a new checker. This is
279279
/// handy if a CallDescriptionMap is already there.
280280
///

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E,
247247
}
248248
return T;
249249
};
250-
while (!Type.isNull()) {
250+
// As an additional protection against infinite loops, bound the number of
251+
// simplification steps.
252+
size_t StepCount = 0;
253+
const size_t MaxSteps = 64;
254+
while (!Type.isNull() && StepCount++ < MaxSteps) {
251255
QualType New = SimplifyOneStep(Type);
252256
if (New == Type)
253257
break;

clang/test/AST/ByteCode/builtin-functions.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,22 @@ namespace BuiltinMemcpy {
12721272
return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3];
12731273
}
12741274
static_assert(test_incomplete_array_type() == 1234); // both-error {{constant}} both-note {{in call}}
1275+
1276+
1277+
/// FIXME: memmove needs to support overlapping memory regions.
1278+
constexpr bool memmoveOverlapping() {
1279+
char s1[] {1, 2, 3};
1280+
__builtin_memmove(s1, s1 + 1, 2 * sizeof(char));
1281+
// Now: 2, 3, 3
1282+
bool Result1 = (s1[0] == 2 && s1[1] == 3 && s1[2]== 3);
1283+
1284+
__builtin_memmove(s1 + 1, s1, 2 * sizeof(char));
1285+
// Now: 2, 2, 3
1286+
bool Result2 = (s1[0] == 2 && s1[1] == 2 && s1[2]== 3);
1287+
1288+
return Result1 && Result2;
1289+
}
1290+
static_assert(memmoveOverlapping()); // expected-error {{failed}}
12751291
}
12761292

12771293
namespace Memcmp {

compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ TEST(SanitizerCommon, ReportFile) {
352352
// This will close tmpfile.
353353
report_file.SetReportPath("stderr");
354354
Unlink(tmpfile);
355+
Unlink(path);
355356
}
356357

357358
TEST(SanitizerCommon, FileExists) {

compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@ int test__aeabi_idivmod(si_int a, si_int b,
1414
{
1515
si_int rem;
1616
du_int ret = __aeabi_idivmod(a, b);
17+
// __aeabi_idivmod actually returns a struct { quotient; remainder; } using
18+
// value_in_regs calling convention. Due to the ABI rules, struct fields
19+
// come in the same order regardless of endianness. However since the
20+
// result is received here as a 64-bit integer, in which endianness does
21+
// matter, the position of each component (quotient and remainder) varies
22+
// depending on endianness.
23+
# if _YUGA_BIG_ENDIAN
24+
rem = ret & 0xFFFFFFFF;
25+
si_int result = ret >> 32;
26+
# else
1727
rem = ret >> 32;
1828
si_int result = ret & 0xFFFFFFFF;
29+
# endif
1930
if (result != expected_result) {
2031
printf("error in __aeabi_idivmod: %d / %d = %d, expected %d\n",
2132
a, b, result, expected_result);

compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,19 @@ int test__aeabi_uidivmod(su_int a, su_int b,
1313
su_int expected_result, su_int expected_rem)
1414
{
1515
du_int ret = __aeabi_uidivmod(a, b);
16+
// __aeabi_uidivmod actually returns a struct { quotient; remainder; }
17+
// using value_in_regs calling convention. Due to the ABI rules, struct
18+
// fields come in the same order regardless of endianness. However since
19+
// the result is received here as a 64-bit integer, in which endianness
20+
// does matter, the position of each component (quotient and remainder)
21+
// varies depending on endianness.
22+
# if _YUGA_BIG_ENDIAN
23+
su_int rem = ret & 0xFFFFFFFF;
24+
si_int result = ret >> 32;
25+
# else
1626
su_int rem = ret >> 32;
1727
si_int result = ret & 0xFFFFFFFF;
28+
# endif
1829

1930
if (result != expected_result) {
2031
printf("error in __aeabi_uidivmod: %u / %u = %u, expected %u\n",

compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,37 @@ COMPILER_RT_ABI void /* __value_in_regs */ __aeabi_uldivmod(du_int a, du_int b);
1212
int test_aeabi_uldivmod(du_int a, du_int b, du_int expected_q, du_int expected_r)
1313
{
1414
du_int q, r;
15+
// __aeabi_uldivmod returns a struct { quotient; remainder; } using
16+
// value_in_regs calling convention. Each field is a 64-bit integer, so the
17+
// quotient resides in r0 and r1, while the remainder in r2 and r3. The
18+
// byte order however depends on the endianness.
1519
__asm__(
20+
# if _YUGA_BIG_ENDIAN
21+
"movs r1, %Q[a] \n"
22+
"movs r0, %R[a] \n"
23+
"movs r3, %Q[b] \n"
24+
"movs r2, %R[b] \n"
25+
# else
1626
"movs r0, %Q[a] \n"
1727
"movs r1, %R[a] \n"
1828
"movs r2, %Q[b] \n"
1929
"movs r3, %R[b] \n"
30+
# endif
2031
"bl __aeabi_uldivmod \n"
32+
# if _YUGA_BIG_ENDIAN
33+
"movs %Q[q], r1\n"
34+
"movs %R[q], r0\n"
35+
"movs %Q[r], r3\n"
36+
"movs %R[r], r2\n"
37+
# else
2138
"movs %Q[q], r0\n"
2239
"movs %R[q], r1\n"
2340
"movs %Q[r], r2\n"
2441
"movs %R[r], r3\n"
25-
: [q] "=r" (q), [r] "=r"(r)
42+
# endif
43+
: [q] "=r"(q), [r] "=r"(r)
2644
: [a] "r"(a), [b] "r"(b)
27-
: "lr", "r0", "r1", "r2", "r3"
28-
);
45+
: "lr", "r0", "r1", "r2", "r3");
2946
if (q != expected_q || r != expected_r)
3047
printf("error in aeabi_uldivmod: %llX / %llX = %llX, R = %llX, expected %llX, %llX\n",
3148
a, b, q, r, expected_q, expected_r);

0 commit comments

Comments
 (0)