fix crash in machine trace metrics due to processing dbg_value instructions (PR24199)
authorSanjay Patel <spatel@rotateright.com>
Thu, 23 Jul 2015 22:56:53 +0000 (22:56 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 23 Jul 2015 22:56:53 +0000 (22:56 +0000)
commitc3bac701a5788e6d2bec19acd5b6d96c6f67f7c4
treef679a8e38091d20c594e8f7ebf8923d53c7e80a5
parente2d5247deea2d2e32d4eef71cfa9396c90de6c24
fix crash in machine trace metrics due to processing dbg_value instructions (PR24199)

The test in PR24199 ( https://llvm.org/bugs/show_bug.cgi?id=24199 ) crashes because machine
trace metrics was not ignoring dbg_value instructions when calculating data dependencies.

The machine-combiner pass asks machine trace metrics to calculate an instruction trace,
does some reassociations, and calls MachineInstr::eraseFromParentAndMarkDBGValuesForRemoval()
along with MachineTraceMetrics::invalidate(). The dbg_value instructions have their operands
invalidated, but the instructions are not expected to be deleted.

On a subsequent loop iteration of the machine-combiner pass, machine trace metrics would be
called again and die while accessing the invalid debug instructions.

Differential Revision: http://reviews.llvm.org/D11423

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243057 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/MachineTraceMetrics.cpp
test/CodeGen/X86/machine-trace-metrics-crash.ll [new file with mode: 0644]