This is an archive of the discontinued LLVM Phabricator instance.

[libc++] add basic runtime assertions to <barrier>
ClosedPublic

Authored by diamante0018 on Jul 6 2023, 10:33 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rG1122cbf40354: [libc++] add basic runtime assertions to <barrier>
Summary

Adding assertions will aid users that have bugs in their code to receive better error messages.

Diff Detail

Event Timeline

diamante0018 created this revision.Jul 6 2023, 10:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 10:33 AM
diamante0018 requested review of this revision.Jul 6 2023, 10:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 10:33 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
diamante0018 edited the summary of this revision. (Show Details)

Remove reduntant function declaration

ldionne requested changes to this revision.Jul 10 2023, 1:45 PM
ldionne added inline comments.
libcxx/include/barrier
318

I see this:

The behavior is undefined if n is less than or equal to 0 or greater than the expected count for the current barrier phase.

It seems that we're not checking the second condition here. I think that's something we could check from __barrier_base::arrive.

This revision now requires changes to proceed.Jul 10 2023, 1:45 PM

Address review

diamante0018 marked an inline comment as done.Jul 10 2023, 2:44 PM

I think the up-to-date code should capture and assert that as well. I added the test file to confirm the correctness of the assertion

Fix logic in the asserts

Note: the tests appear to have failed but in reality it's just two sole time outs out of the entire CI run.

add test for both ctors of barrier, remove extra compiler flag from test file that might be causing issues (fails) on the mac runners.

Push patch with context

Fix CI runner not being able to create branch (rebase)

Add xfail flag present in other barrier test files

ldionne accepted this revision.Jul 13 2023, 2:32 PM

LGTM with comments applied and green CI. Thanks!

libcxx/test/libcxx/thread/thread.barrier/assert.arrive.pass.cpp
22–24

We generally try to group Lit annotations like this. Please move those above right under the XFAIL. Here and elsewhere.

libcxx/test/libcxx/thread/thread.barrier/assert.ctor.pass.cpp
39

constexpr and noexcept are not necessary here, and they make the reader wonder whether they are relevant to the test. I'd remove them.

This revision is now accepted and ready to land.Jul 13 2023, 2:32 PM

Address review comments

diamante0018 marked 2 inline comments as done.Jul 13 2023, 2:42 PM

Fix compilation error in my patch I missed

Change flag for tests file in attempt to fix CI on apply-backdeployment

Add xfail flags for macos builds specifically

diamante0018 added a comment.EditedJul 15 2023, 12:42 AM

As this CI turned green and should be approved, please use the following details when landing it. However, if the XFAILs flags needs to be modified please let me know.

Edoardo Sanguineti <edoardo.sanguineti222@gmail.com>

Thanks to the reviewers here and on the Discord server