Skip to content

Commit fc10370

Browse files
committed
Merge remote-tracking branch 'upstream/release/14.x' into rustc/14.0-2022-03-22
2 parents 326efc9 + 0e27d08 commit fc10370

File tree

60 files changed

+1027
-228
lines changed

Some content is hidden

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

60 files changed

+1027
-228
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,7 @@ Work around VLLDM erratum CVE-2021-35465 (ARM only)
32933293

32943294
.. option:: -mno-bti-at-return-twice
32953295

3296-
Do not add a BTI instruction after a setjmp or other return-twice construct (Arm only)
3296+
Do not add a BTI instruction after a setjmp or other return-twice construct (AArch32/AArch64 only)
32973297

32983298
.. option:: -mno-movt
32993299

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ Arm and AArch64 Support in Clang
381381
- The ``attribute((target("branch-protection=...)))`` attributes will now also
382382
work for the ARM backend.
383383

384+
- When using ``-mbranch-protection=bti`` with AArch64, calls to setjmp will
385+
now be followed by a BTI instruction. This is done to be compatible with
386+
setjmp implementations that return with a br instead of a ret. You can
387+
disable this behaviour using the ``-mno-bti-at-return-twice`` option.
388+
384389
SPIR-V Support in Clang
385390
-----------------------
386391

@@ -391,7 +396,6 @@ SPIR-V Support in Clang
391396
- Added linking of separate object files in SPIR-V format using external
392397
``spirv-link`` tool.
393398

394-
395399
Floating Point Support in Clang
396400
-------------------------------
397401
- The default setting of FP contraction (FMA) is now -ffp-contract=on (for

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3372,7 +3372,7 @@ def mmark_bti_property : Flag<["-"], "mmark-bti-property">,
33723372
def mno_bti_at_return_twice : Flag<["-"], "mno-bti-at-return-twice">,
33733373
Group<m_arm_Features_Group>,
33743374
HelpText<"Do not add a BTI instruction after a setjmp or other"
3375-
" return-twice construct (Arm only)">;
3375+
" return-twice construct (Arm/AArch64 only)">;
33763376

33773377
foreach i = {1-31} in
33783378
def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group<m_Group>,

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4895,15 +4895,25 @@ RValue CodeGenFunction::EmitSimpleCallExpr(const CallExpr *E,
48954895
return EmitCall(E->getCallee()->getType(), Callee, E, ReturnValue);
48964896
}
48974897

4898+
// Detect the unusual situation where an inline version is shadowed by a
4899+
// non-inline version. In that case we should pick the external one
4900+
// everywhere. That's GCC behavior too.
4901+
static bool OnlyHasInlineBuiltinDeclaration(const FunctionDecl *FD) {
4902+
for (const FunctionDecl *PD = FD; PD; PD = PD->getPreviousDecl())
4903+
if (!PD->isInlineBuiltinDeclaration())
4904+
return false;
4905+
return true;
4906+
}
4907+
48984908
static CGCallee EmitDirectCallee(CodeGenFunction &CGF, GlobalDecl GD) {
48994909
const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
49004910

49014911
if (auto builtinID = FD->getBuiltinID()) {
49024912
std::string FDInlineName = (FD->getName() + ".inline").str();
49034913
// When directing calling an inline builtin, call it through it's mangled
49044914
// name to make it clear it's not the actual builtin.
4905-
if (FD->isInlineBuiltinDeclaration() &&
4906-
CGF.CurFn->getName() != FDInlineName) {
4915+
if (CGF.CurFn->getName() != FDInlineName &&
4916+
OnlyHasInlineBuiltinDeclaration(FD)) {
49074917
llvm::Constant *CalleePtr = EmitFunctionDeclPointer(CGF.CGM, GD);
49084918
llvm::Function *Fn = llvm::cast<llvm::Function>(CalleePtr);
49094919
llvm::Module *M = Fn->getParent();

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,4 +592,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
592592
// Enabled A53 errata (835769) workaround by default on android
593593
Features.push_back("+fix-cortex-a53-835769");
594594
}
595+
596+
if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
597+
Features.push_back("+no-bti-at-return-twice");
595598
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang_cc1 -triple x86_64 -S -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
2+
//
3+
// Verifies that clang-generated *.inline are removed when shadowed by an
4+
// external definition, even when that definition appears at the end of the
5+
// file.
6+
7+
// CHECK-NOT: strlen.inline
8+
9+
extern unsigned long strlen(char const *s);
10+
11+
extern __inline __attribute__((__always_inline__)) __attribute__((__gnu_inline__)) unsigned long strlen(char const *s) {
12+
return 1;
13+
}
14+
15+
static unsigned long chesterfield(char const *s) {
16+
return strlen(s);
17+
}
18+
static unsigned long (*_strlen)(char const *ptr);
19+
20+
unsigned long blutch(char const *s) {
21+
return chesterfield(s);
22+
}
23+
24+
unsigned long strlen(char const *s) {
25+
return _strlen(s);
26+
}

compiler-rt/lib/asan/asan_linux.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,24 @@ static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size,
131131
VReport(2, "info->dlpi_name = %s\tinfo->dlpi_addr = %p\n", info->dlpi_name,
132132
(void *)info->dlpi_addr);
133133

134-
// Continue until the first dynamic library is found
135-
if (!info->dlpi_name || info->dlpi_name[0] == 0)
136-
return 0;
137-
138-
// Ignore vDSO
139-
if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
140-
return 0;
134+
const char **name = (const char **)data;
141135

142-
#if SANITIZER_FREEBSD || SANITIZER_NETBSD
143136
// Ignore first entry (the main program)
144-
char **p = (char **)data;
145-
if (!(*p)) {
146-
*p = (char *)-1;
137+
if (!*name) {
138+
*name = "";
147139
return 0;
148140
}
149-
#endif
150141

151-
#if SANITIZER_SOLARIS
152-
// Ignore executable on Solaris
153-
if (info->dlpi_addr == 0)
142+
# if SANITIZER_LINUX
143+
// Ignore vDSO. glibc versions earlier than 2.15 (and some patched
144+
// by distributors) return an empty name for the vDSO entry, so
145+
// detect this as well.
146+
if (!info->dlpi_name[0] ||
147+
internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
154148
return 0;
155-
#endif
149+
# endif
156150

157-
*(const char **)data = info->dlpi_name;
151+
*name = info->dlpi_name;
158152
return 1;
159153
}
160154

@@ -175,7 +169,7 @@ void AsanCheckDynamicRTPrereqs() {
175169
// Ensure that dynamic RT is the first DSO in the list
176170
const char *first_dso_name = nullptr;
177171
dl_iterate_phdr(FindFirstDSOCallback, &first_dso_name);
178-
if (first_dso_name && !IsDynamicRTName(first_dso_name)) {
172+
if (first_dso_name && first_dso_name[0] && !IsDynamicRTName(first_dso_name)) {
179173
Report("ASan runtime does not come first in initial library list; "
180174
"you should either link runtime to your application or "
181175
"manually preload it with LD_PRELOAD.\n");

compiler-rt/lib/builtins/clear_cache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ void __clear_cache(void *start, void *end) {
130130
__asm __volatile("dsb ish");
131131
}
132132
__asm __volatile("isb sy");
133-
#elif defined(__powerpc64__)
133+
#elif defined(__powerpc__)
134+
// Newer CPUs have a bigger line size made of multiple blocks, so the
135+
// following value is a minimal common denominator for what used to be
136+
// a single block cache line and is therefore inneficient.
134137
const size_t line_size = 32;
135138
const size_t len = (uintptr_t)end - (uintptr_t)start;
136139

libcxx/include/__support/openbsd/xlocale.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,24 @@
1616
#include <ctype.h>
1717
#include <cwctype>
1818

19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
24+
inline _LIBCPP_HIDE_FROM_ABI long
25+
strtol_l(const char *nptr, char **endptr, int base, locale_t) {
26+
return ::strtol(nptr, endptr, base);
27+
}
28+
29+
inline _LIBCPP_HIDE_FROM_ABI unsigned long
30+
strtoul_l(const char *nptr, char **endptr, int base, locale_t) {
31+
return ::strtoul(nptr, endptr, base);
32+
}
33+
34+
35+
#ifdef __cplusplus
36+
}
37+
#endif
38+
1939
#endif

lld/COFF/DebugTypes.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,11 @@ struct GHashTable {
902902

903903
/// A ghash table cell for deduplicating types from TpiSources.
904904
class GHashCell {
905-
uint64_t data = 0;
905+
// Force "data" to be 64-bit aligned; otherwise, some versions of clang
906+
// will generate calls to libatomic when using some versions of libstdc++
907+
// on 32-bit targets. (Also, in theory, there could be a target where
908+
// new[] doesn't always return an 8-byte-aligned allocation.)
909+
alignas(sizeof(uint64_t)) uint64_t data = 0;
906910

907911
public:
908912
GHashCell() = default;

0 commit comments

Comments
 (0)