[llvm] [CodeGen] Merge lowerConstantIntrinsics into pre-isel lowering (PR #97727)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 4 06:30:42 PDT 2024
================
@@ -66,6 +71,27 @@ struct PreISelIntrinsicLowering {
} // namespace
+template <class T>
+static bool forEachCall(Function &Intrin, T Callback) {
+ // Lowering all intrinsics in a function will delete multiple uses, so we
+ // can't use an early-inc-range. In case some remain, we don't want to look
+ // at them again. Unfortunately, Value::UseList is private, so we can't use a
+ // simple Use**. If LastUse is null, we the next use to consider is
+ // Intrin.use_begin(), otherwise it's LastUse->getNext().
+ Use *LastUse = nullptr;
+ bool Changed = false;
+ while (!Intrin.use_empty() && (!LastUse || LastUse->getNext())) {
+ Use *U = LastUse ? LastUse->getNext() : &*Intrin.use_begin();
+ bool Removed = false;
+ auto CI = dyn_cast<CallInst>(U->getUser());
+ if (CI && CI->getCalledOperand() == &Intrin)
----------------
jayfoad wrote:
These conditions should always be true. The IR verifier checks that.
https://github.com/llvm/llvm-project/pull/97727
More information about the llvm-commits
mailing list