1//===- RuntimeLibcallInfo.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#include "llvm/Analysis/RuntimeLibcallInfo.h"
10#include "llvm/InitializePasses.h"
11
12using namespace llvm;
13
14AnalysisKey RuntimeLibraryAnalysis::Key;
15
16RuntimeLibraryAnalysis::RuntimeLibraryAnalysis(const Triple &TT,
17 ExceptionHandling ExceptionModel,
18 FloatABI::ABIType FloatABI,
19 EABI EABIVersion,
20 StringRef ABIName,
21 VectorLibrary VecLib)
22 : LibcallsInfo(std::in_place, TT, ExceptionModel, FloatABI, EABIVersion,
23 ABIName, VecLib) {}
24
25RTLIB::RuntimeLibcallsInfo
26RuntimeLibraryAnalysis::run(const Module &M, ModuleAnalysisManager &) {
27 if (!LibcallsInfo)
28 LibcallsInfo = RTLIB::RuntimeLibcallsInfo(M);
29 return *LibcallsInfo;
30}
31
32INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info",
33 "Runtime Library Function Analysis", false, true)
34
35RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper()
36 : ImmutablePass(ID), RTLA(RTLIB::RuntimeLibcallsInfo(Triple())) {}
37
38RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper(
39 const Triple &TT, ExceptionHandling ExceptionModel,
40 FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName,
41 VectorLibrary VecLib)
42 : ImmutablePass(ID), RTLCI(std::in_place, TT, ExceptionModel, FloatABI,
43 EABIVersion, ABIName, VecLib) {}
44
45char RuntimeLibraryInfoWrapper::ID = 0;
46
47ModulePass *llvm::createRuntimeLibraryInfoWrapperPass() {
48 return new RuntimeLibraryInfoWrapper();
49}
50
51void RuntimeLibraryInfoWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
52 AU.setPreservesAll();
53}
54
55// Assume this is stable unless explicitly invalidated.
56bool RTLIB::RuntimeLibcallsInfo::invalidate(
57 Module &M, const PreservedAnalyses &PA,
58 ModuleAnalysisManager::Invalidator &) {
59 auto PAC = PA.getChecker<RuntimeLibraryAnalysis>();
60 return !PAC.preservedWhenStateless();
61}
62