Index: tools/bugpoint/CrashDebugger.cpp =================================================================== --- tools/bugpoint/CrashDebugger.cpp +++ tools/bugpoint/CrashDebugger.cpp @@ -1043,6 +1043,24 @@ return Error::success(); } +static void DoTypeNameCleanup(Module *M) { + // When we roundtrip types through bitcode, those end up being not unique, + // so they get renamed, causing really long chains of type.123.234.342.etc. + // Instead of this, find the part of the name that is not just numbers and use + // that as the type name. + std::vector Types = M->getIdentifiedStructTypes(); + for (StructType *T : Types) { + StringRef Name = T->getName(); + // Count the number of characters that are either dots or numbers from the + // end. + const uint8_t *cur, *end; + cur = end = Name.bytes_end() - 1; + while (cur > Name.bytes_begin() && (*cur == '.' || isdigit(*cur))) + --cur; + T->setName(Name.drop_back(end - cur)); + } +} + /// DebugACrash - Given a predicate that determines whether a component crashes /// on a program, try to destructively reduce the program while still keeping /// the predicate true. @@ -1184,6 +1202,15 @@ // Find out if the pass still crashes on the cleaned up program... if (TestFn(BD, M)) { BD.setNewProgram(M); // Yup, it does, keep the reduced version... + + // Bugpoints makes a mess of type names. Try to clean them up. + DoTypeNameCleanup(M); + + // In principle something could depend on names, I suppose + if (!TestFn(BD, M)) { + return make_error("Cleaning up type names hides bug", + inconvertibleErrorCode()); + } } else { delete M; }