Skip to content

Commit

Permalink
Fix issues in reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancern committed Jan 31, 2024
1 parent ba4b5aa commit 5e25553
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ RValue CIRGenFunction::GetUndefRValue(QualType Ty) {
mlir::Value CIRGenFunction::buildRuntimeCall(mlir::Location loc,
mlir::cir::FuncOp callee,
ArrayRef<mlir::Value> args) {
// TODO(cir): set the calling convention to this runtime call.
assert(!UnimplementedFeature::setCallingConv());

auto call = builder.create<mlir::cir::CallOp>(loc, callee, args);
assert(call->getNumResults() <= 1 &&
"runtime functions have at most 1 result");
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,7 @@ mlir::Value CIRGenFunction::buildDynamicCast(Address ThisAddr,
QualType srcRecordTy;
QualType destRecordTy;
if (isDynCastToVoid) {
srcRecordTy = srcTy->getPointeeType();
// No DestRecordTy.
llvm_unreachable("NYI");
} else if (const PointerType *DestPTy = destTy->getAs<PointerType>()) {
srcRecordTy = srcTy->castAs<PointerType>()->getPointeeType();
destRecordTy = DestPTy->getPointeeType();
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2188,13 +2188,20 @@ void CIRGenItaniumCXXABI::buildThrow(CIRGenFunction &CGF,

static mlir::cir::FuncOp getBadCastFn(CIRGenFunction &CGF) {
// Prototype: void __cxa_bad_cast();

// TODO(cir): set the calling convention of the runtime function.
assert(!UnimplementedFeature::setCallingConv());

mlir::cir::FuncType FTy =
CGF.getBuilder().getFuncType({}, CGF.getBuilder().getVoidTy());
return CGF.CGM.getOrCreateRuntimeFunction(FTy, "__cxa_bad_cast");
}

void CIRGenItaniumCXXABI::buildBadCastCall(CIRGenFunction &CGF,
mlir::Location loc) {
// TODO(cir): set the calling convention to the runtime function.
assert(!UnimplementedFeature::setCallingConv());

CGF.buildRuntimeCall(loc, getBadCastFn(CGF));
// TODO(cir): mark the current insertion point as unreachable.
}
Expand Down Expand Up @@ -2262,6 +2269,9 @@ static mlir::cir::FuncOp getItaniumDynamicCastFn(CIRGenFunction &CGF) {

// TODO(cir): mark the function as nowind readonly.

// TODO(cir): set the calling convention of the runtime function.
assert(!UnimplementedFeature::setCallingConv());

mlir::cir::FuncType FTy = CGF.getBuilder().getFuncType(
{VoidPtrTy, RTTIPtrTy, RTTIPtrTy, PtrDiffTy}, VoidPtrTy);
return CGF.CGM.getOrCreateRuntimeFunction(FTy, "__dynamic_cast");
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CIR/CodeGen/UnimplementedFeatureGuarding.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ struct UnimplementedFeature {
static bool isSEHTryScope() { return false; }
static bool emitScalarRangeCheck() { return false; }
static bool stmtExprEvaluation() { return false; }
static bool setCallingConv() { return false; }
};
} // namespace cir

Expand Down

0 comments on commit 5e25553

Please sign in to comment.