Skip to content

Conversation

bruteforceboy
Copy link
Contributor

@bruteforceboy bruteforceboy commented Jun 4, 2025

This PR introduces TryMarkNoThrow. isInterposable isn't fully implemented and I'm not quite sure we need it? Anyway, I have introduced a missing feature getSemanticInterposition relevant for its completion.

I have also updated an old test -- foo() should be marked as unwind/nothrow. I have compared with the original CodeGen and attached the llvm output for verification.

One concern I have is if the cases I have to mimic mayThrow from the OG are enough, please let me know your thoughts.

if (isInterposable(fn))
return;

for (auto &blk : fn.getBlocks()) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of walking the function here (which could be expensive), we could keep some state in cgf to track when those operations are emitted, then you could change this function to just check that state and go about the business of adding attributes. How does that sound?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! I will update the PR next week.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bcardosolopes updated)

@bcardosolopes
Copy link
Member

One concern I have is if the cases I have to mimic mayThrow from the OG are enough, please let me know your thoughts.

Sounds good enough, perhaps as you add the cgf state mentioned in the review comment you could mention that it needs to be updated in case we add more operations that are related to it (but so far looks complete).

@bcardosolopes bcardosolopes merged commit 481118d into llvm:main Jun 9, 2025
9 checks passed
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
)

This PR introduces
[`TryMarkNoThrow`](https://github.com/llvm/clangir/blob/6e5fa09550c98f84d017873ed3e5667fd5fd909c/clang/lib/CodeGen/CodeGenFunction.cpp#L1394).
[`isInterposable`](https://github.com/llvm/clangir/blob/6e5fa09550c98f84d017873ed3e5667fd5fd909c/clang/lib/CodeGen/CodeGenFunction.cpp#L1397C10-L1397C26)
isn't fully implemented and I'm not quite sure we need it? Anyway, I
have introduced a missing feature `getSemanticInterposition` relevant
for its completion.

I have also updated an old test --
[`foo()`](https://github.com/llvm/clangir/blob/6e5fa09550c98f84d017873ed3e5667fd5fd909c/clang/test/CIR/CodeGen/try-catch-dtors.cpp#L313)
should be marked as unwind/nothrow. I have compared with the original
CodeGen and attached the llvm output for verification.

One concern I have is if the cases I have to mimic
[`mayThrow`](https://github.com/llvm/clangir/blob/6e5fa09550c98f84d017873ed3e5667fd5fd909c/llvm/lib/IR/Instruction.cpp#L1158)
from the OG are enough, please let me know your thoughts.
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