Skip to content

Commit 6093dc7

Browse files
committed
IRGen: Restore implicit truncation in some calls to llvm::APInt ctor
Follow-up to #81464. Fixes an assertion failure on 32-bit Windows. The default value was flipped in llvm/llvm-project#114539.
1 parent fa87afb commit 6093dc7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,9 +2556,10 @@ llvm::Value *emitIndirectAsyncFunctionPointer(IRGenFunction &IGF,
25562556
llvm::Constant *One =
25572557
llvm::Constant::getIntegerValue(IntPtrTy, APInt(IntPtrTy->getBitWidth(),
25582558
1));
2559-
llvm::Constant *NegativeOne =
2560-
llvm::Constant::getIntegerValue(IntPtrTy, APInt(IntPtrTy->getBitWidth(),
2561-
-2));
2559+
// TODO: Avoid implicit truncation.
2560+
llvm::Constant *NegativeOne = llvm::Constant::getIntegerValue(
2561+
IntPtrTy, APInt(IntPtrTy->getBitWidth(), -2, /*isSigned*/ false,
2562+
/*implicitTrunc*/ true));
25622563
swift::irgen::Alignment PointerAlignment = IGF.IGM.getPointerAlignment();
25632564

25642565
llvm::Value *PtrToInt = IGF.Builder.CreatePtrToInt(pointer, IntPtrTy);
@@ -2587,8 +2588,10 @@ llvm::Value *emitIndirectCoroFunctionPointer(IRGenFunction &IGF,
25872588
IntPtrTy, APInt(IntPtrTy->getBitWidth(), 0));
25882589
llvm::Constant *One = llvm::Constant::getIntegerValue(
25892590
IntPtrTy, APInt(IntPtrTy->getBitWidth(), 1));
2591+
// TODO: Avoid implicit truncation.
25902592
llvm::Constant *NegativeOne = llvm::Constant::getIntegerValue(
2591-
IntPtrTy, APInt(IntPtrTy->getBitWidth(), -2));
2593+
IntPtrTy, APInt(IntPtrTy->getBitWidth(), -2, /*isSigned*/ false,
2594+
/*implicitTrunc*/ true));
25922595
swift::irgen::Alignment PointerAlignment = IGF.IGM.getPointerAlignment();
25932596

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

0 commit comments

Comments
 (0)