Skip to content

Commit 2c3fb03

Browse files
committed
[clang] Replace uses of CreatePointerBitCastOrAddrSpaceCast (NFC)
With opaque pointers, CreatePointerBitCastOrAddrSpaceCast is same as CreateAddrSpaceCast. Replace or remove uses of CreatePointerBitCastOrAddrSpaceCast. Opaque pointer cleanup effort.
1 parent 8fd02d5 commit 2c3fb03

File tree

5 files changed

+5
-8
lines changed

5 files changed

+5
-8
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ static void CreateCoercedStore(llvm::Value *Src,
13761376
llvm::PointerType *DstPtrTy = llvm::dyn_cast<llvm::PointerType>(DstTy);
13771377
if (SrcPtrTy && DstPtrTy &&
13781378
SrcPtrTy->getAddressSpace() != DstPtrTy->getAddressSpace()) {
1379-
Src = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DstTy);
1379+
Src = CGF.Builder.CreateAddrSpaceCast(Src, DstTy);
13801380
CGF.Builder.CreateStore(Src, Dst, DstIsVolatile);
13811381
return;
13821382
}

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
11231123
if (!CurFnInfo->getReturnInfo().getIndirectByVal()) {
11241124
ReturnValuePointer =
11251125
CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
1126-
Builder.CreateStore(Builder.CreatePointerBitCastOrAddrSpaceCast(
1127-
ReturnValue.getPointer(), Int8PtrTy),
1128-
ReturnValuePointer);
1126+
Builder.CreateStore(ReturnValue.getPointer(), ReturnValuePointer);
11291127
}
11301128
} else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::InAlloca &&
11311129
!hasScalarEvaluationKind(CurFnInfo->getReturnType())) {

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,9 +3088,6 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
30883088
CharUnits Align = CGM.getContext().getDeclAlign(VD);
30893089
Val = Builder.CreateAlignedLoad(Var->getValueType(), Val, Align);
30903090
}
3091-
if (Val->getType() != Wrapper->getReturnType())
3092-
Val = Builder.CreatePointerBitCastOrAddrSpaceCast(
3093-
Val, Wrapper->getReturnType(), "");
30943091

30953092
Builder.CreateRet(Val);
30963093
}

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ llvm::Value *TargetCodeGenInfo::performAddrSpaceCast(
137137
if (auto *C = dyn_cast<llvm::Constant>(Src))
138138
return performAddrSpaceCast(CGF.CGM, C, SrcAddr, DestAddr, DestTy);
139139
// Try to preserve the source's name to make IR more readable.
140-
return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
140+
return CGF.Builder.CreateAddrSpaceCast(
141141
Src, DestTy, Src->hasName() ? Src->getName() + ".ascast" : "");
142142
}
143143

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,8 @@ class IRBuilderBase {
21382138
return Insert(CastInst::CreatePointerCast(V, DestTy), Name);
21392139
}
21402140

2141+
// With opaque pointers enabled, this is same as CreateAddressSpaceCast.
2142+
// TODO: Replace uses of this method and remove the method itself.
21412143
Value *CreatePointerBitCastOrAddrSpaceCast(Value *V, Type *DestTy,
21422144
const Twine &Name = "") {
21432145
if (V->getType() == DestTy)

0 commit comments

Comments
 (0)