Skip to content

Commit

Permalink
Zero-initialize stack pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
ollef committed May 31, 2024
1 parent 5950442 commit 1002c1a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/LowToLLVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1002c1a

Please sign in to comment.