[llvm] [SandboxIR] Add utility function to find the base Value for Mem instructions (PR #112030)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 11:38:12 PDT 2024


================
@@ -49,6 +49,16 @@ class Utils {
     return const_cast<Instruction *>(I);
   }
 
+  /// \Returns the base Value for load or store instruction \p LSI.
+  template <typename LoadOrStoreT>
+  static Value *getMemInstructionBase(const LoadOrStoreT *LSI) {
+    static_assert(std::is_same_v<LoadOrStoreT, LoadInst> ||
+                      std::is_same_v<LoadOrStoreT, StoreInst>,
+                  "Expected sandboxir::Load or sandboxir::Store!");
+    return LSI->Ctx.getOrCreateValue(
----------------
Sterling-Augustine wrote:

getUnderlyingObject returns an llvm::Value, getOrCreateValue converts that to a sandboxir::Value.

https://github.com/llvm/llvm-project/pull/112030


More information about the llvm-commits mailing list