Skip to content

Commit bab13b3

Browse files
authored
merge main into amd-staging (llvm#2891)
2 parents 53e665e + 6f2cec2 commit bab13b3

File tree

96 files changed

+664
-589
lines changed

Some content is hidden

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

96 files changed

+664
-589
lines changed

.github/workflows/libcxx-restart-preempted-jobs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
// the "higher priority" message comes from github canceling a workflow because the user updated the change.
3737
// And the "exit code 1" message indicates a genuine failure.
3838
const failure_regex = /(Process completed with exit code 1.)|(Canceling since a higher priority waiting request)|(The run was canceled by)/
39-
const preemption_regex = /(The runner has received a shutdown signal)|(The operation was canceled)/
39+
const preemption_regex = /(The runner has received a shutdown signal)/
4040
4141
const wf_run = context.payload.workflow_run
4242
core.notice(`Running on "${wf_run.display_title}" by @${wf_run.actor.login} (event: ${wf_run.event})\nWorkflow run URL: ${wf_run.html_url}`)

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3918,15 +3918,40 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
39183918
return Address;
39193919
};
39203920

3921+
// Try to allocate sections before the \p Address and return an address for
3922+
// the allocation of the first section, or 0 if [0, Address) range is not
3923+
// big enough to fit all sections.
3924+
auto allocateBefore = [&](uint64_t Address) -> uint64_t {
3925+
for (BinarySection *Section : llvm::reverse(CodeSections)) {
3926+
if (Section->getOutputSize() > Address)
3927+
return 0;
3928+
Address -= Section->getOutputSize();
3929+
Address = alignDown(Address, Section->getAlignment());
3930+
Section->setOutputAddress(Address);
3931+
}
3932+
return Address;
3933+
};
3934+
39213935
// Check if we can fit code in the original .text
39223936
bool AllocationDone = false;
39233937
if (opts::UseOldText) {
3924-
const uint64_t CodeSize =
3925-
allocateAt(BC->OldTextSectionAddress) - BC->OldTextSectionAddress;
3938+
uint64_t StartAddress;
3939+
uint64_t EndAddress;
3940+
if (opts::HotFunctionsAtEnd) {
3941+
EndAddress = BC->OldTextSectionAddress + BC->OldTextSectionSize;
3942+
StartAddress = allocateBefore(EndAddress);
3943+
} else {
3944+
StartAddress = BC->OldTextSectionAddress;
3945+
EndAddress = allocateAt(BC->OldTextSectionAddress);
3946+
}
39263947

3948+
const uint64_t CodeSize = EndAddress - StartAddress;
39273949
if (CodeSize <= BC->OldTextSectionSize) {
39283950
BC->outs() << "BOLT-INFO: using original .text for new code with 0x"
3929-
<< Twine::utohexstr(opts::AlignText) << " alignment\n";
3951+
<< Twine::utohexstr(opts::AlignText) << " alignment";
3952+
if (StartAddress != BC->OldTextSectionAddress)
3953+
BC->outs() << " at 0x" << Twine::utohexstr(StartAddress);
3954+
BC->outs() << '\n';
39303955
AllocationDone = true;
39313956
} else {
39323957
BC->errs()

bolt/test/code-at-high-address.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Check that llvm-bolt pushes code to higher addresses under
2+
// --hot-functions-at-end when rewriting code in-place.
3+
4+
// REQUIRES: system-linux
5+
6+
// RUN: %clang %cflags -O0 %s -o %t -no-pie -Wl,-q -falign-functions=64 \
7+
// RUN: -nostartfiles -nostdlib -ffreestanding
8+
// RUN: llvm-bolt %t -o %t.bolt --use-old-text --align-functions=1 \
9+
// RUN: --no-huge-pages --align-text=1 --use-gnu-stack --hot-functions-at-end \
10+
// RUN: | FileCheck %s --check-prefix=CHECK-BOLT
11+
// RUN: llvm-readelf --sections %t.bolt | FileCheck %s
12+
13+
// CHECK-BOLT: using original .text for new code with 0x1 alignment at {{.*}}
14+
15+
// As .text is pushed higher, preceding .bolt.org.text should have non-zero
16+
// size.
17+
// CHECK: .bolt.org.text PROGBITS
18+
// CHECK-NOT: {{ 000000 }}
19+
// CHECK-SAME: AX
20+
// CHECK-NEXT: .text PROGBITS
21+
22+
int foo() { return 0; }
23+
24+
int main() { return foo(); }

clang-tools-extra/modularize/Modularize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ struct HeaderEntry {
459459
return !(X == Y);
460460
}
461461
friend bool operator<(const HeaderEntry &X, const HeaderEntry &Y) {
462-
return X.Loc < Y.Loc || (X.Loc == Y.Loc && X.Name < Y.Name);
462+
return std::tie(X.Loc, X.Name) < std::tie(Y.Loc, Y.Name);
463463
}
464464
friend bool operator>(const HeaderEntry &X, const HeaderEntry &Y) {
465465
return Y < X;

clang/lib/Format/BreakableToken.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ getCommentSplit(StringRef Text, unsigned ContentStartColumn,
158158
return BreakableToken::Split(StringRef::npos, 0);
159159
StringRef BeforeCut = Text.substr(0, SpaceOffset).rtrim(Blanks);
160160
StringRef AfterCut = Text.substr(SpaceOffset);
161-
// Don't trim the leading blanks if it would create a */ after the break.
162-
if (!DecorationEndsWithStar || AfterCut.size() <= 1 || AfterCut[1] != '/')
161+
if (!DecorationEndsWithStar)
163162
AfterCut = AfterCut.ltrim(Blanks);
164163
return BreakableToken::Split(BeforeCut.size(),
165164
AfterCut.begin() - BeforeCut.end());

clang/unittests/Format/FormatTestComments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ TEST_F(FormatTestComments, BlockComments) {
24862486
EXPECT_EQ("/*\n"
24872487
"**\n"
24882488
"* aaaaaa\n"
2489-
"*aaaaaa\n"
2489+
"* aaaaaa\n"
24902490
"*/",
24912491
format("/*\n"
24922492
"**\n"

flang/include/flang/Optimizer/Builder/IntrinsicCall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ static inline mlir::FunctionType genFuncType(mlir::MLIRContext *context,
753753
}
754754

755755
if (TyR::ty == ParamTypeId::Void)
756-
return mlir::FunctionType::get(context, argTypes, std::nullopt);
756+
return mlir::FunctionType::get(context, argTypes, {});
757757

758758
auto resType = getTypeHelper(context, builder, TyR::ty, TyR::kind);
759759
return mlir::FunctionType::get(context, argTypes, {resType});

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5150,9 +5150,9 @@ void IntrinsicLibrary::genIeeeGetOrSetModesOrStatus(
51505150
isModes ? fir::runtime::genGetModesTypeSize(builder, loc)
51515151
: fir::runtime::genGetStatusTypeSize(builder, loc);
51525152
byteSize = builder.createConvert(loc, builder.getIndexType(), byteSize);
5153-
addr =
5154-
builder.create<fir::AllocMemOp>(loc, extractSequenceType(heapTy),
5155-
/*typeparams=*/std::nullopt, byteSize);
5153+
addr = builder.create<fir::AllocMemOp>(loc, extractSequenceType(heapTy),
5154+
/*typeparams=*/mlir::ValueRange(),
5155+
byteSize);
51565156
mlir::Value shape = builder.create<fir::ShapeOp>(loc, byteSize);
51575157
builder.create<fir::StoreOp>(
51585158
loc, builder.create<fir::EmboxOp>(loc, fieldTy, addr, shape), fieldRef);

flang/lib/Optimizer/Builder/PPCIntrinsicCall.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,8 +2888,7 @@ void PPCIntrinsicLibrary::genVecStore(llvm::ArrayRef<fir::ExtendedValue> args) {
28882888
llvm_unreachable("invalid vector operation for generator");
28892889
}
28902890

2891-
auto funcType{
2892-
mlir::FunctionType::get(context, {stTy, addr.getType()}, std::nullopt)};
2891+
auto funcType{mlir::FunctionType::get(context, {stTy, addr.getType()}, {})};
28932892
mlir::func::FuncOp funcOp = builder.createFunction(loc, fname, funcType);
28942893

28952894
llvm::SmallVector<mlir::Value, 4> biArgs;

llvm/include/llvm/ADT/SmallPtrSet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class SmallPtrSetImplBase : public DebugEpochBase {
8080
explicit SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
8181
: CurArray(SmallStorage), CurArraySize(SmallSize), NumNonEmpty(0),
8282
NumTombstones(0), IsSmall(true) {
83-
assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
83+
assert(llvm::has_single_bit(SmallSize) &&
8484
"Initial size must be a power of two!");
8585
}
8686

0 commit comments

Comments
 (0)