Skip to content

Commit

Permalink
Sanity check to detect LLVM bug 96267
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Jun 21, 2024
1 parent 02785af commit 1728474
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/kernel/checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,30 @@

namespace kernel {

bool Clang_IndVarSimplify_Bug_SanityCheck() {
// See https://github.com/llvm/llvm-project/issues/96267
const char s[] = {0, 0x75};
signed int last = 0xff;
for (const char *it = s; it < &s[2]; ++it) {
if (*it <= 0x4e) {
} else if (*it == 0x75 && last <= 0x4e) {
return true;
}
last = *it;
}
return false;
}

util::Result<void> SanityChecks(const Context&)
{
if (!dbwrapper_SanityCheck()) {
return util::Error{Untranslated("Database sanity check failure. Aborting.")};
}

if (!Clang_IndVarSimplify_Bug_SanityCheck()) {
return util::Error{Untranslated("Compiler optimization sanity check failure. Aborting.")};
}

if (!ECC_InitSanityCheck()) {
return util::Error{Untranslated("Elliptic curve cryptography sanity check failure. Aborting.")};
}
Expand Down

0 comments on commit 1728474

Please sign in to comment.