Skip to content

Commit eed067e

Browse files
committed
[llvm] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
1 parent 2c65860 commit eed067e

File tree

5 files changed

+8
-13
lines changed

5 files changed

+8
-13
lines changed

llvm/lib/Target/XCore/XCoreISelLowering.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,10 @@ LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
292292
return GA;
293293
} else {
294294
// Ideally we would not fold in offset with an index <= 11.
295-
Type *Ty = PointerType::getUnqual(*DAG.getContext());
296-
Constant *GA = ConstantExpr::getBitCast(const_cast<GlobalValue*>(GV), Ty);
297-
Ty = Type::getInt32Ty(*DAG.getContext());
295+
Type *Ty = Type::getInt32Ty(*DAG.getContext());
298296
Constant *Idx = ConstantInt::get(Ty, Offset);
299297
Constant *GAI = ConstantExpr::getGetElementPtr(
300-
Type::getInt8Ty(*DAG.getContext()), GA, Idx);
298+
Type::getInt8Ty(*DAG.getContext()), const_cast<GlobalValue *>(GV), Idx);
301299
SDValue CP = DAG.getConstantPool(GAI, MVT::i32);
302300
return DAG.getLoad(getPointerTy(DAG.getDataLayout()), DL,
303301
DAG.getEntryNode(), CP, MachinePointerInfo());

llvm/lib/Transforms/Coroutines/CoroInstr.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
185185
void setCoroutineSelf() {
186186
assert(isa<ConstantPointerNull>(getArgOperand(CoroutineArg)) &&
187187
"Coroutine argument is already assigned");
188-
auto *const Int8PtrTy = PointerType::getUnqual(getContext());
189-
setArgOperand(CoroutineArg,
190-
ConstantExpr::getBitCast(getFunction(), Int8PtrTy));
188+
setArgOperand(CoroutineArg, getFunction());
191189
}
192190

193191
// Methods to support type inquiry through isa, cast, and dyn_cast:

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ bool LoopIdiomRecognize::processLoopStridedStore(
11051105
PatternValue, ".memset_pattern");
11061106
GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global); // Ok to merge these.
11071107
GV->setAlignment(Align(16));
1108-
Value *PatternPtr = ConstantExpr::getBitCast(GV, Int8PtrTy);
1108+
Value *PatternPtr = GV;
11091109
NewCall = Builder.CreateCall(MSP, {BasePtr, PatternPtr, NumBytes});
11101110

11111111
// Set the TBAA info if present.

llvm/lib/Transforms/Utils/SanitizerStats.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void SanitizerStatReport::create(IRBuilder<> &B, SanitizerStatKind SK) {
6565
ConstantInt::get(IntPtrTy, 0), ConstantInt::get(B.getInt32Ty(), 2),
6666
ConstantInt::get(IntPtrTy, Inits.size() - 1),
6767
});
68-
B.CreateCall(StatReport, ConstantExpr::getBitCast(InitAddr, Int8PtrTy));
68+
B.CreateCall(StatReport, InitAddr);
6969
}
7070

7171
void SanitizerStatReport::finish() {
@@ -86,8 +86,7 @@ void SanitizerStatReport::finish() {
8686
{Constant::getNullValue(Int8PtrTy),
8787
ConstantInt::get(Int32Ty, Inits.size()),
8888
ConstantArray::get(makeModuleStatsArrayTy(), Inits)}));
89-
ModuleStatsGV->replaceAllUsesWith(
90-
ConstantExpr::getBitCast(NewModuleStatsGV, ModuleStatsGV->getType()));
89+
ModuleStatsGV->replaceAllUsesWith(NewModuleStatsGV);
9190
ModuleStatsGV->eraseFromParent();
9291

9392
// Create a global constructor to register NewModuleStatsGV.
@@ -100,7 +99,7 @@ void SanitizerStatReport::finish() {
10099
FunctionCallee StatInit =
101100
M->getOrInsertFunction("__sanitizer_stat_init", StatInitTy);
102101

103-
B.CreateCall(StatInit, ConstantExpr::getBitCast(NewModuleStatsGV, Int8PtrTy));
102+
B.CreateCall(StatInit, NewModuleStatsGV);
104103
B.CreateRetVoid();
105104

106105
appendToGlobalCtors(*M, F, 0);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void extractArgumentsFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
113113
replaceFunctionCalls(*F, *ClonedFunc, ArgIndexesToKeep);
114114
// Rename Cloned Function to Old's name
115115
std::string FName = std::string(F->getName());
116-
F->replaceAllUsesWith(ConstantExpr::getBitCast(ClonedFunc, F->getType()));
116+
F->replaceAllUsesWith(ClonedFunc);
117117
F->eraseFromParent();
118118
ClonedFunc->setName(FName);
119119
}

0 commit comments

Comments
 (0)