[llvm] 14947cc - [IR] Handle assume intrinsics in hasClobberingOperandBundle()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 23 01:27:11 PDT 2022
Author: Nikita Popov
Date: 2022-09-23T10:26:58+02:00
New Revision: 14947cc4cd1a2a57a4d2728e8bab0daa60023440
URL: https://github.com/llvm/llvm-project/commit/14947cc4cd1a2a57a4d2728e8bab0daa60023440
DIFF: https://github.com/llvm/llvm-project/commit/14947cc4cd1a2a57a4d2728e8bab0daa60023440.diff
LOG: [IR] Handle assume intrinsics in hasClobberingOperandBundle()
Operand bundles on assumes do not read or write -- we correctly
modelled the read side of this, but not the write side. In practice
this did not matter because of how the method is used, but this
will become relevant for a future patch.
Added:
Modified:
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/IR/Instructions.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 67d4a8c5b9568..dc46c8a43c8b5 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -2075,21 +2075,7 @@ class CallBase : public Instruction {
/// Return true if this operand bundle user has operand bundles that
/// may write to the heap.
- bool hasClobberingOperandBundles() const {
- for (const auto &BOI : bundle_op_infos()) {
- if (BOI.Tag->second == LLVMContext::OB_deopt ||
- BOI.Tag->second == LLVMContext::OB_funclet ||
- BOI.Tag->second == LLVMContext::OB_ptrauth ||
- BOI.Tag->second == LLVMContext::OB_kcfi)
- continue;
-
- // This instruction has an operand bundle that is not known to us.
- // Assume the worst.
- return true;
- }
-
- return false;
- }
+ bool hasClobberingOperandBundles() const;
/// Return true if the bundle operand at index \p OpIdx has the
/// attribute \p A.
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 861a0628bb188..f3bcd5322f6a5 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -511,6 +511,13 @@ bool CallBase::hasReadingOperandBundles() const {
getIntrinsicID() != Intrinsic::assume;
}
+bool CallBase::hasClobberingOperandBundles() const {
+ return hasOperandBundlesOtherThan(
+ {LLVMContext::OB_deopt, LLVMContext::OB_funclet,
+ LLVMContext::OB_ptrauth, LLVMContext::OB_kcfi}) &&
+ getIntrinsicID() != Intrinsic::assume;
+}
+
//===----------------------------------------------------------------------===//
// CallInst Implementation
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list