Skip to content

Commit 4e3aee9

Browse files
authored
merge main into amd-staging (llvm#4177)
2 parents cfa49c9 + d9c2e83 commit 4e3aee9

File tree

169 files changed

+2590
-1050
lines changed

Some content is hidden

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

169 files changed

+2590
-1050
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/Analysis/FlowSensitive/CachedConstAccessorsLattice.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ template <typename Base> class CachedConstAccessorsLattice : public Base {
9090
return Base::operator==(Other);
9191
}
9292

93-
LatticeJoinEffect join(const CachedConstAccessorsLattice &Other);
93+
LatticeEffect join(const CachedConstAccessorsLattice &Other);
9494

9595
private:
9696
// Maps a record storage location and const method to the value to return
@@ -121,21 +121,22 @@ joinConstMethodMap(
121121
llvm::SmallDenseMap<const FunctionDecl *, T *>>
122122
&Map2,
123123
LatticeEffect &Effect) {
124+
// Intersect the two maps, and note if change was made.
124125
llvm::SmallDenseMap<const RecordStorageLocation *,
125126
llvm::SmallDenseMap<const FunctionDecl *, T *>>
126127
Result;
127128
for (auto &[Loc, DeclToT] : Map1) {
128129
auto It = Map2.find(Loc);
129130
if (It == Map2.end()) {
130-
Effect = LatticeJoinEffect::Changed;
131+
Effect = LatticeEffect::Changed;
131132
continue;
132133
}
133134
const auto &OtherDeclToT = It->second;
134135
auto &JoinedDeclToT = Result[Loc];
135136
for (auto [Func, Var] : DeclToT) {
136137
T *OtherVar = OtherDeclToT.lookup(Func);
137138
if (OtherVar == nullptr || OtherVar != Var) {
138-
Effect = LatticeJoinEffect::Changed;
139+
Effect = LatticeEffect::Changed;
139140
continue;
140141
}
141142
JoinedDeclToT.insert({Func, Var});

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/AST/ByteCode/Context.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ bool Context::evaluateStrlen(State &Parent, const Expr *E, uint64_t &Result) {
245245
if (!FieldDesc->isPrimitiveArray())
246246
return false;
247247

248+
if (Ptr.isDummy() || Ptr.isUnknownSizeArray())
249+
return false;
250+
248251
unsigned N = Ptr.getNumElems();
249252
if (Ptr.elemSize() == 1) {
250253
Result = strnlen(reinterpret_cast<const char *>(Ptr.getRawAddress()), N);

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -666,16 +666,6 @@ static bool interp__builtin_abs(InterpState &S, CodePtr OpPC,
666666
return true;
667667
}
668668

669-
static bool interp__builtin_knot(InterpState &S, CodePtr OpPC,
670-
const InterpFrame *Frame,
671-
const CallExpr *Call) {
672-
APSInt Val =
673-
popToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(0)->getType()));
674-
APInt Result = ~Val;
675-
pushInteger(S, APSInt(std::move(Result), true), Call->getType());
676-
return true;
677-
}
678-
679669
static bool interp__builtin_popcount(InterpState &S, CodePtr OpPC,
680670
const InterpFrame *Frame,
681671
const CallExpr *Call) {
@@ -1380,32 +1370,6 @@ static bool interp__builtin_ia32_bzhi(InterpState &S, CodePtr OpPC,
13801370
return true;
13811371
}
13821372

1383-
static bool interp__builtin_ia32_lzcnt(InterpState &S, CodePtr OpPC,
1384-
const InterpFrame *Frame,
1385-
const CallExpr *Call) {
1386-
QualType CallType = Call->getType();
1387-
if (!CallType->isIntegerType() ||
1388-
!Call->getArg(0)->getType()->isIntegerType())
1389-
return false;
1390-
1391-
APSInt Val = popToAPSInt(S, Call->getArg(0));
1392-
pushInteger(S, Val.countLeadingZeros(), CallType);
1393-
return true;
1394-
}
1395-
1396-
static bool interp__builtin_ia32_tzcnt(InterpState &S, CodePtr OpPC,
1397-
const InterpFrame *Frame,
1398-
const CallExpr *Call) {
1399-
QualType CallType = Call->getType();
1400-
if (!CallType->isIntegerType() ||
1401-
!Call->getArg(0)->getType()->isIntegerType())
1402-
return false;
1403-
1404-
APSInt Val = popToAPSInt(S, Call->getArg(0));
1405-
pushInteger(S, Val.countTrailingZeros(), CallType);
1406-
return true;
1407-
}
1408-
14091373
static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC,
14101374
const InterpFrame *Frame,
14111375
const CallExpr *Call) {
@@ -2551,6 +2515,24 @@ static bool interp__builtin_is_within_lifetime(InterpState &S, CodePtr OpPC,
25512515
return true;
25522516
}
25532517

2518+
static bool interp__builtin_elementwise_int_unaryop(
2519+
InterpState &S, CodePtr OpPC, const CallExpr *Call,
2520+
llvm::function_ref<APInt(const APSInt &)> Fn) {
2521+
assert(Call->getNumArgs() == 1);
2522+
assert(Call->getType()->isIntegerType());
2523+
2524+
// Single integer case.
2525+
if (!Call->getArg(0)->getType()->isVectorType()) {
2526+
APSInt Src = popToAPSInt(S, Call->getArg(0));
2527+
APInt Result = Fn(Src);
2528+
pushInteger(S, APSInt(std::move(Result), !Src.isSigned()), Call->getType());
2529+
return true;
2530+
}
2531+
2532+
// TODO: Add vector integer handling.
2533+
return false;
2534+
}
2535+
25542536
static bool interp__builtin_elementwise_int_binop(
25552537
InterpState &S, CodePtr OpPC, const CallExpr *Call,
25562538
llvm::function_ref<APInt(const APSInt &, const APSInt &)> Fn) {
@@ -3283,12 +3265,18 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
32833265
case clang::X86::BI__builtin_ia32_lzcnt_u16:
32843266
case clang::X86::BI__builtin_ia32_lzcnt_u32:
32853267
case clang::X86::BI__builtin_ia32_lzcnt_u64:
3286-
return interp__builtin_ia32_lzcnt(S, OpPC, Frame, Call);
3268+
return interp__builtin_elementwise_int_unaryop(
3269+
S, OpPC, Call, [](const APSInt &Src) {
3270+
return APInt(Src.getBitWidth(), Src.countLeadingZeros());
3271+
});
32873272

32883273
case clang::X86::BI__builtin_ia32_tzcnt_u16:
32893274
case clang::X86::BI__builtin_ia32_tzcnt_u32:
32903275
case clang::X86::BI__builtin_ia32_tzcnt_u64:
3291-
return interp__builtin_ia32_tzcnt(S, OpPC, Frame, Call);
3276+
return interp__builtin_elementwise_int_unaryop(
3277+
S, OpPC, Call, [](const APSInt &Src) {
3278+
return APInt(Src.getBitWidth(), Src.countTrailingZeros());
3279+
});
32923280

32933281
case clang::X86::BI__builtin_ia32_pdep_si:
32943282
case clang::X86::BI__builtin_ia32_pdep_di:
@@ -3661,7 +3649,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
36613649
case X86::BI__builtin_ia32_knothi:
36623650
case X86::BI__builtin_ia32_knotsi:
36633651
case X86::BI__builtin_ia32_knotdi:
3664-
return interp__builtin_knot(S, OpPC, Frame, Call);
3652+
return interp__builtin_elementwise_int_unaryop(
3653+
S, OpPC, Call, [](const APSInt &Src) { return ~Src; });
36653654

36663655
case X86::BI__builtin_ia32_kaddqi:
36673656
case X86::BI__builtin_ia32_kaddhi:

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(),

0 commit comments

Comments
 (0)