This is an archive of the discontinued LLVM Phabricator instance.

Handle accesses to sturctures with embedded arrays and different offsets better
AbandonedPublic

Authored by dberlin on Mar 20 2015, 11:11 AM.

Details

Reviewers
nlewycky
hfinkel
Summary

Fixes the simple testcase:
struct S00 {

char mC_0;
short mS_1;
int mI_2;
int mI_3;

};
struct S03 {

short mS_0;
struct S00 mS00_1[4];
short mS_2;

};
int test_s03c(struct S03* a, struct S03* b)
{

a->mS00_1[0].mI_2=1;
b->mS00_1[1].mI_2=2;
return a->mS00_1[0].mI_2;

}

so that we return 1.

Diff Detail

Event Timeline

dberlin retitled this revision from to Handle accesses to sturctures with embedded arrays and different offsets better.
dberlin updated this object.
dberlin edited the test plan for this revision. (Show Details)
dberlin added reviewers: hfinkel, nlewycky.
dberlin added a subscriber: Unknown Object (MLST).
  • Update borked comment
dberlin added inline comments.Mar 20 2015, 11:18 AM
lib/Analysis/BasicAliasAnalysis.cpp
1072

Technically, the check should be "if the variable indices are equal, or we can prove they can't have values that make offset, size overlap when they wouldn't otherwise".

In particular, if we could prove the the variable indices are always 0 or positive, they can't overlap.

Sadly, we don't have range info in BasicAA to use, and this check is already strictly better than what we have now.

nlewycky added inline comments.Mar 20 2015, 11:41 AM
lib/Analysis/BasicAliasAnalysis.cpp
979

I really don't understand this comment, either from "actual" or "reason about the offsets directly".

Looking at the uses, I don't see any reason not to use llvm::isIdentifiedObject. I think what you need to know is that [V, V+Offset] does not overlap any other object. isIdentifiedObject should be sufficient for that.

983

What about GlobalAlias? GlobalAlias isa GlobalValue.

1063

Full stop after "alias".

1069

Extra space between "both" and "arguments".

1069

Tense agreement between "arguments" and "global variable" and "alloca".

1070

Full stop after "alias".

test/Analysis/BasicAA/gep-alias.ll
235

But they can, I just need to call @test13 with %a = %b + 13 . Did you mean to check whether arguments are noalias?

%6 is %b+17 (aka gep %5, i32 0, i32 1, i32 2)
%10 loads %a+5 (aka gep %a, i32 0, i32 1, i32 0, i32 2)

[I assume one byte of padding in %struct.S00 after the i16.]

236

Full stop after "alias".

ab added a subscriber: ab.Mar 20 2015, 2:33 PM
dberlin abandoned this revision.Jul 6 2016, 9:24 PM