[llvm-dev] Question about a May-alias case

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 13 11:59:39 PDT 2018


On 6/13/2018 5:58 AM, jingu at codeplay.com wrote:
> Hello All,
>
> I have a question about a May-alias case. Let's look at one simple C 
> example.
>
> char *buf[4];
> char c;
> void test(int idx) {
>   char *a = buf[3 - idx];
>   char *b = buf[idx];
>   *a = *b;
>   c++;
>   *a = *b;
> }
>
> We can imagine the second "*a = *b" could be removed.

In general, the second store can't be removed; one or more of the 
pointers in buf could point to c. Not sure what you're trying to show 
with this example.

(On a mostly unrelated note, I think you can remove the first store to 
*a in your testcase, but that doesn't really have anything to do with 
alias analysis.)

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list