Skip to content

Commit 8da1c9f

Browse files
authored
Merge branch 'main' into kvp/large_int_div
2 parents 8a34566 + e501a1f commit 8da1c9f

File tree

140 files changed

+2883
-565
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

+2883
-565
lines changed

bolt/lib/Core/CallGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#undef USE_SSECRC
2323
#endif
2424

25-
static LLVM_ATTRIBUTE_UNUSED inline size_t hash_int64_fallback(int64_t k) {
25+
[[maybe_unused]] static inline size_t hash_int64_fallback(int64_t k) {
2626
uint64_t key = (unsigned long long)k;
2727
// "64 bit Mix Functions", from Thomas Wang's "Integer Hash Function."
2828
// http://www.concentric.net/~ttwang/tech/inthash.htm
@@ -35,7 +35,7 @@ static LLVM_ATTRIBUTE_UNUSED inline size_t hash_int64_fallback(int64_t k) {
3535
return static_cast<size_t>(static_cast<uint32_t>(key));
3636
}
3737

38-
static LLVM_ATTRIBUTE_UNUSED inline size_t hash_int64(int64_t k) {
38+
[[maybe_unused]] static inline size_t hash_int64(int64_t k) {
3939
#if defined(USE_SSECRC) && defined(__SSE4_2__)
4040
size_t h = 0;
4141
__asm("crc32q %1, %0\n" : "+r"(h) : "rm"(k));

bolt/lib/Core/DebugData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ std::optional<AttrInfo> findAttributeInfo(const DWARFDie DIE,
101101
return findAttributeInfo(DIE, AbbrevDecl, *Index);
102102
}
103103

104-
LLVM_ATTRIBUTE_UNUSED
104+
[[maybe_unused]]
105105
static void printLE64(const std::string &S) {
106106
for (uint32_t I = 0, Size = S.size(); I < Size; ++I) {
107107
errs() << Twine::utohexstr(S[I]);

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void printDie(const DWARFDie &DIE) {
6969
}
7070

7171
/// Lazily parse DWARF DIE and print it out.
72-
LLVM_ATTRIBUTE_UNUSED
72+
[[maybe_unused]]
7373
static void printDie(DWARFUnit &DU, uint64_t DIEOffset) {
7474
uint64_t OriginalOffsets = DIEOffset;
7575
uint64_t NextCUOffset = DU.getNextUnitOffset();

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
127127
cir::BoolType getBoolTy() { return cir::BoolType::get(getContext()); }
128128
cir::VoidType getVoidTy() { return cir::VoidType::get(getContext()); }
129129

130+
cir::IntType getUIntNTy(int n) {
131+
return cir::IntType::get(getContext(), n, false);
132+
}
133+
134+
cir::IntType getSIntNTy(int n) {
135+
return cir::IntType::get(getContext(), n, true);
136+
}
137+
130138
cir::PointerType getPointerTo(mlir::Type ty) {
131139
return cir::PointerType::get(ty);
132140
}

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,6 +4044,43 @@ def CIR_ExpectOp : CIR_Op<"expect", [
40444044
}];
40454045
}
40464046

4047+
//===----------------------------------------------------------------------===//
4048+
// PtrDiffOp
4049+
//===----------------------------------------------------------------------===//
4050+
4051+
def CIR_PtrDiffOp : CIR_Op<"ptr_diff", [Pure, SameTypeOperands]> {
4052+
let summary = "Pointer subtraction arithmetic";
4053+
let description = [{
4054+
The cir.ptr_diff operation computes the difference between two pointers that
4055+
have the same element type.
4056+
4057+
The result reflects the ABI-defined size of the pointed-to type. For example,
4058+
subtracting two !cir.ptr<!u64i> values may yield 1, representing an 8-byte
4059+
difference. In contrast, for pointers to void or function types, a result of
4060+
8 corresponds to an 8-byte difference.
4061+
4062+
For pointers to types whose size are not aligned with the target data
4063+
layout, the size is generally rounded to the next power of 2 bits. For
4064+
example, subtracting two !cir.ptr<!s24i> values for the _BitInt(24) type may
4065+
yield 1, representing a 4-byte difference (as opposed to a 3-byte
4066+
difference).
4067+
4068+
Example:
4069+
4070+
```mlir
4071+
%7 = cir.ptr_diff %0, %1 : !cir.ptr<!u64i> -> !u64i
4072+
```
4073+
}];
4074+
4075+
let arguments = (ins CIR_PointerType:$lhs, CIR_PointerType:$rhs);
4076+
let results = (outs CIR_AnyFundamentalIntType:$result);
4077+
4078+
let assemblyFormat = [{
4079+
$lhs `,` $rhs `:` qualified(type($lhs)) `->` qualified(type($result))
4080+
attr-dict
4081+
}];
4082+
}
4083+
40474084
//===----------------------------------------------------------------------===//
40484085
// Floating Point Ops
40494086
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ struct MissingFeatures {
322322
static bool invokeOp() { return false; }
323323
static bool labelOp() { return false; }
324324
static bool ptrDiffOp() { return false; }
325+
static bool llvmLoweringPtrDiffConsidersPointee() { return false; }
325326
static bool ptrStrideOp() { return false; }
326327
static bool switchOp() { return false; }
327328
static bool throwOp() { return false; }

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,16 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
380380
/*relative_layout=*/false);
381381
}
382382

383+
mlir::Value createDynCastToVoid(mlir::Location loc, mlir::Value src,
384+
bool vtableUseRelativeLayout) {
385+
// TODO(cir): consider address space here.
386+
assert(!cir::MissingFeatures::addressSpace());
387+
cir::PointerType destTy = getVoidPtrTy();
388+
return cir::DynamicCastOp::create(
389+
*this, loc, destTy, cir::DynamicCastKind::Ptr, src,
390+
cir::DynamicCastInfoAttr{}, vtableUseRelativeLayout);
391+
}
392+
383393
Address createBaseClassAddr(mlir::Location loc, Address addr,
384394
mlir::Type destType, unsigned offset,
385395
bool assumeNotNull) {

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
463463
return emitLibraryCall(*this, fd, e,
464464
cgm.getBuiltinLibFunction(fd, builtinID));
465465

466-
cgm.errorNYI(e->getSourceRange(), "unimplemented builtin call");
466+
cgm.errorNYI(e->getSourceRange(),
467+
std::string("unimplemented builtin call: ") +
468+
getContext().BuiltinInfo.getName(builtinID));
467469
return getUndefRValue(e->getType());
468470
}
469471

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,9 +1734,9 @@ mlir::Value ScalarExprEmitter::emitSub(const BinOpInfo &ops) {
17341734
// LLVM we shall take VLA's, division by element size, etc.
17351735
//
17361736
// See more in `EmitSub` in CGExprScalar.cpp.
1737-
assert(!cir::MissingFeatures::ptrDiffOp());
1738-
cgf.cgm.errorNYI("ptrdiff");
1739-
return {};
1737+
assert(!cir::MissingFeatures::llvmLoweringPtrDiffConsidersPointee());
1738+
return cir::PtrDiffOp::create(builder, cgf.getLoc(ops.loc), cgf.PtrDiffTy,
1739+
ops.lhs, ops.rhs);
17401740
}
17411741

17421742
mlir::Value ScalarExprEmitter::emitShl(const BinOpInfo &ops) {

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,10 +1313,10 @@ class CIRGenFunction : public CIRGenTypeCache {
13131313

13141314
mlir::Value emitCXXNewExpr(const CXXNewExpr *e);
13151315

1316-
void emitNewArrayInitializer(const CXXNewExpr *E, QualType ElementType,
1317-
mlir::Type ElementTy, Address BeginPtr,
1318-
mlir::Value NumElements,
1319-
mlir::Value AllocSizeWithoutCookie);
1316+
void emitNewArrayInitializer(const CXXNewExpr *e, QualType elementType,
1317+
mlir::Type elementTy, Address beginPtr,
1318+
mlir::Value numElements,
1319+
mlir::Value allocSizeWithoutCookie);
13201320

13211321
RValue emitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *e,
13221322
const CXXMethodDecl *md,

0 commit comments

Comments
 (0)