Skip to content

Commit 29bb79a

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:e0c554ad87d18dcbfcb9b6485d0da800ae1338d1 into amd-gfx:6b757b334e67
Local branch amd-gfx 6b757b3 Merged main:d8db2733c87ef2ee54c322cbee76711147a94948 into amd-gfx:967ab3262a05 Remote branch main e0c554a Port CodeGenPrepare to new pass manager (and BasicBlockSectionsProfil… (llvm#75380)
2 parents 6b757b3 + e0c554a commit 29bb79a

File tree

1,402 files changed

+66493
-40643
lines changed

Some content is hidden

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

1,402 files changed

+66493
-40643
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Github action workflows should be stored in this directrory.
1+
Github action workflows should be stored in this directory.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
name: Build CI Container
3+
4+
permissions:
5+
contents: read
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
paths:
12+
- .github/workflows/build-ci-container.yml
13+
- '.github/workflows/containers/github-action-ci/**'
14+
pull_request:
15+
branches:
16+
- main
17+
paths:
18+
- .github/workflows/build-ci-container.yml
19+
- '.github/workflows/containers/github-action-ci/**'
20+
21+
jobs:
22+
build-ci-container:
23+
if: github.repository_owner == 'llvm'
24+
runs-on: ubuntu-latest
25+
permissions:
26+
packages: write
27+
steps:
28+
- name: Write Variables
29+
id: vars
30+
run: |
31+
tag=`date +%s`
32+
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
33+
echo "container-name=$container_name" >> $GITHUB_OUTPUT
34+
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
35+
36+
- name: Checkout LLVM
37+
uses: actions/checkout@v4
38+
with:
39+
sparse-checkout: .github/workflows/containers/github-action-ci/
40+
41+
- name: Build Container
42+
working-directory: ./.github/workflows/containers/github-action-ci/
43+
run: |
44+
podman build -t ${{ steps.vars.outputs.container-name-tag }} .
45+
podman tag ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}:latest
46+
47+
- name: Test Container
48+
run: |
49+
for image in ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}; do
50+
podman run --rm -it $image /usr/bin/bash -x -c 'printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
51+
done
52+
53+
- name: Push Container
54+
if: github.event_name == 'push'
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
run: |
58+
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
59+
podman push ${{ steps.vars.outputs.container-name-tag }}
60+
podman push ${{ steps.vars.outputs.container-name }}:latest
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM docker.io/library/ubuntu:22.04 as base
2+
ENV LLVM_SYSROOT=/opt/llvm/
3+
4+
FROM base as toolchain
5+
ENV LLVM_MAJOR=17
6+
ENV LLVM_VERSION=${LLVM_MAJOR}.0.6
7+
ENV LLVM_DIRNAME=clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-22.04
8+
ENV LLVM_FILENAME=${LLVM_DIRNAME}.tar.xz
9+
10+
RUN apt-get update && \
11+
apt-get install -y \
12+
curl \
13+
xz-utils
14+
15+
RUN mkdir -p $LLVM_SYSROOT/bin/ $LLVM_SYSROOT/lib/
16+
17+
RUN curl -O -L https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/$LLVM_FILENAME
18+
19+
RUN tar -C $LLVM_SYSROOT --strip-components=1 -xJf $LLVM_FILENAME \
20+
$LLVM_DIRNAME/bin/clang \
21+
$LLVM_DIRNAME/bin/clang++ \
22+
$LLVM_DIRNAME/bin/clang-cl \
23+
$LLVM_DIRNAME/bin/clang-$LLVM_MAJOR \
24+
$LLVM_DIRNAME/bin/lld \
25+
$LLVM_DIRNAME/bin/ld.lld \
26+
$LLVM_DIRNAME/lib/clang/
27+
28+
29+
FROM base
30+
31+
COPY --from=toolchain $LLVM_SYSROOT $LLVM_SYSROOT
32+
33+
# Need to install curl for hendrikmuhs/ccache-action
34+
# Need nodejs for some of the GitHub actions.
35+
# Need perl-modules for clang analyzer tests.
36+
RUN apt-get update && \
37+
apt-get install -y \
38+
binutils \
39+
cmake \
40+
curl \
41+
libstdc++-11-dev \
42+
ninja-build \
43+
nodejs \
44+
perl-modules \
45+
python3-psutil
46+
47+
ENV LLVM_SYSROOT=$LLVM_SYSROOT
48+
ENV PATH=${LLVM_SYSROOT}/bin:${PATH}

.github/workflows/docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,3 @@ jobs:
167167
run: |
168168
cmake -B flang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;mlir;flang" -DLLVM_ENABLE_SPHINX=ON -DSPHINX_WARNINGS_AS_ERRORS=OFF ./llvm
169169
TZ=UTC ninja -C flang-build docs-flang-html docs-flang-man
170-

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,3 @@ jobs:
207207
**/CMakeError.log
208208
**/CMakeOutput.log
209209
**/crash_diagnostics/*
210-

.github/workflows/release-binaries.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ jobs:
9393

9494
- name: Build Clang
9595
run: |
96-
cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_ENABLE_ASSERTIONS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLLVM_ENABLE_PROJECTS=clang -S llvm -B build
97-
ninja -v -C build
96+
cmake -G Ninja -C clang/cmake/caches/Release.cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_POSITION_INDEPENDENT_CODE=ON -S llvm -B build
97+
ninja -v -C build clang
9898
9999
100100
build-binaries:
@@ -152,6 +152,7 @@ jobs:
152152
-triple ${{ matrix.target.triple }} \
153153
-use-ninja \
154154
-no-checkout \
155+
-use-cmake-cache \
155156
-no-test-suite \
156157
-configure-flags "-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
157158

clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ using namespace clang::ast_matchers;
1313
namespace clang::tidy::modernize {
1414

1515
namespace {
16+
AST_MATCHER_P(InitListExpr, initCountLeq, unsigned, N) {
17+
return Node.getNumInits() <= N;
18+
}
19+
1620
// Identical to hasAnyName, except it does not take template specifiers into
1721
// account. This is used to match the functions names as in
1822
// DefaultEmplacyFunctions below without caring about the template types of the
@@ -205,11 +209,12 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
205209
auto HasConstructExpr = has(ignoringImplicit(SoughtConstructExpr));
206210

207211
// allow for T{} to be replaced, even if no CTOR is declared
208-
auto HasConstructInitListExpr = has(initListExpr(anyOf(
209-
allOf(has(SoughtConstructExpr),
210-
has(cxxConstructExpr(argumentCountIs(0)))),
211-
has(cxxBindTemporaryExpr(has(SoughtConstructExpr),
212-
has(cxxConstructExpr(argumentCountIs(0))))))));
212+
auto HasConstructInitListExpr = has(initListExpr(
213+
initCountLeq(1), anyOf(allOf(has(SoughtConstructExpr),
214+
has(cxxConstructExpr(argumentCountIs(0)))),
215+
has(cxxBindTemporaryExpr(
216+
has(SoughtConstructExpr),
217+
has(cxxConstructExpr(argumentCountIs(0))))))));
213218
auto HasBracedInitListExpr =
214219
anyOf(has(cxxBindTemporaryExpr(HasConstructInitListExpr)),
215220
HasConstructInitListExpr);

clang-tools-extra/clangd/Hover.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ void maybeAddSymbolProviders(ParsedAST &AST, HoverInfo &HI,
11941194

11951195
const SourceManager &SM = AST.getSourceManager();
11961196
llvm::SmallVector<include_cleaner::Header> RankedProviders =
1197-
include_cleaner::headersForSymbol(Sym, SM, AST.getPragmaIncludes().get());
1197+
include_cleaner::headersForSymbol(Sym, SM, &AST.getPragmaIncludes());
11981198
if (RankedProviders.empty())
11991199
return;
12001200

@@ -1254,7 +1254,7 @@ void maybeAddUsedSymbols(ParsedAST &AST, HoverInfo &HI, const Inclusion &Inc) {
12541254
llvm::DenseSet<include_cleaner::Symbol> UsedSymbols;
12551255
include_cleaner::walkUsed(
12561256
AST.getLocalTopLevelDecls(), collectMacroReferences(AST),
1257-
AST.getPragmaIncludes().get(), AST.getPreprocessor(),
1257+
&AST.getPragmaIncludes(), AST.getPreprocessor(),
12581258
[&](const include_cleaner::SymbolReference &Ref,
12591259
llvm::ArrayRef<include_cleaner::Header> Providers) {
12601260
if (Ref.RT != include_cleaner::RefType::Explicit ||

clang-tools-extra/clangd/IncludeCleaner.cpp

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include <cassert>
4949
#include <iterator>
5050
#include <map>
51-
#include <memory>
5251
#include <optional>
5352
#include <string>
5453
#include <utility>
@@ -237,18 +236,6 @@ removeAllUnusedIncludes(llvm::ArrayRef<Diag> UnusedIncludes) {
237236
Diag.Fixes.front().Edits.begin(),
238237
Diag.Fixes.front().Edits.end());
239238
}
240-
241-
// TODO(hokein): emit a suitable text for the label.
242-
ChangeAnnotation Annotation = {/*label=*/"",
243-
/*needsConfirmation=*/true,
244-
/*description=*/""};
245-
static const ChangeAnnotationIdentifier RemoveAllUnusedID =
246-
"RemoveAllUnusedIncludes";
247-
for (unsigned I = 0; I < RemoveAll.Edits.size(); ++I) {
248-
ChangeAnnotationIdentifier ID = RemoveAllUnusedID + std::to_string(I);
249-
RemoveAll.Edits[I].annotationId = ID;
250-
RemoveAll.Annotations.push_back({ID, Annotation});
251-
}
252239
return RemoveAll;
253240
}
254241

@@ -268,20 +255,8 @@ addAllMissingIncludes(llvm::ArrayRef<Diag> MissingIncludeDiags) {
268255
Edits.try_emplace(Edit.newText, Edit);
269256
}
270257
}
271-
// FIXME(hokein): emit used symbol reference in the annotation.
272-
ChangeAnnotation Annotation = {/*label=*/"",
273-
/*needsConfirmation=*/true,
274-
/*description=*/""};
275-
static const ChangeAnnotationIdentifier AddAllMissingID =
276-
"AddAllMissingIncludes";
277-
unsigned I = 0;
278-
for (auto &It : Edits) {
279-
ChangeAnnotationIdentifier ID = AddAllMissingID + std::to_string(I++);
258+
for (auto &It : Edits)
280259
AddAllMissing.Edits.push_back(std::move(It.second));
281-
AddAllMissing.Edits.back().annotationId = ID;
282-
283-
AddAllMissing.Annotations.push_back({ID, Annotation});
284-
}
285260
return AddAllMissing;
286261
}
287262
Fix fixAll(const Fix &RemoveAllUnused, const Fix &AddAllMissing) {
@@ -292,11 +267,6 @@ Fix fixAll(const Fix &RemoveAllUnused, const Fix &AddAllMissing) {
292267
FixAll.Edits.push_back(F);
293268
for (const auto &F : AddAllMissing.Edits)
294269
FixAll.Edits.push_back(F);
295-
296-
for (const auto &A : RemoveAllUnused.Annotations)
297-
FixAll.Annotations.push_back(A);
298-
for (const auto &A : AddAllMissing.Annotations)
299-
FixAll.Annotations.push_back(A);
300270
return FixAll;
301271
}
302272

@@ -311,7 +281,7 @@ getUnused(ParsedAST &AST,
311281
auto IncludeID = static_cast<IncludeStructure::HeaderID>(*MFI.HeaderID);
312282
if (ReferencedFiles.contains(IncludeID))
313283
continue;
314-
if (!mayConsiderUnused(MFI, AST, AST.getPragmaIncludes().get())) {
284+
if (!mayConsiderUnused(MFI, AST, &AST.getPragmaIncludes())) {
315285
dlog("{0} was not used, but is not eligible to be diagnosed as unused",
316286
MFI.Written);
317287
continue;
@@ -403,7 +373,7 @@ IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
403373
.getBuiltinDir();
404374
include_cleaner::walkUsed(
405375
AST.getLocalTopLevelDecls(), /*MacroRefs=*/Macros,
406-
AST.getPragmaIncludes().get(), AST.getPreprocessor(),
376+
&AST.getPragmaIncludes(), AST.getPreprocessor(),
407377
[&](const include_cleaner::SymbolReference &Ref,
408378
llvm::ArrayRef<include_cleaner::Header> Providers) {
409379
bool Satisfied = false;

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -653,18 +653,23 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
653653
}
654654

655655
IncludeStructure Includes;
656+
include_cleaner::PragmaIncludes PI;
656657
// If we are using a preamble, copy existing includes.
657658
if (Preamble) {
658659
Includes = Preamble->Includes;
659660
Includes.MainFileIncludes = Patch->preambleIncludes();
660661
// Replay the preamble includes so that clang-tidy checks can see them.
661662
ReplayPreamble::attach(Patch->preambleIncludes(), *Clang,
662663
Patch->modifiedBounds());
664+
PI = *Preamble->Pragmas;
663665
}
664666
// Important: collectIncludeStructure is registered *after* ReplayPreamble!
665667
// Otherwise we would collect the replayed includes again...
666668
// (We can't *just* use the replayed includes, they don't have Resolved path).
667669
Includes.collect(*Clang);
670+
// Same for pragma-includes, we're already inheriting preamble includes, so we
671+
// should only receive callbacks for non-preamble mainfile includes.
672+
PI.record(*Clang);
668673
// Copy over the macros in the preamble region of the main file, and combine
669674
// with non-preamble macros below.
670675
MainFileMacros Macros;
@@ -735,7 +740,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
735740
ParsedAST Result(Filename, Inputs.Version, std::move(Preamble),
736741
std::move(Clang), std::move(Action), std::move(Tokens),
737742
std::move(Macros), std::move(Marks), std::move(ParsedDecls),
738-
std::move(Diags), std::move(Includes));
743+
std::move(Diags), std::move(Includes), std::move(PI));
739744
llvm::move(getIncludeCleanerDiags(Result, Inputs.Contents),
740745
std::back_inserter(Result.Diags));
741746
return std::move(Result);
@@ -828,23 +833,21 @@ ParsedAST::ParsedAST(PathRef TUPath, llvm::StringRef Version,
828833
syntax::TokenBuffer Tokens, MainFileMacros Macros,
829834
std::vector<PragmaMark> Marks,
830835
std::vector<Decl *> LocalTopLevelDecls,
831-
std::vector<Diag> Diags, IncludeStructure Includes)
836+
std::vector<Diag> Diags, IncludeStructure Includes,
837+
include_cleaner::PragmaIncludes PI)
832838
: TUPath(TUPath), Version(Version), Preamble(std::move(Preamble)),
833839
Clang(std::move(Clang)), Action(std::move(Action)),
834840
Tokens(std::move(Tokens)), Macros(std::move(Macros)),
835841
Marks(std::move(Marks)), Diags(std::move(Diags)),
836842
LocalTopLevelDecls(std::move(LocalTopLevelDecls)),
837-
Includes(std::move(Includes)) {
838-
Resolver = std::make_unique<HeuristicResolver>(getASTContext());
843+
Includes(std::move(Includes)), PI(std::move(PI)),
844+
Resolver(std::make_unique<HeuristicResolver>(getASTContext())) {
839845
assert(this->Clang);
840846
assert(this->Action);
841847
}
842848

843-
std::shared_ptr<const include_cleaner::PragmaIncludes>
844-
ParsedAST::getPragmaIncludes() const {
845-
if (!Preamble)
846-
return nullptr;
847-
return Preamble->Pragmas;
849+
const include_cleaner::PragmaIncludes &ParsedAST::getPragmaIncludes() const {
850+
return PI;
848851
}
849852

850853
std::optional<llvm::StringRef> ParsedAST::preambleVersion() const {

clang-tools-extra/clangd/ParsedAST.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@ class ParsedAST {
103103
/// Tokens recorded while parsing the main file.
104104
/// (!) does not have tokens from the preamble.
105105
const syntax::TokenBuffer &getTokens() const { return Tokens; }
106-
/// Returns the PramaIncludes from the preamble.
107-
/// Might be null if AST is built without a preamble.
108-
std::shared_ptr<const include_cleaner::PragmaIncludes>
109-
getPragmaIncludes() const;
106+
/// Returns the PramaIncludes for preamble + main file includes.
107+
const include_cleaner::PragmaIncludes &getPragmaIncludes() const;
110108

111109
/// Returns the version of the ParseInputs this AST was built from.
112110
llvm::StringRef version() const { return Version; }
@@ -129,7 +127,7 @@ class ParsedAST {
129127
std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
130128
MainFileMacros Macros, std::vector<PragmaMark> Marks,
131129
std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
132-
IncludeStructure Includes);
130+
IncludeStructure Includes, include_cleaner::PragmaIncludes PI);
133131
Path TUPath;
134132
std::string Version;
135133
// In-memory preambles must outlive the AST, it is important that this member
@@ -159,6 +157,7 @@ class ParsedAST {
159157
// top-level decls from the preamble.
160158
std::vector<Decl *> LocalTopLevelDecls;
161159
IncludeStructure Includes;
160+
include_cleaner::PragmaIncludes PI;
162161
std::unique_ptr<HeuristicResolver> Resolver;
163162
};
164163

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ maybeFindIncludeReferences(ParsedAST &AST, Position Pos,
13391339
auto Converted = convertIncludes(AST);
13401340
include_cleaner::walkUsed(
13411341
AST.getLocalTopLevelDecls(), collectMacroReferences(AST),
1342-
AST.getPragmaIncludes().get(), AST.getPreprocessor(),
1342+
&AST.getPragmaIncludes(), AST.getPreprocessor(),
13431343
[&](const include_cleaner::SymbolReference &Ref,
13441344
llvm::ArrayRef<include_cleaner::Header> Providers) {
13451345
if (Ref.RT != include_cleaner::RefType::Explicit ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
223223
SlabTuple indexMainDecls(ParsedAST &AST) {
224224
return indexSymbols(
225225
AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(),
226-
&AST.getMacros(), *AST.getPragmaIncludes(),
226+
&AST.getMacros(), AST.getPragmaIncludes(),
227227
/*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
228228
}
229229

0 commit comments

Comments
 (0)