Skip to content

Commit

Permalink
[libc++][NFC] Mark values in gdb pretty print comparison functions as…
Browse files Browse the repository at this point in the history
… live to prevent values being optimized out.

It appears when testing LLVM 13 on Power, we run into failures with the
`libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp` test case optimizing
values out.

Despite some the functions in the test already being marked with optnone,
adding the `MarkAsLive()` calls inside of the pretty printer comparison functions
resolves the issues of the values being optimized out.

This patch aims to address https://llvm.org/PR51675.

Differential Revision: https://reviews.llvm.org/D109204

(cherry picked from commit 217c6d6)
  • Loading branch information
amy-kwan authored and ldionne committed Sep 3, 2021
1 parent c8905f1 commit 1c3fcc8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,28 @@ void MarkAsLive(Type &&) {}
template <typename TypeToPrint> void ComparePrettyPrintToChars(
TypeToPrint value,
const char *expectation) {
MarkAsLive(value);
StopForDebugger(&value, &expectation);
}

template <typename TypeToPrint> void ComparePrettyPrintToRegex(
TypeToPrint value,
const char *expectation) {
MarkAsLive(value);
StopForDebugger(&value, &expectation);
}

void CompareExpressionPrettyPrintToChars(
std::string value,
const char *expectation) {
MarkAsLive(value);
StopForDebugger(&value, &expectation);
}

void CompareExpressionPrettyPrintToRegex(
std::string value,
const char *expectation) {
MarkAsLive(value);
StopForDebugger(&value, &expectation);
}

Expand Down

0 comments on commit 1c3fcc8

Please sign in to comment.