Skip to content

Commit 329e833

Browse files
authored
Merge branch 'main' into decoder_emitter_type_specialization
2 parents d320606 + ccbcebc commit 329e833

File tree

143 files changed

+7172
-1970
lines changed

Some content is hidden

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

143 files changed

+7172
-1970
lines changed

.ci/compute_projects.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"flang",
5050
},
5151
"lld": {"bolt", "cross-project-tests"},
52-
# TODO(issues/132795): LLDB should be enabled on clang changes.
53-
"clang": {"clang-tools-extra", "cross-project-tests"},
52+
"clang": {"clang-tools-extra", "cross-project-tests", "lldb"},
5453
"mlir": {"flang"},
5554
# Test everything if ci scripts are changed.
5655
".ci": {

.ci/compute_projects_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def test_clang(self):
8383
)
8484
self.assertEqual(
8585
env_variables["projects_to_build"],
86-
"clang;clang-tools-extra;lld;llvm",
86+
"clang;clang-tools-extra;lld;lldb;llvm",
8787
)
8888
self.assertEqual(
8989
env_variables["project_check_targets"],
90-
"check-clang check-clang-tools",
90+
"check-clang check-clang-tools check-lldb",
9191
)
9292
self.assertEqual(
9393
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
@@ -158,11 +158,11 @@ def test_cir(self):
158158
)
159159
self.assertEqual(
160160
env_variables["projects_to_build"],
161-
"clang;clang-tools-extra;lld;llvm;mlir",
161+
"clang;clang-tools-extra;lld;lldb;llvm;mlir",
162162
)
163163
self.assertEqual(
164164
env_variables["project_check_targets"],
165-
"check-clang check-clang-cir check-clang-tools",
165+
"check-clang check-clang-cir check-clang-tools check-lldb",
166166
)
167167
self.assertEqual(
168168
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"

.github/workflows/pr-code-format.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ jobs:
7070
- name: Run code formatter
7171
env:
7272
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
73-
START_REV: ${{ github.event.pull_request.base.sha }}
74-
END_REV: ${{ github.event.pull_request.head.sha }}
7573
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
7674
# Create an empty comments file so the pr-write job doesn't fail.
7775
run: |

clang/include/clang/Basic/BuiltinsPPC.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ TARGET_BUILTIN(__builtin_ppc_bcdsub_p, "iiV16UcV16Uc", "",
580580
"isa-v207-instructions")
581581

582582
// P9 Binary-coded decimal (BCD) builtins.
583+
TARGET_BUILTIN(__builtin_ppc_bcdcopysign, "V16UcV16UcV16Uc", "", "power9-vector")
584+
TARGET_BUILTIN(__builtin_ppc_bcdsetsign, "V16UcV16UcUc", "t", "power9-vector")
583585
TARGET_BUILTIN(__builtin_ppc_national2packed, "V16UcV16UcUc", "t", "power9-vector")
584586
TARGET_BUILTIN(__builtin_ppc_packed2national, "V16UcV16Uc", "", "power9-vector")
585587
TARGET_BUILTIN(__builtin_ppc_packed2zoned, "V16UcV16UcUc", "t", "power9-vector")

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,4 +3614,86 @@ def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> {
36143614
}];
36153615
}
36163616

3617+
//===----------------------------------------------------------------------===//
3618+
// Variadic Operations
3619+
//===----------------------------------------------------------------------===//
3620+
3621+
def CIR_VAStartOp : CIR_Op<"va_start"> {
3622+
let summary = "Starts a variable argument list";
3623+
let description = [{
3624+
The cir.va_start operation models the C/C++ va_start macro by
3625+
initializing a variable argument list at the given va_list storage
3626+
location.
3627+
3628+
The first operand must be a pointer to the target's `va_list`
3629+
representation. This operation has no results and produces its effect by
3630+
mutating the storage referenced by the pointer operand. The second operand
3631+
must be an integer value that contains the expected number of arguments in
3632+
that list.
3633+
3634+
Each `cir.va_start` must be paired with a corresponding `cir.va_end`
3635+
on the same logical `va_list` object along all control-flow paths. After
3636+
`cir.va_end`, the `va_list` must not be accessed unless reinitialized
3637+
with another `cir.va_start`.
3638+
3639+
Lowering maps this to the LLVM intrinsic `llvm.va_start`, passing the
3640+
appropriately decayed pointer to the underlying `va_list` storage.
3641+
3642+
Example:
3643+
3644+
```mlir
3645+
// %args : !cir.ptr<!cir.array<!rec___va_list_tag x 1>>
3646+
%p = cir.cast(array_to_ptrdecay, %args
3647+
: !cir.ptr<!cir.array<!rec___va_list_tag x 1>>),
3648+
!cir.ptr<!rec___va_list_tag>
3649+
%count = cir.load %0 : !cir.ptr<!s32i>, !s32i
3650+
cir.va_start %p %count : !cir.ptr<!rec___va_list_tag>, !s32i
3651+
```
3652+
}];
3653+
let arguments = (ins
3654+
CIR_PointerType:$arg_list,
3655+
CIR_AnyFundamentalIntType:$count
3656+
);
3657+
3658+
let assemblyFormat = [{
3659+
$arg_list $count attr-dict `:` type(operands)
3660+
}];
3661+
}
3662+
3663+
def CIR_VAEndOp : CIR_Op<"va_end"> {
3664+
let summary = "Ends a variable argument list";
3665+
let description = [{
3666+
The `cir.va_end` operation models the C/C++ va_end macro by finalizing
3667+
and cleaning up a variable argument list previously initialized with
3668+
`cir.va_start`.
3669+
3670+
The operand must be a pointer to the target's `va_list` representation.
3671+
This operation has no results and produces its effect by mutating the
3672+
storage referenced by the pointer operand.
3673+
3674+
`cir.va_end` must only be called after a matching `cir.va_start` on the
3675+
same `va_list` along all control-flow paths. After `cir.va_end`, the
3676+
`va_list` is invalid and must not be accessed unless reinitialized.
3677+
3678+
Lowering typically maps this to the LLVM intrinsic `llvm.va_end`,
3679+
passing the appropriately decayed pointer to the underlying `va_list`
3680+
storage.
3681+
3682+
Example:
3683+
```mlir
3684+
// %args : !cir.ptr<!cir.array<!rec___va_list_tag x 1>>
3685+
%p = cir.cast(array_to_ptrdecay, %args
3686+
: !cir.ptr<!cir.array<!rec___va_list_tag x 1>>),
3687+
!cir.ptr<!rec___va_list_tag>
3688+
cir.va_end %p : !cir.ptr<!rec___va_list_tag>
3689+
```
3690+
}];
3691+
3692+
let arguments = (ins CIR_PointerType:$arg_list);
3693+
3694+
let assemblyFormat = [{
3695+
$arg_list attr-dict `:` type(operands)
3696+
}];
3697+
}
3698+
36173699
#endif // CLANG_CIR_DIALECT_IR_CIROPS_TD

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,17 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
19391939
PrimType TargetT = classifyPrim(Init->getType());
19401940

19411941
auto Eval = [&](const IntegerLiteral *IL, unsigned ElemIndex) {
1942-
if (!this->emitConst(IL->getValue(), Init))
1943-
return false;
1942+
if (TargetT == PT_Float) {
1943+
if (!this->emitConst(IL->getValue(), classifyPrim(IL), Init))
1944+
return false;
1945+
const auto *Sem = &Ctx.getFloatSemantics(CAT->getElementType());
1946+
if (!this->emitCastIntegralFloating(classifyPrim(IL), Sem,
1947+
getFPOptions(E), E))
1948+
return false;
1949+
} else {
1950+
if (!this->emitConst(IL->getValue(), TargetT, Init))
1951+
return false;
1952+
}
19441953
return this->emitInitElem(TargetT, ElemIndex, IL);
19451954
};
19461955
if (!EmbedS->doForEachDataElement(Eval, ElementIndex))
@@ -3181,13 +3190,6 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) {
31813190
if (T->isRecordType()) {
31823191
const CXXConstructorDecl *Ctor = E->getConstructor();
31833192

3184-
// Trivial copy/move constructor. Avoid copy.
3185-
if (Ctor->isDefaulted() && Ctor->isCopyOrMoveConstructor() &&
3186-
Ctor->isTrivial() &&
3187-
E->getArg(0)->isTemporaryObject(Ctx.getASTContext(),
3188-
T->getAsCXXRecordDecl()))
3189-
return this->visitInitializer(E->getArg(0));
3190-
31913193
// If we're discarding a construct expression, we still need
31923194
// to allocate a variable and call the constructor and destructor.
31933195
if (DiscardResult) {
@@ -3203,6 +3205,13 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) {
32033205
return false;
32043206
}
32053207

3208+
// Trivial copy/move constructor. Avoid copy.
3209+
if (Ctor->isDefaulted() && Ctor->isCopyOrMoveConstructor() &&
3210+
Ctor->isTrivial() &&
3211+
E->getArg(0)->isTemporaryObject(Ctx.getASTContext(),
3212+
T->getAsCXXRecordDecl()))
3213+
return this->visitInitializer(E->getArg(0));
3214+
32063215
// Zero initialization.
32073216
if (E->requiresZeroInitialization()) {
32083217
const Record *R = getRecord(E->getType());
@@ -4108,8 +4117,7 @@ bool Compiler<Emitter>::VisitCXXStdInitializerListExpr(
41084117

41094118
PrimType SecondFieldT = classifyPrim(R->getField(1u)->Decl->getType());
41104119
if (isIntegralType(SecondFieldT)) {
4111-
if (!this->emitConst(static_cast<APSInt>(ArrayType->getSize()),
4112-
SecondFieldT, E))
4120+
if (!this->emitConst(ArrayType->getSize(), SecondFieldT, E))
41134121
return false;
41144122
return this->emitInitField(SecondFieldT, R->getField(1u)->Offset, E);
41154123
}
@@ -4119,7 +4127,7 @@ bool Compiler<Emitter>::VisitCXXStdInitializerListExpr(
41194127
return false;
41204128
if (!this->emitExpandPtr(E))
41214129
return false;
4122-
if (!this->emitConst(static_cast<APSInt>(ArrayType->getSize()), PT_Uint64, E))
4130+
if (!this->emitConst(ArrayType->getSize(), PT_Uint64, E))
41234131
return false;
41244132
if (!this->emitArrayElemPtrPop(PT_Uint64, E))
41254133
return false;
@@ -4497,12 +4505,18 @@ bool Compiler<Emitter>::emitConst(T Value, const Expr *E) {
44974505
template <class Emitter>
44984506
bool Compiler<Emitter>::emitConst(const APSInt &Value, PrimType Ty,
44994507
const Expr *E) {
4508+
return this->emitConst(static_cast<const APInt &>(Value), Ty, E);
4509+
}
4510+
4511+
template <class Emitter>
4512+
bool Compiler<Emitter>::emitConst(const APInt &Value, PrimType Ty,
4513+
const Expr *E) {
45004514
if (Ty == PT_IntAPS)
45014515
return this->emitConstIntAPS(Value, E);
45024516
if (Ty == PT_IntAP)
45034517
return this->emitConstIntAP(Value, E);
45044518

4505-
if (Value.isSigned())
4519+
if (isSignedType(Ty))
45064520
return this->emitConst(Value.getSExtValue(), Ty, E);
45074521
return this->emitConst(Value.getZExtValue(), Ty, E);
45084522
}

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,10 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
347347

348348
/// Emits an APSInt constant.
349349
bool emitConst(const llvm::APSInt &Value, PrimType Ty, const Expr *E);
350+
bool emitConst(const llvm::APInt &Value, PrimType Ty, const Expr *E);
350351
bool emitConst(const llvm::APSInt &Value, const Expr *E);
351352
bool emitConst(const llvm::APInt &Value, const Expr *E) {
352-
return emitConst(static_cast<llvm::APSInt>(Value), E);
353+
return emitConst(Value, classifyPrim(E), E);
353354
}
354355

355356
/// Emits an integer constant.

clang/lib/AST/ByteCode/Disasm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const {
545545
OS << " Initialized: " << IsInitialized << "\n";
546546
OS << " Weak: " << isWeak() << "\n";
547547
OS << " Dummy: " << isDummy() << '\n';
548-
OS << " Dynamic: " << IsDynamic << "\n";
548+
OS << " Dynamic: " << isDynamic() << "\n";
549549
}
550550

551551
LLVM_DUMP_METHOD void EvaluationResult::dump() const {

clang/lib/AST/ByteCode/DynamicAllocator.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,17 @@ Block *DynamicAllocator::allocate(const Descriptor *D, unsigned EvalID,
101101
ID->LifeState =
102102
AllocForm == Form::Operator ? Lifetime::Ended : Lifetime::Started;
103103

104-
B->IsDynamic = true;
105-
106-
if (auto It = AllocationSites.find(D->asExpr()); It != AllocationSites.end())
104+
if (auto It = AllocationSites.find(D->asExpr());
105+
It != AllocationSites.end()) {
107106
It->second.Allocations.emplace_back(std::move(Memory));
108-
else
107+
B->setDynAllocId(It->second.NumAllocs);
108+
++It->second.NumAllocs;
109+
} else {
109110
AllocationSites.insert(
110111
{D->asExpr(), AllocationSite(std::move(Memory), AllocForm)});
112+
B->setDynAllocId(0);
113+
}
114+
assert(B->isDynamic());
111115
return B;
112116
}
113117

clang/lib/AST/ByteCode/DynamicAllocator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ class DynamicAllocator final {
4848

4949
struct AllocationSite {
5050
llvm::SmallVector<Allocation> Allocations;
51+
unsigned NumAllocs = 0;
5152
Form AllocForm;
5253

5354
AllocationSite(std::unique_ptr<std::byte[]> Memory, Form AllocForm)
5455
: AllocForm(AllocForm) {
5556
Allocations.push_back({std::move(Memory)});
57+
++NumAllocs;
5658
}
5759

5860
size_t size() const { return Allocations.size(); }

0 commit comments

Comments
 (0)