refactor and differentiate local and global allocations during code generation