In compiler design, basic blocks are straight-line sequences of instructions that model control flow, and constructing them requires careful management of block IDs and edges, particularly when handling conditional branches where the target blocks may not yet exist during compilation. The compiler must maintain mappings between terminators and their successor basic blocks, often using a counter-based ID system where the return block is reserved as ID 0, and subsequent blocks are assigned incrementing IDs. This systematic approach ensures proper control flow graph construction even when dealing with complex nested control structures.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
studying compilers every day until i land a compiler role (day 204)Added:
[sighs] Okay. Uh we are we are back again. Um hello all hello world. It's been a couple days. Um this is day 204 of studying compilers every day until I land a compiler role. Um yes, this past weekend I've just been like dealing with I guess making sure all my school work was done and good to go. And then yesterday I had Ghazer which was a systems themed I guess conference/workshop.
Um it was a good time. Um yeah overall I think I think that was very well spent.
Uh time very well spent. But yeah it is it is time to get back to compiler work.
Uh it's good skill. It's good to see you. Um last stream. What did we do last stream? We supposedly finished up the expressions and the um uh the instructions in the rewrite this time.
Hopefully we can get all of the remaining glue work done and everything is uh yeah hopefully everything will be good to go by that by the end of all that. Uh I just took a linear algebra final and I've gotten a total of 7 hours of sleep.
Damn that is that is rough.
Um, I thought I was feeling sleep deprived, but that is like that might be categorically that might be a little bit worse, if not even like categorically worse.
Um, I hope I hope you get to catch up on sleep at some point. It's pretty important.
Um, okay. Where was I?
Status get log. Okay. Yeah. Okay. So, we did some more stuff in here. Uh, what am I looking for? to mir.
Yeah. Okay.
Yeah. Today's today's early. Uh what's up, Ezra? Um yeah, I have somewhere to be at 7 and then working backwards from that. I got that means I probably got to go to the gym around like 5 or so, which means I need to fit in the stream somewhere, which means it's got to be here, unfortunately. So yeah, that is that is kind of a resultant effect of all of this. Last time tomorrow and then I'm home free. Nice.
Yeah. I mean that's that's kind of finals, right?
Like that's that's the life.
It's I don't know. I think school is a lot of just like waiting for stress, right? Like the average case really isn't that bad, but like there are like really bad waves of stress at least.
Yeah, as long as you're like making time for yourself, that's a good thing.
Um, okay. I remember why I didn't do this last time. Um, uh, yeah, we've got a lot of to-dos to look at and a lot of this is just annoying work and I don't really want to do that. So yeah, um let's see how do we make parameters again.
So let's just uh this is Yeah. How did I do this before? Oh no, I don't want live captions. No windows, please.
Just leaving to walk my dog before it rains. Yeah, I feel you. It's like I don't know. The clouds here are like they look like they look like we're on the verge of getting some rain.
Um, what the Sorry, one one of my classes just had one of the funniest one of the funniest comments I've seen in a second.
I I don't think I'm I don't think I should share like class materials, but it's like if you're in if you're team I please review please review team I + 3 mod 16 and I + 5 mod 16 like what are we doing just in the thick of it? Yeah. I mean, the the nice thing is like once once you're through all of it, like you will feel like um you you will feel kind of unstoppable, right? Like anytime you get another course load and like you think it's bad, you like think back to this and you're like, "Damn, I got through that. I can get through this as well."
And it's it's like light work.
Okay, this is this is what we did.
So we want to what type is this? This is a front end type.
So we want to make a new type. This is param type to mir.
And then let's let's actually just yank that line actually.
Yeah. So, we make a variable.
Yeah, we don't need to make a scope for this. I think we probably want to add it to the scope mapping in some way though.
Um, let's see.
This is probably what like the global scope or this would be like scope zero maybe.
So I think yeah I think we should when do we call make params actually yeah so this is before visiting the body so that means this should be in like scope zero.
Uh what part of your school year are you in right now? Um we're past roughly midterms week. Like this is the time when like registration starts picking up.
So, um, yeah, I don't have any exams, so I I have it a little bit late, but we've got like other work to do, so that's kind of that's kind of how it be.
Um, okay, let's let's do all of this stuff. So, we have Pam.
Um, yeah. So, we want to make the alloc and the store Yeah, we want to do that uh for SSA related reasons.
Yeah, so this works.
Uh do I need value mappings and type mappings?
I I forget what I forget what I had.
It's been it's been a second.
Um, okay. So, we have scope binding types.
Duh.
Um, oh man, this is Yeah, this is so messy.
Yeah, we we've got all of the we've got all the visitors. What's up, Aiden?
Wait, so what what do I even What am I doing here? It's I leave the codebase for 3 days and I immediately forget everything I've written.
What am I mapping to? What? Okay, so these are all function stuff. So we don't we don't care about those.
So it's these or this one. It's not an expert, so we don't care. So it's just these two then.
Yeah, we want scope bindings and scope binding types.
So scope bindings.
Oh wait, this needs to be tomire visitor. That thing.
So what what goes into this again? What type is this?
This is Okay. So, we want back for both of these.
So, thankful I did a research masters.
Yeah. Honestly, like at some point I was like, I don't want to write a thesis anymore and I just want to be done. But then I like thought about it more and I was like I don't want to take the classes either. So, like the thesis is definitely the more interesting of the two. Um, also just like research is pretty fun.
I think the biggest thing I learned just from like this past weekend is that like the research community really is just like a bunch of really cool people. And I think like that's kind of the big thing I've been missing from it cuz I don't know. I've kind of like compartmentalized that sort of part of my academics into its own little box.
But I've never really like engaged in it too much beyond just like talking to my adviser and being like I did X thing and then that my adviser is like cool.
So yeah, I think I think that's at least been very rewarding for me at least.
Um, okay. So this is we want pram name to we want an ID here actually. Can we just pram name get value?
Let's paste like that.
So this gets um allocate get and then this gets type right.
What type is this?
Oh man, this is pram type.
And then we have to like clone this thing.
Wait, what?
Oh, get nice. Okay, that that's very clean.
So, we do this and we do this.
Yeah, it it is it definitely has its drawbacks, but I mean I think at least I've been engaging with it a lot less than I should have this whole time.
Uh, wait, let me get food.
One second.
I need to We need to do a little bit of nepotism. Let's figure out what I want to eat.
What is good here? Does anyone know what is good here?
Presumably, presumably I want to lean towards like something chickeny here.
When is the deadline for me to we are getting money through some uh very legal means right now.
Okay, I'll I'll put this on the second monitor so as not to like [ __ ] up the stream. But yeah, I'll just I'll wait for other people.
Uh, what's up? Uh, what's up, Slappy? I am continuing the big rewrite pile.
Studs less as a student unless you're publishing. Yeah, I imagine like it's at least like it's definitely something that like matters a lot less if you're just like if you're just there for the degree and like if you kind of isolate yourself.
Um, but yeah, I think like at the PhD level it starts I would imagine it starts getting a little bit annoying.
There we go. Okay, so this is all cleaned up.
Um, what else do we want to do?
This is fine.
What type is What type is this again?
This is a really ugly pair. Okay. Yeah, there's there's a reason we're doing this like this then actually.
Um what is res supposed to be again? Oh, we want the value.
Um okay. So then here res push back stood move I move pram like that. Okay.
So that looks about right. You'll you deal with other people and things. Yeah.
I mean, it dealing with people kind of sucks, but at the same time, I feel like [snorts] maybe I'm just like really freaking isolated and I like sit in my room all day and like only interact with people like for 3 hours a day, but like it's kind of nice. It's kind of nice talking to people. Like everyone's everyone's so smart honestly. Like Yeah.
Yeah. It I think like the whole check mark-based economy is probably not a good thing, but I don't really see a particular way around it. So that's like Yeah. Although like um one of the professors that I like really looked up to um they were at the they were at the conference yesterday um and like one of the topics that came up was like the PhD experience and like they mentioned that like it was a very check mark based economy. Like in theory, you could just be done with your PhD if your reviewers just immediately signed off on it. Like you could theoretically be done with it, but that's not going to happen ever, right?
So like um one of the things that they mentioned was like the bar to the bar to signing off on everything like goes down substantially if you have something like lined up already for next year, right?
So like um Yeah. So, it's like if like if you present yourself as like, oh yeah, like this is the cool research stuff. This is like the paper I've been working on. Oh, by the way, I also have a job lined up for 3 months later. The the framing goes from like I don't think you're ready yet to like, oh, we got to get you out of here. Let's figure out how to do that.
Uh the chill guy I had during my time doing research was a furry. [laughter] I mean, like, we we joke about this, but like you look at the entire like Rust community and like there's like there's like this whole stereotype and it's like um are you live on Twitch? Um I'm not.
I'm trying to keep everything compartmentalized to YouTube at least cuz I don't really like Twitch as a platform and also like I used to stream like esportsy stuff there. So, it feels a little bit odd to I guess pivot there.
It also just like makes production really annoying because then I have to like figure out how to like dual stream.
Um, and like YouTube lets me I think generate a better platform overall or at least keep a more coherent platform all in one place.
Are you live on Discord? I can be.
Um, I don't I don't make money on Discord though, so I will not be live on Discord.
Maybe I maybe I should make Tik Toks.
Maybe I should do that.
Anyway, that's a that's a future concern for me.
It's very much not like that here really.
Like the attit like I assume you're talking about like the whole attitude towards graduation thing.
Okay, how many to-dos do I have left? We cut out four of them there, so that's good.
Please bleach this. This will not get bleached.
Okay, so we need to figure out how to map basic blocks or at least how to add like edges properly.
Um, yeah, this this seems like something this was something that I struggled with before.
Um, yeah, like cyclical basic block dependencies were very annoying.
Um, or like creating an edge to a basic block that doesn't exist yet was a really big problem.
Yeah. So, the way I managed it before was I made like a mapping from basic blocks to like their successors.
Um, we might still have problems with this though. So I need to figure out how I want to map that.
So we have like function level mappings.
We have like variable level mappings I guess.
Yeah. So these are expert these are like scope related.
Um, okay. Okay, let's do a let's add one more level here which is like basic block level.
I know that like I should not be we should not be unordered mapping everything known to humankind but oh well we will we will deal with this.
What do we even call this? Like basic block to ah what do we even call this?
[sighs] We could do like basic block to ID or something. I don't know. This is like this is getting really awful.
How do you feel about this whole module thing in C++ being bolted on like scavenger run in a movie?
Um, I don't know what you're referring to actually.
Oh, like the new mo the alternative module system.
I like I think I looked at it once, almost threw up, and never looked at it since.
Yeah. Like like what are we doing?
Yeah, I mean like I imagine it's like I imagine a lot of the job stuff is like injust but like um yeah I think it's like the at least the amount of like the threshold that they care about it I think goes down a little bit at least just like perceptually.
Yeah. What are we doing here with modules?
I I think this I think this title is pretty funny.
Yeah. I don't I don't understand the point of this at least.
Anyways, let's move the food to the side.
Um, yeah.
Okay. Anyways, before I before I get sidetracked by food again, I'm going to get back to work here.
Um, let's see.
Okay. Had to What type of food? Um, this type of food.
Actually, I'm hitting order now. There is nothing There is nothing you can do about it.
Um, Let's look at the mules. I'm getting hungry.
Yeah, like it it is the committee, but like if you I don't know if you're like homies of the committee, I think that helps a little bit.
Okay. Anyways, before I before I get far far too far too sidetracked by food again, I'm I'm actually like big and greedy right now. I'm like, "Oh my god, I want to bulk." Um, anyways, so we're trying to map basic blocks here.
Uh, what's up, Jac?
>> Okay. Um, we have this basic block edges resolution thing. We need a way to track basic blocks.
Um, I remember doing this in like my MIR thing. I was not very happy with my MI thing because it was really, really ugly.
Um, yeah, it was it was not good. It was like this this really ugly Yeah, I we had like indices or something. It was so stupid. Um, do not do this when your data structures look like a vector of pair of something to another vector. You know something has gone really wrong.
Um, let's see.
Yeah, I I don't I don't have a great idea for this. Um, cuz basic blocks are like a completely new construct that we've created pretty much.
So, Yeah, I I don't know how to map this properly.
Um, the idea So, we make all the basic blocks and then we like connect them up later cuz some basic blocks don't exist yet when we make the terminators for the previous basic block.
So, we just set them to null and then we update them as we go. Um, maybe we could do like a connect to previous block thing. I don't think there's an instance where we jump ahead.
H, no, we do. We definitely do.
Um, let's see.
Yeah. How do we do this?
H yeah, this is this is a lot harder when I don't have like labels for instance.
I guess the case the case I'm not concerned about is like straight line stuff. The case I'm concerned about is if we have like nested if statements.
So like if And then we have like if bar and then like need to call A here, B here, and then like C here.
And then these all like join up at the same block.
It's like how do we figure out this block at least?
Ghost, you're actually going to make me hungry. Like, this is this is dangerous.
This is super dangerous.
Yeah. How How do I want to connect this?
This doesn't This doesn't seem very fun.
Um, yeah, I'm I'm really struggling here.
If we just had labels, we could like make basic blocks from those labels, but we don't really have labels anymore, which causes a big problem.
Yeah, [laughter] man. Okay. Um, let's see.
Maybe we could like make a stack or something just to store it state temporarily instead of like doing this weird mapping thing.
Um hm.
We could make like we could make a counter and then every time we make a block we connect everything that depended on that block.
But then we don't know the count beforehand. So that causes a problem.
Oh man.
Okay. Let's let's just like figure this out case by case, I think.
Um yeah, we need to we already mapped the function type.
And then is that all of the stuff we need to do mapping here? I think so. Right.
That should all be good.
Yeah, we have function IDs. We have function types. That should be good.
Okay, so those we have to deal with eventually.
Yeah, this is this is really throwing me for a loop actually.
Okay. Um.
Hm.
I guess with the we could start with a return block. I think that's like the most we don't have the we don't make a damn return block yet. Maybe we should make the return block first and then we can like make the blocks in like reverse order almost.
And then we can construct the program back to front almost.
That might actually that might actually work better.
I have to I have to figure out more logistics. One second.
Okay. Anyways, um yeah, I'm sorry. I'm I'm really struggling to figure out what I want to do here. So, this is probably fine.
Um maybe we're maybe reverse order would have been nicer, but I think forward is probably good. Um can you go back and pass the labels on? I don't make labels in the uh at the though is the problem.
uh which is this is kind of one of the things that like having h did I guess resolve a little bit but it just doesn't it doesn't really work here because I don't support labels in the front end proper or in like the um are you working on your own language or are you implementing a compiler for an existing language I am I make it in compiler for C Okay, sorry. I am like I'm getting like super sidetracked. I should I should not be doing that.
Um, yeah, I don't think this this backwards thing really works to be honest.
I guess like h most of these things we can kind of understand like sequentially like we could keep track of like previous block in like a stack or something.
I don't know this is this is really annoying. So um let me just like try to draw out the problem.
So like we have this block here.
So a basic block is like a straight line sequence of instructions if you're not familiar with that. Um the idea is we can like model control flow with these.
And then let's say here we have like a branch, right?
So like this is like an if statement like if something is true then like we go here otherwise we just fall through and then this like directs back there so on and so forth. Um, the problem is we're making these, I guess, in this direction pretty much when reading through the program. So, we we haven't made the next basic block yet, which means we can't like make the pointer to it yet, I guess. Um, so like it it might seem simple to just like keep track of like basic block every time you make one, like link it to the previous, but then you get to like these sorts of control flow structures which cause problems.
Um, yeah.
Yeah, that's that's kind of the big problem I'm running into right now at least.
Yeah, previously I've just been like making these without the edges and then figuring out like the edges at some point in the future, but I don't know how to keep track of that properly.
I really don't want to like index by strings or something. That would be really annoying.
How does LVM manage this again? I know it has like a basic block builder or it has like a IR builder which I think would handle this for it.
Um our our lowering thing is kind of a builder in and of itself. So, I imagine there's some way to abstract it out, but this this is annoying at least.
Um, yeah, this is actually like super super annoying.
Let's maybe we could worry about branching control flow in a second. We could like start by figuring out straight line then maybe or like return at least.
Let's let's just start with a mapping uh from like some sort of number to like basic some sort of basic block.
Yeah, we'll do basic block putter.
Um, we'll just do that. I don't know.
So then crap.
Where where do we make the where do we make the return block? I guess we kind of implicitly make it.
So we can kind of just like make that a zero.
And then we can keep a counter here which is like basic blocks or I guess like cur basic block id.
And then we need to initialize that somewhere. But we'll we'll see if this even like works in theory before making changes in places that I will forget about.
So let's start with start with return.
Slener.
Yeah, let's do it like down here.
So at Yeah, we want the Okay, that maps to the basic block and then we want something to map I guess like actually this should be basic block ids and then we want to map from uh the actual ual instructions that need these.
So, Terminator star to I guess a list of unit 64t and this should be basic block edges potentially.
Um [ __ ] Okay.
So let's do basic block edges at I guess branch get equals zero which will just be the index of the default one.
We'll just do that.
[sighs] Um, yeah. And then we can figure out what to do with make basic block.
Yeah, that'll be that'll be very annoying.
So then yeah, con branch. So this I guess anything with conditional branching is going to be annoying.
So the problem is like we might have recursion which will like be annoying.
So let's let's start with this.
So that should be curve basic block id + one, right? Cuz one of the blocks goes one way and then we need to make the block.
So the the making the block will use up the current ID. So the next one is plus one here.
Um, you need to do this.
Oh man.
Yeah. How do we how do we even do this properly?
We'll just do this. We need that maybe.
Um, yeah. So, we can do that, I guess, to keep that because we're going to be moving this in there.
So then we make this con bird putter after we make the true branch.
I guess the false branch. Oh, that's really annoying.
Yeah, that's really annoying.
That's very annoying.
Respect the grind, bro. Thank you. I am I'm struggling, but I I appreciate it a lot.
Actually, this is this is probably fine.
Um, yes, cuz then the next block is necessarily Yeah, cuz this we visited the body.
So then we can definitely do this.
So that should be current plus one.
Let's just let's also do Uh, let's do this real quick.
So, we do that and then basic block edges or not edges IDs at curve basic block id++.
Yeah. So we want that.
So that maps that maps it to basic block ids and then it increments current basic block id. So with that now we can continue doing this slush.
So um actually We could do it like this.
Um, so we've already made it here. So we can do this.
And then here we've made it. So then we can do this is going to be really ugly. So we can do I we can do a turner operator inside of this because we love we love ugly code here. So, if it has a false branch, then it's the current block.
It's It's going to be the current block anyway, actually, now that I think about it.
Yeah, I But this is like really ugly code at least. So, I don't really like this.
Um, yes, we're writing a to-do to write a comment. This this is the state of affairs in this world. Um, yeah.
Um, so we have con branch. Let's actually just make this like T branch.
We'll just simplify these names a little bit.
Yeah. So, we're going to need that after we make the basic block.
And then this should be null putter for now.
Uh, this should be f branched putter.
Oh, we can't do auto here. God damn it.
Ah, okay. Um, can I just do fashter equals f forget?
Does that work? No, cuz I need cuz auto is not enough here.
Yeah. Okay. So, we have to do that then.
Uh oh, you weren't here for the answer. Um, I am making a compiler for C. So, I'm I'm going from C to X8664 right now.
Okay, let me actually figure out food.
Um, okay. I I actually got to figure this out real quick before I get yelled at.
Let's see.
Let's get a mule.
Oh, let's get that.
Uh Okay, let's I'll just take a screenshot of that.
That will be easier.
Okay. Uh, have you used Bison or Lux during this? Um, I have not, but I'm using a different parser generator. Um, I'm using Pectal because I'm I'm somewhat familiar with it and I don't want to write a parser by hand.
Um, it's it's a template header only uh parser generator.
Um, okay. Anyways, let's let's figure this out for a second.
Yeah. Okay. So, yeah. What is the best way to associate this?
Um, okay. So, we keep the pointer so we can associate this later.
So, this would go at the end here.
I'm fairly sure.
I guess we could put this here as well.
So, false branch put her. Actually, we could just auto here, right? Because we don't care about it outside.
Yeah. So, we can do that.
What am I doing here?
I guess we don't need to. No.
Ah, actually, this is probably fine then. We don't even need this then.
Yeah. So, that should be good. So, that maps the false branch properly to the next block.
Um, but we need let's do the true block real quick.
Let's go that. Or we could even Ah, this sucks. Okay. I I want to do it this way just so I can standardize it a little bit and help readability in a sense.
So we do that that associates.
I'm putting off making an assembler. I yeah, assemblers are hard. Assemblers are really difficult. Um, Pectal is like fine. Um, it's it's been really funny learning that there are features that trivialize very large slots of my code, but yeah, I I would honest I don't even know if I'd suggest it. Honestly, like with parsing, just do whatever you want at this point.
I think that's kind of that's kind of the only way to go about it.
Um, okay. Yeah.
So, this Yeah. So, let's do it this way.
So then uh So then yeah, what do we how do we want to organize this better? I guess this this kind of thing is kind of working.
Uh let's move this up here instead.
Uh so this is con to true this is con to false or cont.
So I guess we don't need to explain it then.
So this we want to push back curve basic block ID.
Sorry. Um okay son this all this all should be fine from here I think.
School project. Oh okay. that that sounds simultaneously better and worse.
If it was like if you were trying to like meet actual spec, I think it'd be miserable. But at the same time, I think it being school like puts a lot of time pressure, right? Like that seems that doesn't seem fun in its own way as well.
Okay. So we have so con to true we have K to whatever else and then this should be or maybe we could is it bad style to like do one big inline comment as well.
Yeah, we can do that.
So that's false to [ __ ] This should be true to [ __ ] Oh, we need to we need to make that as well. It just occurred to me.
Um Oh, we do it here. I see. That's Yeah. Okay, that makes sense actually.
Um, yeah. Okay. This This makes complete sense. So, let's do it like that.
Um, this could also just be this.
Yeah. So, we're going to do that. So, that's consistent.
This is fine. This is fine.
Full tool chain assemb assembler linker and emulator. Oh, wow. Wait, that's that's crazy for a class. That's really cool.
Um, yeah, like damn, I don't think our our compilers class was ever that comprehensive. It's all just like it's all very much backend heavy and a little bit of middle end and like a little bit of front end. Um, how do you find interesting compiler design? Um, I took a class in college and I thought it was cool. Um, it covered like the front end and the back end of a compiler as opposed to like the optimizer, but I still thought it was like really interesting. Um, I thought that it it was cool how it combined like PL stuff along with like system stuff as well as some like software engineering and like um, uh, what's it called? some like theory, algorithms. I think those are all kind of like what makes uh computer science cool for me. So, it was just really cool seeing like a field that I guess included all of that in some in one place.
Okay, so we can get rid of these to-dos now.
Um, yeah, we don't need this anymore.
Yeah. Okay. So, now we need to figure out while we need to figure out how the hell we're going to do this. Uh oh. Yeah, we also need to like wrap up the previous block as well in some way.
I I think we do that. I don't remember if we do though.
I guess we don't need to for if but it matters for these loops at least.
Um yeah so we can do this so you can call that prove.
So this should be con and then this should be I don't know body.
Sure. We we'll call it that.
Um, yeah, we can do that. We can do that.
That can be arranged.
Yeah. And then we start with a clean basic block and then life is good.
Okay. So, let's I think we could start with this at least.
Um or maybe we could do conet cuz I think there's only like or there's two places this could be actually. So we do want conutter.
So cond get do that.
So that's fine.
So con to uh I think this is body.
Yeah. We also want pre to let's actually just write all the comments out real quick.
Actually, we could just do this even.
So, edges at pre get equals this plus one.
Unless we standardized it in some way. I don't think we do like a plus one anywhere else.
Yeah, we should we should probably standardize it then.
Yeah. So, we'll do that.
Yeah. Okay. Nice. And then, yeah, we can do it that way. That cleans up our code a little bit or at least tries to make it a little bit readable.
A little bit more readable.
Um, yeah. So we can do this.
We can make that condition branch.
So we do this.
Um so con to body and then we need to figure out con to K, I guess.
It's probably like here or um Okay. So, this is body to cond.
Yeah. Okay. So, this is like the fall through So this goes to the condition, this goes to the body, this goes back to the condition, and this is the fall through slashcontin.
Okay, so we get rid of these to-dos now.
Um, okay. Let's yank that.
So, she body putter.
So that goes to not that but this is converter.
This should push.
Yeah, we should push this back.
And then this should be [sighs and gasps] uh I guess we could keep a a temporary here.
We can do that.
And this should be con basic block ID.
Yeah. Okay.
This is very messy, but I mean it's it's more manageable than before.
Yeah. Okay. So, now all we need to do is actually like tie the edges together.
And I think I think we should be in a pretty solid state.
Uh, I'm clicking things. Okay.
[sighs] Yeah, I'm tired. Um, let's try to let's try to be brisk with the rest of this.
So, we want to figure out how to resolve all of this.
Now, uh we also need to we need to initialize that in the constructor real quick.
I hit N. So, I lost where I was. That's really annoying.
So, have that cur basic block ID is one because zero is reserved for the return block.
Um, we should probably map that as well real quick.
Which lives in Where does this live? Where does this live again?
It lives here. Okay.
Do we ever close the basic block at all?
Do we even make the We don't even make the return block or make return block.
Um, actually, yeah, this is fine. We can just we can do it in this order.
So, we visit the body. That cleans all of that up.
Um, does it?
No, it doesn't quite actually h actually that doesn't quite that is really annoying cuz we also we do need to like close the block I think.
Yeah.
So, we should we should handle this distinctly from just the visitor.
But we can we can yank all this stuff real quick.
Uh So, let's do that.
And then want to do that maybe. I don't know.
Uh, so we have that and then yeah, I don't even remember how I wanted to close the final thing. I think I think it should just jump to the return block.
Yeah. So, we need to handle this separately.
Uh yeah. And then we should just generate a branch. I believe that's kind of how we want to handle this. I think I think we did this before here though somewhere.
Close dangling block. Yeah. So we just we just go to the we just go here to the return block. Okay. So then, yeah. What do we do here?
Yeah. So, I'm going to do that.
Okay.
So, this is like fine.
And then we clean that up.
And then was there anything else that I'm missing?
I don't think so. I think that's the big thing that we were missing at least.
Um that that cleans up the final block.
So then yeah, what do we what else do we want to do from here? I think this is sufficient.
Yeah, cuz this all all we wanted to do was just close the final block.
Yeah. So then yeah.
Okay. So then we can do this like resolve basic block edges thing.
We can kind of we can even get rid of this. Um what's up parsa? Um are you using WSL? Yes. Um, I'm using WSL instead of like dual booting or like using a proper VM because I'm lazy. Um, I also have a bit of a Valerant addiction. So, we need we need to preserve Valerant, which means I need Windows.
Okay, let's clean this up now. So, then this actually should be a little bit less awful cuz we kind of we kind of associate all the blocks now, which is very nice.
So then for uh let's see how do we want to map this at least.
Yeah. What are what are we doing here?
Yeah. Like this was this was really messy.
because like we had to like translate labels as well. We had to keep track of like a third state. This somehow manages to be less less messy.
So we want um Terminator and edges in basic block edges.
Can I Okay, that's not a thing.
So, we do this. And then for auto edge, I guess ID in edges.
We do something.
So then Terminator or we we could do like a dynamic cast thing like we did in the original.
Yeah. So we did this.
But this is very ugly. So we're going to we're going to take inspiration from this only.
So we'll shorten that.
shorten that.
That should be terminator.
We'll figure out what to do in there in a second. Or actually, we could just do this.
I don't know why we needed these IDs again. I think although I think there is something that I'm forgetting about.
What the hell am I doing here?
Oh, we need to add edges. Oh, okay.
What am I doing here? Why do why did I want to separate this out again? This was very pointless.
What's up, Nash?
This actually makes zero sense why I did it like this. I don't know why I had to check twice.
Yeah, like this should be fine anyways.
Um, so that should be okay. So we want to set successor to basic block ids at uh edges zero I think.
Okay. So, let's do the same same idea here.
We don't need this honestly.
We can do T successor.
Do that.
We can do it like this. Everything should be good.
I still don't know why I separated this out, though. This feels a little bit redundant.
Yeah. Oh, actually, I know why. Cuz we don't have the block itself. Obviously, that that does cause a problem. Yeah.
Um h maybe we could iterate through the blocks instead of doing it like this and that might help actually instead.
Let's let's try it like that. So that way we just loop over it once.
Yeah. So we can loop through that.
Yeah, we we literally have this do that.
Let's make a T.
What's wrong here?
Oh, I see.
Um, so we do that. We can do that, I guess.
Yeah. Okay.
So that kind of cleans that up in a sense. And then we can also uh set successor actually. Yeah, we should we should just do it like this.
So this should be successor, right?
What's wrong here?
Oh, successor ID and then This should also be a putter.
We also need to just change this type, but we'll worry about that in a second.
Um, that's that's like a future problem at least.
Okay. Um, yeah. So we can do basic block ids at uh successor id this can be successor and then basic block and then we can add edge to successor did I okay that's good and then successor get predecessors and we add edge to basic block.
[snorts] Look at that. Okay, so that's actually not that bad surprisingly.
Um, yeah. So, we can do this.
So, we have this. This is Terminator Zero.
Maybe we should make this like a helper H.
Yeah, this is kind of messy.
Um, okay. So, we want I guess like Hol or I guess like add edge.
Let's see.
So, we want T And then we want I think we kind of just want Yeah.
Yeah. So we want Okay. This actually doesn't This doesn't modularize well, which is fine.
Let's just Let's just do it like this.
So this is fine.
So we have this.
So instead of this, this should be true successor ID.
Or maybe we could maybe we can just put this in here and it's fine.
Honestly, it's not the end of the world.
Yeah, I can do that.
Okay. So, we can set true successor to T successor.
Oh, wait. Con branch.
Not that. Okay. So, now we can yink this uh Linux not quite. I'm using WSL which is like it's like a VM but not it's I guess Linux emulation.
This should be one if I can type.
Yes, you are correct.
Okay, this should all be correct now in theory.
And all the to-dos we have left is like stuff that we actually should save as to-do for now.
Okay, so this should be done.
Um, let's see.
What the [ __ ] Okay. Anyways, um, what time did I have to go by? It got pushed back.
It got pushed back. So, I have an hour, which is very nice. Let's Let's keep going. Let's actually try to get this looped into our our stuff now. Um, I'm going to keep this HR directory around for a little bit. H, actually, should I?
Let's get rid of this as well as all these for now. We'll see if that deviously breaks anything.
This will definitely break things. Let's see how much it breaks.
Okay, so let's start with compiler.
So this is in driver compiler.
Um what the Okay, so we got to we got to fix our formatting here because I was that's part of the big rewrite.
So these headers go to the top now.
These stay down here.
This doesn't exist anymore. This should be as to mir.
Yeah. Okay. So that's fine.
And then all the back end stuff is there. Then we have the middle end.
That's all good. Okay. So we don't have this anymore.
Not that anymore.
Okay, we'll just slowly trim stuff out of here.
So, this should just be two mir. This should take as the a instead.
Wait, what?
Oh, lower. That's what we called it.
God damn it. Okay.
Yeah, sure. That that actually makes a lot of sense. Okay. And then the rest of this looks like it's fine.
runner. Oh, we need to Oh, no.
What? Where is this linking in?
Okay, we'll worry about that in a second. I might have just forgotten to implement something somewhere, but that's that's an issue for a couple seconds later.
Yeah. So, we can do that.
Uh, we don't have this anymore.
Okay. We We got to We got to do this by hand.
Okay. And then this doesn't exist anymore.
Um Okay.
Okay. We're still in trouble.
We're still super in trouble.
undefined reference to lower.
Oh no. Oh no.
Are we in Are we in template hell? Is that something that I like messed up somewhere?
Uh, what the unless I like forgot to maybe I messed up the build order.
No, definitely not.
So that's the runner. That's the compiler. Okay.
Not even two mir. That's crazy.
What?
Yeah. Why doesn't this link anymore?
Oh man. Is this something to do with the damn install file? Is that what's going wrong? Let's just add all this real quick. Real quick. Let's also Yeah.
Okay. Um, oh man, I don't want to I don't want to deal with I don't want to deal with Cmake. I really don't want to deal with Cake right now.
Yeah, this is this is not going to be fun.
Yeah. Like what do I even do with this?
I know this all exists. So I think I think something is going wrong in my cmake.
That's really annoying.
I know we did some like really messy stuff here as well.
This Yeah, this this makes little sense at least to me.
What is what is happening here?
Let's look at this. Let's look at this more closely. [sighs] What version are we do we care about? I don't think it matters.
I don't want to I don't want to do CMake. I really don't want to do CMake right now.
Ah, no.
No.
Okay, let's I'm actually just going to throw this into an LM. I really don't want to think about this right now.
So, let's pull up quad.
Uh, I need to I need to change cloud accounts real quick.
Okay, that is me.
Let's see. I think it's AC make issue.
Oh, wait.
Uh, where did what file was this again?
Is this Are we kidding me? Okay.
Are we stupid? Okay, this is not helpful.
Okay. [ __ ] [ __ ] Claude. This is not helpful.
Um, yeah. We're just going to stare at this for a while as well.
Let's see.
What is this? Install targets. When was this added? Deprecated. Okay, great.
Okay, so we want Do I need to install the libraries actually?
Oh, I might need to install the libraries. That's the big thing that I might even be missing, right? No, I Wait, do I do this though?
Yes, I do.
Man, yeah, I don't think Cloud would be able to give context if I'm just pasting it in. So, it's also just like uninteresting to do that.
Yeah. So we are installing everything.
Maybe if we don't do or actually Oh, wait. Okay. Wait.
Yeah, that doesn't make a lot of sense.
I should figure out the distinction at least.
We'll just start the We'll start the overview.
Um, yeah, sure. That makes sense.
Yeah. How does how does that work anyway?
Sure.
That Okay, that makes sense.
Okay, that also makes sense.
Um, yeah, that makes sense.
See, this this makes little sense to me, you know.
I guess maybe I should move this thing over as well.
Was it this that wish? What had the big explainer?
Um, Let's see this mentioned passing it.
Yeah. So, dash prefix. So, we can just do it here in Dary.
So, maybe this will clean it up as well.
Make clean.
Oh, wait. That still doesn't work. Okay.
Wait. So, this isn't even like an install thing anymore.
Yeah. Make build.
Sorry, I'm apologies if I'm not like commentating a lot. I'm just genuinely trying to figure out what's happening here.
Um, yeah. What is going wrong here?
Okay, let's let's look at like pop atom for instance.
Oh, do I need to name space these?
There's no way that's what it is, right?
Oh my god, it is. Why the [ __ ] do these need name space specifiers? So then what's the point of this?
What what is what is the point of this?
Like what? What was the point then if we have to specify anyway?
That's really dumb.
Okay, well that's that's fine. Um or what if we just What if we did this then instead?
Maybe. Yeah, maybe this is the correct way to do it actually.
Yeah, okay. This that makes sense.
Okay, let's try that again.
Okay, so that did not solve anything somehow.
Lower is missing for some reason.
Oh man, what the [ __ ] So, this rewrite thing did not do what I wanted it to.
So, do we still have to What?
Like this should be fine.
We literally do this properly.
What the [ __ ] >> [sighs] >> What the [ __ ] Okay, that's that's so irritating.
So, do I just need to do this then?
That's really annoying.
So, is this literally what I have to do?
It really is.
Are we serious?
That's so stupid. That actually irritates me so much.
I just wanted to d nest this. I don't doesn't um I don't think it's supposed to. Using should just like make it this should just be like name space from here down at least, you know.
Maybe that's fine though.
Yeah, but it should be local to the file. So everything there should resolve properly.
Yeah. So like this this file works perfectly fine.
But then I guess maybe mixing these causes problems or mixing globals.
That seems like what's causing it to break at least.
I was like, why is lower missing?
Do I really have to specify that there?
No. Okay.
So, let's let's fix all of these then, I guess, which is really stupid, but I mean, it seems like it seems like it wants me to do that. So, I mean, what can I say?
So, the C++ files specifically need to have this thing work.
[sighs and gasps] That's really annoying.
So this should fix like some more things.
A this is this is really irritating now.
[sighs] Wait, so why can't I just do that?
Yeah, let's let's put let's I think this is a better question to ask Claude. Why doesn't this why does this result in linker?
Sorry. Ah, let's Oh, wait. That's a thing.
>> [sighs] >> Wait, but we define it in a header.
Sure.
What? What the [ __ ] Wait, what?
This isn't even about inlining.
So why does so given the current header why does the namespace block work but using namespace doesn't mean uh what did I >> [sighs] >> Wow, that's so stupid.
Thanks.
Okay, so I do need the namespace block.
That's so dumb. That's That's actually so irritating to me.
Like we can we cannot be for real here.
I don't know if this is true or not though.
Ah, what?
That's so stupid.
This doesn't even make sense to me.
Okay, here's here's what we're going to do. I wanted to The whole reason I cared about this is to d nest. Um, it's So, we're going to add these back, which is fine. We'll just have to do that real quick.
Let's Let's start with utils.
We're going to change the formatting a little bit, though.
We're going to go back to claim format.
We'll deindent that. There we go.
Uh, we should keep the make file changes, I think, though.
Or we could worry about that in a second.
Okay, we're like slowly working backwards to end up with like just LOVM formatting at this point, which I think is really funny.
Okay, so we'll rewrite these slowly.
I guess this does have the benefit of like fixing our headers as well, so I can't really complain that much.
So we can do that.
That kind of works out.
Huzzah. Okay.
Um, so we'll just do this to be consistent with it.
This is so dumb. This That's actually so dumb. I guess like I'm I'm sure there's like a real reason for it, but like God, that irritates me.
Okay. What am I doing there?
Uh, what's the bridge?
Yeah, this is this is not going great.
So, do I have to like I don't think I've like oversp specified anywhere in there at least.
Definitely not in there. So maybe in here we have problems.
We can do this now, I think.
Sure. Okay, that works.
Um, yeah. Okay, we'll just deal with that.
That's fine.
I'm already getting lazy to type. We're already copying things.
Okay. Um format to do.
See, these were fine, I think.
Yeah, all of these were fine. I think the parser was where we ran into the most issues, though.
Yeah, this this is my life now. This is what I have to do forever.
Um, [sighs and gasps] okay.
We need to we need to do more of this. I think I think this we can keep actually.
I think that is fine because we're just calling that name space.
Yeah. Okay. This is fine.
I I think this level specification is fine here. I think it makes sense for that file specifically.
Uh this Okay, now we get to now we get to have fun. Let me just make sure this is comprehensive. I forgot to format this.
Um this is good.
That's good.
That's fine. That's fine.
That's fine. Okay.
We did all the utils.
Yeah.
Okay.
So now okay the pre-processor we also did so it is just the parser now which this is hell.
Uh yeah we we don't need to qualify that anymore. So this is where we have to start like fixing our our code base.
Okay, that does need to be externed.
Oh, that is a that is a crazy crazy way that works though. That irritates me to no end.
[snorts] Okay. So then name space front end we'll do this again.
I'm sure this is exactly what everyone wanted to see on stream instead of like actual code, you know, because because who who would want to like watch someone actually write a program, you know, instead of dealing with name spaces.
Okay. Um anyway, enough complaining. Uh this is almost done.
One brings the name space to you, the other brings you. Oh, actually when you wear it like that, that makes so much more sense. Wow. Wait.
Wow. Wait, that that actually is I I'm pinning this.
That's actually such a good explanation.
Yeah, it's it's actually like it's actually bars. Holy [ __ ] Okay, so now make build.
Please, please work get value. I forgot what where the hell does this live? Okay, this is an EST instruction.
What?
Wait, am I tripping?
What the Are we serious?
What?
Wait, where? Why is this going wrong?
The are studying this on your own or from school? Um, this is just completely on my own. Um, independent from like research stuff.
This is so mysterious.
Is this Wait.
Oh, wait. We didn't we didn't implement it. Okay. This This is not mysterious anymore. Okay. Um, so this goes here.
What the did I do? Whoa. Oh my god.
Okay.
Okay. So, we can do that.
Let's go back here.
So, this goes up here.
Okay, there we go. First try.
Um, okay.
So, make install.
Okay, that looks like it works.
Oh, I don't want it to install all that. But what? Okay, that's not good.
Okay. Well, we get to figure we get to figure this out next time.
Um, so this is turns out we do need name scopes. That is that is a really good way of thinking about it, though. I'm I'm keeping that. I'm keeping that for future use.
Uh, while we're at it, let's see if we can skip installing some stuff as well.
Specifically, the tests or the test runner at least.
I guess we don't necessarily install it, which is fine then. That's good.
So, what happens if we bring J32 back?
Oh, we already did. Okay, nice.
Fix make file separate install stuff.
Okay. Um, how do we format all again?
Uh, what's up, Mike? Um, I got to head out soon. So, I'm gonna I'm gonna format all and then we're going to call it a day. I think we'll just do this.
Um, let's see. Cuz we have to we have more format rules to enforce across everything, right? This is all source. Okay.
took a nice three-day break. Yeah, I do feel refreshed. And um I also went to a research conference and I said hi to Matt Gladwell. It was really cool. Um Matt, if you're watching this, hello. I don't I wouldn't imagine you are, but yeah.
Okay. Uh what did we do here?
My new format rules.
Okay, I think that is good for now.
Uh, what's up playing? Yeah, God is a fire last name.
Uh, Matt Godbolt, the guy that made this website.
Um, yeah, we'll we'll find out if this passes checks.
I don't speak a lick of C++. Yeah, I mean C++ is not fun. Oh my. More formatting issues.
Are we serious?
This has to be a bug or something. I don't know. Anyway, we'll worry about this next time. Um, is it is Bjorn's book a good place to begin? It probably is. PR is smart. Um, yeah, I got to head out now. Uh, one of my friends is waiting for me. So, yeah.
Um, like the stream, sub to the channel if you haven't. Uh, join the Discord if you haven't. That's in the description.
It's the best place to get pinged when I go live and stay connected with everyone else. Uh, my GitHub is down there as well if you want to add me there. Um, my LinkedIn is down there, although I haven't been on that in a second. I have like 50 connections that I need to like accept, but I'll get around to that. Um, and my GitHub sponsors is there if you want to give me money. Um, yeah, I'm going to go to the gym now and do the rest of the stuff I needed to do at night. Um, take care y'all. Take it easy. And I will see you all tomorrow for real.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Instagram accounts got PWNed
EricParker
13K views•2026-06-03











