[PATCH] D58226: [InferAddressSpaces] Prevent crash on nested ConstantExpr

Joey Gouly via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 14 08:00:25 PST 2019


joey added a comment.

Sorry i should have provided more context, this is the original crash:

  opt: ../lib/Transforms/Scalar/InferAddressSpaces.cpp:316: void {anonymous}::InferAddressSpaces::appendsFlatAddressExpressionToPostorderStack(llvm::Value*, std::vector<std::pair<llvm::Value*, bool> >&, llvm::DenseSet<llvm::Value*>&) const: Assertion `V->getType()->isPointerTy()' failed.

I changed the test to use a scalar pointer and still got the same crash.

`appendsFlatAddressExpressionToPostorderStack` gets called with `%add.ptr157` as `V`. Then the it iterates over the operands, and it sees the `select` and `isAddressExpression` returns `true`.

After the `select` is added to `PostorderStack` the loop inside `collectFlatAddressExpressions` calls `getPointerOperands`. In my test case, this returns `i64 73` and then crashes since this is not a pointer.

Maybe `isAddressExpression` should also check if the result of the `select` is a pointer?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58226





More information about the llvm-commits mailing list