Skip to content

Commit c42d006

Browse files
committed
[llvm][InstrProfiling] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
1 parent f575d79 commit c42d006

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ bool DataFlowSanitizer::runImpl(
15751575
// below will take care of instrumenting it.
15761576
Function *NewF =
15771577
buildWrapperFunction(F, "", GA.getLinkage(), F->getFunctionType());
1578-
GA.replaceAllUsesWith(ConstantExpr::getBitCast(NewF, GA.getType()));
1578+
GA.replaceAllUsesWith(NewF);
15791579
NewF->takeName(&GA);
15801580
GA.eraseFromParent();
15811581
FnsToInstrument.push_back(NewF);
@@ -1622,9 +1622,6 @@ bool DataFlowSanitizer::runImpl(
16221622
WrapperLinkage, FT);
16231623
NewF->removeFnAttrs(ReadOnlyNoneAttrs);
16241624

1625-
Value *WrappedFnCst =
1626-
ConstantExpr::getBitCast(NewF, PointerType::getUnqual(FT));
1627-
16281625
// Extern weak functions can sometimes be null at execution time.
16291626
// Code will sometimes check if an extern weak function is null.
16301627
// This could look something like:
@@ -1657,9 +1654,9 @@ bool DataFlowSanitizer::runImpl(
16571654
}
16581655
return true;
16591656
};
1660-
F.replaceUsesWithIf(WrappedFnCst, IsNotCmpUse);
1657+
F.replaceUsesWithIf(NewF, IsNotCmpUse);
16611658

1662-
UnwrappedFnMap[WrappedFnCst] = &F;
1659+
UnwrappedFnMap[NewF] = &F;
16631660
*FI = NewF;
16641661

16651662
if (!F.isDeclaration()) {

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ static inline Constant *getFuncAddrForProfData(Function *Fn) {
10101010
// If we can't use an alias, we must use the public symbol, even though this
10111011
// may require a symbolic relocation.
10121012
if (shouldUsePublicSymbol(Fn))
1013-
return ConstantExpr::getBitCast(Fn, Int8PtrTy);
1013+
return Fn;
10141014

10151015
// When possible use a private alias to avoid symbolic relocations.
10161016
auto *GA = GlobalAlias::create(GlobalValue::LinkageTypes::PrivateLinkage,
@@ -1033,7 +1033,7 @@ static inline Constant *getFuncAddrForProfData(Function *Fn) {
10331033

10341034
// appendToCompilerUsed(*Fn->getParent(), {GA});
10351035

1036-
return ConstantExpr::getBitCast(GA, Int8PtrTy);
1036+
return GA;
10371037
}
10381038

10391039
static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) {
@@ -1299,8 +1299,7 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc,
12991299
getInstrProfSectionName(IPSK_vals, TT.getObjectFormat()));
13001300
ValuesVar->setAlignment(Align(8));
13011301
maybeSetComdat(ValuesVar, Fn, CntsVarName);
1302-
ValuesPtrExpr =
1303-
ConstantExpr::getBitCast(ValuesVar, PointerType::getUnqual(Ctx));
1302+
ValuesPtrExpr = ValuesVar;
13041303
}
13051304

13061305
uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();

0 commit comments

Comments
 (0)