Stream: compiler development

Topic: More LLVM Fun


view this post on Zulip Brendan Hansknecht (May 01 2024 at 20:27):

Just was listening to some LLVM terrible compilation time issues:

In this example, someone made a tuple with 2000 elements (all u8). Took 3 seconds to compile.
They then made a tuple with 5000 elements.... it took 2 minutes to compile.

This is for like 7 lines of code that just creates a zeroed tuple and then sets a few values in it.

view this post on Zulip Brendan Hansknecht (May 01 2024 at 20:30):

The reason was that the generated llvm ir did something like:

%val = load [2000 x u8] %mem

And in the 5000 case, just swap out the number with 5000.

Why does this explode llvm: ssa values in llvm are meant to be passed in registers

view this post on Zulip Brendan Hansknecht (May 01 2024 at 20:30):

So this was asking llvm to simply load the value into the 2000 registers it has lying around.

view this post on Zulip Brendan Hansknecht (May 01 2024 at 20:31):

Or 5000 in the worse case.

view this post on Zulip Brendan Hansknecht (May 01 2024 at 20:31):

Fundamental comment/lesson: llvm ssa values are meant to fit in roughly 2 or 3 registers. Anything else should never be an ssa value.

view this post on Zulip Brendan Hansknecht (May 01 2024 at 20:32):

llvm is not built for that and will explode.

view this post on Zulip Brendan Hansknecht (May 01 2024 at 20:35):

Just a general reminder of things we should make sure to avoid in our llvm ir.


Last updated: Jul 06 2025 at 12:14 UTC