LLVM 24.0.0git
DeclareRuntimeLibcalls.cpp
Go to the documentation of this file.
1//===- DeclareRuntimeLibcalls.cpp -----------------------------------------===//
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//
9// Insert declarations for all runtime library calls known for the target.
10//
11//===----------------------------------------------------------------------===//
12
15#include "llvm/IR/Module.h"
17
18using namespace llvm;
19
22 const RTLIB::RuntimeLibcallsInfo &RTLCI =
23 MAM.getResult<RuntimeLibraryAnalysis>(M);
24
25 for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
26 if (!RTLCI.isAvailable(Impl))
27 continue;
28
30 RTLCI.getOrInsertImplGlobal(M, Impl);
31 else
32 RTLCI.getOrInsertLibcallDecl(M, Impl);
33 }
34
36}
Module.h This file contains the declarations for the Module class.
ModuleAnalysisManager MAM
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
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 auto libcall_impls()
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A simple container for information about the supported runtime calls.
LLVM_ABI FunctionCallee getOrInsertLibcallDecl(Module &M, RTLIB::LibcallImpl LibcallImpl) const
static bool isVariable(RTLIB::LibcallImpl LibcallImpl)
LLVM_ABI GlobalValue * getOrInsertImplGlobal(Module &M, RTLIB::LibcallImpl LibcallImpl) const
bool isAvailable(RTLIB::LibcallImpl Impl) const