From 1002c1a3314e5a059be6780c845af199375a4a95 Mon Sep 17 00:00:00 2001 From: Olle Fredriksson Date: Fri, 31 May 2024 23:19:11 +0200 Subject: [PATCH] Zero-initialize stack pointers --- src/LowToLLVM.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/LowToLLVM.hs b/src/LowToLLVM.hs index 250ae74..548df78 100644 --- a/src/LowToLLVM.hs +++ b/src/LowToLLVM.hs @@ -431,6 +431,15 @@ assembleTerm env nameSuggestion passBy = \case varName bytes <> " = add i32 " <> varName pointerBytes <> ", " <> varName nonPointerBytes allocaBytes <- freshVar "alloca_bytes" emitInstruction $ varName allocaBytes <> " = alloca i8, i32 " <> varName bytes + declareLLVMGlobal "llvm.memset.p0.i32" "declare void @llvm.memset.p0.i32(ptr, i8, i32, i1)" + emitInstruction $ + "call void @llvm.memset.p0.i32" + <> parens + [ "ptr " <> varName allocaBytes + , "i8 0" -- val + , "i32 " <> varName pointerBytes + , "i1 0" -- isvolatile + ] nonPointerPointer <- freshVar "non_pointer_pointer" emitInstruction $ varName nonPointerPointer