[Lldb-commits] [PATCH] D78972: Treat hasWeakODRLinkage symbols as external in REPL computations
Jim Ingham via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 27 17:16:46 PDT 2020
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.
rG LLVM Github Monorepo
@@ -331,7 +331,8 @@
const bool external =
- function.hasExternalLinkage() || function.hasLinkOnceODRLinkage();
+ function.hasExternalLinkage() || function.hasLinkOnceODRLinkage()
+ || function.hasWeakODRLinkage();
void *fun_ptr = m_execution_engine_up->getPointerToFunction(&function);
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 552 bytes
Desc: not available
More information about the lldb-commits