[PATCH] D44312: Retain both sets of debug intrinsics in HoistThenElseCodeToIf (fixes PR 36410)

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 9 13:29:23 PST 2018


efriedma added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:1261
+  for (;;) {
+    // Move over debug info from both sides unchanged.
+    while (isa<DbgInfoIntrinsic>(I1)) {
----------------
If I'm following this correctly, you're hoisting all dbg.value intrinsics from both sides to the predecessor.  So given code like the following:

```
int foo(bool b) {
  int a;
  if (b) {
    a = 10;
    bar();
  } else {
    a = 20;
    baz();
  }
  return a;
}
```

You'll end up with two dbg.value intrinsics in the entry block for the variable "a", so the debugger will choose randomly (?) whether to print a=10 or a=20.  That seems wrong.


https://reviews.llvm.org/D44312





More information about the llvm-commits mailing list