-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][CodeGen] Make UnqualPtrTy
truly unqualified
#94388
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?
Changes from 2 commits
cdf95a8
d05b71c
b62f653
894b48b
5eef3a9
86c0ff9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4656,14 +4656,14 @@ static void InitCatchParam(CodeGenFunction &CGF, | |
auto catchRD = CatchType->getAsCXXRecordDecl(); | ||
CharUnits caughtExnAlignment = CGF.CGM.getClassPointerAlignment(catchRD); | ||
|
||
llvm::Type *PtrTy = CGF.UnqualPtrTy; // addrspace 0 ok | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not convinced this is actually correct, it's been a long time since I looked at C++ exception handling, but I would have assumed this to either be a stack variable or a global? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a pointer to a heap-allocated object. In any case, we shouldn't need to cast the return value of __cxa_begin_catch to a different address-space; we can just drop the bitcasts. |
||
llvm::Type *PtrTy = CGF.UnqualPtrTy; // unqualified is ok | ||
|
||
// Check for a copy expression. If we don't have a copy expression, | ||
// that means a trivial copy is okay. | ||
const Expr *copyExpr = CatchParam.getInit(); | ||
if (!copyExpr) { | ||
llvm::Value *rawAdjustedExn = CallBeginCatch(CGF, Exn, true); | ||
Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), | ||
Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), | ||
LLVMCatchTy, caughtExnAlignment); | ||
LValue Dest = CGF.MakeAddrLValue(ParamAddr, CatchType); | ||
LValue Src = CGF.MakeAddrLValue(adjustedExn, CatchType); | ||
|
@@ -4677,7 +4677,7 @@ static void InitCatchParam(CodeGenFunction &CGF, | |
CGF.EmitNounwindRuntimeCall(getGetExceptionPtrFn(CGF.CGM), Exn); | ||
|
||
// Cast that to the appropriate type. | ||
Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), | ||
Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), | ||
LLVMCatchTy, caughtExnAlignment); | ||
|
||
// The copy expression is defined in terms of an OpaqueValueExpr. | ||
|
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'd argue we should just remove this variable, and the few cases that actually want AS0 can call PointerType::get(0) directly.
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'm not opposed to this in principle; might have some additional benefits in that it forces people to knowingly opt for something via
PointerType::getUnqual
/PointerType::get(some_as)
, rather than accidentally stumbling into it.