Description
This reduced test case has been causing crashes recently when assertions are enabled:
struct c {
virtual ~c();
};
struct d : virtual c {};
class a : d {};
a f;
When compiled with recent changes in trunk, this crashes in InstCombine
pass:
clang -cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fstrict-vtable-pointers -O1 test.cc
Assertion failed: DT.dominates(BB, UserParent) && "Dominance relation broken?", file llvm\lib\Transforms\InstCombine\InstructionCombining.cpp, line 4031
As far as I can see, the crash is new but we have been generating ill-formed IR for a very long time.
Changing the frontend invocation so that the verifier is executed produces:
clang -cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fstrict-vtable-pointers -O1 -disable-llvm-passes test.cc
Instruction does not dominate all uses!
%1 = call ptr @llvm.launder.invariant.group.p0(ptr %this1)
%3 = call ptr @llvm.launder.invariant.group.p0(ptr %1)
fatal error: error in backend: Broken module found, compilation aborted!
You can easily reproduce this as is as far back as LLVM-14, but that's because the verifier call that catches it during this invocation was introduced between 13 and 14, in this commit: 9efce0b
If you backport this patch, I have seen this problem in at least LLVM-11, but that's because I just stopped there, the build system was starting to get difficult.
On a related note, why aren't we just always running the verifier? It doesn't seem to cost too much.