Skip to content

Commit 26dd95b

Browse files
authored
Merge branch 'main' into revert-154115-v_mov_64_bitcast_combine
2 parents ea66de8 + 57e3f02 commit 26dd95b

File tree

64 files changed

+1155
-482
lines changed

Some content is hidden

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

64 files changed

+1155
-482
lines changed

.github/renovate.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended"
5+
],
6+
"includePaths": [".github/**"],
7+
"schedule": "* 0 * * 1",
8+
"minimumReleaseAge": "3 days",
9+
"assignees": ["boomanaiden154"],
10+
"ignorePaths": [".github/workflows/containers/**"],
11+
"groupName": "[Github] Update GHA Dependencies"
12+
}

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ struct MissingFeatures {
214214
static bool ehCleanupScopeRequiresEHCleanup() { return false; }
215215
static bool ehCleanupBranchFixups() { return false; }
216216
static bool ehstackBranches() { return false; }
217+
static bool emitBranchThroughCleanup() { return false; }
217218
static bool emitCheckedInBoundsGEP() { return false; }
218219
static bool emitCondLikelihoodViaExpectIntrinsic() { return false; }
219220
static bool emitLifetimeMarkers() { return false; }

clang/include/clang/Tooling/Refactoring/RefactoringOptionVisitor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ namespace internal {
3737
template <typename T> struct HasHandle {
3838
private:
3939
template <typename ClassT>
40-
static auto check(ClassT *) -> typename std::is_same<
41-
decltype(std::declval<RefactoringOptionVisitor>().visit(
42-
std::declval<RefactoringOption>(),
43-
*std::declval<std::optional<T> *>())),
44-
void>::type;
40+
static auto check(ClassT *)
41+
-> std::is_same<decltype(std::declval<RefactoringOptionVisitor>().visit(
42+
std::declval<RefactoringOption>(),
43+
*std::declval<std::optional<T> *>())),
44+
void>;
4545

4646
template <typename> static std::false_type check(...);
4747

clang/lib/CIR/CodeGen/CIRGenCall.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class ReturnValueSlot {
256256
ReturnValueSlot() = default;
257257
ReturnValueSlot(Address addr) : addr(addr) {}
258258

259+
bool isNull() const { return !addr.isValid(); }
259260
Address getValue() const { return addr; }
260261
};
261262

clang/lib/CIR/CodeGen/CIRGenClass.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,86 @@ void CIRGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &args) {
778778
s->getStmtClassName());
779779
}
780780

781+
void CIRGenFunction::emitForwardingCallToLambda(
782+
const CXXMethodDecl *callOperator, CallArgList &callArgs) {
783+
// Get the address of the call operator.
784+
const CIRGenFunctionInfo &calleeFnInfo =
785+
cgm.getTypes().arrangeCXXMethodDeclaration(callOperator);
786+
cir::FuncOp calleePtr = cgm.getAddrOfFunction(
787+
GlobalDecl(callOperator), cgm.getTypes().getFunctionType(calleeFnInfo));
788+
789+
// Prepare the return slot.
790+
const FunctionProtoType *fpt =
791+
callOperator->getType()->castAs<FunctionProtoType>();
792+
QualType resultType = fpt->getReturnType();
793+
ReturnValueSlot returnSlot;
794+
795+
// We don't need to separately arrange the call arguments because
796+
// the call can't be variadic anyway --- it's impossible to forward
797+
// variadic arguments.
798+
799+
// Now emit our call.
800+
CIRGenCallee callee =
801+
CIRGenCallee::forDirect(calleePtr, GlobalDecl(callOperator));
802+
RValue rv = emitCall(calleeFnInfo, callee, returnSlot, callArgs);
803+
804+
// If necessary, copy the returned value into the slot.
805+
if (!resultType->isVoidType() && returnSlot.isNull()) {
806+
if (getLangOpts().ObjCAutoRefCount && resultType->isObjCRetainableType())
807+
cgm.errorNYI(callOperator->getSourceRange(),
808+
"emitForwardingCallToLambda: ObjCAutoRefCount");
809+
emitReturnOfRValue(*currSrcLoc, rv, resultType);
810+
} else {
811+
cgm.errorNYI(callOperator->getSourceRange(),
812+
"emitForwardingCallToLambda: return slot is not null");
813+
}
814+
}
815+
816+
void CIRGenFunction::emitLambdaDelegatingInvokeBody(const CXXMethodDecl *md) {
817+
const CXXRecordDecl *lambda = md->getParent();
818+
819+
// Start building arguments for forwarding call
820+
CallArgList callArgs;
821+
822+
QualType lambdaType = getContext().getCanonicalTagType(lambda);
823+
QualType thisType = getContext().getPointerType(lambdaType);
824+
Address thisPtr =
825+
createMemTemp(lambdaType, getLoc(md->getSourceRange()), "unused.capture");
826+
callArgs.add(RValue::get(thisPtr.getPointer()), thisType);
827+
828+
// Add the rest of the parameters.
829+
for (auto *param : md->parameters())
830+
emitDelegateCallArg(callArgs, param, param->getBeginLoc());
831+
832+
const CXXMethodDecl *callOp = lambda->getLambdaCallOperator();
833+
// For a generic lambda, find the corresponding call operator specialization
834+
// to which the call to the static-invoker shall be forwarded.
835+
if (lambda->isGenericLambda()) {
836+
assert(md->isFunctionTemplateSpecialization());
837+
const TemplateArgumentList *tal = md->getTemplateSpecializationArgs();
838+
FunctionTemplateDecl *callOpTemplate =
839+
callOp->getDescribedFunctionTemplate();
840+
void *InsertPos = nullptr;
841+
FunctionDecl *correspondingCallOpSpecialization =
842+
callOpTemplate->findSpecialization(tal->asArray(), InsertPos);
843+
assert(correspondingCallOpSpecialization);
844+
callOp = cast<CXXMethodDecl>(correspondingCallOpSpecialization);
845+
}
846+
emitForwardingCallToLambda(callOp, callArgs);
847+
}
848+
849+
void CIRGenFunction::emitLambdaStaticInvokeBody(const CXXMethodDecl *md) {
850+
if (md->isVariadic()) {
851+
// Codgen for LLVM doesn't emit code for this as well, it says:
852+
// FIXME: Making this work correctly is nasty because it requires either
853+
// cloning the body of the call operator or making the call operator
854+
// forward.
855+
cgm.errorNYI(md->getSourceRange(), "emitLambdaStaticInvokeBody: variadic");
856+
}
857+
858+
emitLambdaDelegatingInvokeBody(md);
859+
}
860+
781861
void CIRGenFunction::destroyCXXObject(CIRGenFunction &cgf, Address addr,
782862
QualType type) {
783863
const auto *record = type->castAsCXXRecordDecl();

clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ static void storeAnyExprIntoOneUnit(CIRGenFunction &cgf, const Expr *init,
238238
cgf.makeAddrLValue(newPtr, allocType), false);
239239
return;
240240
case cir::TEK_Complex:
241-
cgf.cgm.errorNYI(init->getSourceRange(),
242-
"storeAnyExprIntoOneUnit: complex");
241+
cgf.emitComplexExprIntoLValue(init, cgf.makeAddrLValue(newPtr, allocType),
242+
/*isInit*/ true);
243243
return;
244244
case cir::TEK_Aggregate: {
245245
assert(!cir::MissingFeatures::aggValueSlotGC());

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ class ComplexExprEmitter : public StmtVisitor<ComplexExprEmitter, mlir::Value> {
193193
mlir::Value VisitUnaryNot(const UnaryOperator *e);
194194
// LNot,Real,Imag never return complex.
195195
mlir::Value VisitUnaryExtension(const UnaryOperator *e) {
196-
cgf.cgm.errorNYI(e->getExprLoc(), "ComplexExprEmitter VisitUnaryExtension");
197-
return {};
196+
return Visit(e->getSubExpr());
198197
}
199198
mlir::Value VisitCXXDefaultArgExpr(CXXDefaultArgExpr *dae) {
200199
cgf.cgm.errorNYI(dae->getExprLoc(),

clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,25 +1464,24 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &value,
14641464
case APValue::ComplexInt:
14651465
case APValue::ComplexFloat: {
14661466
mlir::Type desiredType = cgm.convertType(destType);
1467-
cir::ComplexType complexType =
1468-
mlir::dyn_cast<cir::ComplexType>(desiredType);
1467+
auto complexType = mlir::dyn_cast<cir::ComplexType>(desiredType);
14691468

14701469
mlir::Type complexElemTy = complexType.getElementType();
14711470
if (isa<cir::IntType>(complexElemTy)) {
1472-
llvm::APSInt real = value.getComplexIntReal();
1473-
llvm::APSInt imag = value.getComplexIntImag();
1474-
return builder.getAttr<cir::ConstComplexAttr>(
1475-
complexType, cir::IntAttr::get(complexElemTy, real),
1476-
cir::IntAttr::get(complexElemTy, imag));
1471+
const llvm::APSInt &real = value.getComplexIntReal();
1472+
const llvm::APSInt &imag = value.getComplexIntImag();
1473+
return cir::ConstComplexAttr::get(builder.getContext(), complexType,
1474+
cir::IntAttr::get(complexElemTy, real),
1475+
cir::IntAttr::get(complexElemTy, imag));
14771476
}
14781477

14791478
assert(isa<cir::FPTypeInterface>(complexElemTy) &&
14801479
"expected floating-point type");
1481-
llvm::APFloat real = value.getComplexFloatReal();
1482-
llvm::APFloat imag = value.getComplexFloatImag();
1483-
return builder.getAttr<cir::ConstComplexAttr>(
1484-
complexType, cir::FPAttr::get(complexElemTy, real),
1485-
cir::FPAttr::get(complexElemTy, imag));
1480+
const llvm::APFloat &real = value.getComplexFloatReal();
1481+
const llvm::APFloat &imag = value.getComplexFloatImag();
1482+
return cir::ConstComplexAttr::get(builder.getContext(), complexType,
1483+
cir::FPAttr::get(complexElemTy, real),
1484+
cir::FPAttr::get(complexElemTy, imag));
14861485
}
14871486
case APValue::FixedPoint:
14881487
case APValue::AddrLabelDiff:

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,10 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn,
577577
getCIRGenModule().errorNYI(bodyRange, "CUDA kernel");
578578
} else if (isa<CXXMethodDecl>(funcDecl) &&
579579
cast<CXXMethodDecl>(funcDecl)->isLambdaStaticInvoker()) {
580-
getCIRGenModule().errorNYI(bodyRange, "Lambda static invoker");
580+
// The lambda static invoker function is special, because it forwards or
581+
// clones the body of the function call operator (but is actually
582+
// static).
583+
emitLambdaStaticInvokeBody(cast<CXXMethodDecl>(funcDecl));
581584
} else if (funcDecl->isDefaulted() && isa<CXXMethodDecl>(funcDecl) &&
582585
(cast<CXXMethodDecl>(funcDecl)->isCopyAssignmentOperator() ||
583586
cast<CXXMethodDecl>(funcDecl)->isMoveAssignmentOperator())) {

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,8 @@ class CIRGenFunction : public CIRGenTypeCache {
12741274

12751275
mlir::Value emitPromotedValue(mlir::Value result, QualType promotionType);
12761276

1277+
void emitReturnOfRValue(mlir::Location loc, RValue rv, QualType ty);
1278+
12771279
/// Emit the computation of the specified expression of scalar type.
12781280
mlir::Value emitScalarExpr(const clang::Expr *e);
12791281

@@ -1293,6 +1295,9 @@ class CIRGenFunction : public CIRGenTypeCache {
12931295

12941296
mlir::LogicalResult emitForStmt(const clang::ForStmt &s);
12951297

1298+
void emitForwardingCallToLambda(const CXXMethodDecl *lambdaCallOperator,
1299+
CallArgList &callArgs);
1300+
12961301
/// Emit the computation of the specified expression of complex type,
12971302
/// returning the result.
12981303
mlir::Value emitComplexExpr(const Expr *e);
@@ -1355,6 +1360,9 @@ class CIRGenFunction : public CIRGenTypeCache {
13551360
mlir::LogicalResult emitLabel(const clang::LabelDecl &d);
13561361
mlir::LogicalResult emitLabelStmt(const clang::LabelStmt &s);
13571362

1363+
void emitLambdaDelegatingInvokeBody(const CXXMethodDecl *md);
1364+
void emitLambdaStaticInvokeBody(const CXXMethodDecl *md);
1365+
13581366
mlir::LogicalResult emitIfStmt(const clang::IfStmt &s);
13591367

13601368
/// Emit code to compute the specified expression,

0 commit comments

Comments
 (0)