Skip to content

Commit 7007c9d

Browse files
committed
merge main into amd-staging
2 parents 52b4e0f + d20796d commit 7007c9d

File tree

235 files changed

+6902
-4739
lines changed

Some content is hidden

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

235 files changed

+6902
-4739
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,20 +2697,19 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
26972697
BD->nameStartsWith("_ZTCN"))) { // construction vtable
26982698
BinaryFunction *BF = BC->getBinaryFunctionContainingAddress(
26992699
SymbolAddress, /*CheckPastEnd*/ false, /*UseMaxSize*/ true);
2700-
if (!BF || BF->getAddress() != SymbolAddress) {
2701-
BC->errs()
2702-
<< "BOLT-ERROR: the virtual function table entry at offset 0x"
2703-
<< Twine::utohexstr(Rel.getOffset());
2704-
if (BF)
2705-
BC->errs() << " points to the middle of a function @ 0x"
2706-
<< Twine::utohexstr(BF->getAddress()) << "\n";
2707-
else
2708-
BC->errs() << " does not point to any function\n";
2709-
exit(1);
2700+
if (BF) {
2701+
if (BF->getAddress() != SymbolAddress) {
2702+
BC->errs()
2703+
<< "BOLT-ERROR: the virtual function table entry at offset 0x"
2704+
<< Twine::utohexstr(Rel.getOffset())
2705+
<< " points to the middle of a function @ 0x"
2706+
<< Twine::utohexstr(BF->getAddress()) << "\n";
2707+
exit(1);
2708+
}
2709+
BC->addRelocation(Rel.getOffset(), BF->getSymbol(), RType, Addend,
2710+
ExtractedValue);
2711+
return;
27102712
}
2711-
BC->addRelocation(Rel.getOffset(), BF->getSymbol(), RType, Addend,
2712-
ExtractedValue);
2713-
return;
27142713
}
27152714
}
27162715

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Test the fix that BOLT should skip special handling of any non-virtual
2+
// function pointer relocations in relative vtable.
3+
4+
// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-gnu %s -o %t.o
5+
// RUN: %clang %cxxflags -fuse-ld=lld %t.o -o %t.so -Wl,-q
6+
// RUN: llvm-bolt %t.so -o %t.bolted.so
7+
8+
.text
9+
.p2align 2
10+
.type foo,@function
11+
foo:
12+
.cfi_startproc
13+
adrp x8, _ZTV3gooE
14+
add x8, x8, :lo12:_ZTV3gooE
15+
ldr x0, [x8]
16+
ret
17+
.Lfunc_end0:
18+
.size foo, .Lfunc_end0-foo
19+
.cfi_endproc
20+
21+
.type _fake_rtti_data,@object
22+
.section .rodata.cst16._fake_rtti_data,"aMG",@progbits,16,_fake_rtti_data,comdat
23+
.p2align 3, 0x0
24+
_fake_rtti_data:
25+
.ascii "_FAKE_RTTI_DATA_"
26+
.size _fake_rtti_data, 16
27+
28+
.type _ZTV3gooE,@object
29+
.section .rodata,"a",@progbits
30+
.p2align 2, 0x0
31+
_ZTV3gooE:
32+
.word 0
33+
.word _fake_rtti_data-_ZTV3gooE-8
34+
.word foo@PLT-_ZTV3gooE-8
35+
.size _ZTV3gooE, 12

clang/docs/ReleaseNotes.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,27 @@ C Language Changes
150150
- Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which
151151
diagnoses implicit conversion from ``void *`` to another pointer type as
152152
being incompatible with C++. (#GH17792)
153+
- Added ``-Wc++-hidden-decl``, grouped under ``-Wc++-compat``, which diagnoses
154+
use of tag types which are visible in C but not visible in C++ due to scoping
155+
rules. e.g.,
156+
157+
.. code-block:: c
158+
159+
struct S {
160+
struct T {
161+
int x;
162+
} t;
163+
};
164+
struct T t; // Invalid C++, valid C, now diagnosed
165+
- Added ``-Wimplicit-int-enum-cast``, grouped under ``-Wc++-compat``, which
166+
diagnoses implicit conversion from integer types to an enumeration type in C,
167+
which is not compatible with C++. #GH37027
168+
- Split "implicit conversion from enum type to different enum type" diagnostic
169+
from ``-Wenum-conversion`` into its own diagnostic group,
170+
``-Wimplicit-enum-enum-cast``, which is grouped under both
171+
``-Wenum-conversion`` and ``-Wimplicit-int-enum-cast``. This conversion is an
172+
int-to-enum conversion because the enumeration on the right-hand side is
173+
promoted to ``int`` before the assignment.
153174

154175
C2y Feature Support
155176
^^^^^^^^^^^^^^^^^^^
@@ -211,6 +232,8 @@ Non-comprehensive list of changes in this release
211232
- Added `__builtin_elementwise_exp10`.
212233
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
213234
- Added `__builtin_elementwise_minnum` and `__builtin_elementwise_maxnum`.
235+
- No longer crashing on invalid Objective-C categories and extensions when
236+
dumping the AST as JSON. (#GH137320)
214237

215238
New Compiler Flags
216239
------------------

clang/include/clang/AST/DeclBase.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2239,10 +2239,14 @@ class DeclContext {
22392239
return DC && this->getPrimaryContext() == DC->getPrimaryContext();
22402240
}
22412241

2242-
/// Determine whether this declaration context encloses the
2242+
/// Determine whether this declaration context semantically encloses the
22432243
/// declaration context DC.
22442244
bool Encloses(const DeclContext *DC) const;
22452245

2246+
/// Determine whether this declaration context lexically encloses the
2247+
/// declaration context DC.
2248+
bool LexicallyEncloses(const DeclContext *DC) const;
2249+
22462250
/// Find the nearest non-closure ancestor of this context,
22472251
/// i.e. the innermost semantic parent of this context which is not
22482252
/// a closure. A context may be its own non-closure ancestor.

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ def AnonEnumEnumConversion : DiagGroup<"anon-enum-enum-conversion",
103103
[DeprecatedAnonEnumEnumConversion]>;
104104
def EnumEnumConversion : DiagGroup<"enum-enum-conversion",
105105
[DeprecatedEnumEnumConversion]>;
106+
def ImplicitEnumEnumCast : DiagGroup<"implicit-enum-enum-cast">;
106107
def EnumFloatConversion : DiagGroup<"enum-float-conversion",
107108
[DeprecatedEnumFloatConversion]>;
108109
def EnumConversion : DiagGroup<"enum-conversion",
109110
[EnumEnumConversion,
111+
ImplicitEnumEnumCast,
110112
EnumFloatConversion,
111113
EnumCompareConditional]>;
112114
def DeprecatedOFast : DiagGroup<"deprecated-ofast">;
@@ -154,10 +156,14 @@ def BuiltinRequiresHeader : DiagGroup<"builtin-requires-header">;
154156
def C99Compat : DiagGroup<"c99-compat">;
155157
def C23Compat : DiagGroup<"c23-compat">;
156158
def : DiagGroup<"c2x-compat", [C23Compat]>;
159+
def HiddenCppDecl : DiagGroup<"c++-hidden-decl">;
157160
def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">;
158161
def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>;
159162
def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">;
160-
def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit]>;
163+
def ImplicitIntToEnumCast : DiagGroup<"implicit-int-enum-cast",
164+
[ImplicitEnumEnumCast]>;
165+
def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit,
166+
ImplicitIntToEnumCast, HiddenCppDecl]>;
161167

162168
def ExternCCompat : DiagGroup<"extern-c-compat">;
163169
def KeywordCompat : DiagGroup<"keyword-compat">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,10 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
496496
"%select{used|required to be captured for this use}1">,
497497
InGroup<UnusedLambdaCapture>, DefaultIgnore;
498498

499+
def warn_decl_hidden_in_cpp : Warning<
500+
"%select{struct|union|enum}0 defined within a struct or union is not visible "
501+
"in C++">, InGroup<HiddenCppDecl>, DefaultIgnore;
502+
499503
def warn_reserved_extern_symbol: Warning<
500504
"identifier %0 is reserved because %select{"
501505
"<ERROR>|" // ReservedIdentifierStatus::NotReserved
@@ -4310,7 +4314,10 @@ def warn_impcast_string_literal_to_bool : Warning<
43104314
InGroup<StringConversion>, DefaultIgnore;
43114315
def warn_impcast_different_enum_types : Warning<
43124316
"implicit conversion from enumeration type %0 to different enumeration type "
4313-
"%1">, InGroup<EnumConversion>;
4317+
"%1">, InGroup<ImplicitEnumEnumCast>;
4318+
def warn_impcast_int_to_enum : Warning<
4319+
"implicit conversion from %0 to enumeration type %1 is invalid in C++">,
4320+
InGroup<ImplicitIntToEnumCast>, DefaultIgnore;
43144321
def warn_impcast_bool_to_null_pointer : Warning<
43154322
"initialization of pointer of type %0 to null from a constant boolean "
43164323
"expression">, InGroup<BoolConversion>;

clang/include/clang/Basic/DiagnosticSerializationKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ def warn_decls_in_multiple_modules : Warning<
139139
InGroup<DiagGroup<"decls-in-multiple-modules">>,
140140
DefaultIgnore;
141141

142+
def warn_module_file_mapping_mismatch
143+
: Warning<"loaded module file '%0' conflicts with imported file '%1'">,
144+
InGroup<DiagGroup<"module-file-mapping-mismatch">>,
145+
DefaultIgnore;
146+
142147
def err_failed_to_find_module_file : Error<
143148
"failed to find module file for module '%0'">;
144149
} // let CategoryName

clang/include/clang/CIR/Dialect/IR/CIRDialect.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class SameFirstOperandAndResultType
5959

6060
using BuilderCallbackRef =
6161
llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>;
62+
using BuilderOpStateCallbackRef = llvm::function_ref<void(
63+
mlir::OpBuilder &, mlir::Location, mlir::OperationState &)>;
6264

6365
namespace cir {
6466
void buildTerminatedBody(mlir::OpBuilder &builder, mlir::Location loc);

0 commit comments

Comments
 (0)