003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/Transforms/Utils
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
Transforms
/
Utils
/
📁
..
📄
AMDGPUEmitPrintf.h
(864 B)
📄
ASanStackFrameLayout.h
(3.51 KB)
📄
AddDiscriminators.h
(1.04 KB)
📄
AssumeBundleBuilder.h
(2.29 KB)
📄
BasicBlockUtils.h
(20.81 KB)
📄
BreakCriticalEdges.h
(1.16 KB)
📄
BuildLibCalls.h
(9.67 KB)
📄
BypassSlowDivision.h
(2.55 KB)
📄
CallGraphUpdater.h
(3.84 KB)
📄
CallPromotionUtils.h
(3.41 KB)
📄
CanonicalizeAliases.h
(998 B)
📄
CanonicalizeFreezeInLoops.h
(1.15 KB)
📄
Cloning.h
(12.34 KB)
📄
CodeExtractor.h
(9.58 KB)
📄
CodeMoverUtils.h
(2.85 KB)
📄
CtorUtils.h
(1021 B)
📄
Debugify.h
(3.36 KB)
📄
EntryExitInstrumenter.h
(1.16 KB)
📄
EscapeEnumerator.h
(1.56 KB)
📄
Evaluator.h
(4.69 KB)
📄
FunctionComparator.h
(17.12 KB)
📄
FunctionImportUtils.h
(5.73 KB)
📄
GlobalStatus.h
(2.97 KB)
📄
GuardUtils.h
(1.92 KB)
📄
ImportedFunctionsInliningStatistics.h
(4.35 KB)
📄
InjectTLIMappings.h
(1.27 KB)
📄
IntegerDivision.h
(2.88 KB)
📄
LCSSA.h
(1.56 KB)
📄
LibCallsShrinkWrap.h
(908 B)
📄
Local.h
(24.77 KB)
📄
LoopRotationUtils.h
(1.54 KB)
📄
LoopSimplify.h
(2.85 KB)
📄
LoopUtils.h
(21.25 KB)
📄
LoopVersioning.h
(5.87 KB)
📄
LowerInvoke.h
(1.08 KB)
📄
LowerMemIntrinsics.h
(2.14 KB)
📄
Mem2Reg.h
(921 B)
📄
MisExpect.h
(1.81 KB)
📄
ModuleUtils.h
(5.04 KB)
📄
NameAnonGlobals.h
(1.03 KB)
📄
PredicateInfo.h
(7.76 KB)
📄
PromoteMemToReg.h
(1.57 KB)
📄
SSAUpdater.h
(6.12 KB)
📄
SSAUpdaterBulk.h
(3.18 KB)
📄
SSAUpdaterImpl.h
(15.75 KB)
📄
SanitizerStats.h
(1.53 KB)
📄
ScalarEvolutionExpander.h
(17.87 KB)
📄
SimplifyIndVar.h
(2.12 KB)
📄
SimplifyLibCalls.h
(10.85 KB)
📄
SizeOpts.h
(4.84 KB)
📄
SplitModule.h
(1.53 KB)
📄
SymbolRewriter.h
(5.02 KB)
📄
UnifyFunctionExitNodes.h
(1.83 KB)
📄
UniqueInternalLinkageNames.h
(1.07 KB)
📄
UnrollLoop.h
(6.05 KB)
📄
VNCoercion.h
(4.99 KB)
📄
ValueMapper.h
(11.67 KB)
Editing: SimplifyLibCalls.h
//===- SimplifyLibCalls.h - Library call simplifier -------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file exposes an interface to build some C language libcalls for // optimization passes that need to call the various functions. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H #define LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H #include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/TargetLibraryInfo.h" namespace llvm { class StringRef; class Value; class CallInst; class DataLayout; class Instruction; class IRBuilderBase; class TargetLibraryInfo; class Function; class OptimizationRemarkEmitter; class BlockFrequencyInfo; class ProfileSummaryInfo; /// This class implements simplifications for calls to fortified library /// functions (__st*cpy_chk, __memcpy_chk, __memmove_chk, __memset_chk), to, /// when possible, replace them with their non-checking counterparts. /// Other optimizations can also be done, but it's possible to disable them and /// only simplify needless use of the checking versions (when the object size /// is unknown) by passing true for OnlyLowerUnknownSize. class FortifiedLibCallSimplifier { private: const TargetLibraryInfo *TLI; bool OnlyLowerUnknownSize; public: FortifiedLibCallSimplifier(const TargetLibraryInfo *TLI, bool OnlyLowerUnknownSize = false); /// Take the given call instruction and return a more /// optimal value to replace the instruction with or 0 if a more /// optimal form can't be found. /// The call must not be an indirect call. Value *optimizeCall(CallInst *CI, IRBuilderBase &B); private: Value *optimizeMemCpyChk(CallInst *CI, IRBuilderBase &B); Value *optimizeMemMoveChk(CallInst *CI, IRBuilderBase &B); Value *optimizeMemSetChk(CallInst *CI, IRBuilderBase &B); /// Str/Stp cpy are similar enough to be handled in the same functions. Value *optimizeStrpCpyChk(CallInst *CI, IRBuilderBase &B, LibFunc Func); Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilderBase &B, LibFunc Func); Value *optimizeStrLenChk(CallInst *CI, IRBuilderBase &B); Value *optimizeMemCCpyChk(CallInst *CI, IRBuilderBase &B); Value *optimizeSNPrintfChk(CallInst *CI, IRBuilderBase &B); Value *optimizeSPrintfChk(CallInst *CI,IRBuilderBase &B); Value *optimizeStrCatChk(CallInst *CI, IRBuilderBase &B); Value *optimizeStrLCat(CallInst *CI, IRBuilderBase &B); Value *optimizeStrNCatChk(CallInst *CI, IRBuilderBase &B); Value *optimizeStrLCpyChk(CallInst *CI, IRBuilderBase &B); Value *optimizeVSNPrintfChk(CallInst *CI, IRBuilderBase &B); Value *optimizeVSPrintfChk(CallInst *CI, IRBuilderBase &B); /// Checks whether the call \p CI to a fortified libcall is foldable /// to the non-fortified version. /// /// \param CI the call to the fortified libcall. /// /// \param ObjSizeOp the index of the object size parameter of this chk /// function. Not optional since this is mandatory. /// /// \param SizeOp optionally set to the parameter index of an explicit buffer /// size argument. For instance, set to '2' for __strncpy_chk. /// /// \param StrOp optionally set to the parameter index of the source string /// parameter to strcpy-like functions, where only the strlen of the source /// will be writtin into the destination. /// /// \param FlagsOp optionally set to the parameter index of a 'flags' /// parameter. These are used by an implementation to opt-into stricter /// checking. bool isFortifiedCallFoldable(CallInst *CI, unsigned ObjSizeOp, Optional<unsigned> SizeOp = None, Optional<unsigned> StrOp = None, Optional<unsigned> FlagsOp = None); }; /// LibCallSimplifier - This class implements a collection of optimizations /// that replace well formed calls to library functions with a more optimal /// form. For example, replacing 'printf("Hello!")' with 'puts("Hello!")'. class LibCallSimplifier { private: FortifiedLibCallSimplifier FortifiedSimplifier; const DataLayout &DL; const TargetLibraryInfo *TLI; OptimizationRemarkEmitter &ORE; BlockFrequencyInfo *BFI; ProfileSummaryInfo *PSI; bool UnsafeFPShrink; function_ref<void(Instruction *, Value *)> Replacer; function_ref<void(Instruction *)> Eraser; /// Internal wrapper for RAUW that is the default implementation. /// /// Other users may provide an alternate function with this signature instead /// of this one. static void replaceAllUsesWithDefault(Instruction *I, Value *With) { I->replaceAllUsesWith(With); } /// Internal wrapper for eraseFromParent that is the default implementation. static void eraseFromParentDefault(Instruction *I) { I->eraseFromParent(); } /// Replace an instruction's uses with a value using our replacer. void replaceAllUsesWith(Instruction *I, Value *With); /// Erase an instruction from its parent with our eraser. void eraseFromParent(Instruction *I); /// Replace an instruction with a value and erase it from its parent. void substituteInParent(Instruction *I, Value *With) { replaceAllUsesWith(I, With); eraseFromParent(I); } Value *foldMallocMemset(CallInst *Memset, IRBuilderBase &B); public: LibCallSimplifier( const DataLayout &DL, const TargetLibraryInfo *TLI, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, function_ref<void(Instruction *, Value *)> Replacer = &replaceAllUsesWithDefault, function_ref<void(Instruction *)> Eraser = &eraseFromParentDefault); /// optimizeCall - Take the given call instruction and return a more /// optimal value to replace the instruction with or 0 if a more /// optimal form can't be found. Note that the returned value may /// be equal to the instruction being optimized. In this case all /// other instructions that use the given instruction were modified /// and the given instruction is dead. /// The call must not be an indirect call. Value *optimizeCall(CallInst *CI, IRBuilderBase &B); private: // String and Memory Library Call Optimizations Value *optimizeStrCat(CallInst *CI, IRBuilderBase &B); Value *optimizeStrNCat(CallInst *CI, IRBuilderBase &B); Value *optimizeStrChr(CallInst *CI, IRBuilderBase &B); Value *optimizeStrRChr(CallInst *CI, IRBuilderBase &B); Value *optimizeStrCmp(CallInst *CI, IRBuilderBase &B); Value *optimizeStrNCmp(CallInst *CI, IRBuilderBase &B); Value *optimizeStrNDup(CallInst *CI, IRBuilderBase &B); Value *optimizeStrCpy(CallInst *CI, IRBuilderBase &B); Value *optimizeStpCpy(CallInst *CI, IRBuilderBase &B); Value *optimizeStrNCpy(CallInst *CI, IRBuilderBase &B); Value *optimizeStrLen(CallInst *CI, IRBuilderBase &B); Value *optimizeStrPBrk(CallInst *CI, IRBuilderBase &B); Value *optimizeStrTo(CallInst *CI, IRBuilderBase &B); Value *optimizeStrSpn(CallInst *CI, IRBuilderBase &B); Value *optimizeStrCSpn(CallInst *CI, IRBuilderBase &B); Value *optimizeStrStr(CallInst *CI, IRBuilderBase &B); Value *optimizeMemChr(CallInst *CI, IRBuilderBase &B); Value *optimizeMemRChr(CallInst *CI, IRBuilderBase &B); Value *optimizeMemCmp(CallInst *CI, IRBuilderBase &B); Value *optimizeBCmp(CallInst *CI, IRBuilderBase &B); Value *optimizeMemCmpBCmpCommon(CallInst *CI, IRBuilderBase &B); Value *optimizeMemCCpy(CallInst *CI, IRBuilderBase &B); Value *optimizeMemPCpy(CallInst *CI, IRBuilderBase &B); Value *optimizeMemCpy(CallInst *CI, IRBuilderBase &B); Value *optimizeMemMove(CallInst *CI, IRBuilderBase &B); Value *optimizeMemSet(CallInst *CI, IRBuilderBase &B); Value *optimizeRealloc(CallInst *CI, IRBuilderBase &B); Value *optimizeWcslen(CallInst *CI, IRBuilderBase &B); Value *optimizeBCopy(CallInst *CI, IRBuilderBase &B); // Wrapper for all String/Memory Library Call Optimizations Value *optimizeStringMemoryLibCall(CallInst *CI, IRBuilderBase &B); // Math Library Optimizations Value *optimizeCAbs(CallInst *CI, IRBuilderBase &B); Value *optimizePow(CallInst *CI, IRBuilderBase &B); Value *replacePowWithExp(CallInst *Pow, IRBuilderBase &B); Value *replacePowWithSqrt(CallInst *Pow, IRBuilderBase &B); Value *optimizeExp2(CallInst *CI, IRBuilderBase &B); Value *optimizeFMinFMax(CallInst *CI, IRBuilderBase &B); Value *optimizeLog(CallInst *CI, IRBuilderBase &B); Value *optimizeSqrt(CallInst *CI, IRBuilderBase &B); Value *optimizeSinCosPi(CallInst *CI, IRBuilderBase &B); Value *optimizeTan(CallInst *CI, IRBuilderBase &B); // Wrapper for all floating point library call optimizations Value *optimizeFloatingPointLibCall(CallInst *CI, LibFunc Func, IRBuilderBase &B); // Integer Library Call Optimizations Value *optimizeFFS(CallInst *CI, IRBuilderBase &B); Value *optimizeFls(CallInst *CI, IRBuilderBase &B); Value *optimizeAbs(CallInst *CI, IRBuilderBase &B); Value *optimizeIsDigit(CallInst *CI, IRBuilderBase &B); Value *optimizeIsAscii(CallInst *CI, IRBuilderBase &B); Value *optimizeToAscii(CallInst *CI, IRBuilderBase &B); Value *optimizeAtoi(CallInst *CI, IRBuilderBase &B); Value *optimizeStrtol(CallInst *CI, IRBuilderBase &B); // Formatting and IO Library Call Optimizations Value *optimizeErrorReporting(CallInst *CI, IRBuilderBase &B, int StreamArg = -1); Value *optimizePrintF(CallInst *CI, IRBuilderBase &B); Value *optimizeSPrintF(CallInst *CI, IRBuilderBase &B); Value *optimizeSnPrintF(CallInst *CI, IRBuilderBase &B); Value *optimizeFPrintF(CallInst *CI, IRBuilderBase &B); Value *optimizeFWrite(CallInst *CI, IRBuilderBase &B); Value *optimizeFPuts(CallInst *CI, IRBuilderBase &B); Value *optimizePuts(CallInst *CI, IRBuilderBase &B); // Helper methods Value *emitStrLenMemCpy(Value *Src, Value *Dst, uint64_t Len, IRBuilderBase &B); void classifyArgUse(Value *Val, Function *F, bool IsFloat, SmallVectorImpl<CallInst *> &SinCalls, SmallVectorImpl<CallInst *> &CosCalls, SmallVectorImpl<CallInst *> &SinCosCalls); Value *optimizePrintFString(CallInst *CI, IRBuilderBase &B); Value *optimizeSPrintFString(CallInst *CI, IRBuilderBase &B); Value *optimizeSnPrintFString(CallInst *CI, IRBuilderBase &B); Value *optimizeFPrintFString(CallInst *CI, IRBuilderBase &B); /// hasFloatVersion - Checks if there is a float version of the specified /// function by checking for an existing function with name FuncName + f bool hasFloatVersion(StringRef FuncName); /// Shared code to optimize strlen+wcslen. Value *optimizeStringLength(CallInst *CI, IRBuilderBase &B, unsigned CharSize); }; } // End llvm namespace #endif
Upload File
Create Folder