[llvm-dev] Memory SSA for this problem?

Alina Sbirlea via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 8 16:54:33 PST 2021


Does Bar have attribute 'read/write none'? Test
MSSA->getMemoryAccess(BarInstruction); and see if there's a MemoryAccess
associated with the instruction.
You should not create an artificial MemoryAccess.

Alina

On Mon, Nov 8, 2021 at 4:36 PM Riyaz Puthiyapurayil <
Riyaz.Puthiyapurayil at synopsys.com> wrote:

> Thanks Alina. This is exactly what I wanted to do. But what would
> “MemoryAccess associated with Bar” be? Notice that in the original code Bar
> (before I rewrite Bar to BarP), Bar didn’t read any memory. It was passed
> %foo (target of load) by value. Do I have to create an artificial memory
> access instruction before calling MemorySSA? Am I missing something here?
>
>
>
> *From:* Alina Sbirlea <alina.sbirlea at gmail.com>
> *Sent:* Monday, November 8, 2021 1:42 PM
> *To:* Riyaz Puthiyapurayil <riyaz at synopsys.com>
> *Cc:* llvm-dev at lists.llvm.org
> *Subject:* Re: [llvm-dev] Memory SSA for this problem?
>
>
>
> Hi Riyaz,
>
>
>
> With MemorySSA you could query clobbering on the G at the Bar callsite
> using the API: `MemoryAccess *getClobberingMemoryAccess(MemoryAccess *MA,
> const MemoryLocation &Loc)`, where MA is "the MemoryAccess associated with
> Bar"->getDefiningAccess() and Loc is the memorylocation defining G.
>
> If the returned clobber access dominates the load, then there are no
> additional clobbering accesses between the load and the call.
>
>
>
> Alina
>
>
>
> On Mon, Nov 8, 2021 at 12:19 PM Riyaz Puthiyapurayil via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
> I am trying to figure what is the best way to do the following in LLVM.
> Specifically wonder if MemorySSA can be used here…any pointers to existing
> code that does something similar will be useful.
>
>
>
> Consider this code:
>
>
>
> %foo = load i256, i256* @G
>
>>
> possible uses of %foo
>
>>
> %bar = call i32 @Bar(i256 %foo)
>
>
>
> Now if I know that there are no writes to @G between the load and the
> call, I would like to convert the call to @Bar to a call to @BarP which
> accepts a pointer to i256:
>
>
>
> %bar = call i32 @BarP(i256* @G)
>
>
>
> How can I check if there are no clobbers of @G between the load and the
> call? @G does not alias with any other memory but there can be writes to @G
> between the above load and the call and if so, the safe thing to do is:
>
>
>
> %foop = alloca i256
>
> store i256 %foo, i256* %foop
>
>>
> %bar = call i32 @BarP(i256* %foop)
>
>
>
> Note that I am trying to avoid creating a copy of %foo on the stack when
> possible.
>
>
>
> The goal here is to keep the wide integer in SSA form (there is
> performance benefit in doing this) but when I have to pass the wide vector
> to a library function, I want to pass its address. Since @G may be a copy
> of %foo, I would like to pass @G instead of creating a temp with alloca
> whenever it is safe to do so. The question is how to check if @G still has
> the same value as %foo.
>
>
>
>
>
> /Riyaz
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> <https://urldefense.com/v3/__https:/lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev__;!!A4F2R9G_pg!IiUsjHksGaaFO5c4V01C4QL4ID-PqtsFYsYkU5Cq60T2sVw0wEw_MR75IaZW6i2n0n8VNxNqwL1o$>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211108/535f7523/attachment-0001.html>


More information about the llvm-dev mailing list