Skip to content

Commit

Permalink
clean up global region
Browse files Browse the repository at this point in the history
  • Loading branch information
serkm committed Oct 22, 2024
1 parent 6b31a7c commit 6cd7557
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion libraries/llvm/rts.ll
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ define private void @eraseFrames(%StackPointer %stackPointer) alwaysinline {

define private tailcc void @topLevel(%Pos %val, %Stack %stack) {
%rest = call %Stack @underflowStack(%Stack %stack)
; assert %rest == null
; rest holds global variables
call void @eraseStack(%Stack %rest)
ret void
}

Expand All @@ -550,6 +551,20 @@ define private %Stack @withEmptyStack() {
%globals = call %Prompt @freshPrompt()
%globalsStack = call %Stack @newStack(%Prompt %globals)

%globalsStackPointer_pointer = getelementptr %StackValue, %Stack %globalsStack, i64 0, i32 1, i32 0
%globalsStackPointer = load %StackPointer, ptr %globalsStackPointer_pointer

%returnAddressPointer.0 = getelementptr %FrameHeader, %StackPointer %globalsStackPointer, i64 0, i32 0
%sharerPointer.0 = getelementptr %FrameHeader, %StackPointer %globalsStackPointer, i64 0, i32 1
%eraserPointer.0 = getelementptr %FrameHeader, %StackPointer %globalsStackPointer, i64 0, i32 2

store ptr @nop, ptr %returnAddressPointer.0
store ptr @nop, ptr %sharerPointer.0
store ptr @free, ptr %eraserPointer.0

%globalsStackPointer_2 = getelementptr %FrameHeader, %StackPointer %globalsStackPointer, i64 1
store %StackPointer %globalsStackPointer_2, ptr %globalsStackPointer_pointer

%prompt = call %Prompt @freshPrompt()
%stack = call %Stack @newStack(%Prompt %prompt)

Expand Down

0 comments on commit 6cd7557

Please sign in to comment.