[clang] 5532d67 - [clang] Remove no-op ptr-to-ptr bitcasts (NFC)
Youngsuk Kim via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 2 10:48:00 PDT 2023
Author: Youngsuk Kim
Date: 2023-11-02T12:43:26-05:00
New Revision: 5532d67a360e99f6b60d311d64e94a5a32d5d141
URL: https://github.com/llvm/llvm-project/commit/5532d67a360e99f6b60d311d64e94a5a32d5d141
DIFF: https://github.com/llvm/llvm-project/commit/5532d67a360e99f6b60d311d64e94a5a32d5d141.diff
LOG: [clang] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC)
Added:
Modified:
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index dbc4cffa8976d6f..4f3a6e34bda2fe1 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -164,8 +164,7 @@ static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM,
CGM.getLangOpts().getGC() == LangOptions::NonGC) {
descName = getBlockDescriptorName(blockInfo, CGM);
if (llvm::GlobalValue *desc = CGM.getModule().getNamedValue(descName))
- return llvm::ConstantExpr::getBitCast(desc,
- CGM.getBlockDescriptorType());
+ return desc;
}
// If there isn't an equivalent block descriptor global variable, create a new
@@ -242,7 +241,7 @@ static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM,
global->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
}
- return llvm::ConstantExpr::getBitCast(global, CGM.getBlockDescriptorType());
+ return global;
}
/*
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e10617162733bba..93742688fb9cbdd 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -126,7 +126,7 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D,
CGM.getLLVMContext(), CGM.getContext().getTargetAddressSpace(DestAS));
auto SrcAS = D.getType().getQualifiers().getAddressSpace();
if (DestAS == SrcAS)
- Argument = llvm::ConstantExpr::getBitCast(Addr.getPointer(), DestTy);
+ Argument = Addr.getPointer();
else
// FIXME: On addr space mismatch we are passing NULL. The generation
// of the global destructor function should be adjusted accordingly.
@@ -167,8 +167,7 @@ void CodeGenFunction::EmitInvariantStart(llvm::Constant *Addr, CharUnits Size) {
// Emit a call with the size in bytes of the object.
uint64_t Width = Size.getQuantity();
- llvm::Value *Args[2] = { llvm::ConstantInt::getSigned(Int64Ty, Width),
- llvm::ConstantExpr::getBitCast(Addr, Int8PtrTy)};
+ llvm::Value *Args[2] = {llvm::ConstantInt::getSigned(Int64Ty, Width), Addr};
Builder.CreateCall(InvariantStart, Args);
}
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index cd91a698a9336f8..69616dcc07efe1f 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1630,13 +1630,8 @@ namespace {
IndexValues[i] = llvm::ConstantInt::get(CGM.Int32Ty, Indices[i]);
}
- // Form a GEP and then bitcast to the placeholder type so that the
- // replacement will succeed.
- llvm::Constant *location =
- llvm::ConstantExpr::getInBoundsGetElementPtr(BaseValueTy,
- Base, IndexValues);
- location = llvm::ConstantExpr::getBitCast(location,
- placeholder->getType());
+ llvm::Constant *location = llvm::ConstantExpr::getInBoundsGetElementPtr(
+ BaseValueTy, Base, IndexValues);
Locations.insert({placeholder, location});
}
@@ -2037,8 +2032,6 @@ ConstantLValue
ConstantLValueEmitter::VisitAddrLabelExpr(const AddrLabelExpr *E) {
assert(Emitter.CGF && "Invalid address of label expression outside function");
llvm::Constant *Ptr = Emitter.CGF->GetAddrOfLabel(E->getLabel());
- Ptr = llvm::ConstantExpr::getBitCast(Ptr,
- CGM.getTypes().ConvertType(E->getType()));
return Ptr;
}
More information about the cfe-commits
mailing list