[PATCH] D61652: [LangRef][Attr] Clarify dereferenceable(_in_scope)

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 21:06:31 PDT 2019


sanjoy added inline comments.


================
Comment at: llvm/docs/LangRef.rst:1164
+
+``dereferenceable_in_scope(<n>)``
+    This indicates that the annotated pointer value has the
----------------
I'm not sure if this is a good semantic property.  Consider (the CFG form of):

```
if (cond) {
  a = dereferenceable_in_scope(4) ...
} else {
  ...
}
side_effect_that_frees_a()
```

I think this program above is well defined because the definition of `a` does not dominate `side_effect_that_frees_a()`.  But that means we can't tail duplicate the program into:

```
if (cond) {
  a = dereferenceable_in_scope(4) ...
  side_effect_that_frees_a()
} else {
  ...
  side_effect_that_frees_a()
}
```

Same applies for inlining.  Any transform that can extend the dominance region of some value needs to be audited.

What is the use case for this attribute?  Can we do something more targeted for this use case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61652/new/

https://reviews.llvm.org/D61652





More information about the llvm-commits mailing list