Skip to content

Commit

Permalink
Revert "workarounds for gcc optimizer misbuilds" [ci skip]
Browse files Browse the repository at this point in the history
This reverts commit 51491b3.
  • Loading branch information
biojppm committed Jan 20, 2025
1 parent 2fcd2d4 commit 1b3b0c3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
2 changes: 1 addition & 1 deletion ext/c4core
14 changes: 0 additions & 14 deletions src/c4/yml/parse_engine.def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ inline bool _is_doc_token(csubstr s) noexcept
// The current version does not suffer this problem, but it may
// appear again.
//
//
// UPDATE. The problem appeared again in gcc12 and gcc13 with -Os
// (but not any other optimization level, nor any other compiler
// or version), because the assignment to s is being hoisted out
// of the loop which calls this function. Then the length doesn't
// enter the s.len >= 3 when it should. Adding a
// C4_DONT_OPTIMIZE(var) makes the problem go away.
//
if(s.len >= 3)
{
switch(s.str[0])
Expand Down Expand Up @@ -1947,9 +1939,6 @@ typename ParseEngine<EventHandler>::ScannedScalar ParseEngine<EventHandler>::_sc
while( ! _finished_file())
{
const csubstr line = m_evt_handler->m_curr->line_contents.rem;
#if defined(__GNUC__) && __GNUC__ == 11
C4_DONT_OPTIMIZE(line); // prevent erroneous hoist of the assignment out of the loop
#endif
bool line_is_blank = true;
_c4dbgpf("scanning double quoted scalar @ line[{}]: line='{}'", m_evt_handler->m_curr->pos.line, line);
for(size_t i = 0; i < line.len; ++i)
Expand Down Expand Up @@ -2099,9 +2088,6 @@ void ParseEngine<EventHandler>::_scan_block(ScannedBlock *C4_RESTRICT sb, size_t
{
// peek next line, but do not advance immediately
lc.reset_with_next_line(m_buf, m_evt_handler->m_curr->pos.offset);
#if defined(__GNUC__) && (__GNUC__ == 12 || __GNUC__ == 13)
C4_DONT_OPTIMIZE(lc.rem);
#endif
_c4dbgpf("blck: peeking at [{}]~~~{}~~~", lc.stripped.len, lc.stripped);
// evaluate termination conditions
if(indentation != npos)
Expand Down
3 changes: 0 additions & 3 deletions src/c4/yml/parser_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ struct LineContents
++e;
RYML_ASSERT(e >= offset);
const substr stripped_ = buf.range(offset, e);
#if defined(__GNUC__) && __GNUC__ == 11
C4_DONT_OPTIMIZE(stripped_);
#endif
// advance pos to include the first line ending
if(e < buf.len && buf.str[e] == '\r')
++e;
Expand Down

0 comments on commit 1b3b0c3

Please sign in to comment.