[DebugInfo][RemoveDIs] Don't convert debug-intrinsics to Unreachable (#72380)
commitf42482def236999b0f7896c09cd714b708861c8b
authorJeremy Morse <jeremy.morse@sony.com>
Mon, 20 Nov 2023 20:53:24 +0000 (20 20:53 +0000)
committerGitHub <noreply@github.com>
Mon, 20 Nov 2023 20:53:24 +0000 (20 20:53 +0000)
tree5af8ca0c198f5fd71b50511d61cbd9ea558834d5
parent6352a07ba65301b60ace8e5e67e54f4967e375ae
[DebugInfo][RemoveDIs] Don't convert debug-intrinsics to Unreachable (#72380)

It might seem obvious, but it's not a good idea to convert a
debug-intrinsic instruction into an UnreachableInst, as this means
things operate differently with and without the -g option. However this
can happen due to the "mutate the next instruction" API calls we make.
With RemoveDIs eliminating debug intrinsics, this behaviour is at risk
of changing, hence this patch ensures we only ever mutate the next _non_
debuginfo instruction into an Unreachable.

The tests instrumented with the --try... flag all exercise this, I've
added some metadata to a SCCP test to ensure it's exercised.
llvm/lib/Transforms/IPO/SCCP.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/InstCombine/assume.ll
llvm/test/Transforms/InstCombine/unreachable-dbg-info-modified.ll
llvm/test/Transforms/SCCP/ipsccp-branch-unresolved-undef.ll
llvm/test/Transforms/SimplifyCFG/PR27615-simplify-cond-br.ll
llvm/test/Transforms/SimplifyCFG/branch-fold-dbg.ll
llvm/test/Transforms/SimplifyCFG/dbginfo.ll