[PATCH] D142146: [IR] Avoid creation of GEPs into vectors (in one place)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 02:43:15 PST 2023


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

This change has two effects: First. we will no longer generate GEPs indexing into vectors during transforms. With opaque pointers, the main remaining transform of this kind is the one that canonicalized constant expression GEPs, and which is also the one leading to the miscompile here.

Second, this API is also used to index into constant aggregates based on offsets. For example, I expect that this change will regress operations like "load ptr at offset 4 of `<2 x ptr> <ptr @g, ptr @g>`, because we will now fail to index into the vector constant. Integer/float load folding should still work via the reinterpret load fold (which is, incidentally, the second one involved in the miscompile here, introducing those "padding" bytes). It can probably also negatively affect the global ctor evaluator.

I think overall, those optimization regressions are unlikely to matter (vector of pointer global initializers sound pretty exotic) and this does mitigate an active miscompile, so I'm okay with doing the change. We might want to undo it later, if we change our canonical form for constant GEPs.

So LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142146



More information about the llvm-commits mailing list