on master help sign in
Merge pull request #601 from Ralith/fix-negative-ints

Fix LLVM codegen of negative integer literals

commit0469bca384d49db9809c646b78a15242d03e2523 authorEdwin Brady <edwin.brady@gmail.com> dateFri 8 Nov 2013, 00:08 (13 years ago) parent9c0cb92ec5de33
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]