user1091
user1091

Reputation: 11

Global variables and basic blocks

I want to support global variables in my tiny compiler. Do I need to make a "global" basic block which would hold all other basic blocks and global variables, or I can keep global variables outside?

Upvotes: 0

Views: 183

Answers (1)

arrowd
arrowd

Reputation: 34421

As @EJP said, basic blocks contain code. So, even if you create a BB that would contain some allocas, you would need to wrap this into a function first, and thus, these variables would become local variables of that function.

So, if you want global variables, read appropriate reference section for description of how it works.

Upvotes: 4

Related Questions