Skip to content

Commit cf09dbf

Browse files
authored
[CIR] Fix build due to deprecated interfaces (#1299)
- After abba01a, 'is' and 'get' interfaces are deprecated even though not removed yet. However, it causes warnings and triggers build failures if that warnings are treated as errors.
1 parent 3c3b096 commit cf09dbf

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3638,8 +3638,8 @@ class CIR_CallOp<string mnemonic, list<Trait> extra_traits = []> :
36383638
void setCalleeFromCallable(::mlir::CallInterfaceCallable callee) {
36393639
if (auto calling =
36403640
(*this)->getAttrOfType<mlir::SymbolRefAttr>(getCalleeAttrName()))
3641-
(*this)->setAttr(getCalleeAttrName(), callee.get<mlir::SymbolRefAttr>());
3642-
setOperand(0, callee.get<mlir::Value>());
3641+
(*this)->setAttr(getCalleeAttrName(), mlir::cast<mlir::SymbolRefAttr>(callee));
3642+
setOperand(0, mlir::cast<mlir::Value>(callee));
36433643
}
36443644

36453645
bool isIndirect() { return !getCallee(); }

clang/lib/CIR/CodeGen/CIRGenCall.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ void CIRGenFunction::emitCallArgs(
10531053
const auto *MD = mlir::dyn_cast<const ObjCMethodDecl *>(Prototype.P);
10541054
assert(!MD && "ObjCMethodDecl NYI");
10551055

1056-
const auto *FPT = Prototype.P.get<const FunctionProtoType *>();
1056+
const auto *FPT = mlir::cast<const FunctionProtoType *>(Prototype.P);
10571057
IsVariadic = FPT->isVariadic();
10581058
ExplicitCC = FPT->getExtInfo().getCC();
10591059
ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,

clang/lib/CIR/CodeGen/CIRGenExprConst.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,8 @@ mlir::Attribute ConstantLValueEmitter::tryEmit() {
14561456
// Convert to the appropriate type; this could be an lvalue for
14571457
// an integer. FIXME: performAddrSpaceCast
14581458
if (mlir::isa<cir::PointerType>(destTy)) {
1459-
if (value.is<mlir::Attribute>())
1460-
return value.get<mlir::Attribute>();
1459+
if (auto attr = mlir::dyn_cast<mlir::Attribute>(value))
1460+
return attr;
14611461
llvm_unreachable("NYI");
14621462
}
14631463

clang/lib/CIR/CodeGen/CIRGenValue.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ class RValue {
7070
/// Return the mlir::Value of the address of the aggregate.
7171
Address getAggregateAddress() const {
7272
assert(isAggregate() && "Not an aggregate!");
73-
auto align = reinterpret_cast<uintptr_t>(V2.getPointer().get<int *>()) >>
74-
AggAlignShift;
73+
auto align =
74+
reinterpret_cast<uintptr_t>(mlir::cast<int *>(V2.getPointer())) >>
75+
AggAlignShift;
7576
return Address(V1.getPointer(), ElementType,
7677
clang::CharUnits::fromQuantity(align));
7778
}

clang/lib/CIR/CodeGen/ConstantInitBuilder.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ ConstantInitBuilderBase::ConstantInitBuilderBase(CIRGenModule &CGM)
2323

2424
mlir::Type ConstantInitFuture::getType() const {
2525
assert(Data && "dereferencing null future");
26-
if (Data.is<mlir::Attribute>()) {
27-
auto attr = mlir::dyn_cast<mlir::TypedAttr>(Data.get<mlir::Attribute>());
28-
assert(attr && "expected typed attribute");
29-
return attr.getType();
26+
if (auto attr = mlir::dyn_cast<mlir::Attribute>(Data)) {
27+
auto typedAttr = mlir::dyn_cast<mlir::TypedAttr>(attr);
28+
assert(typedAttr && "expected typed attribute");
29+
return typedAttr.getType();
3030
} else {
3131
llvm_unreachable("Only sypport typed attributes here");
3232
}
@@ -42,8 +42,8 @@ void ConstantInitFuture::abandon() {
4242

4343
void ConstantInitFuture::installInGlobal(cir::GlobalOp GV) {
4444
assert(Data && "installing null future");
45-
if (Data.is<mlir::Attribute>()) {
46-
CIRGenModule::setInitializer(GV, Data.get<mlir::Attribute>());
45+
if (auto attr = mlir::dyn_cast<mlir::Attribute>(Data)) {
46+
CIRGenModule::setInitializer(GV, attr);
4747
} else {
4848
llvm_unreachable("NYI");
4949
// auto &builder = *Data.get<ConstantInitBuilderBase *>();

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ OpFoldResult cir::CastOp::fold(FoldAdaptor adaptor) {
784784
// create a new attribute that's capable of representing the source.
785785
llvm::SmallVector<mlir::OpFoldResult, 1> foldResults;
786786
auto foldOrder = getSrc().getDefiningOp()->fold(foldResults);
787-
if (foldOrder.succeeded() && foldResults[0].is<mlir::Attribute>())
788-
return foldResults[0].get<mlir::Attribute>();
787+
if (foldOrder.succeeded() && mlir::isa<mlir::Attribute>(foldResults[0]))
788+
return mlir::cast<mlir::Attribute>(foldResults[0]);
789789
return {};
790790
}
791791
case cir::CastKind::bitcast:

clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,11 @@ static Location getEndLocForHist(Region *R) {
526526

527527
static Location getEndLocForHist(LifetimeCheckPass::LexicalScopeContext &lsc) {
528528
assert(!lsc.parent.isNull() && "shouldn't be null");
529-
if (lsc.parent.is<Region *>())
530-
return getEndLocForHist(lsc.parent.get<Region *>());
531-
assert(lsc.parent.is<Operation *>() &&
529+
if (auto r = mlir::dyn_cast<Region *>(lsc.parent))
530+
return getEndLocForHist(r);
531+
assert(mlir::isa<Operation *>(lsc.parent) &&
532532
"Only support operation beyond this point");
533-
return getEndLocForHist(lsc.parent.get<Operation *>());
533+
return getEndLocForHist(mlir::cast<Operation *>(lsc.parent));
534534
}
535535

536536
void LifetimeCheckPass::killInPset(mlir::Value ptrKey, const State &s,

clang/test/CodeGenOpenCL/printf.cl

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// RUN: %clang_cc1 -no-enable-noundef-analysis -cl-std=CL3.0 -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s
55
// RUN: %clang_cc1 -no-enable-noundef-analysis -cl-std=clc++2021 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=FP64,ALL %s
66
// RUN: %clang_cc1 -no-enable-noundef-analysis -cl-std=clc++2021 -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s
7-
// XFAIL: *
87

98
typedef __attribute__((ext_vector_type(2))) float float2;
109
typedef __attribute__((ext_vector_type(2))) half half2;

0 commit comments

Comments
 (0)