Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake option DXC_CODEGEN_EXCEPTIONS_TRAP #6764

Merged
merged 1 commit into from
Jul 12, 2024
Merged

Conversation

dneto0
Copy link
Collaborator

@dneto0 dneto0 commented Jul 10, 2024

When enabled, any hlsl::Exception thrown during code generation and optimization will cause the process to trap.


edit: I've changed the implementation to generate a trap, instead of std::abort

@dneto0 dneto0 requested a review from llvm-beanz July 10, 2024 23:37
@dneto0 dneto0 marked this pull request as ready for review July 10, 2024 23:37
@dneto0 dneto0 requested a review from a team as a code owner July 10, 2024 23:37
Copy link
Contributor

github-actions bot commented Jul 10, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

I really don't like this change. It's an unfortunate hack around a problem rather than fixing it. That said, the problem isn't easy to fix and I can't really come up with a better way to address it that isn't insanely massive.

I wish we could just make exceptions an optional configuration, but that would be a huge change and even making our tests pass with exceptions replaced by fatal errors is a huge effort.

Exceptions are evil.
This code all makes me sad.
I refuse to say it "looks good" to me.
I will say it is an acceptable (although unfortunate) compromise.

One small change requested to use llvm::errs() instead of fprintf.

tools/clang/lib/CodeGen/BackendUtil.cpp Outdated Show resolved Hide resolved
@dneto0 dneto0 marked this pull request as draft July 11, 2024 13:38
@dneto0
Copy link
Collaborator Author

dneto0 commented Jul 11, 2024

+1

I wish the exception-catching had not been inserted.

After posting I realized this patch has a big downside: we don't get a stack trace. Which means bug report deduplication will get too agressive and we'll likely miss things.

I converted to draft for now.

@dneto0 dneto0 changed the title Add CMake option DXC_CODEGEN_EXCEPTIONS_ABORT Add CMake option DXC_CODEGEN_EXCEPTIONS_TRAP Jul 11, 2024
When enabled, any hlsl::Exception thrown during code generation
and optimization will cause the process to trap.

When used in Chrome, the trap will trigger a meaningful crash report.
@dneto0 dneto0 marked this pull request as ready for review July 11, 2024 22:09
@dneto0 dneto0 requested a review from sudonatalie July 12, 2024 13:34
@dneto0 dneto0 merged commit b18fe87 into microsoft:main Jul 12, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants