[llvm] eed067e - [llvm] Remove no-op ptr-to-ptr bitcasts (NFC)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 12:37:38 PST 2023
Author: Youngsuk Kim
Date: 2023-11-13T14:33:41-06:00
New Revision: eed067e9fb9602cac07b1b5166cd4a05b368262f
URL: https://github.com/llvm/llvm-project/commit/eed067e9fb9602cac07b1b5166cd4a05b368262f
DIFF: https://github.com/llvm/llvm-project/commit/eed067e9fb9602cac07b1b5166cd4a05b368262f.diff
LOG: [llvm] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
Added:
Modified:
llvm/lib/Target/XCore/XCoreISelLowering.cpp
llvm/lib/Transforms/Coroutines/CoroInstr.h
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/lib/Transforms/Utils/SanitizerStats.cpp
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.cpp b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
index 4f4fccd80f7608c..b3dd4de2a769c7a 100644
--- a/llvm/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
@@ -292,12 +292,10 @@ LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
return GA;
} else {
// Ideally we would not fold in offset with an index <= 11.
- Type *Ty = PointerType::getUnqual(*DAG.getContext());
- Constant *GA = ConstantExpr::getBitCast(const_cast<GlobalValue*>(GV), Ty);
- Ty = Type::getInt32Ty(*DAG.getContext());
+ Type *Ty = Type::getInt32Ty(*DAG.getContext());
Constant *Idx = ConstantInt::get(Ty, Offset);
Constant *GAI = ConstantExpr::getGetElementPtr(
- Type::getInt8Ty(*DAG.getContext()), GA, Idx);
+ Type::getInt8Ty(*DAG.getContext()), const_cast<GlobalValue *>(GV), Idx);
SDValue CP = DAG.getConstantPool(GAI, MVT::i32);
return DAG.getLoad(getPointerTy(DAG.getDataLayout()), DL,
DAG.getEntryNode(), CP, MachinePointerInfo());
diff --git a/llvm/lib/Transforms/Coroutines/CoroInstr.h b/llvm/lib/Transforms/Coroutines/CoroInstr.h
index 95e30a2a569ff22..f01aa58eb899961 100644
--- a/llvm/lib/Transforms/Coroutines/CoroInstr.h
+++ b/llvm/lib/Transforms/Coroutines/CoroInstr.h
@@ -185,9 +185,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
void setCoroutineSelf() {
assert(isa<ConstantPointerNull>(getArgOperand(CoroutineArg)) &&
"Coroutine argument is already assigned");
- auto *const Int8PtrTy = PointerType::getUnqual(getContext());
- setArgOperand(CoroutineArg,
- ConstantExpr::getBitCast(getFunction(), Int8PtrTy));
+ setArgOperand(CoroutineArg, getFunction());
}
// Methods to support type inquiry through isa, cast, and dyn_cast:
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 3b2a7b03dd6d34e..4093a5a51a4d79e 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -1105,7 +1105,7 @@ bool LoopIdiomRecognize::processLoopStridedStore(
PatternValue, ".memset_pattern");
GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global); // Ok to merge these.
GV->setAlignment(Align(16));
- Value *PatternPtr = ConstantExpr::getBitCast(GV, Int8PtrTy);
+ Value *PatternPtr = GV;
NewCall = Builder.CreateCall(MSP, {BasePtr, PatternPtr, NumBytes});
// Set the TBAA info if present.
diff --git a/llvm/lib/Transforms/Utils/SanitizerStats.cpp b/llvm/lib/Transforms/Utils/SanitizerStats.cpp
index f780b4567bd28d3..1791694ec36aa26 100644
--- a/llvm/lib/Transforms/Utils/SanitizerStats.cpp
+++ b/llvm/lib/Transforms/Utils/SanitizerStats.cpp
@@ -65,7 +65,7 @@ void SanitizerStatReport::create(IRBuilder<> &B, SanitizerStatKind SK) {
ConstantInt::get(IntPtrTy, 0), ConstantInt::get(B.getInt32Ty(), 2),
ConstantInt::get(IntPtrTy, Inits.size() - 1),
});
- B.CreateCall(StatReport, ConstantExpr::getBitCast(InitAddr, Int8PtrTy));
+ B.CreateCall(StatReport, InitAddr);
}
void SanitizerStatReport::finish() {
@@ -86,8 +86,7 @@ void SanitizerStatReport::finish() {
{Constant::getNullValue(Int8PtrTy),
ConstantInt::get(Int32Ty, Inits.size()),
ConstantArray::get(makeModuleStatsArrayTy(), Inits)}));
- ModuleStatsGV->replaceAllUsesWith(
- ConstantExpr::getBitCast(NewModuleStatsGV, ModuleStatsGV->getType()));
+ ModuleStatsGV->replaceAllUsesWith(NewModuleStatsGV);
ModuleStatsGV->eraseFromParent();
// Create a global constructor to register NewModuleStatsGV.
@@ -100,7 +99,7 @@ void SanitizerStatReport::finish() {
FunctionCallee StatInit =
M->getOrInsertFunction("__sanitizer_stat_init", StatInitTy);
- B.CreateCall(StatInit, ConstantExpr::getBitCast(NewModuleStatsGV, Int8PtrTy));
+ B.CreateCall(StatInit, NewModuleStatsGV);
B.CreateRetVoid();
appendToGlobalCtors(*M, F, 0);
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
index d3572e2f5abf75b..5b1363d3293a6cc 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -113,7 +113,7 @@ static void extractArgumentsFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
replaceFunctionCalls(*F, *ClonedFunc, ArgIndexesToKeep);
// Rename Cloned Function to Old's name
std::string FName = std::string(F->getName());
- F->replaceAllUsesWith(ConstantExpr::getBitCast(ClonedFunc, F->getType()));
+ F->replaceAllUsesWith(ClonedFunc);
F->eraseFromParent();
ClonedFunc->setName(FName);
}
More information about the llvm-commits
mailing list