Skip to content

Commit 6e48069

Browse files
authored
Merge branch 'main' into fixup/missing-prof-expand-variadics
2 parents 8f969c9 + 3705921 commit 6e48069

File tree

305 files changed

+68866
-64251
lines changed

Some content is hidden

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

305 files changed

+68866
-64251
lines changed

.github/workflows/libcxx-build-containers.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ jobs:
6464

6565
- name: Push the images
6666
if: github.event_name == 'push'
67-
run: docker compose push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder
67+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder
68+
env:
69+
TAG: ${{ github.sha }}
6870

6971
# We create tarballs with the images and upload them as artifacts, since that's useful for testing
7072
# the images when making changes.

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ static Object serializeComment(const CommentInfo &I, Object &Description) {
140140
insertComment(Description, TextCommentsArray, "BriefComments");
141141
else if (I.Name == "return")
142142
insertComment(Description, TextCommentsArray, "ReturnComments");
143+
else if (I.Name == "throws" || I.Name == "throw") {
144+
json::Value ThrowsVal = Object();
145+
auto &ThrowsObj = *ThrowsVal.getAsObject();
146+
ThrowsObj["Exception"] = I.Args.front();
147+
ThrowsObj["Children"] = TextCommentsArray;
148+
insertComment(Description, ThrowsVal, "ThrowsComments");
149+
}
143150
return Obj;
144151
}
145152

clang-tools-extra/clang-doc/assets/comment-template.mustache

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
</div>
5555
{{/CodeComments}}
5656
{{/HasCodeComments}}
57+
{{#HasThrowsComments}}
58+
<h3>Throws</h3>
59+
{{#ThrowsComments}}
60+
<div>
61+
<b>{{Exception}}</b> {{#Children}}{{TextComment}}{{/Children}}
62+
</div>
63+
{{/ThrowsComments}}
64+
{{/HasThrowsComments}}
5765
{{#BlockCommandComment}}
5866
<div class="block-command-comment__command">
5967
<div class="block-command-command">

clang-tools-extra/test/clang-doc/basic-project.mustache.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,10 @@ HTML-CALC: </div>
384384
HTML-CALC: <h3>Returns</h3>
385385
HTML-CALC: <p> double The result of a / b.</p>
386386
HTML-CALC: <p></p>
387-
HTML-CALC: </div>
387+
HTML-CALC: <h3>Throws</h3>
388+
HTML-CALC: <div>
389+
HTML-CALC: <b>std::invalid_argument</b> if b is zero.
390+
HTML-CALC: </div>
388391
HTML-CALC: </div>
389392
HTML-CALC: </div>
390393
HTML-CALC: <div class="delimiter-container">

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,15 @@ class SMTConv {
456456
llvm::SMTExprRef OperandExp =
457457
getSymExpr(Solver, Ctx, USE->getOperand(), &OperandTy, hasComparison);
458458

459-
if (const BinarySymExpr *BSE =
460-
dyn_cast<BinarySymExpr>(USE->getOperand())) {
461-
if (USE->getOpcode() == UO_Minus &&
462-
BinaryOperator::isComparisonOp(BSE->getOpcode()))
463-
// The comparison operator yields a boolean value in the Z3
464-
// language and applying the unary minus operator on a boolean
465-
// crashes Z3. However, the unary minus does nothing in this
466-
// context (a number is truthy if and only if its negative is
467-
// truthy), so let's just ignore the unary minus.
468-
// TODO: Replace this with a more general solution.
469-
return OperandExp;
459+
// When the operand is a bool expr, but the operator is an integeral
460+
// operator, casting the bool expr to the integer before creating the
461+
// unary operator.
462+
// E.g. -(5 && a)
463+
if (OperandTy == Ctx.BoolTy && OperandTy != *RetTy &&
464+
(*RetTy)->isIntegerType()) {
465+
OperandExp = fromCast(Solver, OperandExp, (*RetTy),
466+
Ctx.getTypeSize(*RetTy), OperandTy, 1);
467+
OperandTy = (*RetTy);
470468
}
471469

472470
llvm::SMTExprRef UnaryExp =

clang/lib/Analysis/BodyFarm.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,14 @@ static CallExpr *create_call_once_lambda_call(ASTContext &C, ASTMaker M,
293293
FunctionDecl *callOperatorDecl = CallbackDecl->getLambdaCallOperator();
294294
assert(callOperatorDecl != nullptr);
295295

296-
DeclRefExpr *callOperatorDeclRef =
297-
DeclRefExpr::Create(/* Ctx =*/ C,
298-
/* QualifierLoc =*/ NestedNameSpecifierLoc(),
299-
/* TemplateKWLoc =*/ SourceLocation(),
300-
const_cast<FunctionDecl *>(callOperatorDecl),
301-
/* RefersToEnclosingVariableOrCapture=*/ false,
302-
/* NameLoc =*/ SourceLocation(),
303-
/* T =*/ callOperatorDecl->getType(),
304-
/* VK =*/ VK_LValue);
296+
DeclRefExpr *callOperatorDeclRef = DeclRefExpr::Create(
297+
/* Ctx =*/C,
298+
/* QualifierLoc =*/NestedNameSpecifierLoc(),
299+
/* TemplateKWLoc =*/SourceLocation(), callOperatorDecl,
300+
/* RefersToEnclosingVariableOrCapture=*/false,
301+
/* NameLoc =*/SourceLocation(),
302+
/* T =*/callOperatorDecl->getType(),
303+
/* VK =*/VK_LValue);
305304

306305
return CXXOperatorCallExpr::Create(
307306
/*AstContext=*/C, OO_Call, callOperatorDeclRef,

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,10 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
315315
return getConstantInt(loc, getUInt32Ty(), c);
316316
}
317317
cir::ConstantOp getSInt64(uint64_t c, mlir::Location loc) {
318-
cir::IntType sInt64Ty = getSInt64Ty();
319-
return cir::ConstantOp::create(*this, loc, cir::IntAttr::get(sInt64Ty, c));
318+
return getConstantInt(loc, getSInt64Ty(), c);
319+
}
320+
cir::ConstantOp getUInt64(uint64_t c, mlir::Location loc) {
321+
return getConstantInt(loc, getUInt64Ty(), c);
320322
}
321323

322324
mlir::Value createNeg(mlir::Value value) {
@@ -572,6 +574,35 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
572574
info.isSigned, isLvalueVolatile,
573575
addr.getAlignment().getAsAlign().value());
574576
}
577+
578+
cir::VecShuffleOp
579+
createVecShuffle(mlir::Location loc, mlir::Value vec1, mlir::Value vec2,
580+
llvm::ArrayRef<mlir::Attribute> maskAttrs) {
581+
auto vecType = mlir::cast<cir::VectorType>(vec1.getType());
582+
auto resultTy = cir::VectorType::get(getContext(), vecType.getElementType(),
583+
maskAttrs.size());
584+
return cir::VecShuffleOp::create(*this, loc, resultTy, vec1, vec2,
585+
getArrayAttr(maskAttrs));
586+
}
587+
588+
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1,
589+
mlir::Value vec2,
590+
llvm::ArrayRef<int64_t> mask) {
591+
auto maskAttrs = llvm::to_vector_of<mlir::Attribute>(
592+
llvm::map_range(mask, [&](int32_t idx) {
593+
return cir::IntAttr::get(getSInt32Ty(), idx);
594+
}));
595+
return createVecShuffle(loc, vec1, vec2, maskAttrs);
596+
}
597+
598+
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1,
599+
llvm::ArrayRef<int64_t> mask) {
600+
/// Create a unary shuffle. The second vector operand of the IR instruction
601+
/// is poison.
602+
cir::ConstantOp poison =
603+
getConstant(loc, cir::PoisonAttr::get(vec1.getType()));
604+
return createVecShuffle(loc, vec1, poison, mask);
605+
}
575606
};
576607

577608
} // namespace clang::CIRGen

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,22 @@ CIRGenFunction::emitTargetBuiltinExpr(unsigned builtinID, const CallExpr *e,
630630
getTarget().getTriple().getArch());
631631
}
632632

633+
mlir::Value CIRGenFunction::emitScalarOrConstFoldImmArg(
634+
const unsigned iceArguments, const unsigned idx, const Expr *argExpr) {
635+
mlir::Value arg = {};
636+
if ((iceArguments & (1 << idx)) == 0) {
637+
arg = emitScalarExpr(argExpr);
638+
} else {
639+
// If this is required to be a constant, constant fold it so that we
640+
// know that the generated intrinsic gets a ConstantInt.
641+
const std::optional<llvm::APSInt> result =
642+
argExpr->getIntegerConstantExpr(getContext());
643+
assert(result && "Expected argument to be a constant");
644+
arg = builder.getConstInt(getLoc(argExpr->getSourceRange()), *result);
645+
}
646+
return arg;
647+
}
648+
633649
/// Given a builtin id for a function like "__builtin_fabsf", return a Function*
634650
/// for "fabsf".
635651
cir::FuncOp CIRGenModule::getBuiltinLibFunction(const FunctionDecl *fd,

clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "clang/Basic/Builtins.h"
1717
#include "clang/Basic/TargetBuiltins.h"
1818
#include "clang/CIR/MissingFeatures.h"
19-
#include "llvm/IR/IntrinsicsX86.h"
2019

2120
using namespace clang;
2221
using namespace clang::CIRGen;
@@ -66,9 +65,8 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
6665
getContext().GetBuiltinType(builtinID, error, &iceArguments);
6766
assert(error == ASTContext::GE_None && "Error while getting builtin type.");
6867

69-
for (auto [idx, arg] : llvm::enumerate(e->arguments())) {
68+
for (auto [idx, arg] : llvm::enumerate(e->arguments()))
7069
ops.push_back(emitScalarOrConstFoldImmArg(iceArguments, idx, arg));
71-
}
7270

7371
CIRGenBuilderTy &builder = getBuilder();
7472
mlir::Type voidTy = builder.getVoidTy();
@@ -98,6 +96,10 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
9896
case X86::BI__builtin_ia32_undef128:
9997
case X86::BI__builtin_ia32_undef256:
10098
case X86::BI__builtin_ia32_undef512:
99+
cgm.errorNYI(e->getSourceRange(),
100+
std::string("unimplemented X86 builtin call: ") +
101+
getContext().BuiltinInfo.getName(builtinID));
102+
return {};
101103
case X86::BI__builtin_ia32_vec_ext_v4hi:
102104
case X86::BI__builtin_ia32_vec_ext_v16qi:
103105
case X86::BI__builtin_ia32_vec_ext_v8hi:
@@ -107,7 +109,22 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
107109
case X86::BI__builtin_ia32_vec_ext_v32qi:
108110
case X86::BI__builtin_ia32_vec_ext_v16hi:
109111
case X86::BI__builtin_ia32_vec_ext_v8si:
110-
case X86::BI__builtin_ia32_vec_ext_v4di:
112+
case X86::BI__builtin_ia32_vec_ext_v4di: {
113+
unsigned numElts = cast<cir::VectorType>(ops[0].getType()).getSize();
114+
115+
uint64_t index =
116+
ops[1].getDefiningOp<cir::ConstantOp>().getIntValue().getZExtValue();
117+
118+
index &= numElts - 1;
119+
120+
cir::ConstantOp indexVal =
121+
builder.getUInt64(index, getLoc(e->getExprLoc()));
122+
123+
// These builtins exist so we can ensure the index is an ICE and in range.
124+
// Otherwise we could just do this in the header file.
125+
return cir::VecExtractOp::create(builder, getLoc(e->getExprLoc()), ops[0],
126+
indexVal);
127+
}
111128
case X86::BI__builtin_ia32_vec_set_v4hi:
112129
case X86::BI__builtin_ia32_vec_set_v16qi:
113130
case X86::BI__builtin_ia32_vec_set_v8hi:

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,18 @@ RValue CIRGenFunction::emitLoadOfExtVectorElementLValue(LValue lv) {
669669
return RValue::get(cir::VecExtractOp::create(builder, loc, vec, index));
670670
}
671671

672-
cgm.errorNYI(
673-
loc, "emitLoadOfExtVectorElementLValue: Result of expr is vector type");
674-
return {};
672+
// Always use shuffle vector to try to retain the original program structure
673+
SmallVector<int64_t> mask;
674+
for (auto i : llvm::seq<unsigned>(0, exprVecTy->getNumElements()))
675+
mask.push_back(getAccessedFieldNo(i, elts));
676+
677+
cir::VecShuffleOp resultVec = builder.createVecShuffle(loc, vec, mask);
678+
if (lv.getType()->isExtVectorBoolType()) {
679+
cgm.errorNYI(loc, "emitLoadOfExtVectorElementLValue: ExtVectorBoolType");
680+
return {};
681+
}
682+
683+
return RValue::get(resultVec);
675684
}
676685

677686
static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd) {

0 commit comments

Comments
 (0)