[PATCH] D18738: Add new !unconditionally_dereferenceable load instruction metadata
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 3 11:47:52 PDT 2016
sanjoy added a comment.
I haven't done a full review, but one aspect of this change worries me
at a theoretical level -- after this change it is possible to cause
miscompiles by introducing dynamically dead code.
E.g. if we have
void @foo() {
%t = alloca i32*
}
and say we change it to
void @foo() {
%t = alloca i32*
if (false) {
%ptr = load i32*, i32** %t, !unconditionally_dereferenceable
%val = load i32, i32* %ptr
}
}
In theory the second program should be equivalent to the first, since
only dynamically dead code was added (that would never execute at
runtime). But, given the semantics of the
`!unconditionally_dereferenceable` attribute, I can further transform
the program to
void @foo() {
%t = alloca i32*
%ptr = load i32*, i32** %t, !unconditionally_dereferenceable
;; allocas are always dereferenceable
%val = load i32, i32* %ptr
;; load from unconditionally dereferenceable value
if (false) {
}
}
which would has undefined behavior.
Is there a way you can change the semantics of this attribute so that
one of the above transforms isn't possible?
Repository:
rL LLVM
http://reviews.llvm.org/D18738
More information about the llvm-commits
mailing list