[PATCH] D50340: [Local] Add dbg location on unreachable inst in changeToUnreachable

Anastasis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 6 10:25:01 PDT 2018


gramanas created this revision.
gramanas added a reviewer: vsk.
Herald added a subscriber: llvm-commits.

As show in https://bugs.llvm.org/show_bug.cgi?id=37960
it would be desirable to have debug location in the unreachable
instruction.

> If the unreachable is lowered to llvm.trap() or similar,
>  it could be really useful to have line/scope information there
>  to make forensic debugging more pleasant.

I am not sure whether to add a unit test for this funtion.


Repository:
  rL LLVM

https://reviews.llvm.org/D50340

Files:
  lib/Transforms/Utils/Local.cpp


Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -1930,7 +1930,8 @@
     CallInst *CallTrap = CallInst::Create(TrapFn, "", I);
     CallTrap->setDebugLoc(I->getDebugLoc());
   }
-  new UnreachableInst(I->getContext(), I);
+  auto *UI = new UnreachableInst(I->getContext(), I);
+  UI->setDebugLoc(I->getDebugLoc());
 
   // All instructions after this are dead.
   unsigned NumInstrsRemoved = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50340.159332.patch
Type: text/x-patch
Size: 525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180806/de1cbaf9/attachment.bin>


More information about the llvm-commits mailing list