Skip to content

Commit 29620ed

Browse files
committed
Merge remote-tracking branch 'upstream/main' into data-scalarization-gep-cleanup
2 parents 6132b19 + 8b59622 commit 29620ed

File tree

1,851 files changed

+31290
-22049
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,851 files changed

+31290
-22049
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ concurrency:
3636
jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
39-
runs-on: llvm-premerge-libcxx-next-runners
39+
runs-on: llvm-premerge-libcxx-runners
4040
continue-on-error: false
4141
strategy:
4242
fail-fast: false
@@ -73,7 +73,7 @@ jobs:
7373
**/crash_diagnostics/*
7474
stage2:
7575
if: github.repository_owner == 'llvm'
76-
runs-on: llvm-premerge-libcxx-next-runners
76+
runs-on: llvm-premerge-libcxx-runners
7777
needs: [ stage1 ]
7878
continue-on-error: false
7979
strategy:
@@ -148,19 +148,19 @@ jobs:
148148
'generic-static',
149149
'bootstrapping-build'
150150
]
151-
machine: [ 'llvm-premerge-libcxx-next-runners' ]
151+
machine: [ 'llvm-premerge-libcxx-runners' ]
152152
include:
153153
- config: 'generic-cxx26'
154-
machine: llvm-premerge-libcxx-next-runners
154+
machine: llvm-premerge-libcxx-runners
155155
- config: 'generic-asan'
156-
machine: llvm-premerge-libcxx-next-runners
156+
machine: llvm-premerge-libcxx-runners
157157
- config: 'generic-tsan'
158-
machine: llvm-premerge-libcxx-next-runners
158+
machine: llvm-premerge-libcxx-runners
159159
- config: 'generic-ubsan'
160-
machine: llvm-premerge-libcxx-next-runners
160+
machine: llvm-premerge-libcxx-runners
161161
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
162162
- config: 'generic-msan'
163-
machine: llvm-premerge-libcxx-next-runners
163+
machine: llvm-premerge-libcxx-runners
164164
runs-on: ${{ matrix.machine }}
165165
steps:
166166
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

.github/workflows/libcxx-build-containers.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ on:
1515
branches:
1616
- main
1717
paths:
18-
- 'libcxx/utils/ci/**'
18+
- 'libcxx/utils/ci/docker/**'
1919
- '.github/workflows/libcxx-build-containers.yml'
2020
pull_request:
2121
paths:
22-
- 'libcxx/utils/ci/**'
22+
- 'libcxx/utils/ci/docker/**'
2323
- '.github/workflows/libcxx-build-containers.yml'
2424

2525
jobs:
@@ -40,17 +40,18 @@ jobs:
4040
echo '{ "data-root": "/mnt/docker" }' | sudo tee /etc/docker/daemon.json
4141
sudo systemctl restart docker
4242
43-
- name: Build the Linux builder image
44-
working-directory: libcxx/utils/ci
45-
run: |
46-
docker compose build builder-base
47-
docker compose build actions-builder
43+
- name: Build the base image
44+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder-base
45+
env:
46+
TAG: ${{ github.sha }}
47+
48+
- name: Build the Linux Github Actions image
49+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder
4850
env:
4951
TAG: ${{ github.sha }}
5052

5153
- name: Build the Android builder image
52-
working-directory: libcxx/utils/ci
53-
run: docker compose build android-buildkite-builder
54+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-android-builder
5455
env:
5556
TAG: ${{ github.sha }}
5657

@@ -61,19 +62,21 @@ jobs:
6162
username: ${{ github.actor }}
6263
password: ${{ secrets.GITHUB_TOKEN }}
6364

64-
- name: Push the Linux builder image
65+
- name: Push the images
6566
if: github.event_name == 'push'
66-
working-directory: libcxx/utils/ci
67-
run: |
68-
docker compose push builder-base
69-
docker compose push actions-builder
70-
env:
71-
TAG: ${{ github.sha }}
67+
run: docker compose push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder
7268

73-
- name: Push the Android builder image
74-
if: github.event_name == 'push'
75-
working-directory: libcxx/utils/ci
69+
# We create tarballs with the images and upload them as artifacts, since that's useful for testing
70+
# the images when making changes.
71+
- name: Create image tarballs
7672
run: |
77-
docker compose push android-buildkite-builder
78-
env:
79-
TAG: ${{ github.sha }}
73+
docker image save ghcr.io/llvm/libcxx-linux-builder-base:${{ github.sha }} | gzip > libcxx-linux-builder-base.tar.gz
74+
docker image save ghcr.io/llvm/libcxx-linux-builder:${{ github.sha }} | gzip > libcxx-linux-builder.tar.gz
75+
docker image save ghcr.io/llvm/libcxx-android-builder:${{ github.sha }} | gzip > libcxx-android-builder.tar.gz
76+
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
77+
with:
78+
name: libcxx-docker-images
79+
path: |
80+
libcxx-linux-builder-base.tar.gz
81+
libcxx-linux-builder.tar.gz
82+
libcxx-android-builder.tar.gz

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ class RewriteInstance {
139139
void handleRelocation(const object::SectionRef &RelocatedSection,
140140
const RelocationRef &Rel);
141141

142+
/// Collect functions that are specified to be bumped.
143+
void selectFunctionsToPrint();
144+
142145
/// Mark functions that are not meant for processing as ignored.
143146
void selectFunctionsToProcess();
144147

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ extern cl::OptionCategory BoltOptCategory;
6161

6262
extern cl::opt<bool> EnableBAT;
6363
extern cl::opt<bool> Instrument;
64+
extern cl::list<std::string> PrintOnly;
65+
extern cl::opt<std::string> PrintOnlyFile;
6466
extern cl::opt<bool> StrictMode;
6567
extern cl::opt<bool> UpdateDebugSections;
6668
extern cl::opt<unsigned> Verbosity;
@@ -133,14 +135,6 @@ PrintDynoStatsOnly("print-dyno-stats-only",
133135
cl::Hidden,
134136
cl::cat(BoltCategory));
135137

136-
static cl::list<std::string>
137-
PrintOnly("print-only",
138-
cl::CommaSeparated,
139-
cl::desc("list of functions to print"),
140-
cl::value_desc("func1,func2,func3,..."),
141-
cl::Hidden,
142-
cl::cat(BoltCategory));
143-
144138
cl::opt<bool>
145139
TimeBuild("time-build",
146140
cl::desc("print time spent constructing binary functions"),

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ extern cl::opt<bool> Hugify;
8282
extern cl::opt<bool> Instrument;
8383
extern cl::opt<bool> KeepNops;
8484
extern cl::opt<bool> Lite;
85+
extern cl::list<std::string> PrintOnly;
86+
extern cl::opt<std::string> PrintOnlyFile;
8587
extern cl::list<std::string> ReorderData;
8688
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
8789
extern cl::opt<bool> TerminalHLT;
@@ -730,6 +732,8 @@ Error RewriteInstance::run() {
730732
<< "\n";
731733
BC->outs() << "BOLT-INFO: BOLT version: " << BoltRevision << "\n";
732734

735+
selectFunctionsToPrint();
736+
733737
if (Error E = discoverStorage())
734738
return E;
735739
if (Error E = readSpecialSections())
@@ -3100,17 +3104,22 @@ static BinaryFunction *getInitFunctionIfStaticBinary(BinaryContext &BC) {
31003104
return BC.getBinaryFunctionAtAddress(BD->getAddress());
31013105
}
31023106

3107+
static void populateFunctionNames(cl::opt<std::string> &FunctionNamesFile,
3108+
cl::list<std::string> &FunctionNames) {
3109+
if (FunctionNamesFile.empty())
3110+
return;
3111+
std::ifstream FuncsFile(FunctionNamesFile, std::ios::in);
3112+
std::string FuncName;
3113+
while (std::getline(FuncsFile, FuncName))
3114+
FunctionNames.push_back(FuncName);
3115+
}
3116+
3117+
void RewriteInstance::selectFunctionsToPrint() {
3118+
populateFunctionNames(opts::PrintOnlyFile, opts::PrintOnly);
3119+
}
3120+
31033121
void RewriteInstance::selectFunctionsToProcess() {
31043122
// Extend the list of functions to process or skip from a file.
3105-
auto populateFunctionNames = [](cl::opt<std::string> &FunctionNamesFile,
3106-
cl::list<std::string> &FunctionNames) {
3107-
if (FunctionNamesFile.empty())
3108-
return;
3109-
std::ifstream FuncsFile(FunctionNamesFile, std::ios::in);
3110-
std::string FuncName;
3111-
while (std::getline(FuncsFile, FuncName))
3112-
FunctionNames.push_back(FuncName);
3113-
};
31143123
populateFunctionNames(opts::FunctionNamesFile, opts::ForceFunctionNames);
31153124
populateFunctionNames(opts::SkipFunctionNamesFile, opts::SkipFunctionNames);
31163125
populateFunctionNames(opts::FunctionNamesFileNR, opts::ForceFunctionNamesNR);

bolt/lib/Utils/CommandLineOpts.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ cl::opt<bool> PrintCacheMetrics(
245245
cl::desc("calculate and print various metrics for instruction cache"),
246246
cl::cat(BoltOptCategory));
247247

248+
cl::list<std::string> PrintOnly("print-only", cl::CommaSeparated,
249+
cl::desc("list of functions to print"),
250+
cl::value_desc("func1,func2,func3,..."),
251+
cl::Hidden, cl::cat(BoltCategory));
252+
253+
cl::opt<std::string>
254+
PrintOnlyFile("print-only-file",
255+
cl::desc("file with list of functions to print"), cl::Hidden,
256+
cl::cat(BoltCategory));
257+
248258
cl::opt<bool> PrintSections("print-sections",
249259
cl::desc("print all registered sections"),
250260
cl::Hidden, cl::cat(BoltCategory));

bolt/test/print-only.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Verify if `--print-only` and `--print-only-files` work fine.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: %clang %cflags -x c %p/Inputs/bolt_icf.cpp -o %t -Wl,-q
6+
# RUN: llvm-bolt %t -o %t.bolt --icf=none --print-cfg \
7+
# RUN: --print-only=foo.*,bar.*,main.* 2>&1 | FileCheck %s
8+
9+
# RUN: echo "bar.*" > %t.pof
10+
# RUN: echo "main.*" >> %t.pof
11+
# RUN: llvm-bolt %t -o %t.bolt --icf=none --print-cfg \
12+
# RUN: --print-only=foo.* --print-only-file=%t.pof \
13+
# RUN: 2>&1 | FileCheck %s
14+
15+
# RUN: echo "foo.*" >> %t.pof
16+
# RUN: llvm-bolt %t -o %t.bolt --icf=none --print-cfg \
17+
# RUN: --print-only-file=%t.pof 2>&1 | FileCheck %s
18+
19+
# CHECK-NOT: Binary Function "fiz" after building cfg
20+
# CHECK-NOT: Binary Function "faz" after building cfg
21+
# CHECK-NOT: Binary Function "zip" after building cfg
22+
# CHECK-NOT: Binary Function "zap" after building cfg
23+
# CHECK: Binary Function "foo" after building cfg
24+
# CHECK: Binary Function "bar" after building cfg
25+
# CHECK: Binary Function "main" after building cfg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
BasedOnStyle: LLVM
22
QualifierAlignment: Left
33
LineEnding: LF
4+
InsertNewlineAtEOF: true

clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,102 @@
1111
#include "clang/Lex/Preprocessor.h"
1212
#include <optional>
1313

14-
namespace clang::tidy::google::readability {
14+
namespace clang::tidy {
15+
16+
namespace google::readability {
17+
18+
enum class StyleKind { Parentheses, Hyphen };
19+
20+
} // namespace google::readability
21+
22+
template <> struct OptionEnumMapping<google::readability::StyleKind> {
23+
static ArrayRef<std::pair<google::readability::StyleKind, StringRef>>
24+
getEnumMapping() {
25+
static constexpr std::pair<google::readability::StyleKind, StringRef>
26+
Mapping[] = {
27+
{google::readability::StyleKind::Hyphen, "Hyphen"},
28+
{google::readability::StyleKind::Parentheses, "Parentheses"},
29+
};
30+
return {Mapping};
31+
}
32+
};
33+
34+
} // namespace clang::tidy
1535

36+
namespace clang::tidy::google::readability {
1637
class TodoCommentCheck::TodoCommentHandler : public CommentHandler {
1738
public:
1839
TodoCommentHandler(TodoCommentCheck &Check, std::optional<std::string> User)
1940
: Check(Check), User(User ? *User : "unknown"),
20-
TodoMatch("^// *TODO *(\\(.*\\))?:?( )?(.*)$") {}
41+
TodoMatch(R"(^// *TODO *((\((.*)\))?:?( )?|: *(.*) *- *)?(.*)$)") {
42+
const llvm::StringRef TodoStyleString =
43+
Check.Options.get("Style", "Hyphen");
44+
for (const auto &[Value, Name] :
45+
OptionEnumMapping<StyleKind>::getEnumMapping()) {
46+
if (Name == TodoStyleString) {
47+
TodoStyle = Value;
48+
return;
49+
}
50+
}
51+
Check.configurationDiag(
52+
"invalid value '%0' for "
53+
"google-readability-todo.Style; valid values are "
54+
"'Parentheses' and 'Hyphen'. Defaulting to 'Hyphen'")
55+
<< TodoStyleString;
56+
}
2157

2258
bool HandleComment(Preprocessor &PP, SourceRange Range) override {
2359
const StringRef Text =
2460
Lexer::getSourceText(CharSourceRange::getCharRange(Range),
2561
PP.getSourceManager(), PP.getLangOpts());
2662

27-
SmallVector<StringRef, 4> Matches;
63+
SmallVector<StringRef, 7> Matches;
2864
if (!TodoMatch.match(Text, &Matches))
2965
return false;
3066

31-
const StringRef Username = Matches[1];
32-
const StringRef Comment = Matches[3];
67+
const StyleKind ParsedStyle =
68+
!Matches[3].empty() ? StyleKind::Parentheses : StyleKind::Hyphen;
69+
const StringRef Username =
70+
ParsedStyle == StyleKind::Parentheses ? Matches[3] : Matches[5];
71+
const StringRef Comment = Matches[6];
3372

34-
if (!Username.empty())
73+
if (!Username.empty() &&
74+
(ParsedStyle == StyleKind::Parentheses || !Comment.empty())) {
3575
return false;
76+
}
3677

37-
const std::string NewText =
38-
("// TODO(" + Twine(User) + "): " + Comment).str();
78+
if (Username.empty()) {
79+
Check.diag(Range.getBegin(), "missing username/bug in TODO")
80+
<< FixItHint::CreateReplacement(
81+
CharSourceRange::getCharRange(Range),
82+
createReplacementString(Username, Comment));
83+
}
84+
85+
if (Comment.empty())
86+
Check.diag(Range.getBegin(), "missing details in TODO");
3987

40-
Check.diag(Range.getBegin(), "missing username/bug in TODO")
41-
<< FixItHint::CreateReplacement(CharSourceRange::getCharRange(Range),
42-
NewText);
4388
return false;
4489
}
4590

91+
std::string createReplacementString(const StringRef Username,
92+
const StringRef Comment) const {
93+
if (TodoStyle == StyleKind::Parentheses) {
94+
return ("// TODO(" + Twine(User) +
95+
"): " + (Comment.empty() ? "some details" : Comment))
96+
.str();
97+
}
98+
return ("// TODO: " + Twine(User) + " - " +
99+
(Comment.empty() ? "some details" : Comment))
100+
.str();
101+
}
102+
103+
StyleKind getTodoStyle() const { return TodoStyle; }
104+
46105
private:
47106
TodoCommentCheck &Check;
48107
std::string User;
49108
llvm::Regex TodoMatch;
109+
StyleKind TodoStyle = StyleKind::Hyphen;
50110
};
51111

52112
TodoCommentCheck::TodoCommentCheck(StringRef Name, ClangTidyContext *Context)
@@ -62,4 +122,8 @@ void TodoCommentCheck::registerPPCallbacks(const SourceManager &SM,
62122
PP->addCommentHandler(Handler.get());
63123
}
64124

125+
void TodoCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
126+
Options.store(Opts, "Style", Handler->getTodoStyle());
127+
}
128+
65129
} // namespace clang::tidy::google::readability

clang-tools-extra/clang-tidy/google/TodoCommentCheck.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class TodoCommentCheck : public ClangTidyCheck {
2727
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
2828
Preprocessor *ModuleExpanderPP) override;
2929

30+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
31+
3032
private:
3133
class TodoCommentHandler;
3234
std::unique_ptr<TodoCommentHandler> Handler;

0 commit comments

Comments
 (0)