Skip to content

[Cherry-pick][clang] Correct behavior of LLVM_UNREACHABLE_OPTIMIZE=OFF for Release builds #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ Bug Fixes in This Version
virtual member functions even if the target required a greater function
alignment and/or did not have function pointers which point to function entry
points (i.e., uses function descriptor objects instead).
- Fixes a ``clang-17`` regression where ``LLVM_UNREACHABLE_OPTIMIZE=OFF``
cannot be used with ``Release`` mode builds. (`#68237 <https://github.com/llvm/llvm-project/issues/68237>`_).

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
17 changes: 11 additions & 6 deletions clang/utils/TableGen/ClangAttrEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2639,23 +2639,28 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS,
OS << ", ";
emitFormInitializer(OS, Spellings[0], "0");
} else {
OS << ", (\n";
OS << ", [&]() {\n";
OS << " switch (S) {\n";
std::set<std::string> Uniques;
unsigned Idx = 0;
for (auto I = Spellings.begin(), E = Spellings.end(); I != E;
++I, ++Idx) {
const FlattenedSpelling &S = *I;
const auto &Name = SemanticToSyntacticMap[Idx];
if (Uniques.insert(Name).second) {
OS << " S == " << Name << " ? AttributeCommonInfo::Form";
OS << " case " << Name << ":\n";
OS << " return AttributeCommonInfo::Form";
emitFormInitializer(OS, S, Name);
OS << " :\n";
OS << ";\n";
}
}
OS << " (llvm_unreachable(\"Unknown attribute spelling!\"), "
<< " AttributeCommonInfo::Form";
OS << " default:\n";
OS << " llvm_unreachable(\"Unknown attribute spelling!\");\n"
<< " return AttributeCommonInfo::Form";
emitFormInitializer(OS, Spellings[0], "0");
OS << "))";
OS << ";\n"
<< " }\n"
<< " }()";
}

OS << ");\n";
Expand Down