Skip to content

Commit a6d9df5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into spirv_be_staging
2 parents 2e9bc21 + f244386 commit a6d9df5

File tree

78 files changed

+7346
-1334
lines changed

Some content is hidden

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

78 files changed

+7346
-1334
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,9 +1699,19 @@ bool BinaryFunction::scanExternalRefs() {
16991699

17001700
const uint64_t FunctionOffset =
17011701
TargetAddress - TargetFunction->getAddress();
1702-
BranchTargetSymbol =
1703-
FunctionOffset ? TargetFunction->addEntryPointAtOffset(FunctionOffset)
1704-
: TargetFunction->getSymbol();
1702+
if (!TargetFunction->isInConstantIsland(TargetAddress)) {
1703+
BranchTargetSymbol =
1704+
FunctionOffset
1705+
? TargetFunction->addEntryPointAtOffset(FunctionOffset)
1706+
: TargetFunction->getSymbol();
1707+
} else {
1708+
TargetFunction->setIgnored();
1709+
BC.outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
1710+
<< Twine::utohexstr(Address)
1711+
<< " in constant island of function " << *TargetFunction
1712+
<< '\n';
1713+
continue;
1714+
}
17051715
}
17061716

17071717
// Can't find more references. Not creating relocations since we are not

bolt/test/AArch64/constant-island-entry.s

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
// This test checks that we ignore functions which add an entry point that
2-
// is in a constant island.
1+
## This test checks that we ignore functions which add an entry point that
2+
## is in a constant island.
33

44
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
55
# RUN: %clang %cflags %t.o -pie -Wl,-q -o %t.exe
6+
7+
## Check when the caller is successfully disassembled.
68
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
79

10+
## Skip caller to check the identical warning is triggered from ScanExternalRefs().
11+
# RUN: llvm-bolt %t.exe -o %t.bolt -skip-funcs=caller 2>&1 | FileCheck %s
12+
813
# CHECK: BOLT-WARNING: Ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
914

1015
.globl func

clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "RedundantParenthesesCheck.h"
10+
#include "../utils/Matchers.h"
11+
#include "../utils/OptionsUtils.h"
1012
#include "clang/AST/Expr.h"
1113
#include "clang/ASTMatchers/ASTMatchFinder.h"
1214
#include "clang/ASTMatchers/ASTMatchers.h"
@@ -32,15 +34,30 @@ AST_MATCHER(ParenExpr, isInMacro) {
3234

3335
} // namespace
3436

37+
RedundantParenthesesCheck::RedundantParenthesesCheck(StringRef Name,
38+
ClangTidyContext *Context)
39+
: ClangTidyCheck(Name, Context),
40+
AllowedDecls(utils::options::parseStringList(
41+
Options.get("AllowedDecls", "std::max;std::min"))) {}
42+
43+
void RedundantParenthesesCheck::storeOptions(
44+
ClangTidyOptions::OptionMap &Opts) {
45+
Options.store(Opts, "AllowedDecls",
46+
utils::options::serializeStringList(AllowedDecls));
47+
}
48+
3549
void RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
3650
const auto ConstantExpr =
3751
expr(anyOf(integerLiteral(), floatLiteral(), characterLiteral(),
3852
cxxBoolLiteral(), stringLiteral(), cxxNullPtrLiteralExpr()));
3953
Finder->addMatcher(
40-
parenExpr(subExpr(anyOf(parenExpr(), ConstantExpr, declRefExpr())),
41-
unless(anyOf(isInMacro(),
42-
// sizeof(...) is common used.
43-
hasParent(unaryExprOrTypeTraitExpr()))))
54+
parenExpr(
55+
subExpr(anyOf(parenExpr(), ConstantExpr,
56+
declRefExpr(to(namedDecl(unless(
57+
matchers::matchesAnyListedName(AllowedDecls))))))),
58+
unless(anyOf(isInMacro(),
59+
// sizeof(...) is common used.
60+
hasParent(unaryExprOrTypeTraitExpr()))))
4461
.bind("dup"),
4562
this);
4663
}

clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ namespace clang::tidy::readability {
2020
/// https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-parentheses.html
2121
class RedundantParenthesesCheck : public ClangTidyCheck {
2222
public:
23-
RedundantParenthesesCheck(StringRef Name, ClangTidyContext *Context)
24-
: ClangTidyCheck(Name, Context) {}
23+
RedundantParenthesesCheck(StringRef Name, ClangTidyContext *Context);
24+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2525
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
2626
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
2727
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
2828
return LangOpts.CPlusPlus | LangOpts.C99;
2929
}
30+
31+
private:
32+
const std::vector<StringRef> AllowedDecls;
3033
};
3134

3235
} // namespace clang::tidy::readability

clang-tools-extra/docs/clang-tidy/checks/readability/redundant-parentheses.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,16 @@ affect the semantics.
2727
.. code-block:: c++
2828

2929
int a = (1 * 2) + 3; // no warning
30+
31+
Options
32+
-------
33+
34+
.. option:: AllowedDecls
35+
36+
Semicolon-separated list of regular expressions matching names of declarations
37+
to ignore when the parentheses are around. Declarations can include variables
38+
or functions. The default is an `std::max;std::min`.
39+
40+
Some STL library functions may have the same name as widely used function-like
41+
macro. For example, ``std::max`` and ``max`` macro. A workaround to distinguish
42+
them is adding parentheses around functions to prevent function-like macro.

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,12 @@ void exceptions() {
6262
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant parentheses around expression [readability-redundant-parentheses]
6363
// CHECK-FIXES: alignof(3);
6464
}
65+
66+
namespace std {
67+
template<class T> T max(T, T);
68+
template<class T> T min(T, T);
69+
} // namespace std
70+
void ignoreStdMaxMin() {
71+
(std::max)(1,2);
72+
(std::min)(1,2);
73+
}

clang/lib/Basic/Targets/PPC.h

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -445,42 +445,30 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo {
445445
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
446446
IntMaxType = SignedLong;
447447
Int64Type = SignedLong;
448-
std::string DataLayout;
449448

450449
if (Triple.isOSAIX()) {
451450
// TODO: Set appropriate ABI for AIX platform.
452-
DataLayout = "E-m:a-Fi64-i64:64-i128:128-n32:64";
453451
LongDoubleWidth = 64;
454452
LongDoubleAlign = DoubleAlign = 32;
455453
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
456-
} else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
457-
DataLayout = "e-m:e-Fn32-i64:64-i128:128-n32:64";
454+
} else if ((Triple.getArch() == llvm::Triple::ppc64le) ||
455+
Triple.isPPC64ELFv2ABI()) {
458456
ABI = "elfv2";
459457
} else {
460-
DataLayout = "E-m:e";
461-
if (Triple.isPPC64ELFv2ABI()) {
462-
ABI = "elfv2";
463-
DataLayout += "-Fn32";
464-
} else {
465-
ABI = "elfv1";
466-
DataLayout += "-Fi64";
467-
}
468-
DataLayout += "-i64:64-i128:128-n32:64";
458+
ABI = "elfv1";
469459
}
470460

471461
if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
472462
LongDoubleWidth = LongDoubleAlign = 64;
473463
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
474464
}
475465

476-
if (Triple.isOSAIX() || Triple.isOSLinux())
477-
DataLayout += "-S128-v256:256:256-v512:512:512";
478-
resetDataLayout(DataLayout);
479-
480466
// Newer PPC64 instruction sets support atomics up to 16 bytes.
481467
MaxAtomicPromoteWidth = 128;
482468
// Baseline PPC64 supports inlining atomics up to 8 bytes.
483469
MaxAtomicInlineWidth = 64;
470+
471+
calculateDataLayout();
484472
}
485473

486474
void setMaxAtomicWidth() override {
@@ -495,10 +483,33 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo {
495483
return TargetInfo::CharPtrBuiltinVaList;
496484
}
497485

486+
void calculateDataLayout() {
487+
std::string DataLayout;
488+
489+
if (getTriple().isOSAIX()) {
490+
DataLayout = "E-m:a-Fi64-i64:64-i128:128-n32:64";
491+
} else if ((getTriple().getArch() == llvm::Triple::ppc64le)) {
492+
DataLayout = "e-m:e-Fn32-i64:64-i128:128-n32:64";
493+
} else {
494+
DataLayout = "E-m:e";
495+
if (ABI == "elfv2") {
496+
DataLayout += "-Fn32";
497+
} else {
498+
DataLayout += "-Fi64";
499+
}
500+
DataLayout += "-i64:64-i128:128-n32:64";
501+
}
502+
503+
if (getTriple().isOSAIX() || getTriple().isOSLinux())
504+
DataLayout += "-S128-v256:256:256-v512:512:512";
505+
resetDataLayout(DataLayout);
506+
}
507+
498508
// PPC64 Linux-specific ABI options.
499509
bool setABI(const std::string &Name) override {
500510
if (Name == "elfv1" || Name == "elfv2") {
501511
ABI = Name;
512+
calculateDataLayout();
502513
return true;
503514
}
504515
return false;

clang/lib/CodeGen/Targets/SPIR.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ CommonSPIRTargetCodeGenInfo::getNullPointer(const CodeGen::CodeGenModule &CGM,
260260
LangAS AS = QT->getUnqualifiedDesugaredType()->isNullPtrType()
261261
? LangAS::Default
262262
: QT->getPointeeType().getAddressSpace();
263-
if (AS == LangAS::Default || AS == LangAS::opencl_generic)
263+
if (AS == LangAS::Default || AS == LangAS::opencl_generic ||
264+
AS == LangAS::opencl_constant)
264265
return llvm::ConstantPointerNull::get(PT);
265266

266267
auto &Ctx = CGM.getContext();

clang/lib/Tooling/Transformer/RangeSelector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,12 @@ RangeSelector transformer::name(std::string ID) {
205205
// `foo<int>` for which this range will be too short. Doing so will
206206
// require subcasing `NamedDecl`, because it doesn't provide virtual
207207
// access to the \c DeclarationNameInfo.
208-
if (tooling::getText(R, *Result.Context) != D->getName())
209-
return CharSourceRange();
208+
StringRef Text = tooling::getText(R, *Result.Context);
209+
if (Text != D->getName())
210+
return llvm::make_error<StringError>(
211+
llvm::errc::not_supported,
212+
"range selected by name(node id=" + ID + "): '" + Text +
213+
"' is different from decl name '" + D->getName() + "'");
210214
return R;
211215
}
212216
if (const auto *E = Node.get<DeclRefExpr>()) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -target-abi elfv2 %s -o - -emit-llvm | FileCheck %s
2+
3+
// REQUIRES: powerpc-registered-target
4+
5+
// Make sure that overriding the ABI to ELFv2 on a target that defaults to
6+
// ELFv1 changes the data layout:
7+
8+
// CHECK: target datalayout = "E-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512"

0 commit comments

Comments
 (0)