1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Add C binding for AllocaInst::getAllocatedType

Summary:
Comes with an awesome test.

Depends on D16912

Reviewers: bogner, chandlerc, echristo, dblaikie, joker.eph, Wallbraker

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D16942

llvm-svn: 260313
This commit is contained in:
Amaury Sechet 2016-02-09 22:50:53 +00:00
parent 54e8749794
commit d4ff40d570
3 changed files with 26 additions and 1 deletions

View File

@ -2501,6 +2501,24 @@ void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
*/
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueInstructionAlloca Allocas
*
* Functions in this group only apply to instructions that map to
* llvm::AllocaInst instances.
*
* @{
*/
/**
* Obtain the type that is being allocated by the alloca instruction.
*/
LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
/**
* @}
*/

View File

@ -2134,6 +2134,12 @@ LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch) {
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,

View File

@ -306,7 +306,8 @@ struct FunCloner {
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;
}