Closed germanium32 closed 1 year ago
In opt.cpp
, FPM.addPass()
line style is different from your previous PR: SimplifyCFGPass.
Your test cases looks good to me. I'm curious about using malloc
with small size. This case will be optimized too?
In
opt.cpp
,FPM.addPass()
line style is different from your previous PR: SimplifyCFGPass. Your test cases looks good to me. I'm curious about usingmalloc
with small size. This case will be optimized too?
Thanks, I'll consider consistency of code style.
I'm afraid that malloc instructions will not be optimized. Take a look at the mem2reg.cpp file here. This code only checks for alloca instructions.
However, maybe your idea may be an improvement to this. We can promote mallocs to allocas that requires small(within our threshold) memory.
Clang-formatted files and moved testcases' directory!
Overview
Add Mem2Reg pass, which transforms the program's SSA form by promoting stack-allocated memory (allocated by alloca instructions) to register-allocated memory. This reduces the costly use of stack memory into the use of rather cheap registers. This may cause a temporary problem; since it increases the register pressure, however, this can be handled by the nature of registers.
Implementation
Include llvm/Transforms/Utils/Mem2Reg.h into the opt.cpp file, and add it to the FunctionAnalysisManager in the form of llvm::PromotePass.
Unit tests (Mem2Reg-Test#.ll)