Skip to content

Commit aea909d

Browse files
authored
Merge branch 'main' into users/mtrofin/11-05-_profcheck_exclude_instrumentation_tests_for_now_
2 parents 7a5d826 + 2d51705 commit aea909d

File tree

107 files changed

+2066
-460
lines changed

Some content is hidden

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

107 files changed

+2066
-460
lines changed

bolt/lib/Core/Relocation.cpp

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,41 +1018,15 @@ void Relocation::print(raw_ostream &OS) const {
10181018
default:
10191019
OS << "RType:" << Twine::utohexstr(Type);
10201020
break;
1021-
1022-
case Triple::aarch64: {
1023-
static const char *const AArch64RelocNames[] = {
1024-
#define ELF_RELOC(name, value) #name,
1025-
#include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
1026-
#undef ELF_RELOC
1027-
};
1028-
assert(Type < ArrayRef(AArch64RelocNames).size());
1029-
OS << AArch64RelocNames[Type];
1030-
} break;
1031-
1021+
case Triple::aarch64:
1022+
OS << object::getELFRelocationTypeName(ELF::EM_AARCH64, Type);
1023+
break;
10321024
case Triple::riscv64:
1033-
// RISC-V relocations are not sequentially numbered so we cannot use an
1034-
// array
1035-
switch (Type) {
1036-
default:
1037-
llvm_unreachable("illegal RISC-V relocation");
1038-
#define ELF_RELOC(name, value) \
1039-
case value: \
1040-
OS << #name; \
1025+
OS << object::getELFRelocationTypeName(ELF::EM_RISCV, Type);
10411026
break;
1042-
#include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
1043-
#undef ELF_RELOC
1044-
}
1027+
case Triple::x86_64:
1028+
OS << object::getELFRelocationTypeName(ELF::EM_X86_64, Type);
10451029
break;
1046-
1047-
case Triple::x86_64: {
1048-
static const char *const X86RelocNames[] = {
1049-
#define ELF_RELOC(name, value) #name,
1050-
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
1051-
#undef ELF_RELOC
1052-
};
1053-
assert(Type < ArrayRef(X86RelocNames).size());
1054-
OS << X86RelocNames[Type];
1055-
} break;
10561030
}
10571031
OS << ", 0x" << Twine::utohexstr(Offset);
10581032
if (Symbol) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Verify that llvm-bolt correctly prints relocation types.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: %clang %cflags -nostartfiles %s -o %t.exe -Wl,-q,--no-relax
6+
# RUN: llvm-bolt %t.exe --print-cfg --print-relocations -o %t.bolt \
7+
# RUN: | FileCheck %s
8+
9+
.section .text
10+
.align 4
11+
.globl _start
12+
.type _start, %function
13+
_start:
14+
15+
adrp x0, _start
16+
# CHECK: adrp
17+
# CHECK-SAME: R_AARCH64_ADR_PREL_PG_HI21
18+
19+
add x0, x0, :lo12:_start
20+
# CHECK-NEXT: add
21+
# CHECK-SAME: R_AARCH64_ADD_ABS_LO12_NC
22+
23+
ret
24+
.size _start, .-_start

clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ class TrivialFunctionAnalysisVisitor
578578
return WithCachedResult(CS, [&]() { return VisitChildren(CS); });
579579
}
580580

581+
bool VisitCoroutineBodyStmt(const CoroutineBodyStmt *CBS) {
582+
return WithCachedResult(CBS, [&]() { return VisitChildren(CBS); });
583+
}
584+
581585
bool VisitReturnStmt(const ReturnStmt *RS) {
582586
// A return statement is allowed as long as the return value is trivial.
583587
if (auto *RV = RS->getRetValue())
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.UncountedLambdaCapturesChecker -std=c++20 -verify %s
2+
// expected-no-diagnostics
3+
4+
template<typename Arg>
5+
void foo(Arg&& arg)
6+
{
7+
[&]{
8+
co_await [&](auto&&... args) {
9+
}(arg);
10+
}();
11+
}

libc/src/__support/OSUtil/linux/fcntl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ErrorOr<int> fcntl(int fd, int cmd, void *arg) {
6666
LIBC_NAMESPACE::syscall_impl<int>(FCNTL_SYSCALL_ID, fd, cmd, &flk64);
6767
// On failure, return
6868
if (ret < 0)
69-
return Error(-1);
69+
return Error(-ret);
7070
// Check for overflow, i.e. the offsets are not the same when cast
7171
// to off_t from off64_t.
7272
if (static_cast<off_t>(flk64.l_len) != flk64.l_len ||

libc/src/fcntl/linux/creat.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ LLVM_LIBC_FUNCTION(int, creat, (const char *path, int mode_flags)) {
2727
SYS_openat, AT_FDCWD, path, O_CREAT | O_WRONLY | O_TRUNC, mode_flags);
2828
#endif
2929

30-
if (fd > 0)
31-
return fd;
32-
33-
libc_errno = -fd;
34-
return -1;
30+
if (fd < 0) {
31+
libc_errno = -fd;
32+
return -1;
33+
}
34+
return fd;
3535
}
3636

3737
} // namespace LIBC_NAMESPACE_DECL

libc/src/fcntl/linux/openat.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ LLVM_LIBC_FUNCTION(int, openat, (int dfd, const char *path, int flags, ...)) {
3232

3333
int fd = LIBC_NAMESPACE::syscall_impl<int>(SYS_openat, dfd, path, flags,
3434
mode_flags);
35-
if (fd > 0)
36-
return fd;
37-
38-
libc_errno = -fd;
39-
return -1;
35+
if (fd < 0) {
36+
libc_errno = -fd;
37+
return -1;
38+
}
39+
return fd;
4040
}
4141

4242
} // namespace LIBC_NAMESPACE_DECL

libc/src/stdio/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ add_entrypoint_object(
125125
DEPENDS
126126
libc.src.stdio.printf_core.printf_main
127127
libc.src.stdio.printf_core.writer
128+
libc.src.stdio.printf_core.core_structs
129+
libc.src.stdio.printf_core.error_mapper
130+
libc.src.__support.libc_errno
131+
libc.src.__support.CPP.limits
128132
)
129133

130134
add_entrypoint_object(
@@ -136,6 +140,10 @@ add_entrypoint_object(
136140
DEPENDS
137141
libc.src.stdio.printf_core.printf_main
138142
libc.src.stdio.printf_core.writer
143+
libc.src.stdio.printf_core.core_structs
144+
libc.src.stdio.printf_core.error_mapper
145+
libc.src.__support.libc_errno
146+
libc.src.__support.CPP.limits
139147
)
140148

141149
add_entrypoint_object(
@@ -146,6 +154,10 @@ add_entrypoint_object(
146154
asprintf.h
147155
DEPENDS
148156
libc.src.stdio.printf_core.vasprintf_internal
157+
libc.src.stdio.printf_core.core_structs
158+
libc.src.stdio.printf_core.error_mapper
159+
libc.src.__support.libc_errno
160+
libc.src.__support.CPP.limits
149161
)
150162

151163
add_entrypoint_object(
@@ -157,6 +169,10 @@ add_entrypoint_object(
157169
DEPENDS
158170
libc.src.stdio.printf_core.printf_main
159171
libc.src.stdio.printf_core.writer
172+
libc.src.stdio.printf_core.core_structs
173+
libc.src.stdio.printf_core.error_mapper
174+
libc.src.__support.libc_errno
175+
libc.src.__support.CPP.limits
160176
)
161177

162178
add_entrypoint_object(
@@ -168,6 +184,10 @@ add_entrypoint_object(
168184
DEPENDS
169185
libc.src.stdio.printf_core.printf_main
170186
libc.src.stdio.printf_core.writer
187+
libc.src.stdio.printf_core.core_structs
188+
libc.src.stdio.printf_core.error_mapper
189+
libc.src.__support.libc_errno
190+
libc.src.__support.CPP.limits
171191
)
172192

173193
add_entrypoint_object(
@@ -178,6 +198,10 @@ add_entrypoint_object(
178198
vasprintf.h
179199
DEPENDS
180200
libc.src.stdio.printf_core.vasprintf_internal
201+
libc.src.stdio.printf_core.core_structs
202+
libc.src.stdio.printf_core.error_mapper
203+
libc.src.__support.libc_errno
204+
libc.src.__support.CPP.limits
181205
)
182206

183207
add_subdirectory(printf_core)

libc/src/stdio/asprintf.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/stdio/asprintf.h"
10+
#include "src/__support/CPP/limits.h"
1011
#include "src/__support/arg_list.h"
12+
#include "src/__support/libc_errno.h"
1113
#include "src/__support/macros/config.h"
14+
#include "src/stdio/printf_core/core_structs.h"
15+
#include "src/stdio/printf_core/error_mapper.h"
1216
#include "src/stdio/printf_core/vasprintf_internal.h"
1317

1418
namespace LIBC_NAMESPACE_DECL {
@@ -22,8 +26,18 @@ LLVM_LIBC_FUNCTION(int, asprintf,
2226
// and pointer semantics, as well as handling
2327
// destruction automatically.
2428
va_end(vlist);
25-
int ret = printf_core::vasprintf_internal(buffer, format, args);
26-
return ret;
29+
auto ret_val = printf_core::vasprintf_internal(buffer, format, args);
30+
if (!ret_val.has_value()) {
31+
libc_errno = printf_core::internal_error_to_errno(ret_val.error());
32+
return -1;
33+
}
34+
if (ret_val.value() > static_cast<size_t>(cpp::numeric_limits<int>::max())) {
35+
libc_errno =
36+
printf_core::internal_error_to_errno(-printf_core::OVERFLOW_ERROR);
37+
return -1;
38+
}
39+
40+
return static_cast<int>(ret_val.value());
2741
}
2842

2943
} // namespace LIBC_NAMESPACE_DECL

libc/src/stdio/baremetal/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ add_entrypoint_object(
2929
DEPENDS
3030
libc.src.stdio.printf_core.printf_main
3131
libc.src.stdio.printf_core.writer
32+
libc.src.stdio.printf_core.error_mapper
33+
libc.src.stdio.printf_core.core_structs
3234
libc.src.__support.arg_list
3335
libc.src.__support.OSUtil.osutil
36+
libc.src.__support.libc_errno
37+
libc.src.__support.CPP.limits
3438
)
3539

3640
add_entrypoint_object(
@@ -87,8 +91,12 @@ add_entrypoint_object(
8791
DEPENDS
8892
libc.src.stdio.printf_core.printf_main
8993
libc.src.stdio.printf_core.writer
94+
libc.src.stdio.printf_core.error_mapper
95+
libc.src.stdio.printf_core.core_structs
9096
libc.src.__support.arg_list
9197
libc.src.__support.OSUtil.osutil
98+
libc.src.__support.libc_errno
99+
libc.src.__support.CPP.limits
92100
)
93101

94102
add_entrypoint_object(

0 commit comments

Comments
 (0)