on master help sign in
Fix LLVM codegen of negative integer literals
commitec5de335d047007b22b297f23601d5b2b9c7edf3 authorBenjamin Saunders <besaunde@sfu.ca> dateThu 7 Nov 2013, 18:29 (13 years ago) parent9c0cb92
1 file changed+2−1
src/IRTS/CodegenLLVM.hs+2−1
src/IRTS/CodegenLLVM.hs+2−1
@@ -776,7 +776,8 @@ cgConst c@(TT.Str s) = do
776776 str <- addGlobal' (ArrayType (1 + fromIntegral (length s)) (IntegerType 8)) (cgConst' c)
777777 box FString (ConstantOperand $ C.GetElementPtr True str [C.Int 32 0, C.Int 32 0])
778778cgConst c@(TT.BI i) = do
779− str <- addGlobal' (ArrayType (1 + fromInteger (numDigits 10 i)) (IntegerType 8)) (cgConst' c)
779+ let stringRepLen = (if i < 0 then 2 else 1) + fromInteger (numDigits 10 i)
780+ str <- addGlobal' (ArrayType stringRepLen (IntegerType 8)) (cgConst' c)
780781 mpz <- alloc mpzTy
781782 inst $ simpleCall "__gmpz_init_set_str" [mpz
782783 , ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0, C.Int 32 0]