[PATCH] D60793: [Evaluator] Walk initial elements when handling load through bitcast
Robert Lougher via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 17 09:53:40 PDT 2019
rob.lougher added a comment.
In D60793#1470376 <https://reviews.llvm.org/D60793#1470376>, @evgeny777 wrote:
> > "MutatedMemory" is only used to hold evaluated store values
>
> It is also used to patch initializers - see `BatchCommitValueTo`
With values from evaluated stores.
>> Using the bitcast as a key would be dangerous
>
> There is no straightforward way to do this in `MutatedMemory` because GEP is a special key type (see BatchCommitValueTo)
> That's why I suggested using another map.
>
>> we could then get different values for the same memory location
>
> How?
union A {
float f;
int i;
};
void s1(union A *u) {
u->i = 123;
}
void s2(union A *u) {
u->f = 1.23;
}
int foo() {
union A u;
s1(&u);
s2(&u);
return u.i;
}
int i = foo();
Input to Global Var Opt:
define dso_local void @_Z2s1P1A(%union.A* %u) #0 {
%i = bitcast %union.A* %u to i32*
store i32 123, i32* %i, align 4, !tbaa !2
ret void
}
define dso_local void @_Z2s2P1A(%union.A* %u) #0 {
%f = bitcast %union.A* %u to float*
store float 0x3FF3AE1480000000, float* %f, align 4, !tbaa !2
ret void
}
define dso_local i32 @_Z3foov() #0 {
%u = alloca %union.A, align 4
%0 = bitcast %union.A* %u to i8*
call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3
call void @_Z2s1P1A(%union.A* %u)
call void @_Z2s2P1A(%union.A* %u)
%i = bitcast %union.A* %u to i32*
%1 = load i32, i32* %i, align 4, !tbaa !2
call void @llvm.lifetime.end.p0i8(i64 4, i8* %0) #3
ret i32 %1
}
Currently both store bitcasts will be replaced by a GEP to the first element, which means the load will get the correct value.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60793/new/
https://reviews.llvm.org/D60793
More information about the llvm-commits
mailing list