Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
InferFunctionAttrs.cpp
Go to the documentation of this file.
1//===- InferFunctionAttrs.cpp - Infer implicit function attributes --------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include "llvm/IR/Function.h"
12#include "llvm/IR/Module.h"
15using namespace llvm;
16
17#define DEBUG_TYPE "inferattrs"
18
21 bool Changed = false;
22
23 for (Function &F : M.functions())
24 // We only infer things using the prototype and the name; we don't need
25 // definitions. This ensures libfuncs are annotated and also allows our
26 // CGSCC inference to avoid needing to duplicate the inference from other
27 // attribute logic on all calls to declarations (as declarations aren't
28 // explicitly visited by CGSCC passes in the new pass manager.)
29 if (F.isDeclaration() && !F.hasOptNone()) {
30 if (!F.hasFnAttribute(Attribute::NoBuiltin))
33 }
34
35 return Changed;
36}
37
42 auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & {
43 return FAM.getResult<TargetLibraryAnalysis>(F);
44 };
45
46 if (!inferAllPrototypeAttributes(M, GetTLI))
47 // If we didn't infer anything, preserve all analyses.
49
50 // Otherwise, we may have changed fundamental function attributes, so clear
51 // out all the passes.
53}
Module.h This file contains the declarations for the Module class.
static bool inferAllPrototypeAttributes(Module &M, function_ref< TargetLibraryInfo &(Function &)> GetTLI)
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
#define F(x, y, z)
Definition MD5.cpp:55
FunctionAnalysisManager FAM
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition Analysis.h:115
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
An efficient, type-erasing, non-owning reference to a callable.
Changed
This is an optimization pass for GlobalISel generic memory operations.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
LLVM_ABI bool inferNonMandatoryLibFuncAttrs(Module *M, StringRef Name, const TargetLibraryInfo &TLI)
Analyze the name and prototype of the given function and set any applicable attributes.
LLVM_ABI bool inferAttributesFromOthers(Function &F)
If we can infer one attribute from another on the declaration of a function, explicitly materialize t...
Definition Local.cpp:3960
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)