[llvm] [llvm-c] Provide LLVMGetGEPResultElementType (PR #95693)

Vaivaswatha N via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 16 01:48:12 PDT 2024


https://github.com/vaivaswatha created https://github.com/llvm/llvm-project/pull/95693

None

>From 3f98484e97261d7b64dcb14a67a3e6c50d8bbb7d Mon Sep 17 00:00:00 2001
From: Vaivaswatha N <vaivaswatha at users.noreply.github.com>
Date: Sun, 16 Jun 2024 14:16:32 +0530
Subject: [PATCH] [llvm-c] Provide LLVMGetGEPResultElementType

---
 llvm/include/llvm-c/Core.h | 5 +++++
 llvm/lib/IR/Core.cpp       | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 7de99c3a6038d..c7668b4760575 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -3869,6 +3869,11 @@ void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
  */
 LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
 
+/**
+ * Get the result element type of the given GEP operator.
+ */
+LLVMTypeRef LLVMGetGEPResultElementType(LLVMValueRef GEP);
+
 /**
  * @}
  */
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 3a91a4eb6e0d1..5b0a3014e5543 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -3081,6 +3081,10 @@ LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP) {
   return wrap(unwrap<GEPOperator>(GEP)->getSourceElementType());
 }
 
+LLVMTypeRef LLVMGetGEPResultElementType(LLVMValueRef GEP) {
+  return wrap(unwrap<GEPOperator>(GEP)->getResultElementType());
+}
+
 /*--.. Operations on phi nodes .............................................--*/
 
 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,



More information about the llvm-commits mailing list