diff options
author | Youngsuk Kim <youngsuk.kim@hpe.com> | 2023-11-05 10:14:51 -0600 |
---|---|---|
committer | Youngsuk Kim <youngsuk.kim@hpe.com> | 2023-11-05 10:17:45 -0600 |
commit | b26b1cee2e6b0b730fda87dbd4a236810d424129 (patch) | |
tree | 9be1e8bb408848018a5754398811336f6596964b /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 2dace0452107a43ed030f1156d52282dd6495de2 (diff) | |
download | llvm-b26b1cee2e6b0b730fda87dbd4a236810d424129.zip llvm-b26b1cee2e6b0b730fda87dbd4a236810d424129.tar.gz llvm-b26b1cee2e6b0b730fda87dbd4a236810d424129.tar.bz2 |
[clang][CodeGenModule] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 35f651b..f721017 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; |