Skip to content

[SYCL] Refactor sycl-post-link for better error handling and code simplicity#21579

Open
maksimsab wants to merge 2 commits intointel:syclfrom
maksimsab:refactor_tool_part1
Open

[SYCL] Refactor sycl-post-link for better error handling and code simplicity#21579
maksimsab wants to merge 2 commits intointel:syclfrom
maksimsab:refactor_tool_part1

Conversation

@maksimsab
Copy link
Contributor

This commit improves error handling and simplifies code in sycl-post-link without changing functionality:

Error handling improvements:

  • Convert functions to return Error instead of void
  • Propagate errors up to the stack to comply with LLVM guidelines
  • Introduce ExitOnError pattern for consistent error handling
  • Replace error() and checkError() calls with ExitOnErr() for cleaner flow

Code refactoring:

  • Refactor simple utility functions reusing LLVM functionality

Code simplification:

  • Remove unnecessary includes
  • Simplify SmallVector declarations by removing MAX_COLUMNS_IN_FILE_TABLE constant and using default template parameter

These changes prepare the code for extraction to a library component while improving maintainability and following LLVM error handling conventions. All refactored functions maintain the same functionality but with proper error propagation.

…plicity

This commit improves error handling and simplifies code in sycl-post-link
without changing functionality:

**Error handling improvements:**
- Convert functions to return Error instead of void
- Propagate errors up to the stack to comply with LLVM guidelines
- Introduce ExitOnError pattern for consistent error handling
- Replace error() and checkError() calls with ExitOnErr() for cleaner flow

**Code refactoring:**
- Refactor simple utility functions reusing LLVM functionality

**Code simplification:**
- Remove unnecessary includes
- Simplify SmallVector declarations by removing MAX_COLUMNS_IN_FILE_TABLE
  constant and using default template parameter

These changes prepare the code for extraction to a library component while
improving maintainability and following LLVM error handling conventions.
All refactored functions maintain the same functionality but with proper
error propagation.
@maksimsab maksimsab requested a review from a team as a code owner March 20, 2026 14:20
checkError(EC, "error opening the file '" + Filename + "'");
OS.write(Content.data(), Content.size());
OS.close();
static Error writeToFile(const StringRef Filename, const StringRef Content) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good improvement, but let's go further and just use writeToOutput directly without providing this thin wrapper. writeToFile is used in one place and doesn't add any value.

return PropSet;
}

Error writePropertiesToFile(const StringRef Filename,
Copy link
Contributor

Choose a reason for hiding this comment

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

this wrapper makes sense to me, please, keep it.

Copy link
Contributor

@YuriPlyakhin YuriPlyakhin left a comment

Choose a reason for hiding this comment

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

Question: was AI used to generate substantial amount of content of this PR?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants