[llvm-dev] Does anything depend on reg2mem?

172 views
Skip to first unread message

Russell Wallace via llvm-dev

unread,
Jan 16, 2022, 8:09:57 AM1/16/22
to llvm-dev
According to the documentation,

> This file demotes all registers to memory references. It is intended to be the inverse of mem2reg. By converting to load instructions, the only values live across basic blocks are alloca instructions and load instructions before phi nodes. It is intended that this should make CFG hacking much easier. To make later hacking easier, the entry block is split into two, such that all introduced alloca instructions (and nothing else) are in the entry block.

It does make sense that converting everything back to memory references, would make CFG hacking easier. For example, simplifycfg would have an easier job if it requires reg2mem to have been run first.

Does simplifycfg, or any other pass, actually have a 'reg2mem must have been run first' dependency?

Reid Kleckner via llvm-dev

unread,
Jan 26, 2022, 2:55:31 PM1/26/22
to Russell Wallace, llvm-dev
I looked into this back when we were working on Windows EH around four years ago, and at the time, so far as I could tell, no, nothing depends on reg2mem. I asked Dan Gohman about it at the time, and he said that essentially SSAUpdater was introduced and rolled out across the codebase to address these CFG manipulation use cases properly.

I believe there may exist passes that call into reg2mem helper functions to demote specific values into memory across certain operations such as setjmp, for example. Parts of the code may still be in use, but IMO the pass can be deleted.

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Johannes Doerfert via llvm-dev

unread,
Jan 26, 2022, 4:17:03 PM1/26/22
to Reid Kleckner, Russell Wallace, llvm-dev
The web is full of scripts and descriptions that tell you to run reg2mem.

If we delete it we will get regular emails that things don't work anymore.
That said, if we introduce an alias reg2mem -> SROA, we should be fine.

~ Johannes

Roman Lebedev via llvm-dev

unread,
Jan 26, 2022, 5:01:08 PM1/26/22
to Johannes Doerfert, llvm-dev
On Thu, Jan 27, 2022 at 12:17 AM Johannes Doerfert via llvm-dev
<llvm...@lists.llvm.org> wrote:
>
> The web is full of scripts and descriptions that tell you to run reg2mem.
>
> If we delete it we will get regular emails that things don't work anymore.
> That said, if we introduce an alias reg2mem -> SROA, we should be fine.
Note that reg2mem is an opposite transform to that of SROA/mem2reg.

NACK to the removal, unless we also remove all of the functionality
that said pass uses, otherwise we are just reducing test coverage,

> ~ Johannes
Roman

Johannes Doerfert via llvm-dev

unread,
Jan 26, 2022, 5:03:38 PM1/26/22
to Roman Lebedev, llvm-dev

On 1/26/22 16:00, Roman Lebedev wrote:
> On Thu, Jan 27, 2022 at 12:17 AM Johannes Doerfert via llvm-dev
> <llvm...@lists.llvm.org> wrote:
>> The web is full of scripts and descriptions that tell you to run reg2mem.
>>
>> If we delete it we will get regular emails that things don't work anymore.
>> That said, if we introduce an alias reg2mem -> SROA, we should be fine.
> Note that reg2mem is an opposite transform to that of SROA/mem2reg.

Ups, misread. Need more or less coffee.

Reply all
Reply to author
Forward
0 new messages