Skip to content

Commit

Permalink
Differentiate stacktrace_from_current_z_* from the non-z versions in …
Browse files Browse the repository at this point in the history
…another test so they aren't merged during LTO/ICF, related to #179
  • Loading branch information
jeremy-rifkin committed Oct 11, 2024
1 parent 0d53def commit 81d4776
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/unit/from_current_z.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ using namespace std::literals;
// NOTE: returning something and then return stacktrace_from_current_3(line_numbers) * 2; later helps prevent the call from
// being optimized to a jmp
CPPTRACE_FORCE_NO_INLINE int stacktrace_from_current_z_3(std::vector<int>& line_numbers) {
// just here to differentiate from the non-z version to prevent ICF if LTO is being used
[[maybe_unused]] volatile int x = 1;
line_numbers.insert(line_numbers.begin(), __LINE__ + 1);
throw std::runtime_error("foobar");
}

CPPTRACE_FORCE_NO_INLINE int stacktrace_from_current_z_2(std::vector<int>& line_numbers) {
// just here to differentiate from the non-z version to prevent ICF if LTO is being used
[[maybe_unused]] volatile int x = 1;
line_numbers.insert(line_numbers.begin(), __LINE__ + 1);
return stacktrace_from_current_z_3(line_numbers) * 2;
}

CPPTRACE_FORCE_NO_INLINE int stacktrace_from_current_z_1(std::vector<int>& line_numbers) {
// just here to differentiate from the non-z version to prevent ICF if LTO is being used
[[maybe_unused]] volatile int x = 1;
line_numbers.insert(line_numbers.begin(), __LINE__ + 1);
return stacktrace_from_current_z_2(line_numbers) * 2;
}
Expand Down

0 comments on commit 81d4776

Please sign in to comment.