In the patch, https://reviews.llvm.org/D73152 , it adds a new function LiveVariables::addNewBlock.
This new function will add the reg which PHI used to the MBB which reg is from.
But the new function may cause LiveVariable Verification failed when the Src reg in PHI is undef.
For example:
bb.0: ... // no-definiton for %2 bb.1: ... // definiton for %1 bb.2: %3:g8rc = PHI %1, %bb.1, undef %2:g8rc, %bb.0
It's obvious that, the %2 shouldn't live in bb.0, but the patch D73152 will set it live for bb.0.
If you have enabled all the pass verification in llvm/lib/CodeGen/TargetPassConfig.cpp,
then, you can use below command to reproduce the bug.
llvm-lit -a llvm/test/CodeGen/AArch64/shrink-wrap.ll
There is no test case for this patch, because the verification for LiveVariable pass has other errors,
we can't enable the verification for the LiveVariable pass and PHIElimination pass.
From the LiveVariables::analyzePHINodes, we can know we can use getOperand(i).readsReg() to avoid above bug.