Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于mem2reg的设计思路的猜测 #22

Open
yilin0518 opened this issue May 14, 2024 · 1 comment
Open

关于mem2reg的设计思路的猜测 #22

yilin0518 opened this issue May 14, 2024 · 1 comment

Comments

@yilin0518
Copy link

mem2reg要做的是消除所有的alloca、store、load指令,这是通过首先找到所有alloca指令,记录对应的操作数,并生成一个新的操作数(int寄存器形式),然后遍历所有块,找到一个alloca、store、load指令就替换成move指令。

我的理解是这样的,但是我不清楚“并记录向该地址存取的标量”的意思,而且其实按照助教提供的思路好像load指令不能直接删除,还是需要load指令,因为原先的指令序列中load指令的dst会在后续指令中用到。想问一下上面的理解是否正确。

@bw-S0L
Copy link
Collaborator

bw-S0L commented May 14, 2024

1、mem2reg要做的是消除所有的标量对应的alloca指令,以及相关的store、load指令。数组和其他访存仍需要使用alloca、store、load指令。如何判断,我提供了函数is_mem_variable()
2、“并记录向该地址存取的标量”的意思是,将向该地址进行load,store的操作,全部替换成对该temp进行操作。需要维护一下地址和新temp的映射关系。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants