[llvm-dev] mem2reg not working in this case?

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Sun Oct 31 11:59:04 PDT 2021



> On Oct 29, 2021, at 9:56 AM, Frank Winter via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> I can't get the alloca in attached function to be promoted to (a) register(s). 
> 
> I try with
> 
> opt -mem2reg < module_eval0.ll
> 
> but the output is unchanged. Using LLVM 13 release.
> 
> Can anyone see why it's not working? Is this too complicated for mem2reg? The alloca is moved to the beginning.. is this the problem?

Mem2reg only supports trivial loads and stores of the alloca.  These noop GEP operations are blocking it:

%14 = getelementptr float, float* %0, i32 0

I’d recommend changing your frontend to not generate them.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211031/8ae48138/attachment.html>


More information about the llvm-dev mailing list