[Scalarizer] Do not insert instructions between PHI nodes and debug intrinsics.
authorDaniele Vettorel <dvet@google.com>
Tue, 2 Nov 2021 13:52:46 +0000 (09:52 -0400)
committerJakub Kuderski <kubak@google.com>
Tue, 2 Nov 2021 13:53:59 +0000 (09:53 -0400)
commit67887b0f81aca71026a36b42d9ca4189f881862c
tree96ca9c82ba2d18d86924b36aec3d302b288ddee6
parent95a6d3e831e10dfec33170ab71c8995f302cc286
[Scalarizer] Do not insert instructions between PHI nodes and debug intrinsics.

The scalarizer pass seems to be inserting instructions in-between PHI nodes or debug intrinsics that end up staying at the end of the pass, resulting in malformed IR and violating assumptions.

This patch adds a check to make sure the `extractelement` instructions that it adds are correctly placed after all PHI nodes and debug intrinsics.

Patch by vettoreldaniele.

Reviewed By: bjope

Differential Revision: https://reviews.llvm.org/D112472
llvm/lib/Transforms/Scalar/Scalarizer.cpp
llvm/test/Transforms/Scalarizer/dbg-invariant.ll [new file with mode: 0644]
llvm/test/Transforms/Scalarizer/phi-order.ll [new file with mode: 0644]