-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CIR][NFC] Fix warnings in ClangIR code #133134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1366,8 +1366,7 @@ mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( | |
const mlir::Location loc = cgf.getLoc(e->getSourceRange()); | ||
if (auto kind = e->getKind(); | ||
kind == UETT_SizeOf || kind == UETT_DataSizeOf) { | ||
if (const VariableArrayType *variableArrTy = | ||
cgf.getContext().getAsVariableArrayType(typeToSize)) { | ||
if (cgf.getContext().getAsVariableArrayType(typeToSize)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is implemented in the incubator, and we'll use the return type when the implementation is upstreamed. |
||
cgf.getCIRGenModule().errorNYI(e->getSourceRange(), | ||
"sizeof operator for VariableArrayType", | ||
e->getStmtClassName()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,21 +126,6 @@ static mlir::Value emitToMemory(mlir::ConversionPatternRewriter &rewriter, | |
return value; | ||
} | ||
|
||
static mlir::Value | ||
emitCirAttrToMemory(mlir::Operation *parentOp, mlir::Attribute attr, | ||
mlir::ConversionPatternRewriter &rewriter, | ||
const mlir::TypeConverter *converter, | ||
mlir::DataLayout const &dataLayout) { | ||
|
||
mlir::Value loweredValue = | ||
lowerCirAttrAsValue(parentOp, attr, rewriter, converter); | ||
if (auto boolAttr = mlir::dyn_cast<cir::BoolAttr>(attr)) { | ||
return emitToMemory(rewriter, dataLayout, boolAttr.getType(), loweredValue); | ||
} | ||
|
||
return loweredValue; | ||
} | ||
|
||
mlir::LLVM::Linkage convertLinkage(cir::GlobalLinkageKind linkage) { | ||
using CIR = cir::GlobalLinkageKind; | ||
using LLVM = mlir::LLVM::Linkage; | ||
|
@@ -261,7 +246,7 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::ConstArrayAttr attr) { | |
mlir::Location loc = parentOp->getLoc(); | ||
mlir::Value result; | ||
|
||
if (auto zeros = attr.getTrailingZerosNum()) { | ||
if (attr.hasTrailingZeros()) { | ||
mlir::Type arrayTy = attr.getType(); | ||
result = rewriter.create<mlir::LLVM::ZeroOp>( | ||
loc, converter->convertType(arrayTy)); | ||
|
@@ -1251,13 +1236,12 @@ void ConvertCIRToLLVMPass::runOnOperation() { | |
patterns.add<CIRToLLVMStoreOpLowering>(converter, patterns.getContext(), dl); | ||
patterns.add<CIRToLLVMGlobalOpLowering>(converter, patterns.getContext(), dl); | ||
patterns.add<CIRToLLVMCastOpLowering>(converter, patterns.getContext(), dl); | ||
patterns.add<CIRToLLVMConstantOpLowering>(converter, patterns.getContext(), | ||
dl); | ||
patterns.add< | ||
// clang-format off | ||
CIRToLLVMBinOpLowering, | ||
CIRToLLVMBrCondOpLowering, | ||
CIRToLLVMBrOpLowering, | ||
CIRToLLVMConstantOpLowering, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment right above says we'd like to keep these patterns separate because their signature is going to change in the future. That's still the case here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked at the implementation of this one in the incubator, and I don't think the dataLayout use there is necessary. I'm not sure it's necessary anywhere, since we can get it from the module. It seems reasonable to me not to pass dataLayout to this class. |
||
CIRToLLVMFuncOpLowering, | ||
CIRToLLVMTrapOpLowering, | ||
CIRToLLVMUnaryOpLowering | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why
getAs
is not[[nodiscard]]
but hey it's not so no new warning here.(Maybe
isa
is still better?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we'll need the return value here, but probably not for a while. This isn't implemented in the incubator either.