Skip to content

Commit 2968396

Browse files
authored
[CIR] Correct signedness for createSignedInt (#1167)
After I rebased, I found these problems with Spec2017. I was surprised why it doesn't have problems. Maybe some updates in LLVM part.
1 parent e8cdbc1 commit 2968396

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
5050

5151
mlir::Value getSignedInt(mlir::Location loc, int64_t val, unsigned numBits) {
5252
return getConstAPSInt(
53-
loc, llvm::APSInt(llvm::APInt(numBits, val), /*isUnsigned=*/false));
53+
loc, llvm::APSInt(llvm::APInt(numBits, val, /*isSigned=*/true),
54+
/*isUnsigned=*/false));
5455
}
5556

5657
mlir::Value getUnsignedInt(mlir::Location loc, uint64_t val,

clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mlir::Value emitRoundPointerUpToAlignment(cir::CIRBaseBuilderTy &builder,
4545
builder.getUnsignedInt(loc, alignment - 1, /*width=*/32));
4646
return builder.create<cir::PtrMaskOp>(
4747
loc, roundUp.getType(), roundUp,
48-
builder.getSignedInt(loc, -alignment, /*width=*/32));
48+
builder.getSignedInt(loc, -(signed)alignment, /*width=*/32));
4949
}
5050

5151
mlir::Type useFirstFieldIfTransparentUnion(mlir::Type Ty) {

0 commit comments

Comments
 (0)