summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-26 21:49:56 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-26 21:49:56 +0100
commit56b305928143e7411e9fc39dc8d33d8078dd63eb (patch)
tree684f9a7e3b30d379b53279be908e5101791ac8d1
parent3683460c575ce038b2cb3fa00b59dc3ff312d756 (diff)
Fix a VERY elusive segfault.
@lieuwex
-rw-r--r--codegen.hs4
1 files 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)