-
Notifications
You must be signed in to change notification settings - Fork 165
[CIR] Implement virtual destructor call #1856
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
base: main
Are you sure you want to change the base?
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, some nits
clang/test/CIR/CodeGen/virtual-destructor-explicit-unqualified-call.cpp
Outdated
Show resolved
Hide resolved
clang/test/CIR/CodeGen/virtual-destructor-explicit-unqualified-call.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CIRGen lgtm
Some more changes for the test to format it correctly and make it more readable.
clang/test/CIR/CodeGen/virtual-destructor-explicit-unqualified-call.cpp
Outdated
Show resolved
Hide resolved
clang/test/CIR/CodeGen/virtual-destructor-explicit-unqualified-call.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after minor comment
|
||
QualType thisTy = | ||
IsArrow ? Base->getType()->getPointeeType() : Base->getType(); | ||
emitCXXDestructorCall(globalDecl, callee, This.getPointer(), thisTy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some code repetition from the else
part, that can be improved overall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Classic codegen, calls CGM.getCXXABI().EmitVirtualDestructorCall()
here. Is there a reason we can't do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGM.getCXXABI().EmitVirtualDestructorCall()
Thanks for the suggestion. We can use this call instead. Got the same result.
@tommymcm Just wanted to clarify. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs some more info in the tests, once that's done I think it will all lgtm
@@ -19,5 +24,27 @@ A A::B(A) { | |||
// CIR-NEXT: cir.trap | |||
// CIR-NEXT: } | |||
|
|||
|
|||
// LLVM-LABEL: define dso_local %class.A @_ZN1A1BES_( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test has some loose ends.
Could you add the this
argument binding and store, that way we can tie everything together. Something like
// LLVM-LABEL: ...
// LLVM-SAME: %[[THIS_ARG:.*]]
// ...
// LLVM: %[[THIS_VAR:.*]] = alloca ptr
// ...
// LLVM: store ptr %[[THIS]], ptr %[[THIS_VAR]]
// ...
// LLVM: %[[THIS:.*]] = load ptr, ptr %[[THIS_VAR]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for OGCG.
// LLVM: %[[VAL_0:.*]] = alloca ptr, i64 1, align 8 | ||
// LLVM: %[[VAL_6:.*]] = load ptr, ptr %[[VAL_0]], align 8 | ||
// LLVM-NEXT: %[[VAL_7:.*]] = load ptr, ptr %[[VAL_6]], align 8 | ||
// LLVM-NEXT: %[[VAL_8:.*]] = getelementptr inbounds ptr, ptr %[[VAL_7]], i32 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name these variables, for example:
// LLVM-NEXT: %[[VAL_8:.*]] = getelementptr inbounds ptr, ptr %[[VAL_7]], i32 0 | |
// LLVM-NEXT: %[[VIRT_DTOR_ADDR:.*]] = getelementptr inbounds ptr, ptr %[[THIS]], i32 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll look into them.
Implements #1812