[PATCH] D16942: Add C binding for AllocaInst::getAllocatedType
Amaury SECHET via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 6 01:32:14 PST 2016
deadalnix updated this revision to Diff 47079.
deadalnix added a comment.
Rebase on top of http://reviews.llvm.org/D16912
http://reviews.llvm.org/D16942
Files:
include/llvm-c/Core.h
lib/IR/Core.cpp
tools/llvm-c-test/echo.cpp
Index: tools/llvm-c-test/echo.cpp
===================================================================
--- tools/llvm-c-test/echo.cpp
+++ tools/llvm-c-test/echo.cpp
@@ -306,7 +306,8 @@
break;
}
case LLVMAlloca: {
- LLVMTypeRef Ty = LLVMGetElementType(LLVMTypeOf(Src));
+ LLVMContextRef Ctx = LLVMGetModuleContext(get_module(Builder));
+ LLVMTypeRef Ty = clone_type(LLVMGetAllocatedType(Src), Ctx);
Dst = LLVMBuildAlloca(Builder, Ty, Name);
break;
}
Index: lib/IR/Core.cpp
===================================================================
--- lib/IR/Core.cpp
+++ lib/IR/Core.cpp
@@ -2134,6 +2134,12 @@
return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
}
+/*--.. Operations on alloca instructions (only) ............................--*/
+
+LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca) {
+ return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
+}
+
/*--.. Operations on phi nodes .............................................--*/
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h
+++ include/llvm-c/Core.h
@@ -2506,6 +2506,24 @@
*/
/**
+ * @defgroup LLVMCCoreValueInstructionAlloca Allocas
+ *
+ * Functions in this group only apply to instructions that map to
+ * llvm::Alloca instances.
+ *
+ * @{
+ */
+
+/**
+ * Obtain the type that is being allocated by the alloca instruction.
+ */
+LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
+
+/**
+ * @}
+ */
+
+/**
* @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
*
* Functions in this group only apply to instructions that map to
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16942.47079.patch
Type: text/x-patch
Size: 1752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160206/581c5e92/attachment.bin>
More information about the llvm-commits
mailing list