Skip to content

Commit 5bf4832

Browse files
authored
merge main into amd-staging (llvm#4302)
2 parents 1bcbf74 + 644d039 commit 5bf4832

File tree

51 files changed

+2959
-2607
lines changed

Some content is hidden

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

51 files changed

+2959
-2607
lines changed

bolt/lib/Core/Relocation.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ static bool isSupportedAArch64(uint32_t Type) {
8181
case ELF::R_AARCH64_LD64_GOT_LO12_NC:
8282
case ELF::R_AARCH64_TLSDESC_LD64_LO12:
8383
case ELF::R_AARCH64_TLSDESC_ADD_LO12:
84-
case ELF::R_AARCH64_TLSDESC_CALL:
8584
case ELF::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
8685
case ELF::R_AARCH64_PREL16:
8786
case ELF::R_AARCH64_PREL32:
@@ -193,7 +192,6 @@ static size_t getSizeForTypeAArch64(uint32_t Type) {
193192
case ELF::R_AARCH64_LD64_GOT_LO12_NC:
194193
case ELF::R_AARCH64_TLSDESC_LD64_LO12:
195194
case ELF::R_AARCH64_TLSDESC_ADD_LO12:
196-
case ELF::R_AARCH64_TLSDESC_CALL:
197195
case ELF::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
198196
case ELF::R_AARCH64_PREL32:
199197
case ELF::R_AARCH64_MOVW_UABS_G0:
@@ -248,7 +246,14 @@ static bool skipRelocationTypeX86(uint32_t Type) {
248246
}
249247

250248
static bool skipRelocationTypeAArch64(uint32_t Type) {
251-
return Type == ELF::R_AARCH64_NONE || Type == ELF::R_AARCH64_LD_PREL_LO19;
249+
switch (Type) {
250+
default:
251+
return false;
252+
case ELF::R_AARCH64_NONE:
253+
case ELF::R_AARCH64_LD_PREL_LO19:
254+
case ELF::R_AARCH64_TLSDESC_CALL:
255+
return true;
256+
}
252257
}
253258

254259
static bool skipRelocationTypeRISCV(uint32_t Type) {
@@ -362,7 +367,6 @@ static uint64_t extractValueAArch64(uint32_t Type, uint64_t Contents,
362367
return static_cast<int64_t>(PC) + SignExtend64<32>(Contents & 0xffffffff);
363368
case ELF::R_AARCH64_PREL64:
364369
return static_cast<int64_t>(PC) + Contents;
365-
case ELF::R_AARCH64_TLSDESC_CALL:
366370
case ELF::R_AARCH64_JUMP26:
367371
case ELF::R_AARCH64_CALL26:
368372
// Immediate goes in bits 25:0 of B and BL.
@@ -552,7 +556,6 @@ static bool isGOTAArch64(uint32_t Type) {
552556
case ELF::R_AARCH64_TLSDESC_ADR_PAGE21:
553557
case ELF::R_AARCH64_TLSDESC_LD64_LO12:
554558
case ELF::R_AARCH64_TLSDESC_ADD_LO12:
555-
case ELF::R_AARCH64_TLSDESC_CALL:
556559
return true;
557560
}
558561
}
@@ -591,7 +594,6 @@ static bool isTLSAArch64(uint32_t Type) {
591594
case ELF::R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
592595
case ELF::R_AARCH64_TLSDESC_LD64_LO12:
593596
case ELF::R_AARCH64_TLSDESC_ADD_LO12:
594-
case ELF::R_AARCH64_TLSDESC_CALL:
595597
case ELF::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
596598
return true;
597599
}
@@ -667,7 +669,6 @@ static bool isPCRelativeAArch64(uint32_t Type) {
667669
case ELF::R_AARCH64_MOVW_UABS_G2_NC:
668670
case ELF::R_AARCH64_MOVW_UABS_G3:
669671
return false;
670-
case ELF::R_AARCH64_TLSDESC_CALL:
671672
case ELF::R_AARCH64_CALL26:
672673
case ELF::R_AARCH64_JUMP26:
673674
case ELF::R_AARCH64_TSTBR14:

bolt/test/AArch64/tls-desc-call.s

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# RUN: %clang %cflags %s -o %t.so -fPIC -shared -Wl,-q
2+
# RUN: llvm-bolt %t.so -o %t.bolt --debug-only=bolt 2>&1 | FileCheck %s
3+
4+
# REQUIRES: asserts
5+
6+
## Verify that R_AARCH64_TLSDESC_CALL relocations are ignored
7+
8+
# CHECK-NOT: Relocation {{.*}} R_AARCH64_TLSDESC_CALL
9+
10+
.text
11+
.globl get_tls_var
12+
.p2align 2
13+
.type get_tls_var,@function
14+
get_tls_var:
15+
.cfi_startproc
16+
str x30, [sp, #-16]!
17+
adrp x0, :tlsdesc:tls_var
18+
ldr x1, [x0, :tlsdesc_lo12:tls_var]
19+
add x0, x0, :tlsdesc_lo12:tls_var
20+
.tlsdesccall tls_var
21+
blr x1
22+
mrs x8, TPIDR_EL0
23+
ldr w0, [x8, x0]
24+
ldr x30, [sp], #16
25+
ret
26+
.size get_tls_var, .-get_tls_var
27+
.cfi_endproc
28+
29+
.type tls_var,@object
30+
.section .tdata,"awT",@progbits
31+
.globl tls_var
32+
.p2align 2, 0x0
33+
tls_var:
34+
.word 42
35+
.size tls_var, 4

clang/lib/Sema/SemaChecking.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14886,13 +14886,11 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
1488614886
// Diag message shows element size in bits and in "bytes" (platform-
1488714887
// dependent CharUnits)
1488814888
DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
14889-
PDiag(DiagID)
14890-
<< toString(index, 10, true) << AddrBits
14891-
<< (unsigned)ASTC.toBits(*ElemCharUnits)
14892-
<< toString(ElemBytes, 10, false)
14893-
<< toString(MaxElems, 10, false)
14894-
<< (unsigned)MaxElems.getLimitedValue(~0U)
14895-
<< IndexExpr->getSourceRange());
14889+
PDiag(DiagID) << index << AddrBits
14890+
<< (unsigned)ASTC.toBits(*ElemCharUnits)
14891+
<< ElemBytes << MaxElems
14892+
<< MaxElems.getZExtValue()
14893+
<< IndexExpr->getSourceRange());
1489614894

1489714895
const NamedDecl *ND = nullptr;
1489814896
// Try harder to find a NamedDecl to point at in the note.
@@ -14975,10 +14973,10 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
1497514973
unsigned CastMsg = (!ASE || BaseType == EffectiveType) ? 0 : 1;
1497614974
QualType CastMsgTy = ASE ? ASE->getLHS()->getType() : QualType();
1497714975

14978-
DiagRuntimeBehavior(
14979-
BaseExpr->getBeginLoc(), BaseExpr,
14980-
PDiag(DiagID) << toString(index, 10, true) << ArrayTy->desugar()
14981-
<< CastMsg << CastMsgTy << IndexExpr->getSourceRange());
14976+
DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
14977+
PDiag(DiagID)
14978+
<< index << ArrayTy->desugar() << CastMsg
14979+
<< CastMsgTy << IndexExpr->getSourceRange());
1498214980
} else {
1498314981
unsigned DiagID = diag::warn_array_index_precedes_bounds;
1498414982
if (!ASE) {
@@ -14987,8 +14985,7 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
1498714985
}
1498814986

1498914987
DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
14990-
PDiag(DiagID) << toString(index, 10, true)
14991-
<< IndexExpr->getSourceRange());
14988+
PDiag(DiagID) << index << IndexExpr->getSourceRange());
1499214989
}
1499314990

1499414991
const NamedDecl *ND = nullptr;

clang/test/AST/ByteCode/const-eval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ EVAL_EXPR(52, &pr24622 == (void *)&PR24622);
144144

145145
// We evaluate these by providing 2s' complement semantics in constant
146146
// expressions, like we do for integers.
147-
void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a; // both-warning {{the pointer incremented by 18446744073709551615 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2305843009213693952 elements)}}
147+
void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a; // both-warning {{the pointer incremented by 18'446'744'073'709'551'615 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2'305'843'009'213'693'952 elements)}}
148148

149149
void *PR28739b = &PR28739b + (__int128)(unsigned long)-1; // both-warning {{refers past the last possible element}}
150150
__int128 PR28739c = (&PR28739c + (__int128)(unsigned long)-1) - &PR28739c; // both-warning {{refers past the last possible element}}

clang/test/Sema/const-eval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ EVAL_EXPR(52, &pr24622 == (void *)&PR24622);
138138

139139
// We evaluate these by providing 2s' complement semantics in constant
140140
// expressions, like we do for integers.
141-
void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a; // expected-warning {{the pointer incremented by 18446744073709551615 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2305843009213693952 elements)}}
141+
void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a; // expected-warning {{the pointer incremented by 18'446'744'073'709'551'615 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2'305'843'009'213'693'952 elements)}}
142142
void *PR28739b = &PR28739b + (__int128)(unsigned long)-1; // expected-warning {{refers past the last possible element}}
143143
__int128 PR28739c = (&PR28739c + (__int128)(unsigned long)-1) - &PR28739c; // expected-warning {{refers past the last possible element}}
144144
void *PR28739d = &(&PR28739d)[(__int128)(unsigned long)-1]; // expected-warning {{refers past the last possible element}}

clang/test/Sema/integer-overflow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ uint64_t check_integer_overflows(int i) {
143143
(__imag__ x) = 4608 * 1024 * 1024;
144144

145145
// expected-warning@+4 {{overflow in expression; result is 536'870'912 with type 'int'}}
146-
// expected-warning@+3 {{array index 536870912 is past the end of the array (that has type 'uint64_t[10]' (aka 'unsigned long long[10]'))}}
146+
// expected-warning@+3 {{array index 536'870'912 is past the end of the array (that has type 'uint64_t[10]' (aka 'unsigned long long[10]'))}}
147147
// expected-note@+1 {{array 'a' declared here}}
148148
uint64_t a[10];
149149
a[4608 * 1024 * 1024] = 1i;

clang/test/Sema/unbounded-array-bounds.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,44 @@ struct S s[]; // expected-warning {{tentative array definition}} expected-note {
1414
void f1(void) {
1515
++s[3].a;
1616
++s[7073650413200313099].b;
17-
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
18-
// addr32-warning@-2 {{array index 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178956970 elements)}}
19-
// addr64-warning@-3 {{array index 7073650413200313099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements)}}
17+
// addr16-warning@-1 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3'449 elements)}}
18+
// addr32-warning@-2 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178'956'970 elements)}}
19+
// addr64-warning@-3 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576'460'752'303'423'488 elements)}}
2020
++s[7073650].c;
21-
// addr16-warning@-1 {{array index 7073650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
21+
// addr16-warning@-1 {{array index 7'073'650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3'449 elements)}}
2222
}
2323

2424
long long ll[]; // expected-warning {{tentative array definition}} expected-note {{declared here}} addr16-note {{declared here}} addr32-note {{declared here}}
2525

2626
void f2(void) {
2727
++ll[3];
2828
++ll[2705843009213693952];
29-
// addr16-warning@-1 {{array index 2705843009213693952 refers past the last possible element for an array in 16-bit address space containing 64-bit (8-byte) elements (max possible 8192 elements)}}
30-
// addr32-warning@-2 {{array index 2705843009213693952 refers past the last possible element for an array in 32-bit address space containing 64-bit (8-byte) elements (max possible 536870912 elements)}}
31-
// addr64-warning@-3 {{array index 2705843009213693952 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2305843009213693952 elements)}}
29+
// addr16-warning@-1 {{array index 2'705'843'009'213'693'952 refers past the last possible element for an array in 16-bit address space containing 64-bit (8-byte) elements (max possible 8'192 elements)}}
30+
// addr32-warning@-2 {{array index 2'705'843'009'213'693'952 refers past the last possible element for an array in 32-bit address space containing 64-bit (8-byte) elements (max possible 536'870'912 elements)}}
31+
// addr64-warning@-3 {{array index 2'705'843'009'213'693'952 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2'305'843'009'213'693'952 elements)}}
3232
++ll[847073650];
33-
// addr16-warning@-1 {{array index 847073650 refers past the last possible element for an array in 16-bit address space containing 64-bit (8-byte) elements (max possible 8192 elements)}}
34-
// addr32-warning@-2 {{array index 847073650 refers past the last possible element for an array in 32-bit address space containing 64-bit (8-byte) elements (max possible 536870912 elements)}}
33+
// addr16-warning@-1 {{array index 847'073'650 refers past the last possible element for an array in 16-bit address space containing 64-bit (8-byte) elements (max possible 8'192 elements)}}
34+
// addr32-warning@-2 {{array index 847'073'650 refers past the last possible element for an array in 32-bit address space containing 64-bit (8-byte) elements (max possible 536'870'912 elements)}}
3535
}
3636

3737
void f3(struct S p[]) { // expected-note {{declared here}} addr16-note {{declared here}}
3838
++p[3].a;
3939
++p[7073650413200313099].b;
40-
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
41-
// addr32-warning@-2 {{array index 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178956970 elements)}}
42-
// addr64-warning@-3 {{array index 7073650413200313099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements)}}
40+
// addr16-warning@-1 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3'449 elements)}}
41+
// addr32-warning@-2 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178'956'970 elements)}}
42+
// addr64-warning@-3 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576'460'752'303'423'488 elements)}}
4343
++p[7073650].c;
44-
// addr16-warning@-1 {{array index 7073650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
44+
// addr16-warning@-1 {{array index 7'073'650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3'449 elements)}}
4545
}
4646

4747
void f4(struct S *p) { // expected-note {{declared here}} addr16-note {{declared here}}
4848
p += 3;
4949
p += 7073650413200313099;
50-
// addr16-warning@-1 {{the pointer incremented by 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
51-
// addr32-warning@-2 {{the pointer incremented by 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178956970 elements)}}
52-
// addr64-warning@-3 {{the pointer incremented by 7073650413200313099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements)}}
50+
// addr16-warning@-1 {{the pointer incremented by 7'073'650'413'200'313'099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3'449 elements)}}
51+
// addr32-warning@-2 {{the pointer incremented by 7'073'650'413'200'313'099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178'956'970 elements)}}
52+
// addr64-warning@-3 {{the pointer incremented by 7'073'650'413'200'313'099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576'460'752'303'423'488 elements)}}
5353
p += 7073650;
54-
// addr16-warning@-1 {{the pointer incremented by 7073650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
54+
// addr16-warning@-1 {{the pointer incremented by 7'073'650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3'449 elements)}}
5555
}
5656

5757
struct BQ {
@@ -63,7 +63,7 @@ struct BQ bq[]; // expected-warning {{tentative array definition}} addr16-note {
6363
void f5(void) {
6464
++bq[0].bigblock[0].a;
6565
++bq[1].bigblock[0].a;
66-
// addr16-warning@-1 {{array index 1 refers past the last possible element for an array in 16-bit address space containing 497952-bit (62244-byte) elements (max possible 1 element)}}
66+
// addr16-warning@-1 {{array index 1 refers past the last possible element for an array in 16-bit address space containing 497952-bit (62'244-byte) elements (max possible 1 element)}}
6767
}
6868

6969
void f6(void) {
@@ -102,15 +102,15 @@ struct {
102102

103103
void fam_ily() {
104104
++fam.tail[7073650413200313099];
105-
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 8-bit (1-byte) elements (max possible 65536 elements)}}
106-
// addr32-warning@-2 {{array index 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 8-bit (1-byte) elements (max possible 4294967296 elements)}}
105+
// addr16-warning@-1 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 16-bit address space containing 8-bit (1-byte) elements (max possible 65'536 elements)}}
106+
// addr32-warning@-2 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 32-bit address space containing 8-bit (1-byte) elements (max possible 4'294'967'296 elements)}}
107107
// No warning for addr64 because the array index is inbound in that case.
108108
++fam0.tail[7073650413200313099];
109-
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 8-bit (1-byte) elements (max possible 65536 elements)}}
110-
// addr32-warning@-2 {{array index 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 8-bit (1-byte) elements (max possible 4294967296 elements)}}
109+
// addr16-warning@-1 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 16-bit address space containing 8-bit (1-byte) elements (max possible 65'536 elements)}}
110+
// addr32-warning@-2 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 32-bit address space containing 8-bit (1-byte) elements (max possible 4'294'967'296 elements)}}
111111
// No warning for addr64 because the array index is inbound in that case.
112112
++fam1.tail[7073650413200313099];
113-
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 8-bit (1-byte) elements (max possible 65536 elements)}}
114-
// addr32-warning@-2 {{array index 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 8-bit (1-byte) elements (max possible 4294967296 elements)}}
113+
// addr16-warning@-1 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 16-bit address space containing 8-bit (1-byte) elements (max possible 65'536 elements)}}
114+
// addr32-warning@-2 {{array index 7'073'650'413'200'313'099 refers past the last possible element for an array in 32-bit address space containing 8-bit (1-byte) elements (max possible 4'294'967'296 elements)}}
115115
// No warning for addr64 because the array index is inbound in that case.
116116
}

0 commit comments

Comments
 (0)