Skip to content

Commit 8689f0a

Browse files
Merge branch 'llvm:main' into 2-acc-common
2 parents 19c1534 + 297f972 commit 8689f0a

File tree

707 files changed

+60748
-16431
lines changed

Some content is hidden

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

707 files changed

+60748
-16431
lines changed

.ci/premerge_advisor_explain.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Script for getting explanations from the premerge advisor."""
5+
6+
import argparse
7+
import os
8+
import platform
9+
import sys
10+
11+
import requests
12+
13+
import generate_test_report_lib
14+
15+
PREMERGE_ADVISOR_URL = (
16+
"http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/explain"
17+
)
18+
19+
20+
def main(commit_sha: str, build_log_files: list[str]):
21+
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
22+
build_log_files
23+
)
24+
test_failures = generate_test_report_lib.get_failures(junit_objects)
25+
current_platform = f"{platform.system()}-{platform.machine()}".lower()
26+
explanation_request = {
27+
"base_commit_sha": commit_sha,
28+
"platform": current_platform,
29+
"failures": [],
30+
}
31+
if test_failures:
32+
for _, failures in test_failures.items():
33+
for name, failure_messsage in failures:
34+
explanation_request["failures"].append(
35+
{"name": name, "message": failure_messsage}
36+
)
37+
else:
38+
ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs)
39+
for name, failure_message in ninja_failures:
40+
explanation_request["failures"].append(
41+
{"name": name, "message": failure_message}
42+
)
43+
advisor_response = requests.get(PREMERGE_ADVISOR_URL, json=explanation_request)
44+
if advisor_response.status_code == 200:
45+
print(advisor_response.json())
46+
else:
47+
print(advisor_response.reason)
48+
49+
50+
if __name__ == "__main__":
51+
parser = argparse.ArgumentParser()
52+
parser.add_argument("commit_sha", help="The base commit SHA for the test.")
53+
parser.add_argument(
54+
"build_log_files", help="Paths to JUnit report files and ninja logs.", nargs="*"
55+
)
56+
args = parser.parse_args()
57+
58+
# Skip looking for results on AArch64 for now because the premerge advisor
59+
# service is not available on AWS currently.
60+
if platform.machine() == "arm64":
61+
sys.exit(0)
62+
63+
main(args.commit_sha, args.build_log_files)

.ci/utils.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ function at-exit {
4343
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \
4444
$(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \
4545
"${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log
46+
if [[ "$GITHUB_ACTIONS" != "" ]]; then
47+
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_explain.py \
48+
$(git rev-parse HEAD~1) "${BUILD_DIR}"/test-results.*.xml \
49+
"${MONOREPO_ROOT}"/ninja*.log
50+
fi
4651
fi
4752
}
4853
trap at-exit EXIT

.github/CODEOWNERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
/mlir/include/mlir/Interfaces/DestinationStyleOpInterface.* @matthias-springer
5454
/mlir/lib/Interfaces/DestinationStyleOpInterface.* @matthias-springer
5555

56+
# AMDGPU and ROCDL dialects in MLIR.
57+
/mlir/include/mlir/Dialect/AMDGPU @krzysz00 @kuhar
58+
/mlir/lib/Dialect/AMDGPU @krzysz00 @kuhar
59+
/mlir/lib/Conversion/*AMDGPU* @krzysz00 @kuhar
60+
/mlir/lib/Conversion/*ToROCDL @krzysz00 @kuhar
61+
/mlir/include/mlir/Dialect/LLVMIR/ROCDL* @krzysz00 @kuhar
62+
5663
# Bufferization Dialect in MLIR.
5764
/mlir/include/mlir/Dialect/Bufferization @matthias-springer
5865
/mlir/lib/Dialect/Bufferization @matthias-springer

.github/workflows/pr-code-lint.yml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run:
2121
shell: bash
2222
container:
23-
image: 'ghcr.io/llvm/ci-ubuntu-24.04:latest'
23+
image: 'ghcr.io/llvm/ci-ubuntu-24.04-lint'
2424
timeout-minutes: 60
2525
concurrency:
2626
group: ${{ github.workflow }}-${{ github.ref }}
@@ -31,6 +31,11 @@ jobs:
3131
with:
3232
fetch-depth: 2
3333

34+
# FIXME: same as in ".github/workflows/pr-code-format.yml"
35+
- name: Set Safe Directory
36+
run: |
37+
chown -R root $(pwd)
38+
3439
- name: Get changed files
3540
id: changed-files
3641
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
@@ -46,22 +51,6 @@ jobs:
4651
run: |
4752
echo "Changed files:"
4853
echo "$CHANGED_FILES"
49-
50-
# The clang tidy version should always be upgraded to the first version
51-
# of a release cycle (x.1.0) or the last version of a release cycle, or
52-
# if there have been relevant clang-format backports.
53-
- name: Install clang-tidy
54-
uses: aminya/setup-cpp@a276e6e3d1db9160db5edc458e99a30d3b109949 # v1.7.1
55-
with:
56-
clang-tidy: 21.1.0
57-
58-
- name: Setup Python env
59-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
60-
with:
61-
python-version: '3.13'
62-
63-
- name: Install Python dependencies
64-
run: python3 -m pip install -r llvm/utils/git/requirements_linting.txt
6554
6655
# TODO: create special mapping for 'codegen' targets, for now build predefined set
6756
# TODO: add entrypoint in 'compute_projects.py' that only adds a project and its direct dependencies

bolt/lib/Core/BinaryContext.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,8 +1337,17 @@ void BinaryContext::processInterproceduralReferences() {
13371337
<< Function.getPrintName() << " and "
13381338
<< TargetFunction->getPrintName() << '\n';
13391339
}
1340-
if (uint64_t Offset = Address - TargetFunction->getAddress())
1341-
TargetFunction->addEntryPointAtOffset(Offset);
1340+
if (uint64_t Offset = Address - TargetFunction->getAddress()) {
1341+
if (!TargetFunction->isInConstantIsland(Address)) {
1342+
TargetFunction->addEntryPointAtOffset(Offset);
1343+
} else {
1344+
TargetFunction->setIgnored();
1345+
this->outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
1346+
<< Twine::utohexstr(Address)
1347+
<< " in constant island of function " << *TargetFunction
1348+
<< '\n';
1349+
}
1350+
}
13421351

13431352
continue;
13441353
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This test checks that we ignore functions which add an entry point that
2+
// is in a constant island.
3+
4+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5+
# RUN: %clang %cflags %t.o -pie -Wl,-q -o %t.exe
6+
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
7+
8+
# CHECK: BOLT-WARNING: Ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
9+
10+
.globl func
11+
.type func, %function
12+
func:
13+
b .Lafter_constant
14+
15+
.type constant_island, %object
16+
constant_island:
17+
.xword 0xabcdef
18+
19+
.Lafter_constant:
20+
ret
21+
.size func, .-func
22+
23+
.globl caller
24+
.type caller, %function
25+
caller:
26+
bl constant_island
27+
ret

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ static const NamedDecl *findDecl(const RecordDecl &RecDecl,
9393
return nullptr;
9494
}
9595

96-
/// Returns the function that \p Method is overridding. If There are none or
96+
/// Returns the function that \p Method is overriding. If There are none or
9797
/// multiple overrides it returns nullptr. If the overridden function itself is
98-
/// overridding then it will recurse up to find the first decl of the function.
98+
/// overriding then it will recurse up to find the first decl of the function.
9999
static const CXXMethodDecl *getOverrideMethod(const CXXMethodDecl *Method) {
100100
if (Method->size_overridden_methods() != 1)
101101
return nullptr;
@@ -490,7 +490,7 @@ void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl,
490490
NamingCheckFailure &Failure = FailureIter->second;
491491
Failure.Info = std::move(*MaybeFailure);
492492

493-
// Don't overwritte the failure status if it was already set.
493+
// Don't overwrite the failure status if it was already set.
494494
if (!Failure.shouldFix()) {
495495
return;
496496
}

clang-tools-extra/clangd/Protocol.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,12 @@ struct CallHierarchyIncomingCall {
16271627
/// The range at which the calls appear.
16281628
/// This is relative to the caller denoted by `From`.
16291629
std::vector<Range> fromRanges;
1630+
1631+
/// For the case of being a virtual function we also return calls
1632+
/// to the base function. This caller might be a false positive.
1633+
/// We currently have no way of discerning this.
1634+
/// This is a clangd extension.
1635+
bool mightNeverCall = false;
16301636
};
16311637
llvm::json::Value toJSON(const CallHierarchyIncomingCall &);
16321638

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "clang-include-cleaner/Types.h"
2222
#include "index/Index.h"
2323
#include "index/Merge.h"
24+
#include "index/Ref.h"
2425
#include "index/Relation.h"
2526
#include "index/SymbolCollector.h"
2627
#include "index/SymbolID.h"
@@ -56,6 +57,7 @@
5657
#include "clang/Tooling/Syntax/Tokens.h"
5758
#include "llvm/ADT/ArrayRef.h"
5859
#include "llvm/ADT/DenseMap.h"
60+
#include "llvm/ADT/DenseSet.h"
5961
#include "llvm/ADT/STLExtras.h"
6062
#include "llvm/ADT/ScopeExit.h"
6163
#include "llvm/ADT/SmallSet.h"
@@ -66,6 +68,7 @@
6668
#include "llvm/Support/ErrorHandling.h"
6769
#include "llvm/Support/Path.h"
6870
#include "llvm/Support/raw_ostream.h"
71+
#include <algorithm>
6972
#include <optional>
7073
#include <string>
7174
#include <vector>
@@ -2350,51 +2353,64 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
23502353
// to an AST node isn't cheap, particularly when the declaration isn't
23512354
// in the main file.
23522355
// FIXME: Consider also using AST information when feasible.
2353-
RefsRequest Request;
2354-
Request.IDs.insert(*ID);
2355-
Request.WantContainer = true;
2356-
// We could restrict more specifically to calls by introducing a new RefKind,
2357-
// but non-call references (such as address-of-function) can still be
2358-
// interesting as they can indicate indirect calls.
2359-
Request.Filter = RefKind::Reference;
2360-
// Initially store the ranges in a map keyed by SymbolID of the caller.
2361-
// This allows us to group different calls with the same caller
2362-
// into the same CallHierarchyIncomingCall.
2363-
llvm::DenseMap<SymbolID, std::vector<Location>> CallsIn;
2364-
// We can populate the ranges based on a refs request only. As we do so, we
2365-
// also accumulate the container IDs into a lookup request.
2366-
LookupRequest ContainerLookup;
2367-
Index->refs(Request, [&](const Ref &R) {
2368-
auto Loc = indexToLSPLocation(R.Location, Item.uri.file());
2369-
if (!Loc) {
2370-
elog("incomingCalls failed to convert location: {0}", Loc.takeError());
2371-
return;
2372-
}
2373-
CallsIn[R.Container].push_back(*Loc);
2356+
auto QueryIndex = [&](llvm::DenseSet<SymbolID> IDs, bool MightNeverCall) {
2357+
RefsRequest Request;
2358+
Request.IDs = std::move(IDs);
2359+
Request.WantContainer = true;
2360+
// We could restrict more specifically to calls by introducing a new
2361+
// RefKind, but non-call references (such as address-of-function) can still
2362+
// be interesting as they can indicate indirect calls.
2363+
Request.Filter = RefKind::Reference;
2364+
// Initially store the ranges in a map keyed by SymbolID of the caller.
2365+
// This allows us to group different calls with the same caller
2366+
// into the same CallHierarchyIncomingCall.
2367+
llvm::DenseMap<SymbolID, std::vector<Location>> CallsIn;
2368+
// We can populate the ranges based on a refs request only. As we do so, we
2369+
// also accumulate the container IDs into a lookup request.
2370+
LookupRequest ContainerLookup;
2371+
Index->refs(Request, [&](const Ref &R) {
2372+
auto Loc = indexToLSPLocation(R.Location, Item.uri.file());
2373+
if (!Loc) {
2374+
elog("incomingCalls failed to convert location: {0}", Loc.takeError());
2375+
return;
2376+
}
2377+
CallsIn[R.Container].push_back(*Loc);
23742378

2375-
ContainerLookup.IDs.insert(R.Container);
2376-
});
2377-
// Perform the lookup request and combine its results with CallsIn to
2378-
// get complete CallHierarchyIncomingCall objects.
2379-
Index->lookup(ContainerLookup, [&](const Symbol &Caller) {
2380-
auto It = CallsIn.find(Caller.ID);
2381-
assert(It != CallsIn.end());
2382-
if (auto CHI = symbolToCallHierarchyItem(Caller, Item.uri.file())) {
2383-
std::vector<Range> FromRanges;
2384-
for (const Location &L : It->second) {
2385-
if (L.uri != CHI->uri) {
2386-
// Call location not in same file as caller.
2387-
// This can happen in some edge cases. There's not much we can do,
2388-
// since the protocol only allows returning ranges interpreted as
2389-
// being in the caller's file.
2390-
continue;
2379+
ContainerLookup.IDs.insert(R.Container);
2380+
});
2381+
// Perform the lookup request and combine its results with CallsIn to
2382+
// get complete CallHierarchyIncomingCall objects.
2383+
Index->lookup(ContainerLookup, [&](const Symbol &Caller) {
2384+
auto It = CallsIn.find(Caller.ID);
2385+
assert(It != CallsIn.end());
2386+
if (auto CHI = symbolToCallHierarchyItem(Caller, Item.uri.file())) {
2387+
std::vector<Range> FromRanges;
2388+
for (const Location &L : It->second) {
2389+
if (L.uri != CHI->uri) {
2390+
// Call location not in same file as caller.
2391+
// This can happen in some edge cases. There's not much we can do,
2392+
// since the protocol only allows returning ranges interpreted as
2393+
// being in the caller's file.
2394+
continue;
2395+
}
2396+
FromRanges.push_back(L.range);
23912397
}
2392-
FromRanges.push_back(L.range);
2398+
Results.push_back(CallHierarchyIncomingCall{
2399+
std::move(*CHI), std::move(FromRanges), MightNeverCall});
23932400
}
2394-
Results.push_back(
2395-
CallHierarchyIncomingCall{std::move(*CHI), std::move(FromRanges)});
2396-
}
2397-
});
2401+
});
2402+
};
2403+
QueryIndex({ID.get()}, false);
2404+
// In the case of being a virtual function we also want to return
2405+
// potential calls through the base function.
2406+
if (Item.kind == SymbolKind::Method) {
2407+
llvm::DenseSet<SymbolID> IDs;
2408+
RelationsRequest Req{{ID.get()}, RelationKind::OverriddenBy, std::nullopt};
2409+
Index->reverseRelations(Req, [&](const SymbolID &, const Symbol &Caller) {
2410+
IDs.insert(Caller.ID);
2411+
});
2412+
QueryIndex(std::move(IDs), true);
2413+
}
23982414
// Sort results by name of container.
23992415
llvm::sort(Results, [](const CallHierarchyIncomingCall &A,
24002416
const CallHierarchyIncomingCall &B) {

clang-tools-extra/clangd/index/Index.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ void SwapIndex::relations(
7777
return snapshot()->relations(R, CB);
7878
}
7979

80+
void SwapIndex::reverseRelations(
81+
const RelationsRequest &R,
82+
llvm::function_ref<void(const SymbolID &, const Symbol &)> CB) const {
83+
return snapshot()->reverseRelations(R, CB);
84+
}
85+
8086
llvm::unique_function<IndexContents(llvm::StringRef) const>
8187
SwapIndex::indexedFiles() const {
8288
// The index snapshot should outlive this method return value.

0 commit comments

Comments
 (0)