[llvm] Add interface to check if a call has a deopt bundle (NFC) (PR #91348)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 7 08:38:33 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Aleksandr Popov (aleks-tmb)
<details>
<summary>Changes</summary>
Encapsulate check that a call has a deopt bundle to make it easier to change the deopt scheme.
---
Full diff: https://github.com/llvm/llvm-project/pull/91348.diff
4 Files Affected:
- (modified) llvm/include/llvm/IR/InstrTypes.h (+5)
- (modified) llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp (+1-1)
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+2-2)
- (modified) llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (+1-2)
``````````diff
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index b9af3a6ca42c0..eaade9ce4755f 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -2614,6 +2614,11 @@ class CallBase : public Instruction {
op_iterator populateBundleOperandInfos(ArrayRef<OperandBundleDef> Bundles,
const unsigned BeginIndex);
+ /// Return true if the call has deopt state bundle.
+ bool hasDeoptState() const {
+ return getOperandBundle(LLVMContext::OB_deopt).has_value();
+ }
+
public:
/// Return the BundleOpInfo for the operand at index OpIdx.
///
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 77ee5e645288b..457116a739322 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -2849,7 +2849,7 @@ bool IRTranslator::translateInvoke(const User &U,
return false;
// FIXME: support whatever these are.
- if (I.countOperandBundlesOfType(LLVMContext::OB_deopt))
+ if (I.hasDeoptState())
return false;
// FIXME: support control flow guard targets.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index f47aea29625f6..55aed43070dfb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3357,7 +3357,7 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
break;
}
}
- } else if (I.countOperandBundlesOfType(LLVMContext::OB_deopt)) {
+ } else if (I.hasDeoptState()) {
// Currently we do not lower any intrinsic calls with deopt operand bundles.
// Eventually we will support lowering the @llvm.experimental.deoptimize
// intrinsic, and right now there are no plans to support other intrinsics
@@ -9197,7 +9197,7 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
SDValue Callee = getValue(I.getCalledOperand());
- if (I.countOperandBundlesOfType(LLVMContext::OB_deopt))
+ if (I.hasDeoptState())
LowerCallSiteWithDeoptBundle(&I, Callee, nullptr);
else
// Check if we can potentially perform a tail call. More detailed checking
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 286273c897aac..858e54c4a9bc2 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -3046,8 +3046,7 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F, DominatorTree &DT,
// which doesn't know how to produce a proper deopt state. So if we see a
// non-leaf memcpy/memmove without deopt state just treat it as a leaf
// copy and don't produce a statepoint.
- if (!AllowStatepointWithNoDeoptInfo &&
- !Call->getOperandBundle(LLVMContext::OB_deopt)) {
+ if (!AllowStatepointWithNoDeoptInfo && !Call->hasDeoptState()) {
assert((isa<AtomicMemCpyInst>(Call) || isa<AtomicMemMoveInst>(Call)) &&
"Don't expect any other calls here!");
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/91348
More information about the llvm-commits
mailing list