forked from OSchip/llvm-project
[opaque pointer types] Update calls to CreateCall to pass the function
type in lldb and polly. llvm-svn: 353549
This commit is contained in:
parent
d7047276ec
commit
ae2f951219
|
@ -254,7 +254,7 @@ protected:
|
||||||
/// @return
|
/// @return
|
||||||
/// The function pointer, for use in a CallInst.
|
/// The function pointer, for use in a CallInst.
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
llvm::Value *BuildPointerValidatorFunc(lldb::addr_t start_address) {
|
llvm::FunctionCallee BuildPointerValidatorFunc(lldb::addr_t start_address) {
|
||||||
llvm::Type *param_array[1];
|
llvm::Type *param_array[1];
|
||||||
|
|
||||||
param_array[0] = const_cast<llvm::PointerType *>(GetI8PtrTy());
|
param_array[0] = const_cast<llvm::PointerType *>(GetI8PtrTy());
|
||||||
|
@ -266,7 +266,7 @@ protected:
|
||||||
PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
|
PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
|
||||||
Constant *fun_addr_int =
|
Constant *fun_addr_int =
|
||||||
ConstantInt::get(GetIntptrTy(), start_address, false);
|
ConstantInt::get(GetIntptrTy(), start_address, false);
|
||||||
return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
|
return {fun_ty, ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty)};
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
@ -279,7 +279,7 @@ protected:
|
||||||
/// @return
|
/// @return
|
||||||
/// The function pointer, for use in a CallInst.
|
/// The function pointer, for use in a CallInst.
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
llvm::Value *BuildObjectCheckerFunc(lldb::addr_t start_address) {
|
llvm::FunctionCallee BuildObjectCheckerFunc(lldb::addr_t start_address) {
|
||||||
llvm::Type *param_array[2];
|
llvm::Type *param_array[2];
|
||||||
|
|
||||||
param_array[0] = const_cast<llvm::PointerType *>(GetI8PtrTy());
|
param_array[0] = const_cast<llvm::PointerType *>(GetI8PtrTy());
|
||||||
|
@ -292,7 +292,7 @@ protected:
|
||||||
PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
|
PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
|
||||||
Constant *fun_addr_int =
|
Constant *fun_addr_int =
|
||||||
ConstantInt::get(GetIntptrTy(), start_address, false);
|
ConstantInt::get(GetIntptrTy(), start_address, false);
|
||||||
return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
|
return {fun_ty, ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty)};
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerType *GetI8PtrTy() {
|
PointerType *GetI8PtrTy() {
|
||||||
|
@ -382,7 +382,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
llvm::Value *m_valid_pointer_check_func;
|
llvm::FunctionCallee m_valid_pointer_check_func;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjcObjectChecker : public Instrumenter {
|
class ObjcObjectChecker : public Instrumenter {
|
||||||
|
@ -544,7 +544,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
llvm::Value *m_objc_object_check_func;
|
llvm::FunctionCallee m_objc_object_check_func;
|
||||||
};
|
};
|
||||||
|
|
||||||
IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions,
|
IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions,
|
||||||
|
|
|
@ -477,15 +477,15 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
|
||||||
|
|
||||||
ArrayRef<Type *> CFSCWB_arg_types(arg_type_array, 5);
|
ArrayRef<Type *> CFSCWB_arg_types(arg_type_array, 5);
|
||||||
|
|
||||||
llvm::Type *CFSCWB_ty =
|
llvm::FunctionType *CFSCWB_ty =
|
||||||
FunctionType::get(ns_str_ty, CFSCWB_arg_types, false);
|
FunctionType::get(ns_str_ty, CFSCWB_arg_types, false);
|
||||||
|
|
||||||
// Build the constant containing the pointer to the function
|
// Build the constant containing the pointer to the function
|
||||||
PointerType *CFSCWB_ptr_ty = PointerType::getUnqual(CFSCWB_ty);
|
PointerType *CFSCWB_ptr_ty = PointerType::getUnqual(CFSCWB_ty);
|
||||||
Constant *CFSCWB_addr_int =
|
Constant *CFSCWB_addr_int =
|
||||||
ConstantInt::get(m_intptr_ty, CFStringCreateWithBytes_addr, false);
|
ConstantInt::get(m_intptr_ty, CFStringCreateWithBytes_addr, false);
|
||||||
m_CFStringCreateWithBytes =
|
m_CFStringCreateWithBytes = {
|
||||||
ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty);
|
CFSCWB_ty, ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty)};
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantDataSequential *string_array = NULL;
|
ConstantDataSequential *string_array = NULL;
|
||||||
|
@ -880,14 +880,15 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
|
||||||
|
|
||||||
ArrayRef<Type *> srN_arg_types(type_array, 1);
|
ArrayRef<Type *> srN_arg_types(type_array, 1);
|
||||||
|
|
||||||
llvm::Type *srN_type =
|
llvm::FunctionType *srN_type =
|
||||||
FunctionType::get(sel_ptr_type, srN_arg_types, false);
|
FunctionType::get(sel_ptr_type, srN_arg_types, false);
|
||||||
|
|
||||||
// Build the constant containing the pointer to the function
|
// Build the constant containing the pointer to the function
|
||||||
PointerType *srN_ptr_ty = PointerType::getUnqual(srN_type);
|
PointerType *srN_ptr_ty = PointerType::getUnqual(srN_type);
|
||||||
Constant *srN_addr_int =
|
Constant *srN_addr_int =
|
||||||
ConstantInt::get(m_intptr_ty, sel_registerName_addr, false);
|
ConstantInt::get(m_intptr_ty, sel_registerName_addr, false);
|
||||||
m_sel_registerName = ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty);
|
m_sel_registerName = {srN_type,
|
||||||
|
ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty)};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *argument_array[1];
|
Value *argument_array[1];
|
||||||
|
@ -1042,14 +1043,15 @@ bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) {
|
||||||
|
|
||||||
ArrayRef<Type *> ogC_arg_types(type_array, 1);
|
ArrayRef<Type *> ogC_arg_types(type_array, 1);
|
||||||
|
|
||||||
llvm::Type *ogC_type =
|
llvm::FunctionType *ogC_type =
|
||||||
FunctionType::get(class_type, ogC_arg_types, false);
|
FunctionType::get(class_type, ogC_arg_types, false);
|
||||||
|
|
||||||
// Build the constant containing the pointer to the function
|
// Build the constant containing the pointer to the function
|
||||||
PointerType *ogC_ptr_ty = PointerType::getUnqual(ogC_type);
|
PointerType *ogC_ptr_ty = PointerType::getUnqual(ogC_type);
|
||||||
Constant *ogC_addr_int =
|
Constant *ogC_addr_int =
|
||||||
ConstantInt::get(m_intptr_ty, objc_getClass_addr, false);
|
ConstantInt::get(m_intptr_ty, objc_getClass_addr, false);
|
||||||
m_objc_getClass = ConstantExpr::getIntToPtr(ogC_addr_int, ogC_ptr_ty);
|
m_objc_getClass = {ogC_type,
|
||||||
|
ConstantExpr::getIntToPtr(ogC_addr_int, ogC_ptr_ty)};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *argument_array[1];
|
Value *argument_array[1];
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "lldb/Utility/Stream.h"
|
#include "lldb/Utility/Stream.h"
|
||||||
#include "lldb/Utility/StreamString.h"
|
#include "lldb/Utility/StreamString.h"
|
||||||
#include "lldb/lldb-public.h"
|
#include "lldb/lldb-public.h"
|
||||||
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -30,11 +31,9 @@ class Function;
|
||||||
class GlobalValue;
|
class GlobalValue;
|
||||||
class GlobalVariable;
|
class GlobalVariable;
|
||||||
class Instruction;
|
class Instruction;
|
||||||
class IntegerType;
|
|
||||||
class Module;
|
class Module;
|
||||||
class StoreInst;
|
class StoreInst;
|
||||||
class DataLayout;
|
class DataLayout;
|
||||||
class Type;
|
|
||||||
class Value;
|
class Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,18 +555,16 @@ private:
|
||||||
///module.
|
///module.
|
||||||
lldb_private::ClangExpressionDeclMap
|
lldb_private::ClangExpressionDeclMap
|
||||||
*m_decl_map; ///< The DeclMap containing the Decls
|
*m_decl_map; ///< The DeclMap containing the Decls
|
||||||
llvm::Constant *m_CFStringCreateWithBytes; ///< The address of the function
|
llvm::FunctionCallee
|
||||||
///CFStringCreateWithBytes, cast to
|
m_CFStringCreateWithBytes; ///< The address of the function
|
||||||
///the
|
/// CFStringCreateWithBytes, cast to the
|
||||||
/// appropriate function pointer type
|
/// appropriate function pointer type
|
||||||
llvm::Constant *m_sel_registerName; ///< The address of the function
|
llvm::FunctionCallee m_sel_registerName; ///< The address of the function
|
||||||
///sel_registerName, cast to the
|
/// sel_registerName, cast to the
|
||||||
///appropriate
|
/// appropriate function pointer type
|
||||||
/// function pointer type
|
llvm::FunctionCallee m_objc_getClass; ///< The address of the function
|
||||||
llvm::Constant *m_objc_getClass; ///< The address of the function
|
/// objc_getClass, cast to the
|
||||||
///objc_getClass, cast to the
|
/// appropriate function pointer type
|
||||||
///appropriate
|
|
||||||
/// function pointer type
|
|
||||||
llvm::IntegerType
|
llvm::IntegerType
|
||||||
*m_intptr_ty; ///< The type of an integer large enough to hold a pointer.
|
*m_intptr_ty; ///< The type of an integer large enough to hold a pointer.
|
||||||
lldb_private::Stream
|
lldb_private::Stream
|
||||||
|
|
|
@ -192,8 +192,9 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
|
||||||
llvm::LoadInst *new_func_addr_load =
|
llvm::LoadInst *new_func_addr_load =
|
||||||
new llvm::LoadInst(new_func_ptr, "load_func_pointer", call_inst);
|
new llvm::LoadInst(new_func_ptr, "load_func_pointer", call_inst);
|
||||||
// and create a callinstruction from it
|
// and create a callinstruction from it
|
||||||
llvm::CallInst *new_call_inst = llvm::CallInst::Create(
|
llvm::CallInst *new_call_inst =
|
||||||
new_func_addr_load, new_call_args, "new_func_call", call_inst);
|
llvm::CallInst::Create(new_func_type, new_func_addr_load, new_call_args,
|
||||||
|
"new_func_call", call_inst);
|
||||||
new_call_inst->setCallingConv(call_inst->getCallingConv());
|
new_call_inst->setCallingConv(call_inst->getCallingConv());
|
||||||
new_call_inst->setTailCall(call_inst->isTailCall());
|
new_call_inst->setTailCall(call_inst->isTailCall());
|
||||||
llvm::LoadInst *lldb_save_result_address =
|
llvm::LoadInst *lldb_save_result_address =
|
||||||
|
|
|
@ -310,7 +310,8 @@ static void rewriteAllocaAsManagedMemory(AllocaInst *Alloca,
|
||||||
PollyIRBuilder Builder(M->getContext());
|
PollyIRBuilder Builder(M->getContext());
|
||||||
Builder.SetInsertPoint(Alloca);
|
Builder.SetInsertPoint(Alloca);
|
||||||
|
|
||||||
Value *MallocManagedFn = getOrCreatePollyMallocManaged(*Alloca->getModule());
|
Function *MallocManagedFn =
|
||||||
|
getOrCreatePollyMallocManaged(*Alloca->getModule());
|
||||||
const uint64_t Size =
|
const uint64_t Size =
|
||||||
DL.getTypeAllocSize(Alloca->getType()->getElementType());
|
DL.getTypeAllocSize(Alloca->getType()->getElementType());
|
||||||
Value *SizeVal = Builder.getInt64(Size);
|
Value *SizeVal = Builder.getInt64(Size);
|
||||||
|
@ -330,7 +331,7 @@ static void rewriteAllocaAsManagedMemory(AllocaInst *Alloca,
|
||||||
continue;
|
continue;
|
||||||
Builder.SetInsertPoint(Return);
|
Builder.SetInsertPoint(Return);
|
||||||
|
|
||||||
Value *FreeManagedFn = getOrCreatePollyFreeManaged(*M);
|
Function *FreeManagedFn = getOrCreatePollyFreeManaged(*M);
|
||||||
Builder.CreateCall(FreeManagedFn, {RawManagedMem});
|
Builder.CreateCall(FreeManagedFn, {RawManagedMem});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue