Live data from Hacker News

Mapping Python to LLVM

blog.exaloop.io

31–34 of 34 posts

Re: Mapping Python to LLVM

#31
post #30

I recall that Google had a project to compile Python to LLVM (Unladen Swallow @ https://code.google.com/archive/p/unladen-swallow/ ), but work stopped on it a long time ago. If I recall it really wasn't that much faster than CPython given the overhead, but it's been a long time; if it was faster I assume it wouldn't have been abandoned.

Quite. Unladen Swallow was unfortunately a failure, in part because LLVM at the time was quite buggy, and in part because LLVM wasn't (isn't?) magic enough to speed up a dynamic language. The blog post here mentions they do their own optimization passes, before handing over to LLVM. I imagine that's pretty important.

LLVM really wasn't that buggy at the time (circa 2009); the project I was using it for at the time, a .NET compiler that targeted video game consoles, was quite stable from a code generation point of view, and we were shipping games with it.

Re: Mapping Python to LLVM

#32
post #30

Earlier quoted context omitted.

Quite. Unladen Swallow was unfortunately a failure, in part because LLVM at the time was quite buggy, and in part because LLVM wasn't (isn't?) magic enough to speed up a dynamic language. The blog post here mentions they do their own optimization passes, before handing over to LLVM. I imagine that's pretty important.

LLVM really wasn't that buggy at the time (circa 2009); the project I was using it for at the time, a .NET compiler that targeted video game consoles, was quite stable from a code generation point of view, and we were shipping games with it.

Ah, that's cool. Thanks for the correction. I was misremembering the Unladen Swallow retrospective[1]. It's fair to say they used a lot fo their available time contributing to LLVM, but it sounds like that was feature work, not bug focused.

[1] https://qinsb.blogspot.com/2011/03/unladen-swallow-retrospec...

Re: Mapping Python to LLVM

#33
post #24

Have to assign variables to a bit of memory on the stack because SSA??

LLVM has an optimization pass that takes care of that. https://llvm.org/docs/Passes.html#passes-mem2reg

That's not the only way to do that tho? Or is that the recommended way to do it?

Re: Mapping Python to LLVM

#34
post #24

Earlier quoted context omitted.

LLVM has an optimization pass that takes care of that. https://llvm.org/docs/Passes.html#passes-mem2reg

That's not the only way to do that tho? Or is that the recommended way to do it?

You can write your code generator to produce the optimized output right away, of course. But the whole point of LLVM is to not have every compiler worry about doing stuff like this well.
Post reply on HN