[llvm] c42d006 - [llvm][InstrProfiling] Remove no-op ptr-to-ptr bitcasts (NFC)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 12 10:46:42 PST 2023
Author: JOE1994
Date: 2023-11-12T13:44:06-05:00
New Revision: c42d006f05a03cecc0417d77b3bfb8f936d7594a
URL: https://github.com/llvm/llvm-project/commit/c42d006f05a03cecc0417d77b3bfb8f936d7594a
DIFF: https://github.com/llvm/llvm-project/commit/c42d006f05a03cecc0417d77b3bfb8f936d7594a.diff
LOG: [llvm][InstrProfiling] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
Added:
Modified:
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 3c66ebc7db3d804..50b791ff5fff501 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -1575,7 +1575,7 @@ bool DataFlowSanitizer::runImpl(
// below will take care of instrumenting it.
Function *NewF =
buildWrapperFunction(F, "", GA.getLinkage(), F->getFunctionType());
- GA.replaceAllUsesWith(ConstantExpr::getBitCast(NewF, GA.getType()));
+ GA.replaceAllUsesWith(NewF);
NewF->takeName(&GA);
GA.eraseFromParent();
FnsToInstrument.push_back(NewF);
@@ -1622,9 +1622,6 @@ bool DataFlowSanitizer::runImpl(
WrapperLinkage, FT);
NewF->removeFnAttrs(ReadOnlyNoneAttrs);
- Value *WrappedFnCst =
- ConstantExpr::getBitCast(NewF, PointerType::getUnqual(FT));
-
// Extern weak functions can sometimes be null at execution time.
// Code will sometimes check if an extern weak function is null.
// This could look something like:
@@ -1657,9 +1654,9 @@ bool DataFlowSanitizer::runImpl(
}
return true;
};
- F.replaceUsesWithIf(WrappedFnCst, IsNotCmpUse);
+ F.replaceUsesWithIf(NewF, IsNotCmpUse);
- UnwrappedFnMap[WrappedFnCst] = &F;
+ UnwrappedFnMap[NewF] = &F;
*FI = NewF;
if (!F.isDeclaration()) {
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index c426a15eeb0bafb..84cc8c601366e62 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1010,7 +1010,7 @@ static inline Constant *getFuncAddrForProfData(Function *Fn) {
// If we can't use an alias, we must use the public symbol, even though this
// may require a symbolic relocation.
if (shouldUsePublicSymbol(Fn))
- return ConstantExpr::getBitCast(Fn, Int8PtrTy);
+ return Fn;
// When possible use a private alias to avoid symbolic relocations.
auto *GA = GlobalAlias::create(GlobalValue::LinkageTypes::PrivateLinkage,
@@ -1033,7 +1033,7 @@ static inline Constant *getFuncAddrForProfData(Function *Fn) {
// appendToCompilerUsed(*Fn->getParent(), {GA});
- return ConstantExpr::getBitCast(GA, Int8PtrTy);
+ return GA;
}
static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) {
@@ -1299,8 +1299,7 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc,
getInstrProfSectionName(IPSK_vals, TT.getObjectFormat()));
ValuesVar->setAlignment(Align(8));
maybeSetComdat(ValuesVar, Fn, CntsVarName);
- ValuesPtrExpr =
- ConstantExpr::getBitCast(ValuesVar, PointerType::getUnqual(Ctx));
+ ValuesPtrExpr = ValuesVar;
}
uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();
More information about the llvm-commits
mailing list