Skip to content

Commit b38dd5e

Browse files
authored
Merge branch 'main' into wcscat-implmentation
2 parents 611ea63 + 46adbff commit b38dd5e

File tree

240 files changed

+4072
-3726
lines changed

Some content is hidden

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

240 files changed

+4072
-3726
lines changed

.github/workflows/containers/github-action-ci-windows/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RUN powershell -Command \
8585
RUN git config --system core.longpaths true & \
8686
git config --global core.autocrlf false
8787
88-
ARG RUNNER_VERSION=2.324.0
88+
ARG RUNNER_VERSION=2.325.0
8989
ENV RUNNER_VERSION=$RUNNER_VERSION
9090
9191
RUN powershell -Command \

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ WORKDIR /home/gha
8686

8787
FROM ci-container as ci-container-agent
8888

89-
ENV GITHUB_RUNNER_VERSION=2.324.0
89+
ENV GITHUB_RUNNER_VERSION=2.325.0
9090

9191
RUN mkdir actions-runner && \
9292
cd actions-runner && \

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,7 @@ class BinaryFunction {
23482348
releaseCFG();
23492349
CurrentState = State::Emitted;
23502350
}
2351+
clearList(Relocations);
23512352
}
23522353

23532354
/// Process LSDA information for the function.

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,10 +1032,8 @@ void BinaryContext::adjustCodePadding() {
10321032

10331033
if (!hasValidCodePadding(BF)) {
10341034
if (HasRelocations) {
1035-
if (opts::Verbosity >= 1) {
1036-
this->outs() << "BOLT-INFO: function " << BF
1037-
<< " has invalid padding. Ignoring the function.\n";
1038-
}
1035+
this->errs() << "BOLT-WARNING: function " << BF
1036+
<< " has invalid padding. Ignoring the function\n";
10391037
BF.setIgnored();
10401038
} else {
10411039
BF.setMaxSize(BF.getSize());

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,6 @@ Error BinaryFunction::disassemble() {
15261526
if (uint64_t Offset = getFirstInstructionOffset())
15271527
Labels[Offset] = BC.Ctx->createNamedTempSymbol();
15281528

1529-
clearList(Relocations);
1530-
15311529
if (!IsSimple) {
15321530
clearList(Instructions);
15331531
return createNonFatalBOLTError("");
@@ -3244,16 +3242,26 @@ void BinaryFunction::setTrapOnEntry() {
32443242
}
32453243

32463244
void BinaryFunction::setIgnored() {
3245+
IsIgnored = true;
3246+
32473247
if (opts::processAllFunctions()) {
32483248
// We can accept ignored functions before they've been disassembled.
3249-
// In that case, they would still get disassembled and emited, but not
3249+
// In that case, they would still get disassembled and emitted, but not
32503250
// optimized.
3251-
assert(CurrentState == State::Empty &&
3252-
"cannot ignore non-empty functions in current mode");
3253-
IsIgnored = true;
3251+
if (CurrentState != State::Empty) {
3252+
BC.errs() << "BOLT-ERROR: cannot ignore non-empty function " << *this
3253+
<< " in current mode\n";
3254+
exit(1);
3255+
}
32543256
return;
32553257
}
32563258

3259+
IsSimple = false;
3260+
LLVM_DEBUG(dbgs() << "Ignoring " << getPrintName() << '\n');
3261+
3262+
if (CurrentState == State::Empty)
3263+
return;
3264+
32573265
clearDisasmState();
32583266

32593267
// Clear CFG state too.
@@ -3273,9 +3281,11 @@ void BinaryFunction::setIgnored() {
32733281

32743282
CurrentState = State::Empty;
32753283

3276-
IsIgnored = true;
3277-
IsSimple = false;
3278-
LLVM_DEBUG(dbgs() << "Ignoring " << getPrintName() << '\n');
3284+
// Fix external references in the original function body.
3285+
if (BC.HasRelocations) {
3286+
LLVM_DEBUG(dbgs() << "Scanning refs in " << *this << '\n');
3287+
scanExternalRefs();
3288+
}
32793289
}
32803290

32813291
void BinaryFunction::duplicateConstantIslands() {
@@ -3764,7 +3774,6 @@ void BinaryFunction::postProcessBranches() {
37643774

37653775
MCSymbol *BinaryFunction::addEntryPointAtOffset(uint64_t Offset) {
37663776
assert(Offset && "cannot add primary entry point");
3767-
assert(CurrentState == State::Empty || CurrentState == State::Disassembled);
37683777

37693778
const uint64_t EntryPointAddress = getAddress() + Offset;
37703779
MCSymbol *LocalSymbol = getOrCreateLocalLabel(EntryPointAddress);
@@ -3773,6 +3782,8 @@ MCSymbol *BinaryFunction::addEntryPointAtOffset(uint64_t Offset) {
37733782
if (EntrySymbol)
37743783
return EntrySymbol;
37753784

3785+
assert(CurrentState == State::Empty || CurrentState == State::Disassembled);
3786+
37763787
if (BinaryData *EntryBD = BC.getBinaryDataAtAddress(EntryPointAddress)) {
37773788
EntrySymbol = EntryBD->getSymbol();
37783789
} else {

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,6 +3446,7 @@ void RewriteInstance::disassembleFunctions() {
34463446
BC->outs() << "BOLT-INFO: could not disassemble function " << Function
34473447
<< ". Will ignore.\n";
34483448
// Forcefully ignore the function.
3449+
Function.scanExternalRefs();
34493450
Function.setIgnored();
34503451
});
34513452

bolt/test/AArch64/patch-ignored.s

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Check that llvm-bolt patches functions that are getting ignored after their
2+
## CFG was constructed.
3+
4+
# RUN: %clang %cflags %s -o %t.exe -Wl,-q
5+
# RUN: llvm-bolt %t.exe -o %t.bolt --force-patch 2>&1 | FileCheck %s
6+
# RUN: llvm-objdump -d %t.bolt | FileCheck %s --check-prefix=CHECK-OBJDUMP
7+
8+
.text
9+
10+
## The function is too small to be patched and BOLT is forced to ignore it under
11+
## --force-patch. Check that the reference to _start is updated.
12+
# CHECK: BOLT-WARNING: failed to patch entries in unpatchable
13+
.globl unpatchable
14+
.type unpatchable, %function
15+
unpatchable:
16+
.cfi_startproc
17+
# CHECK-OBJDUMP: <unpatchable>:
18+
# CHECK-OBJDUMP-NEXT: bl {{.*}} <_start>
19+
bl _start
20+
ret
21+
.cfi_endproc
22+
.size unpatchable, .-unpatchable
23+
24+
.globl _start
25+
.type _start, %function
26+
_start:
27+
.cfi_startproc
28+
cmp x0, 1
29+
b.eq .L0
30+
.L0:
31+
ret x30
32+
.cfi_endproc
33+
.size _start, .-_start

bolt/test/X86/patch-ignored.s

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Check that llvm-bolt patches functions that are getting ignored after their
2+
## CFG was constructed.
3+
4+
# RUN: %clang %cflags %s -o %t.exe -Wl,-q
5+
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
6+
# RUN: llvm-objdump -d %t.bolt | FileCheck %s --check-prefix=CHECK-OBJDUMP
7+
8+
.text
9+
10+
## After the CFG is built, the following function will be marked as ignored
11+
## due to the presence of the internal call.
12+
# CHECK: BOLT-WARNING: will skip the following function
13+
# CHECK-NEXT: internal_call
14+
.globl internal_call
15+
.type internal_call, %function
16+
internal_call:
17+
.cfi_startproc
18+
# CHECK-OBJDUMP: <internal_call>:
19+
call .L1
20+
jmp .L2
21+
# CHECK-OBJDUMP: jmp
22+
.L1:
23+
jmp _start
24+
# CHECK-OBJDUMP: jmp
25+
# CHECK-OBJDUMP-SAME: <_start>
26+
ret
27+
.L2:
28+
jmp _start
29+
# CHECK-OBJDUMP: jmp
30+
# CHECK-OBJDUMP-SAME: <_start>
31+
.cfi_endproc
32+
.size internal_call, .-internal_call
33+
34+
.globl _start
35+
.type _start, %function
36+
_start:
37+
.cfi_startproc
38+
cmpq %rdi, 1
39+
jne .L0
40+
movq %rdi, %rax
41+
.L0:
42+
ret
43+
.cfi_endproc
44+
.size _start, .-_start

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,9 +1464,13 @@ def ShiftOp : CIR_Op<"shift", [Pure]> {
14641464
```
14651465
}];
14661466

1467-
let results = (outs CIR_AnyIntOrVecOfInt:$result);
1468-
let arguments = (ins CIR_AnyIntOrVecOfInt:$value, CIR_AnyIntOrVecOfInt:$amount,
1469-
UnitAttr:$isShiftleft);
1467+
let arguments = (ins
1468+
CIR_AnyIntOrVecOfIntType:$value,
1469+
CIR_AnyIntOrVecOfIntType:$amount,
1470+
UnitAttr:$isShiftleft
1471+
);
1472+
1473+
let results = (outs CIR_AnyIntOrVecOfIntType:$result);
14701474

14711475
let assemblyFormat = [{
14721476
`(`
@@ -2050,7 +2054,7 @@ def VecCreateOp : CIR_Op<"vec.create", [Pure]> {
20502054
in the vector type.
20512055
}];
20522056

2053-
let arguments = (ins Variadic<CIR_AnyType>:$elements);
2057+
let arguments = (ins Variadic<CIR_VectorElementType>:$elements);
20542058
let results = (outs CIR_VectorType:$result);
20552059

20562060
let assemblyFormat = [{
@@ -2085,7 +2089,7 @@ def VecInsertOp : CIR_Op<"vec.insert", [Pure,
20852089

20862090
let arguments = (ins
20872091
CIR_VectorType:$vec,
2088-
AnyType:$value,
2092+
CIR_VectorElementType:$value,
20892093
CIR_AnyFundamentalIntType:$index
20902094
);
20912095

@@ -2118,7 +2122,7 @@ def VecExtractOp : CIR_Op<"vec.extract", [Pure,
21182122
}];
21192123

21202124
let arguments = (ins CIR_VectorType:$vec, CIR_AnyFundamentalIntType:$index);
2121-
let results = (outs CIR_AnyType:$result);
2125+
let results = (outs CIR_VectorElementType:$result);
21222126

21232127
let assemblyFormat = [{
21242128
$vec `[` $index `:` type($index) `]` attr-dict `:` qualified(type($vec))
@@ -2180,7 +2184,7 @@ def VecShuffleDynamicOp : CIR_Op<"vec.shuffle.dynamic",
21802184
```
21812185
}];
21822186

2183-
let arguments = (ins CIR_VectorType:$vec, IntegerVector:$indices);
2187+
let arguments = (ins CIR_VectorType:$vec, CIR_VectorOfIntType:$indices);
21842188
let results = (outs CIR_VectorType:$result);
21852189
let assemblyFormat = [{
21862190
$vec `:` qualified(type($vec)) `,` $indices `:` qualified(type($indices))

clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ class CIR_ConfinedType<Type type, list<Pred> preds, string summary = "">
3131
: Type<And<[type.predicate, CIR_CastedSelfsToType<type.cppType, preds>]>,
3232
summary, type.cppType>;
3333

34+
// Generates a type summary.
35+
// - For a single type: returns its summary.
36+
// - For multiple types: returns `any of <comma-separated summaries>`.
37+
class CIR_TypeSummaries<list<Type> types> {
38+
assert !not(!empty(types)), "expects non-empty list of types";
39+
40+
list<string> summaries = !foreach(type, types, type.summary);
41+
string joined = !interleave(summaries, ", ");
42+
43+
string value = !if(!eq(!size(types), 1), joined, "any of " # joined);
44+
}
45+
3446
//===----------------------------------------------------------------------===//
3547
// Bool Type predicates
3648
//===----------------------------------------------------------------------===//
@@ -184,6 +196,24 @@ def CIR_PtrToVoidPtrType
184196
// Vector Type predicates
185197
//===----------------------------------------------------------------------===//
186198

199+
def CIR_AnyVectorType : CIR_TypeBase<"::cir::VectorType", "vector type">;
200+
201+
def CIR_VectorElementType : AnyTypeOf<[CIR_AnyIntOrFloatType, CIR_AnyPtrType],
202+
"any cir integer, floating point or pointer type"
203+
> {
204+
let cppFunctionName = "isValidVectorTypeElementType";
205+
}
206+
207+
class CIR_ElementTypePred<Pred pred> : SubstLeaves<"$_self",
208+
"::mlir::cast<::cir::VectorType>($_self).getElementType()", pred>;
209+
210+
class CIR_VectorTypeOf<list<Type> types, string summary = "">
211+
: CIR_ConfinedType<CIR_AnyVectorType,
212+
[Or<!foreach(type, types, CIR_ElementTypePred<type.predicate>)>],
213+
!if(!empty(summary),
214+
"vector of " # CIR_TypeSummaries<types>.value,
215+
summary)>;
216+
187217
// Vector of integral type
188218
def IntegerVector : Type<
189219
And<[
@@ -196,8 +226,36 @@ def IntegerVector : Type<
196226
]>, "!cir.vector of !cir.int"> {
197227
}
198228

199-
// Any Integer or Vector of Integer Constraints
200-
def CIR_AnyIntOrVecOfInt: AnyTypeOf<[CIR_AnyIntType, IntegerVector]>;
229+
// Vector of type constraints
230+
def CIR_VectorOfIntType : CIR_VectorTypeOf<[CIR_AnyIntType]>;
231+
def CIR_VectorOfUIntType : CIR_VectorTypeOf<[CIR_AnyUIntType]>;
232+
def CIR_VectorOfSIntType : CIR_VectorTypeOf<[CIR_AnySIntType]>;
233+
def CIR_VectorOfFloatType : CIR_VectorTypeOf<[CIR_AnyFloatType]>;
234+
235+
// Vector or Scalar type constraints
236+
def CIR_AnyIntOrVecOfIntType
237+
: AnyTypeOf<[CIR_AnyIntType, CIR_VectorOfIntType],
238+
"integer or vector of integer type"> {
239+
let cppFunctionName = "isIntOrVectorOfIntType";
240+
}
241+
242+
def CIR_AnySIntOrVecOfSIntType
243+
: AnyTypeOf<[CIR_AnySIntType, CIR_VectorOfSIntType],
244+
"signed integer or vector of signed integer type"> {
245+
let cppFunctionName = "isSIntOrVectorOfSIntType";
246+
}
247+
248+
def CIR_AnyUIntOrVecOfUIntType
249+
: AnyTypeOf<[CIR_AnyUIntType, CIR_VectorOfUIntType],
250+
"unsigned integer or vector of unsigned integer type"> {
251+
let cppFunctionName = "isUIntOrVectorOfUIntType";
252+
}
253+
254+
def CIR_AnyFloatOrVecOfFloatType
255+
: AnyTypeOf<[CIR_AnyFloatType, CIR_VectorOfFloatType],
256+
"floating point or vector of floating point type"> {
257+
let cppFunctionName = "isFPOrVectorOfFPType";
258+
}
201259

202260
//===----------------------------------------------------------------------===//
203261
// Scalar Type predicates

0 commit comments

Comments
 (0)