Skip to content

Commit cf75514

Browse files
committed
Merge branch 'users/meinersbur/flang_runtime' into users/meinersbur/flang_runtime_shared
2 parents 60f62e0 + 8bdea32 commit cf75514

File tree

2,673 files changed

+100949
-83950
lines changed

Some content is hidden

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

2,673 files changed

+100949
-83950
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @dcci @yota9
132132

133133
# Bazel build system.
134-
/utils/bazel/ @rupprecht @keith
134+
/utils/bazel/ @rupprecht @keith @aaronmondal
135135

136136
# InstallAPI and TextAPI
137137
/llvm/**/TextAPI/ @cyndyishida

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ name: Build Docker images for libc++ CI
99

1010
permissions:
1111
contents: read
12-
packages: write
1312

1413
on:
1514
push:

.github/workflows/release-binaries-all.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
required: true
2828
default: false
2929
type: boolean
30+
secrets:
31+
RELEASE_TASKS_USER_TOKEN:
32+
description: "Secret used to check user permissions."
33+
required: false
3034

3135
pull_request:
3236
types:

bolt/include/bolt/Core/BinarySection.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,9 @@ class BinarySection {
359359

360360
/// Add a new relocation at the given /p Offset.
361361
void addRelocation(uint64_t Offset, MCSymbol *Symbol, uint64_t Type,
362-
uint64_t Addend, uint64_t Value = 0,
363-
bool Pending = false) {
362+
uint64_t Addend, uint64_t Value = 0) {
364363
assert(Offset < getSize() && "offset not within section bounds");
365-
if (!Pending) {
366-
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
367-
} else {
368-
PendingRelocations.emplace_back(
369-
Relocation{Offset, Symbol, Type, Addend, Value});
370-
}
364+
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
371365
}
372366

373367
/// Add a dynamic relocation at the given /p Offset.

bolt/lib/RuntimeLibs/RuntimeLibrary.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/Object/Archive.h"
1919
#include "llvm/Object/ObjectFile.h"
2020
#include "llvm/Support/Path.h"
21+
#include "llvm/Support/Program.h"
2122

2223
#define DEBUG_TYPE "bolt-rtlib"
2324

@@ -38,6 +39,23 @@ std::string RuntimeLibrary::getLibPathByToolPath(StringRef ToolPath,
3839
llvm::sys::path::append(LibPath, "lib" LLVM_LIBDIR_SUFFIX);
3940
}
4041
llvm::sys::path::append(LibPath, LibFileName);
42+
if (!llvm::sys::fs::exists(LibPath)) {
43+
// If it is a symlink, check the directory that the symlink points to.
44+
if (llvm::sys::fs::is_symlink_file(ToolPath)) {
45+
SmallString<256> RealPath;
46+
llvm::sys::fs::real_path(ToolPath, RealPath);
47+
if (llvm::ErrorOr<std::string> P =
48+
llvm::sys::findProgramByName(RealPath)) {
49+
outs() << "BOLT-INFO: library not found: " << LibPath << "\n"
50+
<< "BOLT-INFO: " << ToolPath << " is a symlink; will look up "
51+
<< LibFileName
52+
<< " at the target directory that the symlink points to\n";
53+
return getLibPath(*P, LibFileName);
54+
}
55+
}
56+
errs() << "BOLT-ERROR: library not found: " << LibPath << "\n";
57+
exit(1);
58+
}
4159
return std::string(LibPath);
4260
}
4361

bolt/tools/driver/llvm-bolt.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,14 @@ void boltMode(int argc, char **argv) {
173173
}
174174
}
175175

176-
static std::string GetExecutablePath(const char *Argv0) {
177-
SmallString<256> ExecutablePath(Argv0);
178-
// Do a PATH lookup if Argv0 isn't a valid path.
179-
if (!llvm::sys::fs::exists(ExecutablePath))
180-
if (llvm::ErrorOr<std::string> P =
181-
llvm::sys::findProgramByName(ExecutablePath))
182-
ExecutablePath = *P;
183-
return std::string(ExecutablePath);
184-
}
185-
186176
int main(int argc, char **argv) {
187177
// Print a stack trace if we signal out.
188178
sys::PrintStackTraceOnErrorSignal(argv[0]);
189179
PrettyStackTraceProgram X(argc, argv);
190180

191181
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
192182

193-
std::string ToolPath = GetExecutablePath(argv[0]);
183+
std::string ToolPath = llvm::sys::fs::getMainExecutable(argv[0], nullptr);
194184

195185
// Initialize targets and assembly printers/parsers.
196186
llvm::InitializeAllTargetInfos();

bolt/unittests/Core/BinaryContext.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
9393
DataSize, 4);
9494
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
9595
ASSERT_TRUE(RelSymbol1);
96-
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0, true);
96+
BS.addPendingRelocation(
97+
Relocation{8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0});
9798
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
9899
ASSERT_TRUE(RelSymbol2);
99-
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0, true);
100+
BS.addPendingRelocation(
101+
Relocation{12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0});
100102

101-
std::error_code EC;
102103
SmallVector<char> Vect(DataSize);
103104
raw_svector_ostream OS(Vect);
104105

@@ -134,12 +135,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocJUMP26) {
134135
(uint8_t *)Data, Size, 4);
135136
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
136137
ASSERT_TRUE(RelSymbol1);
137-
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0, true);
138+
BS.addPendingRelocation(
139+
Relocation{8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0});
138140
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
139141
ASSERT_TRUE(RelSymbol2);
140-
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0, true);
142+
BS.addPendingRelocation(
143+
Relocation{12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0});
141144

142-
std::error_code EC;
143145
SmallVector<char> Vect(Size);
144146
raw_svector_ostream OS(Vect);
145147

clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
8282
Finder->addMatcher(
8383
cxxConstructExpr(
8484
hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
85-
hasArgument(0, hasType(qualType(isInteger()))),
85+
argumentCountIs(2), hasArgument(0, hasType(qualType(isInteger()))),
8686
hasArgument(1, hasType(qualType(isInteger()))),
8787
anyOf(
8888
// Detect the expression: string('x', 40);
@@ -102,7 +102,7 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
102102
cxxConstructExpr(
103103
hasDeclaration(cxxConstructorDecl(ofClass(
104104
cxxRecordDecl(hasAnyName(removeNamespaces(StringNames)))))),
105-
hasArgument(0, hasType(CharPtrType)),
105+
argumentCountIs(2), hasArgument(0, hasType(CharPtrType)),
106106
hasArgument(1, hasType(isInteger())),
107107
anyOf(
108108
// Detect the expression: string("...", 0);
@@ -114,7 +114,34 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
114114
// Detect the expression: string("lit", 5)
115115
allOf(hasArgument(0, ConstStrLiteral.bind("literal-with-length")),
116116
hasArgument(1, ignoringParenImpCasts(
117-
integerLiteral().bind("int"))))))
117+
integerLiteral().bind("length"))))))
118+
.bind("constructor"),
119+
this);
120+
121+
// Check the literal string constructor with char pointer, start position and
122+
// length parameters. [i.e. string (const char* s, size_t pos, size_t count);]
123+
Finder->addMatcher(
124+
cxxConstructExpr(
125+
hasDeclaration(cxxConstructorDecl(ofClass(
126+
cxxRecordDecl(hasAnyName(removeNamespaces(StringNames)))))),
127+
argumentCountIs(3), hasArgument(0, hasType(CharPtrType)),
128+
hasArgument(1, hasType(qualType(isInteger()))),
129+
hasArgument(2, hasType(qualType(isInteger()))),
130+
anyOf(
131+
// Detect the expression: string("...", 1, 0);
132+
hasArgument(2, ZeroExpr.bind("empty-string")),
133+
// Detect the expression: string("...", -4, 1);
134+
hasArgument(1, NegativeExpr.bind("negative-pos")),
135+
// Detect the expression: string("...", 0, -4);
136+
hasArgument(2, NegativeExpr.bind("negative-length")),
137+
// Detect the expression: string("lit", 0, 0x1234567);
138+
hasArgument(2, LargeLengthExpr.bind("large-length")),
139+
// Detect the expression: string("lit", 1, 5)
140+
allOf(hasArgument(0, ConstStrLiteral.bind("literal-with-length")),
141+
hasArgument(
142+
1, ignoringParenImpCasts(integerLiteral().bind("pos"))),
143+
hasArgument(2, ignoringParenImpCasts(
144+
integerLiteral().bind("length"))))))
118145
.bind("constructor"),
119146
this);
120147

@@ -155,14 +182,27 @@ void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) {
155182
diag(Loc, "constructor creating an empty string");
156183
} else if (Result.Nodes.getNodeAs<Expr>("negative-length")) {
157184
diag(Loc, "negative value used as length parameter");
185+
} else if (Result.Nodes.getNodeAs<Expr>("negative-pos")) {
186+
diag(Loc, "negative value used as position of the "
187+
"first character parameter");
158188
} else if (Result.Nodes.getNodeAs<Expr>("large-length")) {
159189
if (WarnOnLargeLength)
160190
diag(Loc, "suspicious large length parameter");
161191
} else if (Result.Nodes.getNodeAs<Expr>("literal-with-length")) {
162192
const auto *Str = Result.Nodes.getNodeAs<StringLiteral>("str");
163-
const auto *Lit = Result.Nodes.getNodeAs<IntegerLiteral>("int");
164-
if (Lit->getValue().ugt(Str->getLength())) {
193+
const auto *Length = Result.Nodes.getNodeAs<IntegerLiteral>("length");
194+
if (Length->getValue().ugt(Str->getLength())) {
165195
diag(Loc, "length is bigger than string literal size");
196+
return;
197+
}
198+
if (const auto *Pos = Result.Nodes.getNodeAs<IntegerLiteral>("pos")) {
199+
if (Pos->getValue().uge(Str->getLength())) {
200+
diag(Loc, "position of the first character parameter is bigger than "
201+
"string literal character range");
202+
} else if (Length->getValue().ugt(
203+
(Str->getLength() - Pos->getValue()).getZExtValue())) {
204+
diag(Loc, "length is bigger than remaining string literal size");
205+
}
166206
}
167207
} else if (const auto *Ptr = Result.Nodes.getNodeAs<Expr>("from-ptr")) {
168208
Expr::EvalResult ConstPtr;

0 commit comments

Comments
 (0)