Skip to content

Blog

LLVM IR Emission(1): Overall and Type Emission

This blog briefly introduces the LLVM IR emission practice in Piovt-Language. The pl utilizes the LLVM to generates the backend code and does optimizer with the help of LLVM passes. The emission happens during converting from AST node into the LLVM, coupled with the syntax check as well. In this blog, we focus on the conversion details between LLVM IR and AST, and by the way inspects the ways of type check in a static language.

LLVM: Control Flow and Phi Node

LLVM provides a set of APIs for you to emit the platform dependent IR, and helps to optimize the generated IR and finally produces the low level executable code.

When writing a compiler, we first need to parse the high level source code into the AST. And then, after processing the modules and type checks, it's time to start to interact with LLVM to emit the LLVM IR.

This blog records my misunderstanding during learning llvm control flow and phi node.

Go Program Out of Memory

Last week, during on duty, one user reported his program exited silently without any useful information during deployment, the process is aborted with a killed information:

[1]    90616 killed     ./bin/server

This is an intrigue question as why the program is killed by OOM killer instead of a fatal stack overflow error.

User Process Management CLI

Generally, it's common to have a cli tool to manage the user processes, with respective commands to help start, stop, restart processes like systemctl. This blog records some experience building a CLI tool in Go to manage processes. Moreover, it lists some sceneries to make it work well as a PID 1 process.

Here are some summary items in this blog:

  • signal handling, wait system calls and process management
  • processes reaping as the init process
  • start, restart and exit handling

Understand Monad Transformers

Monad transformer(monadT) is another significant concept in Haskell. To understand the monadT, it's compulsory to know how monad works and the mechanism of >>=(bind). You can view the blog Understand Monad or any popular monads to learn about them.

In this blog, I will convey how we use monad transformer while how we recognize the idea that monad transformer creates a new monad. I will explain the function lift as well.