[llvm] Allow optimization of __size_returning_new variants. (PR #102258)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 17:59:24 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 874890c68241f500501c42730c2829a5d51f2100 39a19192fca55fdd7d8c4cc7de5344cb5df1e56d --extensions cpp,h -- llvm/include/llvm/Transforms/Utils/BuildLibCalls.h llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/lib/Transforms/Instrumentation/MemProfiler.cpp llvm/lib/Transforms/Utils/BuildLibCalls.cpp llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/Transforms/Utils/BuildLibCalls.h b/llvm/include/llvm/Transforms/Utils/BuildLibCalls.h
index 341a21d16b..1979c4af77 100644
--- a/llvm/include/llvm/Transforms/Utils/BuildLibCalls.h
+++ b/llvm/include/llvm/Transforms/Utils/BuildLibCalls.h
@@ -268,11 +268,12 @@ namespace llvm {
const TargetLibraryInfo *TLI,
LibFunc NewFunc, uint8_t HotCold);
Value *emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B,
- const TargetLibraryInfo *TLI, LibFunc NewFunc,
- uint8_t HotCold);
- Value *emitHotColdSizeReturningNewAligned(Value *Num, Value *Align, IRBuilderBase &B,
- const TargetLibraryInfo *TLI, LibFunc NewFunc,
- uint8_t HotCold);
+ const TargetLibraryInfo *TLI,
+ LibFunc NewFunc, uint8_t HotCold);
+ Value *emitHotColdSizeReturningNewAligned(Value *Num, Value *Align,
+ IRBuilderBase &B,
+ const TargetLibraryInfo *TLI,
+ LibFunc NewFunc, uint8_t HotCold);
}
#endif
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 5fc24e1519..3de1237072 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3947,7 +3947,6 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
}
}
-
// Try to optimize the call if possible, we require DataLayout for most of
// this. None of these calls are seen as possibly dead so go ahead and
// delete the instruction now.
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index efccbe835f..4a43120c9a 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -755,7 +755,7 @@ stackFrameIncludesInlinedCallStack(ArrayRef<Frame> ProfileCallStack,
}
static bool isAllocationWithHotColdVariant(Function *Callee,
- const TargetLibraryInfo &TLI) {
+ const TargetLibraryInfo &TLI) {
if (!Callee)
return false;
LibFunc Func;
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index bb04143d51..dfab87a961 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -1965,8 +1965,9 @@ Value *llvm::emitCalloc(Value *Num, Value *Size, IRBuilderBase &B,
}
Value *llvm::emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B,
- const TargetLibraryInfo *TLI, LibFunc SizeFeedbackNewFunc,
- uint8_t HotCold) {
+ const TargetLibraryInfo *TLI,
+ LibFunc SizeFeedbackNewFunc,
+ uint8_t HotCold) {
Module *M = B.GetInsertBlock()->getModule();
if (!isLibFuncEmittable(M, TLI, SizeFeedbackNewFunc))
return nullptr;
@@ -1974,13 +1975,13 @@ Value *llvm::emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B,
StringRef Name = TLI->getName(SizeFeedbackNewFunc);
// __sized_ptr_t struct return type { void*, size_t }
- llvm::StructType* SizedPtrT = llvm::StructType::get(M->getContext(),
- {B.getPtrTy(), Num->getType()});
- FunctionCallee Func = M->getOrInsertFunction(Name, SizedPtrT,
- Num->getType(), B.getInt8Ty());
+ llvm::StructType *SizedPtrT =
+ llvm::StructType::get(M->getContext(), {B.getPtrTy(), Num->getType()});
+ FunctionCallee Func =
+ M->getOrInsertFunction(Name, SizedPtrT, Num->getType(), B.getInt8Ty());
inferNonMandatoryLibFuncAttrs(M, Name, *TLI);
CallInst *CI = B.CreateCall(Func, {Num, B.getInt8(HotCold)}, Name);
- // Setting the name makes the tests easier to read.
+ // Setting the name makes the tests easier to read.
CI->setName("sized_ptr");
if (const Function *F =
@@ -1990,9 +1991,11 @@ Value *llvm::emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B,
return CI;
}
-Value *llvm::emitHotColdSizeReturningNewAligned(Value *Num, Value *Align, IRBuilderBase &B,
- const TargetLibraryInfo *TLI, LibFunc SizeFeedbackNewFunc,
- uint8_t HotCold) {
+Value *llvm::emitHotColdSizeReturningNewAligned(Value *Num, Value *Align,
+ IRBuilderBase &B,
+ const TargetLibraryInfo *TLI,
+ LibFunc SizeFeedbackNewFunc,
+ uint8_t HotCold) {
Module *M = B.GetInsertBlock()->getModule();
if (!isLibFuncEmittable(M, TLI, SizeFeedbackNewFunc))
return nullptr;
@@ -2000,13 +2003,13 @@ Value *llvm::emitHotColdSizeReturningNewAligned(Value *Num, Value *Align, IRBuil
StringRef Name = TLI->getName(SizeFeedbackNewFunc);
// __sized_ptr_t struct return type { void*, size_t }
- llvm::StructType* SizedPtrT = llvm::StructType::get(M->getContext(),
- {B.getPtrTy(), Num->getType()});
- FunctionCallee Func = M->getOrInsertFunction(Name, SizedPtrT,
- Num->getType(), Align->getType(), B.getInt8Ty());
+ llvm::StructType *SizedPtrT =
+ llvm::StructType::get(M->getContext(), {B.getPtrTy(), Num->getType()});
+ FunctionCallee Func = M->getOrInsertFunction(Name, SizedPtrT, Num->getType(),
+ Align->getType(), B.getInt8Ty());
inferNonMandatoryLibFuncAttrs(M, Name, *TLI);
CallInst *CI = B.CreateCall(Func, {Num, Align, B.getInt8(HotCold)}, Name);
- // Setting the name makes the tests easier to read.
+ // Setting the name makes the tests easier to read.
CI->setName("sized_ptr");
if (const Function *F =
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 6ae8446798..be4d4590cf 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1848,22 +1848,26 @@ Value *LibCallSimplifier::optimizeNew(CallInst *CI, IRBuilderBase &B,
case LibFunc_size_returning_new:
if (HotCold != NotColdNewHintValue)
return emitHotColdSizeReturningNew(CI->getArgOperand(0), B, TLI,
- LibFunc_size_returning_new_hot_cold, HotCold);
+ LibFunc_size_returning_new_hot_cold,
+ HotCold);
break;
case LibFunc_size_returning_new_hot_cold:
- if (OptimizeExistingHotColdNew)
+ if (OptimizeExistingHotColdNew)
return emitHotColdSizeReturningNew(CI->getArgOperand(0), B, TLI,
- LibFunc_size_returning_new_hot_cold, HotCold);
+ LibFunc_size_returning_new_hot_cold,
+ HotCold);
break;
- case LibFunc_size_returning_new_aligned:
+ case LibFunc_size_returning_new_aligned:
if (HotCold != NotColdNewHintValue)
- return emitHotColdSizeReturningNewAligned(CI->getArgOperand(0), CI->getArgOperand(1), B, TLI,
- LibFunc_size_returning_new_aligned_hot_cold, HotCold);
+ return emitHotColdSizeReturningNewAligned(
+ CI->getArgOperand(0), CI->getArgOperand(1), B, TLI,
+ LibFunc_size_returning_new_aligned_hot_cold, HotCold);
break;
case LibFunc_size_returning_new_aligned_hot_cold:
if (OptimizeExistingHotColdNew)
- return emitHotColdSizeReturningNewAligned(CI->getArgOperand(0), CI->getArgOperand(1), B, TLI,
- LibFunc_size_returning_new_aligned_hot_cold, HotCold);
+ return emitHotColdSizeReturningNewAligned(
+ CI->getArgOperand(0), CI->getArgOperand(1), B, TLI,
+ LibFunc_size_returning_new_aligned_hot_cold, HotCold);
break;
default:
return nullptr;
``````````
</details>
https://github.com/llvm/llvm-project/pull/102258
More information about the llvm-commits
mailing list