If a function argument that is passed by reference is remapped to an alloca in the calling function, eliminate the (now) superfluous DW_OP_deref from the DIExpression.
Depends on http://reviews.llvm.org/D6986.
Does createExpression need a DIBuilder? Does it just need access to a Module? (perhaps it could just be a standalone non-member function that takes a Module?)
So if during inlining we take a pointer and remove the indirection (eg: a function has "int *x" and "*x + 3" and its called with "int y = ...; func(&y)", etc) we drop the expression entirely? Because we can't describe the value of the pointer when there's nothing to point to, I take it? (that seems correct, just checking I understand correctly)
Is that case tested?
These two functions have a lot in common (everything except "getAddress/getValue") - should they be combined in some way (should DbgValueInst/DbgDeclareInst have a common "get" (address or value) for ease of access/consistency - or does that not make sense?)? If not, then at least the rest of the function could be pulled out into a common function or template if necessary)
This seems like a lot of code to test this scenario. Could this be simplified further? (I'd also expect to see some attribute((always_inline)) so you don't have to rely on the inliner to pick the right things to inline (You can compile the example with -mllvm -disable-llvm-optzns to get the bitcode before the AlwaysInliner runs (since it'll run at -O0 and a simple "clang -emit-llvm" will get you post-inlined IR, which isn't what you want)))