[llvm] [Loads] Const correct the Size argument to isSafeToLoadUnconditionally. NFC (PR #96993)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 18:51:36 PDT 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/96993

The APInt is not modified so we should pass by const reference.

>From b55769b4e664612c75dc2261fb728e3aaa9e80ad Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 27 Jun 2024 18:49:55 -0700
Subject: [PATCH] [Loads] Const correct the Size argument to
 isSafeToLoadUnconditionally. NFC

The APInt is not modified so we should pass by const reference.
---
 llvm/include/llvm/Analysis/Loads.h | 2 +-
 llvm/lib/Analysis/Loads.cpp        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/Analysis/Loads.h b/llvm/include/llvm/Analysis/Loads.h
index a8d954b9872d9..6da1c5596b10e 100644
--- a/llvm/include/llvm/Analysis/Loads.h
+++ b/llvm/include/llvm/Analysis/Loads.h
@@ -68,7 +68,7 @@ bool isDereferenceableAndAlignedPointer(const Value *V, Align Alignment,
 /// If it is not obviously safe to load from the specified pointer, we do a
 /// quick local scan of the basic block containing ScanFrom, to determine if
 /// the address is already accessed.
-bool isSafeToLoadUnconditionally(Value *V, Align Alignment, APInt &Size,
+bool isSafeToLoadUnconditionally(Value *V, Align Alignment, const APInt &Size,
                                  const DataLayout &DL,
                                  Instruction *ScanFrom = nullptr,
                                  AssumptionCache *AC = nullptr,
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index b2eb5a96d7d93..1d54a66705a2a 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -349,7 +349,7 @@ bool llvm::isDereferenceableAndAlignedInLoop(LoadInst *LI, Loop *L,
 ///
 /// This uses the pointee type to determine how many bytes need to be safe to
 /// load from the pointer.
-bool llvm::isSafeToLoadUnconditionally(Value *V, Align Alignment, APInt &Size,
+bool llvm::isSafeToLoadUnconditionally(Value *V, Align Alignment, const APInt &Size,
                                        const DataLayout &DL,
                                        Instruction *ScanFrom,
                                        AssumptionCache *AC,



More information about the llvm-commits mailing list