[PATCH] D129660: [IR] Add Instruction::getAfterDefInsertionPoint()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 09:40:53 PDT 2022


nikic created this revision.
nikic added reviewers: spatel, fhahn, efriedma, reames.
Herald added a subscriber: hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Transforms occasionally want to insert an instruction directly after the definition point of a value. This involves quite a few different edge cases, e.g. for phi nodes the next insertion point is not the next instruction, and for invokes and callbrs its not even in the next block. Additionally, the insertion point may not exist at all if catchswitch is involved.

We currently reimplement this logic in a few places, and usually get it wrong in one way or another. I've added two tests to demonstrate issues.

This adds a general Instruction::getAfterDefInsertionPoint() API to reuse the (hopefully correct) logic.


https://reviews.llvm.org/D129660

Files:
  llvm/include/llvm/IR/Instruction.h
  llvm/lib/IR/Instruction.cpp
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Scalar/Reassociate.cpp
  llvm/test/Transforms/InstCombine/freeze.ll
  llvm/test/Transforms/Reassociate/callbr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129660.444309.patch
Type: text/x-patch
Size: 10982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220713/2e074110/attachment.bin>


More information about the llvm-commits mailing list