Skip to content

Commit

Permalink
[CGBlocks] Remove no-op ptr-to-ptr bitcasts (NFC)
Browse files Browse the repository at this point in the history
Opaque ptr cleanup effort. NFC.
  • Loading branch information
JOE1994 committed Nov 1, 2023
1 parent 6266b96 commit 09f1aac
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions clang/lib/CodeGen/CGBlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM,
// Signature. Mandatory ObjC-style method descriptor @encode sequence.
std::string typeAtEncoding =
CGM.getContext().getObjCEncodingForBlock(blockInfo.getBlockExpr());
elements.add(llvm::ConstantExpr::getBitCast(
CGM.GetAddrOfConstantCString(typeAtEncoding).getPointer(), i8p));
elements.add(CGM.GetAddrOfConstantCString(typeAtEncoding).getPointer());

// GC layout.
if (C.getLangOpts().ObjC) {
Expand Down Expand Up @@ -809,7 +808,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
llvm::Constant *blockISA = blockInfo.NoEscape
? CGM.getNSConcreteGlobalBlock()
: CGM.getNSConcreteStackBlock();
isa = llvm::ConstantExpr::getBitCast(blockISA, VoidPtrTy);
isa = blockISA;

// Build the block descriptor.
descriptor = buildBlockDescriptor(CGM, blockInfo);
Expand Down Expand Up @@ -1869,7 +1868,7 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) {
CaptureStrKind::CopyHelper, CGM);

if (llvm::GlobalValue *Func = CGM.getModule().getNamedValue(FuncName))
return llvm::ConstantExpr::getBitCast(Func, VoidPtrTy);
return Func;

ASTContext &C = getContext();

Expand Down Expand Up @@ -1990,7 +1989,7 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) {

FinishFunction();

return llvm::ConstantExpr::getBitCast(Fn, VoidPtrTy);
return Fn;
}

static BlockFieldFlags
Expand Down Expand Up @@ -2056,7 +2055,7 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) {
CaptureStrKind::DisposeHelper, CGM);

if (llvm::GlobalValue *Func = CGM.getModule().getNamedValue(FuncName))
return llvm::ConstantExpr::getBitCast(Func, VoidPtrTy);
return Func;

ASTContext &C = getContext();

Expand Down Expand Up @@ -2113,7 +2112,7 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) {

FinishFunction();

return llvm::ConstantExpr::getBitCast(Fn, VoidPtrTy);
return Fn;
}

namespace {
Expand Down Expand Up @@ -2352,7 +2351,7 @@ generateByrefCopyHelper(CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo,

CGF.FinishFunction();

return llvm::ConstantExpr::getBitCast(Fn, CGF.Int8PtrTy);
return Fn;
}

/// Build the copy helper for a __block variable.
Expand Down Expand Up @@ -2408,7 +2407,7 @@ generateByrefDisposeHelper(CodeGenFunction &CGF,

CGF.FinishFunction();

return llvm::ConstantExpr::getBitCast(Fn, CGF.Int8PtrTy);
return Fn;
}

/// Build the dispose helper for a __block variable.
Expand Down

0 comments on commit 09f1aac

Please sign in to comment.