Skip to content

Commit ceac04e

Browse files
committed
Merge remote-tracking branch 'origin/main' into HEAD
2 parents 98255ba + e52cddc commit ceac04e

File tree

216 files changed

+6300
-4202
lines changed

Some content is hidden

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

216 files changed

+6300
-4202
lines changed

.github/workflows/release-binaries.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ jobs:
261261
release_dir=`find ${{ steps.setup-stage.outputs.build-prefix }}/build -iname 'stage2-bins'`
262262
mv $release_dir/${{ needs.prepare.outputs.release-binary-filename }} .
263263
264-
265264
- name: Build Windows
266265
id: build-windows
267266
if: runner.os == 'Windows'
@@ -312,8 +311,7 @@ jobs:
312311
- prepare
313312
- build-release-package
314313
if: >-
315-
github.event_name != 'pull_request' &&
316-
needs.prepare.outputs.upload == 'true'
314+
github.event_name != 'pull_request'
317315
runs-on: ubuntu-24.04
318316
permissions:
319317
contents: write # For release uploads
@@ -334,6 +332,6 @@ jobs:
334332
uses: ./.github/workflows/upload-release-artifact
335333
with:
336334
artifact-id: ${{ needs.build-release-package.outputs.artifact-id }}
337-
attestation-name: ${{ needs.prepare.outputs.release-binary-filename }}
335+
attestation-name: ${{ runner.os }}-${{ runner.arch }}-release-binary-attestation
338336
digest: ${{ needs.build-release-package.outputs.digest }}
339-
upload: true
337+
upload: ${{ needs.prepare.outputs.upload }}

.github/workflows/release-sources.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
attestations: write
109109
steps:
110110
- name: Checkout Release Scripts
111-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
111+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
112112
with:
113113
sparse-checkout: |
114114
.github/workflows/upload-release-artifact

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,19 @@ AST_MATCHER(CXXRecordDecl, hasBases) {
2323
}
2424
} // namespace
2525

26-
// Adds a node (by name) to the interface map, if it was not present in the map
26+
// Adds a node to the interface map, if it was not present in the map
2727
// previously.
2828
void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
2929
bool IsInterface) {
30-
assert(Node->getIdentifier());
31-
const StringRef Name = Node->getIdentifier()->getName();
32-
InterfaceMap.insert(std::make_pair(Name, IsInterface));
30+
InterfaceMap.try_emplace(Node, IsInterface);
3331
}
3432

3533
// Returns "true" if the boolean "isInterface" has been set to the
3634
// interface status of the current Node. Return "false" if the
3735
// interface status for the current node is not yet known.
3836
bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
3937
bool &IsInterface) const {
40-
assert(Node->getIdentifier());
41-
const StringRef Name = Node->getIdentifier()->getName();
42-
auto Pair = InterfaceMap.find(Name);
38+
auto Pair = InterfaceMap.find(Node);
4339
if (Pair == InterfaceMap.end())
4440
return false;
4541
IsInterface = Pair->second;
@@ -59,9 +55,6 @@ bool MultipleInheritanceCheck::isCurrentClassInterface(
5955
}
6056

6157
bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) {
62-
if (!Node->getIdentifier())
63-
return false;
64-
6558
// Short circuit the lookup if we have analyzed this record before.
6659
bool PreviousIsInterfaceResult = false;
6760
if (getInterfaceStatus(Node, PreviousIsInterfaceResult))

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MultipleInheritanceCheck : public ClangTidyCheck {
3838
// Contains the identity of each named CXXRecord as an interface. This is
3939
// used to memoize lookup speeds and improve performance from O(N^2) to O(N),
4040
// where N is the number of classes.
41-
llvm::StringMap<bool> InterfaceMap;
41+
llvm::DenseMap<const CXXRecordDecl *, bool> InterfaceMap;
4242
};
4343

4444
} // namespace clang::tidy::fuchsia

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,12 @@ Changes in existing checks
441441
correctly ignore ``std::array`` and other array-like containers when
442442
`IgnoreArrays` option is set to `true`.
443443

444+
- Improved :doc:`fuchsia-multiple-inheritance
445+
<clang-tidy/checks/fuchsia/multiple-inheritance>`
446+
by fixing an issue where the check would only analyze the first class with
447+
a given name in the program, missing any subsequent classes with that same
448+
name (declared in a different scope).
449+
444450
- Improved :doc:`google-readability-casting
445451
<clang-tidy/checks/google/readability-casting>` check by adding fix-it
446452
notes for downcasts and casts to void pointer.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Checks: '-*'

clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,18 @@ void test_no_crash() {
148148
auto foo = []() {};
149149
WithTemplBase<decltype(foo)>();
150150
}
151+
152+
struct S1 {};
153+
struct S2 {};
154+
155+
struct S3 : S1, S2 {};
156+
157+
namespace N {
158+
159+
struct S1 { int i; };
160+
struct S2 { int i; };
161+
162+
// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
163+
struct S3 : S1, S2 {};
164+
165+
} // namespace N
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
-checks='-*,llvm-namespace-comment'
1+
-checks=-*,llvm-namespace-comment
22
--warnings-as-errors=llvm-namespace-comment

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ Modified Compiler Flags
343343
-----------------------
344344
- The `-gkey-instructions` compiler flag is now enabled by default when DWARF is emitted for plain C/C++ and optimizations are enabled. (#GH149509)
345345
- The `-fconstexpr-steps` compiler flag now accepts value `0` to opt out of this limit. (#GH160440)
346+
- The `-fdevirtualize-speculatively` compiler flag is now supported to enable speculative devirtualization of virtual function calls, it's disabled by default. (#GH159685)
346347

347348
Removed Compiler Flags
348349
-------------------------

clang/docs/UsersManual.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,56 @@ are listed below.
23522352
pure ThinLTO, as all split regular LTO modules are merged and LTO linked
23532353
with regular LTO.
23542354

2355+
.. option:: -fdevirtualize-speculatively
2356+
2357+
Enable speculative devirtualization optimization where a virtual call
2358+
can be transformed into a direct call under the assumption that its
2359+
object is of a particular type. A runtime check is inserted to validate
2360+
the assumption before making the direct call, and if the check fails,
2361+
the original virtual call is made instead. This optimization can enable
2362+
more inlining opportunities and better optimization of the direct call.
2363+
This is different from whole program devirtualization optimization
2364+
that rely on global analysis and hidden visibility of the objects to prove
2365+
that the object is always of a particular type at a virtual call site.
2366+
This optimization doesn't require global analysis or hidden visibility.
2367+
This optimization doesn't devirtualize all virtual calls, but only
2368+
when there's a single implementation of the virtual function in the module.
2369+
There could be a single implementation of the virtual function
2370+
either because the function is not overridden in any derived class,
2371+
or because all objects are instances of the same class/type.
2372+
2373+
Ex of IR before the optimization:
2374+
2375+
.. code-block:: llvm
2376+
2377+
%vtable = load ptr, ptr %BV, align 8, !tbaa !6
2378+
%0 = tail call i1 @llvm.public.type.test(ptr %vtable, metadata !"_ZTS4Base")
2379+
tail call void @llvm.assume(i1 %0)
2380+
%0 = load ptr, ptr %vtable, align 8
2381+
tail call void %0(ptr noundef nonnull align 8 dereferenceable(8) %BV)
2382+
ret void
2383+
2384+
IR after the optimization:
2385+
2386+
.. code-block:: llvm
2387+
2388+
%vtable = load ptr, ptr %BV, align 8, !tbaa !12
2389+
%0 = load ptr, ptr %vtable, align 8
2390+
%1 = icmp eq ptr %0, @_ZN4Base17virtual_function1Ev
2391+
br i1 %1, label %if.true.direct_targ, label %if.false.orig_indirect, !prof !15
2392+
if.true.direct_targ: ; preds = %entry
2393+
tail call void @_ZN4Base17virtual_function1Ev(ptr noundef nonnull align 8 dereferenceable(8) %BV)
2394+
br label %if.end.icp
2395+
if.false.orig_indirect: ; preds = %entry
2396+
tail call void %0(ptr noundef nonnull align 8 dereferenceable(8) %BV)
2397+
br label %if.end.icp
2398+
if.end.icp: ; preds = %if.false.orig_indirect, %if.true.direct_targ
2399+
ret void
2400+
2401+
This feature is temporarily ignored at the LLVM side when LTO is enabled.
2402+
TODO: Update the comment when the LLVM side supports this feature for LTO.
2403+
This feature is turned off by default.
2404+
23552405
.. option:: -f[no-]unique-source-file-names
23562406

23572407
When enabled, allows the compiler to assume that each object file
@@ -5216,6 +5266,8 @@ Execute ``clang-cl /?`` to see a list of supported options:
52165266
-fstandalone-debug Emit full debug info for all types used by the program
52175267
-fstrict-aliasing Enable optimizations based on strict aliasing rules
52185268
-fsyntax-only Run the preprocessor, parser and semantic analysis stages
5269+
-fdevirtualize-speculatively
5270+
Enables speculative devirtualization optimization.
52195271
-fwhole-program-vtables Enables whole-program vtable optimization. Requires -flto
52205272
-gcodeview-ghash Emit type record hashes in a .debug$H section
52215273
-gcodeview Generate CodeView debug information

0 commit comments

Comments
 (0)