This is a follow-up to https://reviews.llvm.org/D46362.
When evaluating a complex expression in DWARFExpression::Evaluate, file addresses must be resolved to load addresses before we can perform operations such as DW_OP_deref on them.
For this the address goes through three steps
- Read the file address as stored in the DWARF
- Link/relocate the file address (when reading from a .dSYM, this is a no-op)
- Convert the file address to a load address.
D46362 implemented step (3) by resolving the file address using the Module that the original DWARF came from. In the case of a dSYM that is correct, but when reading from .o files, we need to look up relocated/linked addresses, so the right place to look them up is the current frame's module. This patch fixes that by getting the module from the ExecutionContext. PLease let me know if there is a better way to get from the .o-Module to the linked Module that contains that Module.
A word a bout the unorthodox testcase: The motivating testcase for this fix is in Swift, but I managed to hand-modify LLVM-IR for a trivial C program to exhibit the same problem, so we can fix this in llvm.org.
rdar://problem/44689915
Should we check in bitcode instead? That might make it easier to avoid breakage when the textual IR format changes.