Reputation: 11
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
Reputation: 34421
As @EJP said, basic blocks contain code. So, even if you create a BB that would contain some alloca
s, 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