From 56b305928143e7411e9fc39dc8d33d8078dd63eb Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 26 Jan 2017 21:49:56 +0100 Subject: Fix a VERY elusive segfault. @lieuwex --- codegen.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen.hs b/codegen.hs index 34a757c..cda6239 100644 --- a/codegen.hs +++ b/codegen.hs @@ -126,14 +126,14 @@ variableOperand name = get >>= (maybe getGlobal getLocal . Map.lookup name . var where getLocal :: (Type, LLName) -> CGMonad A.Operand getLocal (t, nm) = do - let loadoper = A.LocalReference (toLLVMType t) (A.Name nm) + let loadoper = A.LocalReference (A.ptr (toLLVMType t)) (A.Name nm) label <- addInstr $ A.Load False loadoper Nothing 0 [] return $ A.LocalReference (toLLVMType t) (A.Name label) getGlobal :: CGMonad A.Operand getGlobal = do (t, nm) <- lookupGlobalVar name - let loadoper = A.ConstantOperand $ A.C.GlobalReference (toLLVMType t) (A.Name nm) + let loadoper = A.ConstantOperand $ A.C.GlobalReference (A.ptr (toLLVMType t)) (A.Name nm) label <- addInstr $ A.Load False loadoper Nothing 0 [] return $ A.LocalReference (toLLVMType t) (A.Name label) -- cgit v1.2.3-70-g09d2