Skip to content

[Comgr] Replace llvm_unreachables with graceful errors#1635

Open
chinmaydd wants to merge 1 commit intoROCm:amd-mainfrom
chinmaydd:users/chinmaydd/comgr-fatal-cleanup
Open

[Comgr] Replace llvm_unreachables with graceful errors#1635
chinmaydd wants to merge 1 commit intoROCm:amd-mainfrom
chinmaydd:users/chinmaydd/comgr-fatal-cleanup

Conversation

@chinmaydd
Copy link

Comgr should fail gracefully through all code paths.

This PR is a first step towards that effort.

@chinmaydd chinmaydd requested a review from lamb-j as a code owner March 4, 2026 05:32
@chinmaydd chinmaydd requested a review from jmmartinez March 4, 2026 05:33
@z1-cciauto
Copy link
Collaborator

}

llvm_unreachable("invalid language");
return "<unknown>";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could clean these up to be AMD_COMGR_LANGUAGE_UNKNOWN maybe ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, this really is unreachable though right? The error message would probably be more accurate if it said something like "it shouldn't be possible to get here"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding a failing assertion?

Maybe a call to something like:

static void assert_unreachable() __attribute__((cold)) {
  assert(false && "Unreachable");
}

Then developer builds could catch early that something undefined is happening.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, this really is unreachable though right?

I hear you, but with most AMD compiler and runtime components open-source one could develop custom forks with other "custom" language support. I think we should more generally have an infrastructure that does not crash by default. Another option would be to add a default case and then clean up the unreachable. I'm okay with that.

Then developer builds could catch early that something undefined is happening.

Do we test with assertions on in our CQE testing phases ? If so, then I can get behind that.

@chinmaydd chinmaydd added the comgr Related to Code Object Manager label Mar 4, 2026
@lamb-j lamb-j changed the base branch from amd-staging to amd-main March 5, 2026 02:12
@skganesan008
Copy link
Collaborator

!PSDB

@z1-cciauto
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comgr Related to Code Object Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants