[PATCH] D20116: Add speculatable function attribute
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 21 15:05:27 PDT 2017
sanjoy added a comment.
I'm okay with this as long as this is allowed only on specific intrinsics (i.e. it cannot be used by external clients, but we //know// that certain intrinsics are speculatable). I don't think we can allow this as generic function attribute, since that allows dead code to affect program behavior. E.g.:
if (false)
puts("hi") speculatable;
which can get transformed to
puts("hi") speculatable;
if (false)
;
The `speculatable` attribute on `puts` is incorrect, but we need to allow such "bogus" IR down dead paths. For instance, the original program could have been:
void do_call(fnptr f, bool is_speculatable) {
if (is_speculatable)
f("hi") speculatable;
else
f("hi");
}
// Later
do_call(puts, false);
https://reviews.llvm.org/D20116
More information about the llvm-commits
mailing list