[clang] b26b1ce - [clang][CodeGenModule] Remove no-op ptr-to-ptr bitcasts (NFC)
Youngsuk Kim via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 5 08:19:49 PST 2023
Author: Youngsuk Kim
Date: 2023-11-05T10:17:45-06:00
New Revision: b26b1cee2e6b0b730fda87dbd4a236810d424129
URL: https://github.com/llvm/llvm-project/commit/b26b1cee2e6b0b730fda87dbd4a236810d424129
DIFF: https://github.com/llvm/llvm-project/commit/b26b1cee2e6b0b730fda87dbd4a236810d424129.diff
LOG: [clang][CodeGenModule] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
Added:
Modified:
clang/lib/CodeGen/CodeGenModule.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 35f651b39f6748a..f72101799d31e4c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3201,10 +3201,9 @@ llvm::Constant *CodeGenModule::EmitAnnotationArgs(const AnnotateAttr *Attr) {
".args");
GV->setSection(AnnotationSection);
GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
- auto *Bitcasted = llvm::ConstantExpr::getBitCast(GV, GlobalsInt8PtrTy);
- Lookup = Bitcasted;
- return Bitcasted;
+ Lookup = GV;
+ return GV;
}
llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
@@ -3227,11 +3226,7 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
// Create the ConstantStruct for the global annotation.
llvm::Constant *Fields[] = {
- llvm::ConstantExpr::getBitCast(GVInGlobalsAS, GlobalsInt8PtrTy),
- llvm::ConstantExpr::getBitCast(AnnoGV, ConstGlobalsPtrTy),
- llvm::ConstantExpr::getBitCast(UnitGV, ConstGlobalsPtrTy),
- LineNoCst,
- Args,
+ GVInGlobalsAS, AnnoGV, UnitGV, LineNoCst, Args,
};
return llvm::ConstantStruct::getAnon(Fields);
}
@@ -4697,9 +4692,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty,
GV->takeName(Entry);
if (!Entry->use_empty()) {
- llvm::Constant *NewPtrForOldDecl =
- llvm::ConstantExpr::getBitCast(GV, Entry->getType());
- Entry->replaceAllUsesWith(NewPtrForOldDecl);
+ Entry->replaceAllUsesWith(GV);
}
Entry->eraseFromParent();
@@ -4878,9 +4871,7 @@ llvm::GlobalVariable *CodeGenModule::CreateOrReplaceCXXRuntimeVariable(
GV->takeName(OldGV);
if (!OldGV->use_empty()) {
- llvm::Constant *NewPtrForOldDecl =
- llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
- OldGV->replaceAllUsesWith(NewPtrForOldDecl);
+ OldGV->replaceAllUsesWith(GV);
}
OldGV->eraseFromParent();
@@ -5766,8 +5757,7 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
// Remove it and replace uses of it with the alias.
GA->takeName(Entry);
- Entry->replaceAllUsesWith(llvm::ConstantExpr::getBitCast(GA,
- Entry->getType()));
+ Entry->replaceAllUsesWith(GA);
Entry->eraseFromParent();
} else {
GA->setName(MangledName);
@@ -5845,8 +5835,7 @@ void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
// Remove it and replace uses of it with the ifunc.
GIF->takeName(Entry);
- Entry->replaceAllUsesWith(llvm::ConstantExpr::getBitCast(GIF,
- Entry->getType()));
+ Entry->replaceAllUsesWith(GIF);
Entry->eraseFromParent();
} else
GIF->setName(MangledName);
@@ -6042,9 +6031,6 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
llvm::Constant *Str =
llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);
- if (isUTF16)
- // Cast the UTF16 string to the correct type.
- Str = llvm::ConstantExpr::getBitCast(Str, Int8PtrTy);
Fields.add(Str);
// String length.
@@ -6414,8 +6400,7 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
// replace it with the new global now.
llvm::Constant *&Entry = MaterializedGlobalTemporaryMap[E];
if (Entry) {
- Entry->replaceAllUsesWith(
- llvm::ConstantExpr::getBitCast(CV, Entry->getType()));
+ Entry->replaceAllUsesWith(CV);
llvm::cast<llvm::GlobalVariable>(Entry)->eraseFromParent();
}
Entry = CV;
More information about the cfe-commits
mailing list