jingham created this revision. jingham added a reviewer: JDevlieghere. jingham added a project: LLDB. Herald added a subscriber: lldb-commits.
The way both the REPL and the --top-level mode of the expression parser work is that they compile and JIT the code the user provided, and then look through the resultant IR and find any llvm::Functions produced by the compilation. Then it iterates over those functions and if they are marked "external", it adds them to a table of functions that it then makes available to subsequent expressions. The test we were using for "is external" was hasExternalLinkage || hasLinkOnceODRLinkage. However, there's a third form of external function: hasWeakODRLinkage that can sometimes be produced, which is also intended to be an exported symbol. This patch just includes that predicate to the test we were doing. I don't have a way to write a C-based test for this as I don't know how to craft a user expression in C that will make such a thing. I asked around a bit and nobody had an easy way to do this. OTOH, the swift compiler uses this linkage type when it makes the "default argument provider" for a function with default arguments. So I can easily write a swift REPL test for this. But if somebody knows how to make a C function in the lldb expression parser with a WeakODRLinkage, show me and I'll happily add a test for it here. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D78972 Files: lldb/source/Expression/IRExecutionUnit.cpp Index: lldb/source/Expression/IRExecutionUnit.cpp =================================================================== --- lldb/source/Expression/IRExecutionUnit.cpp +++ lldb/source/Expression/IRExecutionUnit.cpp @@ -331,7 +331,8 @@ continue; const bool external = - function.hasExternalLinkage() || function.hasLinkOnceODRLinkage(); + function.hasExternalLinkage() || function.hasLinkOnceODRLinkage() + || function.hasWeakODRLinkage(); void *fun_ptr = m_execution_engine_up->getPointerToFunction(&function);
Index: lldb/source/Expression/IRExecutionUnit.cpp =================================================================== --- lldb/source/Expression/IRExecutionUnit.cpp +++ lldb/source/Expression/IRExecutionUnit.cpp @@ -331,7 +331,8 @@ continue; const bool external = - function.hasExternalLinkage() || function.hasLinkOnceODRLinkage(); + function.hasExternalLinkage() || function.hasLinkOnceODRLinkage() + || function.hasWeakODRLinkage(); void *fun_ptr = m_execution_engine_up->getPointerToFunction(&function);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits