Skip to content

Commit 9f6d65c

Browse files
committed
Merge branch 'main' into pauth-gnuprop-clang
2 parents b0f9a19 + c4a3d18 commit 9f6d65c

File tree

1,053 files changed

+29154
-10121
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,053 files changed

+29154
-10121
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/llvm/lib/Analysis/ScalarEvolution.cpp @nikic
2424
/llvm/lib/Analysis/ValueTracking.cpp @nikic
2525
/llvm/lib/IR/ConstantRange.cpp @nikic
26+
/llvm/lib/IR/Core.cpp @nikic
2627
/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @nikic
2728
/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @nikic
2829
/llvm/lib/Transforms/InstCombine/ @nikic
@@ -63,8 +64,8 @@ clang/test/AST/Interp/ @tbaederr
6364
/mlir/Dialect/*/Transforms/Bufferize.cpp @matthias-springer
6465

6566
# Linalg Dialect in MLIR.
66-
/mlir/include/mlir/Dialect/Linalg/* @dcaballe @nicolasvasilache
67-
/mlir/lib/Dialect/Linalg/* @dcaballe @nicolasvasilache
67+
/mlir/include/mlir/Dialect/Linalg/* @dcaballe @nicolasvasilache @rengolin
68+
/mlir/lib/Dialect/Linalg/* @dcaballe @nicolasvasilache @rengolin
6869
/mlir/lib/Dialect/Linalg/Transforms/DecomposeLinalgOps.cpp @MaheshRavishankar @nicolasvasilache
6970
/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp @MaheshRavishankar @nicolasvasilache
7071
/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @MaheshRavishankar @nicolasvasilache

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,8 @@ class BinaryFunction {
930930
return const_cast<BinaryFunction *>(this)->getInstructionAtOffset(Offset);
931931
}
932932

933+
std::optional<MCInst> disassembleInstructionAtOffset(uint64_t Offset) const;
934+
933935
/// Return offset for the first instruction. If there is data at the
934936
/// beginning of a function then offset of the first instruction could
935937
/// be different from 0

bolt/include/bolt/Passes/FrameAnalysis.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ class FrameAnalysis {
170170
std::unique_ptr<StackPointerTracking>>
171171
SPTMap;
172172

173-
/// A vector that stores ids of the allocators that are used in SPT
174-
/// computation
175-
std::vector<MCPlusBuilder::AllocatorIdTy> SPTAllocatorsId;
176-
177173
public:
178174
explicit FrameAnalysis(BinaryContext &BC, BinaryFunctionCallGraph &CG);
179175

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,21 @@ void BinaryFunction::handleAArch64IndirectCall(MCInst &Instruction,
11671167
}
11681168
}
11691169

1170+
std::optional<MCInst>
1171+
BinaryFunction::disassembleInstructionAtOffset(uint64_t Offset) const {
1172+
assert(CurrentState == State::Empty && "Function should not be disassembled");
1173+
assert(Offset < MaxSize && "Invalid offset");
1174+
ErrorOr<ArrayRef<unsigned char>> FunctionData = getData();
1175+
assert(FunctionData && "Cannot get function as data");
1176+
MCInst Instr;
1177+
uint64_t InstrSize = 0;
1178+
const uint64_t InstrAddress = getAddress() + Offset;
1179+
if (BC.DisAsm->getInstruction(Instr, InstrSize, FunctionData->slice(Offset),
1180+
InstrAddress, nulls()))
1181+
return Instr;
1182+
return std::nullopt;
1183+
}
1184+
11701185
Error BinaryFunction::disassemble() {
11711186
NamedRegionTimer T("disassemble", "Disassemble function", "buildfuncs",
11721187
"Build Binary Functions", opts::TimeBuild);

bolt/lib/Core/ParallelUtilities.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,7 @@ void runOnEachFunctionWithUniqueAllocId(
231231
}
232232
}
233233

234-
if (!BC.MIB->checkAllocatorExists(AllocId)) {
235-
MCPlusBuilder::AllocatorIdTy Id =
236-
BC.MIB->initializeNewAnnotationAllocator();
237-
(void)Id;
238-
assert(AllocId == Id && "unexpected allocator id created");
239-
}
234+
EnsureAllocatorExists(AllocId);
240235

241236
Pool.async(runBlock, BlockBegin, BC.getBinaryFunctions().end(), AllocId);
242237
Lock.unlock();

bolt/lib/Passes/FrameAnalysis.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,6 @@ FrameAnalysis::FrameAnalysis(BinaryContext &BC, BinaryFunctionCallGraph &CG)
561561
NamedRegionTimer T1("clearspt", "clear spt", "FA", "FA breakdown",
562562
opts::TimeFA);
563563
clearSPTMap();
564-
565-
// Clean up memory allocated for annotation values
566-
if (!opts::NoThreads)
567-
for (MCPlusBuilder::AllocatorIdTy Id : SPTAllocatorsId)
568-
BC.MIB->freeValuesAllocator(Id);
569564
}
570565
}
571566

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,19 @@ bool DataAggregator::doInterBranch(BinaryFunction *FromFunc,
773773

774774
bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
775775
uint64_t Mispreds) {
776+
bool IsReturn = false;
776777
auto handleAddress = [&](uint64_t &Addr, bool IsFrom) -> BinaryFunction * {
777778
if (BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr)) {
778779
Addr -= Func->getAddress();
780+
if (IsFrom) {
781+
auto checkReturn = [&](auto MaybeInst) {
782+
IsReturn = MaybeInst && BC->MIB->isReturn(*MaybeInst);
783+
};
784+
if (Func->hasInstructions())
785+
checkReturn(Func->getInstructionAtOffset(Addr));
786+
else
787+
checkReturn(Func->disassembleInstructionAtOffset(Addr));
788+
}
779789

780790
if (BAT)
781791
Addr = BAT->translate(Func->getAddress(), Addr, IsFrom);
@@ -792,6 +802,9 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
792802
};
793803

794804
BinaryFunction *FromFunc = handleAddress(From, /*IsFrom=*/true);
805+
// Ignore returns.
806+
if (IsReturn)
807+
return true;
795808
BinaryFunction *ToFunc = handleAddress(To, /*IsFrom=*/false);
796809
if (!FromFunc && !ToFunc)
797810
return false;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.globl main
2+
.type main, %function
3+
main:
4+
.cfi_startproc
5+
cmpq $0x3, %rdi
6+
jae .L4
7+
cmpq $0x1, %rdi
8+
jne .L4
9+
mov .Ljt_pic+8(%rip), %rax
10+
lea .Ljt_pic(%rip), %rdx
11+
add %rdx, %rax
12+
jmpq *%rax
13+
.L1:
14+
movq $0x1, %rax
15+
jmp .L5
16+
.L2:
17+
movq $0x0, %rax
18+
jmp .L5
19+
.L3:
20+
movq $0x2, %rax
21+
jmp .L5
22+
.L4:
23+
mov $0x3, %rax
24+
.L5:
25+
retq
26+
.cfi_endproc
27+
28+
.section .rodata
29+
.align 16
30+
.Ljt_pic:
31+
.long .L1 - .Ljt_pic
32+
.long .L2 - .Ljt_pic
33+
.long .L3 - .Ljt_pic
34+
.long .L4 - .Ljt_pic
35+

bolt/test/X86/bolt-address-translation-yaml.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN: llvm-bolt %t.exe -data %t.fdata -w %t.yaml-fdata -o /dev/null
1313
RUN: FileCheck --input-file %t.yaml-fdata --check-prefix YAML-BAT-CHECK %s
1414

1515
# Test resulting YAML profile with the original binary (no-stale mode)
16-
RUN: llvm-bolt %t.exe -data %t.yaml -o %t.null -dyno-stats \
16+
RUN: llvm-bolt %t.exe -data %t.yaml -o %t.null -dyno-stats 2>&1 \
1717
RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s
1818

1919
WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps
@@ -63,7 +63,8 @@ YAML-BAT-CHECK-NEXT: blocks:
6363
YAML-BAT-CHECK: - bid: 1
6464
YAML-BAT-CHECK-NEXT: insns: [[#]]
6565
YAML-BAT-CHECK-NEXT: hash: 0xD70DC695320E0010
66-
YAML-BAT-CHECK-NEXT: succ: {{.*}} { bid: 2, cnt: [[#]] }
66+
YAML-BAT-CHECK-NEXT: succ: {{.*}} { bid: 2, cnt: [[#]]
6767

6868
CHECK-BOLT-YAML: pre-processing profile using YAML profile reader
6969
CHECK-BOLT-YAML-NEXT: 5 out of 16 functions in the binary (31.2%) have non-empty execution profile
70+
CHECK-BOLT-YAML-NOT: invalid (possibly stale) profile
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Verify that BOLT detects fixed destination of indirect jump for PIC
2+
# case.
3+
4+
XFAIL: *
5+
6+
RUN: %clang %cflags -no-pie %S/Inputs/jump-table-fixed-ref-pic.s -Wl,-q -o %t
7+
RUN: llvm-bolt %t --relocs -o %t.null 2>&1 | FileCheck %s
8+
9+
CHECK: BOLT-INFO: fixed indirect branch detected in main

bolt/test/runtime/bolt-reserved.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// REQUIRES: system-linux
2+
3+
/*
4+
* Check that llvm-bolt uses reserved space in a binary for allocating
5+
* new sections.
6+
*/
7+
8+
// RUN: %clang %s -o %t.exe -Wl,-q
9+
// RUN: llvm-bolt %t.exe -o %t.bolt.exe 2>&1 | FileCheck %s
10+
// RUN: %t.bolt.exe
11+
12+
// CHECK: BOLT-INFO: using reserved space
13+
14+
/*
15+
* Check that llvm-bolt detects a condition when the reserved space is
16+
* not enough for allocating new sections.
17+
*/
18+
19+
// RUN: %clang %s -o %t.exe -Wl,--no-eh-frame-hdr -Wl,-q -DTINY
20+
// RUN: not llvm-bolt %t.exe -o %t.bolt.exe 2>&1 | \
21+
// RUN: FileCheck %s --check-prefix=CHECK-TINY
22+
23+
// CHECK-TINY: BOLT-ERROR: reserved space (1 byte) is smaller than required
24+
25+
#ifdef TINY
26+
#define RSIZE "1"
27+
#else
28+
#define RSIZE "8192 * 1024"
29+
#endif
30+
31+
asm(".pushsection .text \n\
32+
.globl __bolt_reserved_start \n\
33+
.type __bolt_reserved_start, @object \n\
34+
__bolt_reserved_start: \n\
35+
.space " RSIZE " \n\
36+
.globl __bolt_reserved_end \n\
37+
__bolt_reserved_end: \n\
38+
.popsection");
39+
40+
int main() { return 0; }

clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() {
1515
static const HeaderMapCollector::RegexHeaderMap STLPostfixHeaderMap = {
1616
{"include/__stdarg___gnuc_va_list.h$", "<cstdarg>"},
1717
{"include/__stdarg___va_copy.h$", "<cstdarg>"},
18+
{"include/__stdarg_header_macro.h$", "<cstdarg>"},
1819
{"include/__stdarg_va_arg.h$", "<cstdarg>"},
1920
{"include/__stdarg_va_copy.h$", "<cstdarg>"},
2021
{"include/__stdarg_va_list.h$", "<cstdarg>"},
22+
{"include/__stddef_header_macro.h$", "<cstddef>"},
2123
{"include/__stddef_max_align_t.h$", "<cstddef>"},
2224
{"include/__stddef_null.h$", "<cstddef>"},
2325
{"include/__stddef_nullptr_t.h$", "<cstddef>"},

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,11 @@ std::optional<RenamerClangTidyCheck::FailureInfo>
178178
ReservedIdentifierCheck::getDeclFailureInfo(const NamedDecl *Decl,
179179
const SourceManager &) const {
180180
assert(Decl && Decl->getIdentifier() && !Decl->getName().empty() &&
181-
!Decl->isImplicit() &&
182181
"Decl must be an explicit identifier with a name.");
182+
// Implicit identifiers cannot fail.
183+
if (Decl->isImplicit())
184+
return std::nullopt;
185+
183186
return getFailureInfoImpl(
184187
Decl->getName(), isa<TranslationUnitDecl>(Decl->getDeclContext()),
185188
/*IsMacro = */ false, getLangOpts(), Invert, AllowedIdentifiers);

clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "SignedBitwiseCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include "clang/ASTMatchers/ASTMatchers.h"
1213

1314
using namespace clang::ast_matchers;
1415
using namespace clang::ast_matchers::internal;
@@ -29,8 +30,8 @@ void SignedBitwiseCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
2930
void SignedBitwiseCheck::registerMatchers(MatchFinder *Finder) {
3031
const auto SignedIntegerOperand =
3132
(IgnorePositiveIntegerLiterals
32-
? expr(ignoringImpCasts(hasType(isSignedInteger())),
33-
unless(integerLiteral()))
33+
? expr(ignoringImpCasts(
34+
allOf(hasType(isSignedInteger()), unless(integerLiteral()))))
3435
: expr(ignoringImpCasts(hasType(isSignedInteger()))))
3536
.bind("signed-operand");
3637

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,10 @@ IdentifierNamingCheck::getFailureInfo(
13741374
std::optional<RenamerClangTidyCheck::FailureInfo>
13751375
IdentifierNamingCheck::getDeclFailureInfo(const NamedDecl *Decl,
13761376
const SourceManager &SM) const {
1377+
// Implicit identifiers cannot be renamed.
1378+
if (Decl->isImplicit())
1379+
return std::nullopt;
1380+
13771381
SourceLocation Loc = Decl->getLocation();
13781382
const FileStyle &FileStyle = getStyleForFile(SM.getFilename(Loc));
13791383
if (!FileStyle.isActive())

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

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ void StaticAccessedThroughInstanceCheck::check(
5959

6060
const Expr *BaseExpr = MemberExpression->getBase();
6161

62-
// Do not warn for overloaded -> operators.
63-
if (isa<CXXOperatorCallExpr>(BaseExpr))
64-
return;
65-
6662
const QualType BaseType =
6763
BaseExpr->getType()->isPointerType()
6864
? BaseExpr->getType()->getPointeeType().getUnqualifiedType()
@@ -89,17 +85,30 @@ void StaticAccessedThroughInstanceCheck::check(
8985
return;
9086

9187
SourceLocation MemberExprStartLoc = MemberExpression->getBeginLoc();
92-
auto Diag =
93-
diag(MemberExprStartLoc, "static member accessed through instance");
94-
95-
if (BaseExpr->HasSideEffects(*AstContext) ||
96-
getNameSpecifierNestingLevel(BaseType) > NameSpecifierNestingThreshold)
97-
return;
88+
auto CreateFix = [&] {
89+
return FixItHint::CreateReplacement(
90+
CharSourceRange::getCharRange(MemberExprStartLoc,
91+
MemberExpression->getMemberLoc()),
92+
BaseTypeName + "::");
93+
};
94+
95+
{
96+
auto Diag =
97+
diag(MemberExprStartLoc, "static member accessed through instance");
98+
99+
if (getNameSpecifierNestingLevel(BaseType) > NameSpecifierNestingThreshold)
100+
return;
101+
102+
if (!BaseExpr->HasSideEffects(*AstContext,
103+
/* IncludePossibleEffects =*/true)) {
104+
Diag << CreateFix();
105+
return;
106+
}
107+
}
98108

99-
Diag << FixItHint::CreateReplacement(
100-
CharSourceRange::getCharRange(MemberExprStartLoc,
101-
MemberExpression->getMemberLoc()),
102-
BaseTypeName + "::");
109+
diag(MemberExprStartLoc, "member base expression may carry some side effects",
110+
DiagnosticIDs::Level::Note)
111+
<< BaseExpr->getSourceRange() << CreateFix();
103112
}
104113

105114
} // namespace clang::tidy::readability

0 commit comments

Comments
 (0)