Skip to content

Commit ff485a0

Browse files
committed
[clang] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
1 parent c12de14 commit ff485a0

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

clang/lib/CodeGen/CGObjC.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,8 @@ static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar,
827827
// sizeof (Type of Ivar), isAtomic, false);
828828
CallArgList args;
829829

830-
llvm::Value *dest =
831-
CGF.Builder.CreateBitCast(CGF.ReturnValue.getPointer(), CGF.VoidPtrTy);
830+
llvm::Value *dest = CGF.ReturnValue.getPointer();
832831
args.add(RValue::get(dest), Context.VoidPtrTy);
833-
834-
src = CGF.Builder.CreateBitCast(src, CGF.VoidPtrTy);
835832
args.add(RValue::get(src), Context.VoidPtrTy);
836833

837834
CharUnits size = CGF.getContext().getTypeSizeInChars(ivar->getType());
@@ -1098,7 +1095,6 @@ static void emitCPPObjectAtomicGetterCall(CodeGenFunction &CGF,
10981095
llvm::Value *ivarAddr =
10991096
CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0)
11001097
.getPointer(CGF);
1101-
ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy);
11021098
args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy);
11031099

11041100
// Third argument is the helper function.
@@ -1340,7 +1336,6 @@ static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD,
13401336
argVar->getType().getNonReferenceType(), VK_LValue,
13411337
SourceLocation());
13421338
llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(CGF);
1343-
argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy);
13441339
args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy);
13451340

13461341
// The third argument is the sizeof the type.
@@ -1377,7 +1372,6 @@ static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF,
13771372
llvm::Value *ivarAddr =
13781373
CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0)
13791374
.getPointer(CGF);
1380-
ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy);
13811375
args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy);
13821376

13831377
// The second argument is the address of the parameter variable.
@@ -1386,7 +1380,6 @@ static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF,
13861380
argVar->getType().getNonReferenceType(), VK_LValue,
13871381
SourceLocation());
13881382
llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(CGF);
1389-
argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy);
13901383
args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy);
13911384

13921385
// Third argument is the helper function.
@@ -3685,7 +3678,6 @@ void CodeGenFunction::EmitExtendGCLifetime(llvm::Value *object) {
36853678
/* constraints */ "r",
36863679
/* side effects */ true);
36873680

3688-
object = Builder.CreateBitCast(object, VoidPtrTy);
36893681
EmitNounwindRuntimeCall(extender, object);
36903682
}
36913683

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,6 @@ MicrosoftCXXABI::performReturnAdjustment(CodeGenFunction &CGF, Address Ret,
22662266
if (RA.isEmpty())
22672267
return Ret.getPointer();
22682268

2269-
auto OrigTy = Ret.getType();
22702269
Ret = Ret.withElementType(CGF.Int8Ty);
22712270

22722271
llvm::Value *V = Ret.getPointer();
@@ -2283,8 +2282,7 @@ MicrosoftCXXABI::performReturnAdjustment(CodeGenFunction &CGF, Address Ret,
22832282
if (RA.NonVirtual)
22842283
V = CGF.Builder.CreateConstInBoundsGEP1_32(CGF.Int8Ty, V, RA.NonVirtual);
22852284

2286-
// Cast back to the original type.
2287-
return CGF.Builder.CreateBitCast(V, OrigTy);
2285+
return V;
22882286
}
22892287

22902288
bool MicrosoftCXXABI::requiresArrayCookie(const CXXDeleteExpr *expr,

0 commit comments

Comments
 (0)