[PATCH] D97244: [SimplifyCFG] Update passingValueIsAlwaysUndefined to check more attributes

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 16 17:23:52 PDT 2021


aqjune added inline comments.


================
Comment at: llvm/include/llvm/IR/InstrTypes.h:1663
+           paramHasAttr(ArgNo, Attribute::Dereferenceable) ||
+           // dereferenceable implies noundef, and null is a well-defined value.
+           paramHasAttr(ArgNo, Attribute::DereferenceableOrNull);
----------------
Carrot wrote:
> It is not true for "this" parameter. It always has dereferenceable and nonnull attribute, if "this" is not used in the function, passing in undef is no problem.
> 
> It causes wrong code generated for our application.
> passing in undef is no problem

This property holds for `nonnull` and `align`, but not for the three attributes listed here. Passing undef to these is UB because LangRef says violation of these is UB. `dereferenceable` paragraph says:

```
The pointer should be well defined, otherwise it is undefined behavior
```

Is your program being transformed from passing valid `this` to passing `undef` by some pass? Then, the pass is the buggy one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97244



More information about the llvm-commits mailing list