Here we try to avoid issues with "explicit branch" with SimplifyBranchOnICmpChain
which can check on undef. Msan by design reports branches on uninitialized
memory and undefs, so we have false report here.
In general msan does not like when we convert
// If at least one of them is true we can MSAN is ok if another is undefs if (a || b) return;
into
// If 'a' is undef MSAN will complain even if 'b' is true if (a) return; if (b) return;
Example
Before optimization we had something like this:
while (true) { bool maybe_undef = doStuff(); while (true) { char c = getChar(); if (c != 10 && c != 13) continue break; } // we know that c == 10 || c == 13 if we get here, // so msan know that branch is not affected by maybe_undef if (maybe_undef || c == 10 || c == 13) continue; return; }
SimplifyBranchOnICmpChain will convert that into
while (true) { bool maybe_undef = doStuff(); while (true) { char c = getChar(); if (c != 10 && c != 13) continue; break; } // however msan will complain here: if (maybe_undef) continue; // we know that c == 10 || c == 13, so either way we will get continue switch(c) { case 10: continue; case 13: continue; } return; }
Can you fix this so we return early before the LLVM_DEBUG log?