Author: Nikita Popov Date: 2022-02-14T09:44:37+01:00 New Revision: ad1feef7b2097090df0d41ad4c35c688dbe1c34a
URL: https://github.com/llvm/llvm-project/commit/ad1feef7b2097090df0d41ad4c35c688dbe1c34a DIFF: https://github.com/llvm/llvm-project/commit/ad1feef7b2097090df0d41ad4c35c688dbe1c34a.diff LOG: [lldb] Remove some uses of getPointerElementType() While in the area, remove some uses of getPointerElementType() that have obvious replacements. Added: Modified: lldb/source/Expression/IRInterpreter.cpp lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp Removed: ################################################################################ diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 338d387d39fcd..42da0e1c7cec0 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -1376,21 +1376,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::DiagnosticManager diagnostics; lldb_private::EvaluateExpressionOptions options; - // We generally receive a function pointer which we must dereference - llvm::Type *prototype = val->getType(); - if (!prototype->isPointerTy()) { - error.SetErrorToGenericError(); - error.SetErrorString("call need function pointer"); - return false; - } - - // Dereference the function pointer - prototype = prototype->getPointerElementType(); - if (!(prototype->isFunctionTy() || prototype->isFunctionVarArg())) { - error.SetErrorToGenericError(); - error.SetErrorString("call need function pointer"); - return false; - } + llvm::FunctionType *prototype = call_inst->getFunctionType(); // Find number of arguments const int numArgs = call_inst->arg_size(); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index fee1a2a5e5e60..10d1e99d756f8 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -328,9 +328,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) { // Construct a new result global and set up its metadata GlobalVariable *new_result_global = new GlobalVariable( - (*m_module), result_global->getValueType(), - false, /* not constant */ - GlobalValue::ExternalLinkage, nullptr, /* no initializer */ + (*m_module), result_global->getValueType(), false, /* not constant */ + GlobalValue::ExternalLinkage, nullptr, /* no initializer */ m_result_name.GetCString()); // It's too late in compilation to create a new VarDecl for this, but we @@ -1106,9 +1105,8 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) { // Now, since the variable is a pointer variable, we will drop in a load of // that pointer variable. - LoadInst *persistent_load = - new LoadInst(persistent_global->getType()->getPointerElementType(), - persistent_global, "", alloc); + LoadInst *persistent_load = new LoadInst(persistent_global->getValueType(), + persistent_global, "", alloc); LLDB_LOG(log, "Replacing \"{0}\" with \"{1}\"", PrintValue(alloc), PrintValue(persistent_load)); diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp index 0233271172cc1..f5c3c139a3ee2 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp @@ -187,18 +187,17 @@ static bool fixupX86StructRetCalls(llvm::Module &module) { (new llvm::StoreInst(new_func_cast, new_func_ptr, call_inst)) ->setName("new_func_ptr_load_cast"); // load the new function address ready for a jump - llvm::LoadInst *new_func_addr_load = - new llvm::LoadInst(new_func_ptr->getType()->getPointerElementType(), - new_func_ptr, "load_func_pointer", call_inst); + llvm::LoadInst *new_func_addr_load = new llvm::LoadInst( + new_func_ptr_type, new_func_ptr, "load_func_pointer", call_inst); // and create a callinstruction from it llvm::CallInst *new_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->setTailCall(call_inst->isTailCall()); - llvm::LoadInst *lldb_save_result_address = new llvm::LoadInst( - return_value_alloc->getType()->getPointerElementType(), - return_value_alloc, "save_return_val", call_inst); + llvm::LoadInst *lldb_save_result_address = + new llvm::LoadInst(func->getReturnType(), return_value_alloc, + "save_return_val", call_inst); // Now remove the old broken call call_inst->replaceAllUsesWith(lldb_save_result_address); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits