From 2a8fa2a888ea2a34ae9aaafd4e30d53241bb9dd6 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Sat, 13 Feb 2016 00:01:46 +0000 Subject: Removed many JIT workarounds from IRForTarget. Since IRExecutionUnit is now capable of looking up symbols, and the JIT is up to the task of generating the appropriate relocations, we don't need to do all the work that IRForTarget used to do to fixup symbols at the IR level. We also don't need to allocate data manually (with its attendant bugs) because the JIT is capable of doing so without crashing. We also don't need the awkward lldb.call.realName metadata to determine what calls are objc_msgSend, because they now just reference objc_msgSend. To make this work, we ensure that we recognize which symbols are extern "C" and report them to the compiler as such. We also report the full Decl of functions rather than just making up top-level functions with the appropriate types. This should not break any testcases, but let me know if you run into any issues. llvm-svn: 260768 --- lldb/source/Expression/IRDynamicChecks.cpp | 59 ++++++++++++++++-------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'lldb/source/Expression/IRDynamicChecks.cpp') diff --git a/lldb/source/Expression/IRDynamicChecks.cpp b/lldb/source/Expression/IRDynamicChecks.cpp index 64fdb08157a..c2195de4d44 100644 --- a/lldb/source/Expression/IRDynamicChecks.cpp +++ b/lldb/source/Expression/IRDynamicChecks.cpp @@ -506,6 +506,32 @@ protected: return true; } + + static llvm::Function *GetFunction(llvm::Value *value) + { + if (llvm::Function *function = llvm::dyn_cast(value)) + { + return function; + } + + if (llvm::ConstantExpr *const_expr = llvm::dyn_cast(value)) + { + switch (const_expr->getOpcode()) + { + default: + return nullptr; + case llvm::Instruction::BitCast: + return GetFunction(const_expr->getOperand(0)); + } + } + + return nullptr; + } + + static llvm::Function *GetCalledFunction(llvm::CallInst *inst) + { + return GetFunction(inst->getCalledValue()); + } bool InspectInstruction(llvm::Instruction &i) override { @@ -515,35 +541,12 @@ protected: if (call_inst) { - // This metadata is set by IRForTarget::MaybeHandleCall(). - - MDNode *metadata = call_inst->getMetadata("lldb.call.realName"); - - if (!metadata) + const llvm::Function *called_function = GetCalledFunction(call_inst); + + if (!called_function) return true; - - if (metadata->getNumOperands() != 1) - { - if (log) - log->Printf("Function call metadata has %d operands for [%p] %s", - metadata->getNumOperands(), - static_cast(call_inst), - PrintValue(call_inst).c_str()); - return false; - } - - MDString *real_name = dyn_cast(metadata->getOperand(0)); - - if (!real_name) - { - if (log) - log->Printf("Function call metadata is not an MDString for [%p] %s", - static_cast(call_inst), - PrintValue(call_inst).c_str()); - return false; - } - - std::string name_str = real_name->getString(); + + std::string name_str = called_function->getName().str(); const char* name_cstr = name_str.c_str(); if (log) -- cgit v1.2.3