Skip to content

Commit bc44e6e

Browse files
committed
[clang] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque pointer cleanup effort.
1 parent 008af1c commit bc44e6e

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5049,7 +5049,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
50495049
case Builtin::BI__GetExceptionInfo: {
50505050
if (llvm::GlobalVariable *GV =
50515051
CGM.getCXXABI().getThrowInfo(FD->getParamDecl(0)->getType()))
5052-
return RValue::get(llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy));
5052+
return RValue::get(GV);
50535053
break;
50545054
}
50555055

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
386386
GV->takeName(OldGV);
387387

388388
// Replace all uses of the old global with the new global
389-
llvm::Constant *NewPtrForOldDecl =
390-
llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
391-
OldGV->replaceAllUsesWith(NewPtrForOldDecl);
389+
OldGV->replaceAllUsesWith(GV);
392390

393391
// Erase the old global, since it is no longer used.
394392
OldGV->eraseFromParent();

clang/lib/CodeGen/CodeGenPGO.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,9 +960,8 @@ void CodeGenPGO::emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S,
960960
return;
961961

962962
unsigned Counter = (*RegionCounterMap)[S];
963-
auto *I8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
964963

965-
llvm::Value *Args[] = {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
964+
llvm::Value *Args[] = {FuncNameVar,
966965
Builder.getInt64(FunctionHash),
967966
Builder.getInt32(NumRegionCounters),
968967
Builder.getInt32(Counter), StepV};
@@ -1000,7 +999,7 @@ void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind,
1000999
auto BuilderInsertPoint = Builder.saveIP();
10011000
Builder.SetInsertPoint(ValueSite);
10021001
llvm::Value *Args[5] = {
1003-
llvm::ConstantExpr::getBitCast(FuncNameVar, Builder.getInt8PtrTy()),
1002+
FuncNameVar,
10041003
Builder.getInt64(FunctionHash),
10051004
Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
10061005
Builder.getInt32(ValueKind),

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3938,9 +3938,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
39383938
// If there's already an old global variable, replace it with the new one.
39393939
if (OldGV) {
39403940
GV->takeName(OldGV);
3941-
llvm::Constant *NewPtr =
3942-
llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
3943-
OldGV->replaceAllUsesWith(NewPtr);
3941+
OldGV->replaceAllUsesWith(GV);
39443942
OldGV->eraseFromParent();
39453943
}
39463944

0 commit comments

Comments
 (0)