Skip to content

Commit 57dd23b

Browse files
committed
[llvm] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
1 parent 76ba660 commit 57dd23b

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,7 @@ static void instrumentOneFunc(
875875
F, TLI, ComdatMembers, true, BPI, BFI, IsCS, PGOInstrumentEntry,
876876
PGOBlockCoverage);
877877

878-
Type *I8PtrTy = PointerType::getUnqual(M->getContext());
879-
auto Name = ConstantExpr::getBitCast(FuncInfo.FuncNameVar, I8PtrTy);
878+
auto Name = FuncInfo.FuncNameVar;
880879
auto CFGHash = ConstantInt::get(Type::getInt64Ty(M->getContext()),
881880
FuncInfo.FunctionHash);
882881
if (PGOFunctionEntryCoverage) {
@@ -965,9 +964,8 @@ static void instrumentOneFunc(
965964
populateEHOperandBundle(Cand, BlockColors, OpBundles);
966965
Builder.CreateCall(
967966
Intrinsic::getDeclaration(M, Intrinsic::instrprof_value_profile),
968-
{ConstantExpr::getBitCast(FuncInfo.FuncNameVar, I8PtrTy),
969-
Builder.getInt64(FuncInfo.FunctionHash), ToProfile,
970-
Builder.getInt32(Kind), Builder.getInt32(SiteIndex++)},
967+
{FuncInfo.FuncNameVar, Builder.getInt64(FuncInfo.FunctionHash),
968+
ToProfile, Builder.getInt32(Kind), Builder.getInt32(SiteIndex++)},
971969
OpBundles);
972970
}
973971
} // IPVK_First <= Kind <= IPVK_Last
@@ -1650,12 +1648,10 @@ void SelectInstVisitor::instrumentOneSelectInst(SelectInst &SI) {
16501648
Module *M = F.getParent();
16511649
IRBuilder<> Builder(&SI);
16521650
Type *Int64Ty = Builder.getInt64Ty();
1653-
Type *I8PtrTy = Builder.getInt8PtrTy();
16541651
auto *Step = Builder.CreateZExt(SI.getCondition(), Int64Ty);
16551652
Builder.CreateCall(
16561653
Intrinsic::getDeclaration(M, Intrinsic::instrprof_increment_step),
1657-
{ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
1658-
Builder.getInt64(FuncHash), Builder.getInt32(TotalNumCtrs),
1654+
{FuncNameVar, Builder.getInt64(FuncHash), Builder.getInt32(TotalNumCtrs),
16591655
Builder.getInt32(*CurCtrIdx), Step});
16601656
++(*CurCtrIdx);
16611657
}

llvm/lib/Transforms/Utils/CtorUtils.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ static void removeGlobalCtors(GlobalVariable *GCL, const BitVector &CtorsToRemov
5252
NGV->takeName(GCL);
5353

5454
// Nuke the old list, replacing any uses with the new one.
55-
if (!GCL->use_empty()) {
56-
Constant *V = NGV;
57-
if (V->getType() != GCL->getType())
58-
V = ConstantExpr::getBitCast(V, GCL->getType());
59-
GCL->replaceAllUsesWith(V);
60-
}
55+
if (!GCL->use_empty())
56+
GCL->replaceAllUsesWith(NGV);
57+
6158
GCL->eraseFromParent();
6259
}
6360

llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static void substituteOperandWithArgument(Function *OldF,
175175

176176
// Rename NewF to OldF's name.
177177
std::string FName = OldF->getName().str();
178-
OldF->replaceAllUsesWith(ConstantExpr::getBitCast(NewF, OldF->getType()));
178+
OldF->replaceAllUsesWith(NewF);
179179
OldF->eraseFromParent();
180180
NewF->setName(FName);
181181
}

0 commit comments

Comments
 (0)