[clang] 10e4835 - [clang][CodeGen] Remove ptr-to-ptr bitcasts (NFC) (#73020)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 23 08:35:03 PST 2023
Author: Youngsuk Kim
Date: 2023-11-23T11:34:59-05:00
New Revision: 10e483521a067eb5be9c844a41248e9d12e46dde
URL: https://github.com/llvm/llvm-project/commit/10e483521a067eb5be9c844a41248e9d12e46dde
DIFF: https://github.com/llvm/llvm-project/commit/10e483521a067eb5be9c844a41248e9d12e46dde.diff
LOG: [clang][CodeGen] Remove ptr-to-ptr bitcasts (NFC) (#73020)
Opaque ptr cleanup effort
Added:
Modified:
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGStmt.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 710e4c162103b41..c83ea966fdeadc6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5745,12 +5745,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
Address DestAddr = EmitMSVAListRef(E->getArg(0));
Address SrcAddr = EmitMSVAListRef(E->getArg(1));
- llvm::Type *BPP = Int8PtrPtrTy;
-
- DestAddr = Address(Builder.CreateBitCast(DestAddr.getPointer(), BPP, "cp"),
- Int8PtrTy, DestAddr.getAlignment());
- SrcAddr = Address(Builder.CreateBitCast(SrcAddr.getPointer(), BPP, "ap"),
- Int8PtrTy, SrcAddr.getAlignment());
+ DestAddr = DestAddr.withElementType(Int8PtrTy);
+ SrcAddr = SrcAddr.withElementType(Int8PtrTy);
Value *ArgPtr = Builder.CreateLoad(SrcAddr, "ap.val");
return RValue::get(Builder.CreateStore(ArgPtr, DestAddr));
@@ -8424,8 +8420,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
}
Value *LdPtr = EmitScalarExpr(E->getArg(0));
- Value *Val = Builder.CreateCall(F, Builder.CreateBitCast(LdPtr, Int8PtrTy),
- "ldrexd");
+ Value *Val = Builder.CreateCall(F, LdPtr, "ldrexd");
Value *Val0 = Builder.CreateExtractValue(Val, 1);
Value *Val1 = Builder.CreateExtractValue(Val, 0);
@@ -8483,7 +8478,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
Value *Arg0 = Builder.CreateExtractValue(Val, 0);
Value *Arg1 = Builder.CreateExtractValue(Val, 1);
- Value *StPtr = Builder.CreateBitCast(EmitScalarExpr(E->getArg(1)), Int8PtrTy);
+ Value *StPtr = EmitScalarExpr(E->getArg(1));
return Builder.CreateCall(F, {Arg0, Arg1, StPtr}, "strexd");
}
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index c719df1bfa05036..a7100c8fae2eff9 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1299,8 +1299,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
SLocPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
CGM.getSanitizerMetadata()->disableSanitizerForGlobal(SLocPtr);
assert(ReturnLocation.isValid() && "No valid return location");
- Builder.CreateStore(Builder.CreateBitCast(SLocPtr, Int8PtrTy),
- ReturnLocation);
+ Builder.CreateStore(SLocPtr, ReturnLocation);
}
// Returning from an outlined SEH helper is UB, and we already warn on it.
More information about the cfe-commits
mailing list