Skip to content

Commit e6419b4

Browse files
committed
merge main into amd-staging
2 parents 26c8c65 + f78d6ca commit e6419b4

File tree

140 files changed

+7151
-1552
lines changed

Some content is hidden

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

140 files changed

+7151
-1552
lines changed

.github/workflows/build-ci-container-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
jobs:
2121
build-ci-container-windows:
2222
if: github.repository_owner == 'llvm'
23-
runs-on: windows-2019
23+
runs-on: windows-2022
2424
outputs:
2525
container-name: ${{ steps.vars.outputs.container-name }}
2626
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
@@ -34,7 +34,7 @@ jobs:
3434
id: vars
3535
run: |
3636
$tag = [int64](Get-Date -UFormat %s)
37-
$container_name="ghcr.io/$env:GITHUB_REPOSITORY_OWNER/ci-windows-2019"
37+
$container_name="ghcr.io/$env:GITHUB_REPOSITORY_OWNER/ci-windows-2022"
3838
echo "container-name=${container_name}" >> $env:GITHUB_OUTPUT
3939
echo "container-name-tag=${container_name}:${tag}" >> $env:GITHUB_OUTPUT
4040
echo "container-filename=ci-windows-${tag}.tar" >> $env:GITHUB_OUTPUT
@@ -58,7 +58,7 @@ jobs:
5858
- build-ci-container-windows
5959
permissions:
6060
packages: write
61-
runs-on: windows-2019
61+
runs-on: windows-2022
6262
env:
6363
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6464
steps:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Agent image for LLVM org cluster.
22
# .net 4.8 is required by chocolately package manager.
3-
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
3+
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022
44

55
# Restore the default Windows shell for correct batch processing.
66
SHELL ["cmd", "/S", "/C"]

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ related warnings within the method body.
475475
- Clang now disallows the use of attributes applied before an
476476
``extern template`` declaration (#GH79893).
477477

478+
- Clang will print the "reason" string argument passed on to
479+
``[[clang::warn_unused_result("reason")]]`` as part of the warning diagnostic.
480+
478481
Improvements to Clang's diagnostics
479482
-----------------------------------
480483

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

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ class CIR_BitOpBase<string mnemonic, TypeConstraint operandTy>
27052705
let results = (outs operandTy:$result);
27062706

27072707
let assemblyFormat = [{
2708-
`(` $input `:` type($input) `)` `:` type($result) attr-dict
2708+
$input `:` type($result) attr-dict
27092709
}];
27102710
}
27112711

@@ -2714,20 +2714,20 @@ class CIR_BitZeroCountOpBase<string mnemonic, TypeConstraint operandTy>
27142714
let arguments = (ins operandTy:$input, UnitAttr:$poison_zero);
27152715

27162716
let assemblyFormat = [{
2717-
`(` $input `:` type($input) `)` (`poison_zero` $poison_zero^)?
2717+
$input (`poison_zero` $poison_zero^)?
27182718
`:` type($result) attr-dict
27192719
}];
27202720
}
27212721

2722-
def BitClrsbOp : CIR_BitOpBase<"bit.clrsb", CIR_SIntOfWidths<[32, 64]>> {
2722+
def BitClrsbOp : CIR_BitOpBase<"clrsb", CIR_SIntOfWidths<[32, 64]>> {
27232723
let summary = "Get the number of leading redundant sign bits in the input";
27242724
let description = [{
27252725
Compute the number of leading redundant sign bits in the input integer.
27262726

27272727
The input integer must be a signed integer. The most significant bit of the
2728-
input integer is the sign bit. The `cir.bit.clrsb` operation returns the
2729-
number of consecutive bits following the sign bit that are identical to the
2730-
sign bit.
2728+
input integer is the sign bit. The `cir.clrsb` operation returns the number
2729+
of consecutive bits following the sign bit that are identical to the sign
2730+
bit.
27312731

27322732
The bit width of the input integer must be either 32 or 64.
27332733

@@ -2738,24 +2738,23 @@ def BitClrsbOp : CIR_BitOpBase<"bit.clrsb", CIR_SIntOfWidths<[32, 64]>> {
27382738
%0 = cir.const #cir.int<3735928559> : !s32i
27392739
// %1 will be 1 because there is 1 bit following the most significant bit
27402740
// that is identical to it.
2741-
%1 = cir.bit.clrsb(%0 : !s32i) : !s32i
2741+
%1 = cir.clrsb %0 : !s32i
27422742

27432743
// %2 = 1, 0b0000_0000_0000_0000_0000_0000_0000_0001
27442744
%2 = cir.const #cir.int<1> : !s32i
27452745
// %3 will be 30 because there are 30 consecutive bits following the sign
27462746
// bit that are identical to the sign bit.
2747-
%3 = cir.bit.clrsb(%2 : !s32i) : !s32i
2747+
%3 = cir.clrsb %2 : !s32i
27482748
```
27492749
}];
27502750
}
27512751

2752-
def BitClzOp : CIR_BitZeroCountOpBase<"bit.clz",
2753-
CIR_UIntOfWidths<[16, 32, 64]>> {
2752+
def BitClzOp : CIR_BitZeroCountOpBase<"clz", CIR_UIntOfWidths<[16, 32, 64]>> {
27542753
let summary = "Get the number of leading 0-bits in the input";
27552754
let description = [{
27562755
Compute the number of leading 0-bits in the input.
27572756

2758-
The input integer must be an unsigned integer. The `cir.bit.clz` operation
2757+
The input integer must be an unsigned integer. The `cir.clz` operation
27592758
returns the number of consecutive 0-bits at the most significant bit
27602759
position in the input.
27612760

@@ -2768,18 +2767,17 @@ def BitClzOp : CIR_BitZeroCountOpBase<"bit.clz",
27682767
// %0 = 0b0000_0000_0000_0000_0000_0000_0000_1000
27692768
%0 = cir.const #cir.int<8> : !u32i
27702769
// %1 will be 28
2771-
%1 = cir.bit.clz(%0 : !u32i) poison_zero : !u32i
2770+
%1 = cir.clz %0 poison_zero : !u32i
27722771
```
27732772
}];
27742773
}
27752774

2776-
def BitCtzOp : CIR_BitZeroCountOpBase<"bit.ctz",
2777-
CIR_UIntOfWidths<[16, 32, 64]>> {
2775+
def BitCtzOp : CIR_BitZeroCountOpBase<"ctz", CIR_UIntOfWidths<[16, 32, 64]>> {
27782776
let summary = "Get the number of trailing 0-bits in the input";
27792777
let description = [{
27802778
Compute the number of trailing 0-bits in the input.
27812779

2782-
The input integer must be an unsigned integer. The `cir.bit.ctz` operation
2780+
The input integer must be an unsigned integer. The `cir.ctz` operation
27832781
counts the number of consecutive 0-bits starting from the least significant
27842782
bit.
27852783

@@ -2792,12 +2790,12 @@ def BitCtzOp : CIR_BitZeroCountOpBase<"bit.ctz",
27922790
// %0 = 0b1000
27932791
%0 = cir.const #cir.int<8> : !u32i
27942792
// %1 will be 3
2795-
%1 = cir.bit.ctz(%0 : !u32i) poison_zero : !u32i
2793+
%1 = cir.ctz %0 poison_zero : !u32i
27962794
```
27972795
}];
27982796
}
27992797

2800-
def BitParityOp : CIR_BitOpBase<"bit.parity", CIR_UIntOfWidths<[32, 64]>> {
2798+
def BitParityOp : CIR_BitOpBase<"parity", CIR_UIntOfWidths<[32, 64]>> {
28012799
let summary = "Get the parity of input";
28022800
let description = [{
28032801
Compute the parity of the input. The parity of an integer is the number of
@@ -2811,13 +2809,12 @@ def BitParityOp : CIR_BitOpBase<"bit.parity", CIR_UIntOfWidths<[32, 64]>> {
28112809
// %0 = 0x0110_1000
28122810
%0 = cir.const #cir.int<104> : !u32i
28132811
// %1 will be 1 since there are three 1-bits in %0
2814-
%1 = cir.bit.parity(%0 : !u32i) : !u32i
2812+
%1 = cir.parity %0 : !u32i
28152813
```
28162814
}];
28172815
}
28182816

2819-
def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
2820-
CIR_UIntOfWidths<[16, 32, 64]>> {
2817+
def BitPopcountOp : CIR_BitOpBase<"popcount", CIR_UIntOfWidths<[16, 32, 64]>> {
28212818
let summary = "Get the number of 1-bits in input";
28222819
let description = [{
28232820
Compute the number of 1-bits in the input.
@@ -2830,25 +2827,22 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
28302827
// %0 = 0x0110_1000
28312828
%0 = cir.const #cir.int<104> : !u32i
28322829
// %1 will be 3 since there are 3 1-bits in %0
2833-
%1 = cir.bit.popcnt(%0 : !u32i) : !u32i
2830+
%1 = cir.popcount %0 : !u32i
28342831
```
28352832
}];
28362833
}
28372834

2838-
def BitReverseOp : CIR_BitOpBase<"bit.reverse",
2835+
def BitReverseOp : CIR_BitOpBase<"bitreverse",
28392836
CIR_UIntOfWidths<[8, 16, 32, 64]>> {
28402837
let summary = "Reverse the bit pattern of the operand integer";
28412838
let description = [{
2842-
The `cir.bit.reverse` operation reverses the bits of the operand integer.
2843-
Its only argument must be of unsigned integer types of width 8, 16, 32, or
2844-
64.
2845-
2846-
This operation covers the C/C++ builtin function `__builtin_bitreverse`.
2839+
The `cir.bitreverse` operation reverses the bits of the operand integer. Its
2840+
only argument must be of unsigned integer types of width 8, 16, 32, or 64.
28472841

28482842
Example:
28492843

28502844
```mlir
2851-
%1 = cir.bit.reverse(%0 : !u32i): !u32i
2845+
%1 = cir.bitreverse %0: !u32i
28522846
```
28532847
}];
28542848
}
@@ -2869,7 +2863,7 @@ def ByteSwapOp : CIR_BitOpBase<"byte_swap", CIR_UIntOfWidths<[16, 32, 64]>> {
28692863
%0 = cir.const #cir.int<305419896> : !u32i
28702864

28712865
// %1 should be 0x78563412
2872-
%1 = cir.byte_swap(%0 : !u32i) : !u32i
2866+
%1 = cir.byte_swap %0 : !u32i
28732867
```
28742868
}];
28752869
}

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ struct MissingFeatures {
250250
static bool typeChecks() { return false; }
251251
static bool weakRefReference() { return false; }
252252
static bool writebacks() { return false; }
253+
static bool appleKext() { return false; }
254+
static bool dtorCleanups() { return false; }
255+
static bool completeDtors() { return false; }
256+
static bool vtableInitialization() { return false; }
253257

254258
// Missing types
255259
static bool dataMemberType() { return false; }

clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
4141
assert(!cir::MissingFeatures::cxxabiThisAlignment());
4242
}
4343

44+
cir::GlobalLinkageKind CIRGenCXXABI::getCXXDestructorLinkage(
45+
GVALinkage linkage, const CXXDestructorDecl *dtor, CXXDtorType dt) const {
46+
// Delegate back to cgm by default.
47+
return cgm.getCIRLinkageForDeclarator(dtor, linkage,
48+
/*isConstantVariable=*/false);
49+
}
50+
4451
mlir::Value CIRGenCXXABI::loadIncomingCXXThis(CIRGenFunction &cgf) {
4552
ImplicitParamDecl *vd = getThisDecl(cgf);
4653
Address addr = cgf.getAddrOfLocalVar(vd);

clang/lib/CIR/CodeGen/CIRGenCXXABI.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ class CIRGenCXXABI {
7272
/// Emit constructor variants required by this ABI.
7373
virtual void emitCXXConstructors(const clang::CXXConstructorDecl *d) = 0;
7474

75+
/// Emit dtor variants required by this ABI.
76+
virtual void emitCXXDestructors(const clang::CXXDestructorDecl *d) = 0;
77+
78+
/// Returns true if the given destructor type should be emitted as a linkonce
79+
/// delegating thunk, regardless of whether the dtor is defined in this TU or
80+
/// not.
81+
virtual bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
82+
CXXDtorType dt) const = 0;
83+
84+
virtual cir::GlobalLinkageKind
85+
getCXXDestructorLinkage(GVALinkage linkage, const CXXDestructorDecl *dtor,
86+
CXXDtorType dt) const;
87+
7588
/// Returns true if the given constructor or destructor is one of the kinds
7689
/// that the ABI says returns 'this' (only applies when called non-virtually
7790
/// for destructors).

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn,
463463
startFunction(gd, retTy, fn, funcType, args, loc, bodyRange.getBegin());
464464

465465
if (isa<CXXDestructorDecl>(funcDecl)) {
466-
getCIRGenModule().errorNYI(bodyRange, "C++ destructor definition");
466+
emitDestructorBody(args);
467467
} else if (isa<CXXConstructorDecl>(funcDecl)) {
468468
emitConstructorBody(args);
469469
} else if (getLangOpts().CUDA && !getLangOpts().CUDAIsDevice &&
@@ -540,6 +540,96 @@ void CIRGenFunction::emitConstructorBody(FunctionArgList &args) {
540540
}
541541
}
542542

543+
/// Emits the body of the current destructor.
544+
void CIRGenFunction::emitDestructorBody(FunctionArgList &args) {
545+
const CXXDestructorDecl *dtor = cast<CXXDestructorDecl>(curGD.getDecl());
546+
CXXDtorType dtorType = curGD.getDtorType();
547+
548+
// For an abstract class, non-base destructors are never used (and can't
549+
// be emitted in general, because vbase dtors may not have been validated
550+
// by Sema), but the Itanium ABI doesn't make them optional and Clang may
551+
// in fact emit references to them from other compilations, so emit them
552+
// as functions containing a trap instruction.
553+
if (dtorType != Dtor_Base && dtor->getParent()->isAbstract()) {
554+
cgm.errorNYI(dtor->getSourceRange(), "abstract base class destructors");
555+
return;
556+
}
557+
558+
Stmt *body = dtor->getBody();
559+
assert(body && !cir::MissingFeatures::incrementProfileCounter());
560+
561+
// The call to operator delete in a deleting destructor happens
562+
// outside of the function-try-block, which means it's always
563+
// possible to delegate the destructor body to the complete
564+
// destructor. Do so.
565+
if (dtorType == Dtor_Deleting) {
566+
cgm.errorNYI(dtor->getSourceRange(), "deleting destructor");
567+
return;
568+
}
569+
570+
// If the body is a function-try-block, enter the try before
571+
// anything else.
572+
const bool isTryBody = isa_and_nonnull<CXXTryStmt>(body);
573+
if (isTryBody)
574+
cgm.errorNYI(dtor->getSourceRange(), "function-try-block destructor");
575+
576+
assert(!cir::MissingFeatures::sanitizers());
577+
assert(!cir::MissingFeatures::dtorCleanups());
578+
579+
// If this is the complete variant, just invoke the base variant;
580+
// the epilogue will destruct the virtual bases. But we can't do
581+
// this optimization if the body is a function-try-block, because
582+
// we'd introduce *two* handler blocks. In the Microsoft ABI, we
583+
// always delegate because we might not have a definition in this TU.
584+
switch (dtorType) {
585+
case Dtor_Comdat:
586+
llvm_unreachable("not expecting a COMDAT");
587+
case Dtor_Deleting:
588+
llvm_unreachable("already handled deleting case");
589+
590+
case Dtor_Complete:
591+
assert((body || getTarget().getCXXABI().isMicrosoft()) &&
592+
"can't emit a dtor without a body for non-Microsoft ABIs");
593+
594+
assert(!cir::MissingFeatures::dtorCleanups());
595+
596+
// TODO(cir): A complete destructor is supposed to call the base destructor.
597+
// Since we have to emit both dtor kinds we just fall through for now and.
598+
// As long as we don't support virtual bases this should be functionally
599+
// equivalent.
600+
assert(!cir::MissingFeatures::completeDtors());
601+
602+
// Fallthrough: act like we're in the base variant.
603+
[[fallthrough]];
604+
605+
case Dtor_Base:
606+
assert(body);
607+
608+
assert(!cir::MissingFeatures::dtorCleanups());
609+
assert(!cir::MissingFeatures::vtableInitialization());
610+
611+
if (isTryBody) {
612+
cgm.errorNYI(dtor->getSourceRange(), "function-try-block destructor");
613+
} else if (body) {
614+
(void)emitStmt(body, /*useCurrentScope=*/true);
615+
} else {
616+
assert(dtor->isImplicit() && "bodyless dtor not implicit");
617+
// nothing to do besides what's in the epilogue
618+
}
619+
// -fapple-kext must inline any call to this dtor into
620+
// the caller's body.
621+
assert(!cir::MissingFeatures::appleKext());
622+
623+
break;
624+
}
625+
626+
assert(!cir::MissingFeatures::dtorCleanups());
627+
628+
// Exit the try if applicable.
629+
if (isTryBody)
630+
cgm.errorNYI(dtor->getSourceRange(), "function-try-block destructor");
631+
}
632+
543633
/// Given a value of type T* that may not be to a complete object, construct
544634
/// an l-vlaue withi the natural pointee alignment of T.
545635
LValue CIRGenFunction::makeNaturalAlignPointeeAddrLValue(mlir::Value val,

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ class CIRGenFunction : public CIRGenTypeCache {
830830
LValue emitCompoundAssignmentLValue(const clang::CompoundAssignOperator *e);
831831

832832
void emitConstructorBody(FunctionArgList &args);
833+
void emitDestructorBody(FunctionArgList &args);
833834

834835
mlir::LogicalResult emitContinueStmt(const clang::ContinueStmt &s);
835836

0 commit comments

Comments
 (0)