Track the DIExpression that contains the offset and use it when
comparing variable locations.
Details
Diff Detail
- Build Status
Buildable 9576 Build 9576: arc lint + arc unit
Event Timeline
First off: Thanks!
Does this have have any performance impact? If have the time, it would be nice to just compare the wall clock time of building an asanified (that should generate lots of memory locations) llc or clang with and without the patch.
llvm/lib/CodeGen/LiveDebugValues.cpp | ||
---|---|---|
124 | I wouldn't call it offset if it's the entire expression |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
5173 | I think this should be a separate commit? |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
5173 | Ugh, this doesn't actually do the right thing. Here's my test that comes here: void useptr(int *); void use_alloca(int cond) { int x = 0; int *px = &x; if (cond) useptr(px); } After optimization, px will be described by a dbg.value of x's alloca. This code in InstrEmitter.cpp incorrectly builds an "indirect in memory" DBG_VALUE for px: if (SD->getKind() == SDDbgValue::FRAMEIX) { // Stack address; this needs to be lowered in target-dependent fashion. // EmitTargetCodeForFrameDebugValue is responsible for allocation. return BuildMI(*MF, DL, TII->get(TargetOpcode::DBG_VALUE)) .addFrameIndex(SD->getFrameIx()) .addImm(0) .addMetadata(Var) .addMetadata(Expr); } I guess I'll need to fix that to look for DW_OP_deref. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
5173 | Alternatively, you could say I misunderstood DAG.getFrameIndexDbgValue. |
Can you explain this in terms of an actual debugger scenario that this improves? If we were debugging the code in your test case:
int join_memlocs(int cond) { int x = getint(); if (cond) { x = 42; // Dead store, can delete dostuff(x); // Can propagate 42 x = getint(); } escape(&x); // Escape variable to force it in memory return x; }
What would be the debugger's behavior before the patch and after the patch? And did you check (e.g. with MSVC) that there's actually a discernible result in the debugger experience?
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
5173 | I think it would be best to split the SelectionDAG change out into a separate review and have a MIR-only test for LiveDebugValues. The LiveDebugValues change should be generally good and uncontroversial (apart from performance considerations) and this change looks like it will generate a longer discussion. |
No, but this is a necessary pre-requisite to http://llvm.org/pr34136, starting from the bottom up. Clang doesn't generate the dbg.values used in these test cases yet because LLVM doesn't handle them, but it will soon.
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
5173 | Agreed. |
I wouldn't call it offset if it's the entire expression