[llvm] 06dfc84 - [Local] Mark Instruction argument of wouldInstructionBeTriviallyDead as const. NFC.
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 01:08:00 PDT 2023
Author: Serguei Katkov
Date: 2023-08-14T14:49:51+07:00
New Revision: 06dfc8400d2b87c77f9d445be61ab85eeb293dd4
URL: https://github.com/llvm/llvm-project/commit/06dfc8400d2b87c77f9d445be61ab85eeb293dd4
DIFF: https://github.com/llvm/llvm-project/commit/06dfc8400d2b87c77f9d445be61ab85eeb293dd4.diff
LOG: [Local] Mark Instruction argument of wouldInstructionBeTriviallyDead as const. NFC.
wouldInstructionBeTriviallyDead is not expected to modify instruction,
so mark argument as const to allow its usage in other non-modifying instructions callers.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D157834
Added:
Modified:
llvm/include/llvm/Analysis/AssumeBundleQueries.h
llvm/include/llvm/Transforms/Utils/Local.h
llvm/lib/Analysis/AssumeBundleQueries.cpp
llvm/lib/Transforms/Utils/Local.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/AssumeBundleQueries.h b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
index b3f499faa14edc..df54fd2e9d655d 100644
--- a/llvm/include/llvm/Analysis/AssumeBundleQueries.h
+++ b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
@@ -142,7 +142,7 @@ constexpr StringRef IgnoreBundleTag = "ignore";
///
/// the argument to the call of llvm.assume may still be useful even if the
/// function returned true.
-bool isAssumeWithEmptyBundle(AssumeInst &Assume);
+bool isAssumeWithEmptyBundle(const AssumeInst &Assume);
/// Return a valid Knowledge associated to the Use U if its Attribute kind is
/// in AttrKinds.
diff --git a/llvm/include/llvm/Transforms/Utils/Local.h b/llvm/include/llvm/Transforms/Utils/Local.h
index 4578af069814d0..56db5facb51822 100644
--- a/llvm/include/llvm/Transforms/Utils/Local.h
+++ b/llvm/include/llvm/Transforms/Utils/Local.h
@@ -76,7 +76,7 @@ bool isInstructionTriviallyDead(Instruction *I,
/// Return true if the result produced by the instruction would have no side
/// effects if it was not used. This is equivalent to checking whether
/// isInstructionTriviallyDead would be true if the use count was 0.
-bool wouldInstructionBeTriviallyDead(Instruction *I,
+bool wouldInstructionBeTriviallyDead(const Instruction *I,
const TargetLibraryInfo *TLI = nullptr);
/// Return true if the result produced by the instruction has no side effects on
diff --git a/llvm/lib/Analysis/AssumeBundleQueries.cpp b/llvm/lib/Analysis/AssumeBundleQueries.cpp
index 7440dbd29ccffa..7c6a7bad33b5c9 100644
--- a/llvm/lib/Analysis/AssumeBundleQueries.cpp
+++ b/llvm/lib/Analysis/AssumeBundleQueries.cpp
@@ -122,7 +122,7 @@ RetainedKnowledge llvm::getKnowledgeFromOperandInAssume(AssumeInst &Assume,
return getKnowledgeFromBundle(Assume, BOI);
}
-bool llvm::isAssumeWithEmptyBundle(AssumeInst &Assume) {
+bool llvm::isAssumeWithEmptyBundle(const AssumeInst &Assume) {
return none_of(Assume.bundle_op_infos(),
[](const CallBase::BundleOpInfo &BOI) {
return BOI.Tag->getKey() != IgnoreBundleTag;
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index ff1facb3d797e4..bda67022c14802 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -414,7 +414,7 @@ bool llvm::wouldInstructionBeTriviallyDeadOnUnusedPaths(
return wouldInstructionBeTriviallyDead(I, TLI);
}
-bool llvm::wouldInstructionBeTriviallyDead(Instruction *I,
+bool llvm::wouldInstructionBeTriviallyDead(const Instruction *I,
const TargetLibraryInfo *TLI) {
if (I->isTerminator())
return false;
@@ -428,7 +428,7 @@ bool llvm::wouldInstructionBeTriviallyDead(Instruction *I,
if (isa<DbgVariableIntrinsic>(I))
return false;
- if (DbgLabelInst *DLI = dyn_cast<DbgLabelInst>(I)) {
+ if (const DbgLabelInst *DLI = dyn_cast<DbgLabelInst>(I)) {
if (DLI->getLabel())
return false;
return true;
@@ -461,7 +461,7 @@ bool llvm::wouldInstructionBeTriviallyDead(Instruction *I,
// Special case intrinsics that "may have side effects" but can be deleted
// when dead.
- if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
+ if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
// Safe to delete llvm.stacksave and launder.invariant.group if dead.
if (II->getIntrinsicID() == Intrinsic::stacksave ||
II->getIntrinsicID() == Intrinsic::launder_invariant_group)
More information about the llvm-commits
mailing list