Skip to content

Commit b765ade

Browse files
committed
IRGen: Mark some llvm::APInt constructions as signed
Fixes an assertion failure in the rebranch `llvm::APInt` ctor on 32-bit Windows. We were hitting the assertion because `uint64_t(-2)` does not fit into 32 bits when treated as unsigned. These assertions were enabled by default llvm/llvm-project#114539.
1 parent a868d92 commit b765ade

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,9 +2546,8 @@ llvm::Value *emitIndirectAsyncFunctionPointer(IRGenFunction &IGF,
25462546
llvm::Constant *One =
25472547
llvm::Constant::getIntegerValue(IntPtrTy, APInt(IntPtrTy->getBitWidth(),
25482548
1));
2549-
llvm::Constant *NegativeOne =
2550-
llvm::Constant::getIntegerValue(IntPtrTy, APInt(IntPtrTy->getBitWidth(),
2551-
-2));
2549+
llvm::Constant *NegativeOne = llvm::Constant::getIntegerValue(
2550+
IntPtrTy, APInt(IntPtrTy->getBitWidth(), -2, /*isSigned*/ true));
25522551
swift::irgen::Alignment PointerAlignment = IGF.IGM.getPointerAlignment();
25532552

25542553
llvm::Value *PtrToInt = IGF.Builder.CreatePtrToInt(pointer, IntPtrTy);
@@ -2578,7 +2577,7 @@ llvm::Value *emitIndirectCoroFunctionPointer(IRGenFunction &IGF,
25782577
llvm::Constant *One = llvm::Constant::getIntegerValue(
25792578
IntPtrTy, APInt(IntPtrTy->getBitWidth(), 1));
25802579
llvm::Constant *NegativeOne = llvm::Constant::getIntegerValue(
2581-
IntPtrTy, APInt(IntPtrTy->getBitWidth(), -2));
2580+
IntPtrTy, APInt(IntPtrTy->getBitWidth(), -2, /*isSigned*/ true));
25822581
swift::irgen::Alignment PointerAlignment = IGF.IGM.getPointerAlignment();
25832582

25842583
llvm::Value *PtrToInt = IGF.Builder.CreatePtrToInt(pointer, IntPtrTy);

0 commit comments

Comments
 (0)