Skip to content

Commit 514f984

Browse files
authored
[CIR][NFC] Fix warnings in ClangIR code (#133134)
This fixes unused variable warnings that have crept into the ClangIR code. In some cases the variable will be needed later, but all unused variables are being removed here. They can be reintroduced when they are needed.
1 parent f0b3bdd commit 514f984

File tree

5 files changed

+6
-30
lines changed

5 files changed

+6
-30
lines changed

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *e) {
170170
SourceLocation loc = e->getExprLoc();
171171

172172
assert(!cir::MissingFeatures::pgoUse());
173-
if (const MemberPointerType *MPT = e->getType()->getAs<MemberPointerType>()) {
173+
if (e->getType()->getAs<MemberPointerType>()) {
174174
cgm.errorNYI(e->getSourceRange(),
175175
"evaluateExprAsBool: member pointer type");
176176
return createDummyValue(getLoc(loc), boolTy);

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,7 @@ mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
13661366
const mlir::Location loc = cgf.getLoc(e->getSourceRange());
13671367
if (auto kind = e->getKind();
13681368
kind == UETT_SizeOf || kind == UETT_DataSizeOf) {
1369-
if (const VariableArrayType *variableArrTy =
1370-
cgf.getContext().getAsVariableArrayType(typeToSize)) {
1369+
if (cgf.getContext().getAsVariableArrayType(typeToSize)) {
13711370
cgf.getCIRGenModule().errorNYI(e->getSourceRange(),
13721371
"sizeof operator for VariableArrayType",
13731372
e->getStmtClassName());

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ class CIRGenFunction : public CIRGenTypeCache {
243243
// class is upstreamed.
244244
CIRGenFunction &cgf;
245245

246-
// Block containing cleanup code for things initialized in this lexical
247-
// context (scope).
248-
mlir::Block *cleanupBlock = nullptr;
249-
250246
// Points to the scope entry block. This is useful, for instance, for
251247
// helping to insert allocas before finalizing any recursive CodeGen from
252248
// switches.

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,6 @@ static mlir::Value emitToMemory(mlir::ConversionPatternRewriter &rewriter,
126126
return value;
127127
}
128128

129-
static mlir::Value
130-
emitCirAttrToMemory(mlir::Operation *parentOp, mlir::Attribute attr,
131-
mlir::ConversionPatternRewriter &rewriter,
132-
const mlir::TypeConverter *converter,
133-
mlir::DataLayout const &dataLayout) {
134-
135-
mlir::Value loweredValue =
136-
lowerCirAttrAsValue(parentOp, attr, rewriter, converter);
137-
if (auto boolAttr = mlir::dyn_cast<cir::BoolAttr>(attr)) {
138-
return emitToMemory(rewriter, dataLayout, boolAttr.getType(), loweredValue);
139-
}
140-
141-
return loweredValue;
142-
}
143-
144129
mlir::LLVM::Linkage convertLinkage(cir::GlobalLinkageKind linkage) {
145130
using CIR = cir::GlobalLinkageKind;
146131
using LLVM = mlir::LLVM::Linkage;
@@ -261,7 +246,7 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::ConstArrayAttr attr) {
261246
mlir::Location loc = parentOp->getLoc();
262247
mlir::Value result;
263248

264-
if (auto zeros = attr.getTrailingZerosNum()) {
249+
if (attr.hasTrailingZeros()) {
265250
mlir::Type arrayTy = attr.getType();
266251
result = rewriter.create<mlir::LLVM::ZeroOp>(
267252
loc, converter->convertType(arrayTy));
@@ -1251,13 +1236,12 @@ void ConvertCIRToLLVMPass::runOnOperation() {
12511236
patterns.add<CIRToLLVMStoreOpLowering>(converter, patterns.getContext(), dl);
12521237
patterns.add<CIRToLLVMGlobalOpLowering>(converter, patterns.getContext(), dl);
12531238
patterns.add<CIRToLLVMCastOpLowering>(converter, patterns.getContext(), dl);
1254-
patterns.add<CIRToLLVMConstantOpLowering>(converter, patterns.getContext(),
1255-
dl);
12561239
patterns.add<
12571240
// clang-format off
12581241
CIRToLLVMBinOpLowering,
12591242
CIRToLLVMBrCondOpLowering,
12601243
CIRToLLVMBrOpLowering,
1244+
CIRToLLVMConstantOpLowering,
12611245
CIRToLLVMFuncOpLowering,
12621246
CIRToLLVMTrapOpLowering,
12631247
CIRToLLVMUnaryOpLowering

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,10 @@ class CIRToLLVMStoreOpLowering
113113

114114
class CIRToLLVMConstantOpLowering
115115
: public mlir::OpConversionPattern<cir::ConstantOp> {
116-
mlir::DataLayout const &dataLayout;
117-
118116
public:
119117
CIRToLLVMConstantOpLowering(const mlir::TypeConverter &typeConverter,
120-
mlir::MLIRContext *context,
121-
mlir::DataLayout const &dataLayout)
122-
: OpConversionPattern(typeConverter, context), dataLayout(dataLayout) {
118+
mlir::MLIRContext *context)
119+
: OpConversionPattern(typeConverter, context) {
123120
setHasBoundedRewriteRecursion();
124121
}
125122

0 commit comments

Comments
 (0)