[DebugInfo] Skip ODRUniquing for mismatched tags
authorYuanfang Chen <yuanfang.chen@sony.com>
Tue, 26 Oct 2021 20:58:43 +0000 (13:58 -0700)
committerYuanfang Chen <yuanfang.chen@sony.com>
Tue, 26 Oct 2021 22:28:25 +0000 (15:28 -0700)
commit7c3fa5278544d3830838148ac912cc4b927d1b5b
treebbab8942a662425b9a580317b4701c5b03841e25
parent2887d9fd864c9302608ecd7ff58b28ad181ede9d
[DebugInfo] Skip ODRUniquing for mismatched tags

Otherwise, ODRUniquing would map some member method/variable MDNodes
to have enum type DIScope, resulting in invalid debug info and bad
DWARF.

- Add a Verifier check that when a 'scope:' operand is an ODR type that is not an enum.
- Makes ODRUniquing apply to only ODR types with the same tag so that the debuginfo/DWARF is well-formed.

Reviewed By: probinson, aprantl

Differential Revision: https://reviews.llvm.org/D111770
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/Linker/debug-info-bad-enum.ll [new file with mode: 0644]
llvm/test/Verifier/dbg-invalid-enum-as-scope.ll [new file with mode: 0644]
llvm/unittests/IR/DebugTypeODRUniquingTest.cpp