[llvm-dev] Replace call stack with an equivalent on the heap?

(IIIT) Siddharth Bhat via llvm-dev llvm-dev at lists.llvm.org
Fri Dec 15 17:51:09 PST 2017


Hello,

I'm implementing a custom Haskell-to-LLVM compiler, and in my
experimentation, noticed that GHC is much slower than clang certain
examples, such as the ackermann function. However, from reading their
respective IRs (Cmm for GHC and LLVM for clang), I don't really see much of
a difference. Here is a link to the numbers. (n, m) are the parameters to
the ackermann function
<https://gist.github.com/bgamari/bd424e82d96ddb7b9e67c5e51cdcc5ec>

One major difference is that GHC uses a "stack-in-the-heap", in the sense
that the a is a chunk of heap memory that functions effectively as call
stack. It is managed explicitly by GHC. GHC does not use the native call
stack _at all_. This is to implement continuation passing, in a sense.

I want to check that the difference in the performance is truly from this
"stack in  the heap" behavior, so I want to teach a backend to generate
code that looks like this.

Is code generating  like this something that I could reasonably teach the
backend? To be specific, I wish to teach the backend to manipulate a
"custom stack". I assume this would affect codegen, because one can no
longer use push/pop/call/ret.


Thanks,
Siddharth
-- 
Sending this from my phone, please excuse any typos!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171216/32f2f13c/attachment.html>


More information about the llvm-dev mailing list