llvm-project/llvm/lib/Analysis/RuntimeLibcallInfo.cpp
Matt Arsenault ac547a532a
Analysis: Add RuntimeLibcall analysis pass (#165196)
Currently RuntimeLibcallsInfo is a hardcoded list based on the triple.
In the future the available libcall set should be dynamically modifiable
with module flags.

Note this isn't really used yet. TargetLowering is still constructing
its own copy, and untangling that to use this requires several more
steps.
2025-11-05 14:48:50 -08:00

44 lines
1.4 KiB
C++

//===- RuntimeLibcallInfo.cpp ---------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/RuntimeLibcallInfo.h"
#include "llvm/InitializePasses.h"
using namespace llvm;
AnalysisKey RuntimeLibraryAnalysis::Key;
RTLIB::RuntimeLibcallsInfo
RuntimeLibraryAnalysis::run(const Module &M, ModuleAnalysisManager &) {
return RTLIB::RuntimeLibcallsInfo(M);
}
INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info",
"Runtime Library Function Analysis", false, true)
RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper()
: ImmutablePass(ID), RTLA(RTLIB::RuntimeLibcallsInfo(Triple())) {}
char RuntimeLibraryInfoWrapper::ID = 0;
ModulePass *llvm::createRuntimeLibraryInfoWrapperPass() {
return new RuntimeLibraryInfoWrapper();
}
void RuntimeLibraryInfoWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
// Assume this is stable unless explicitly invalidated.
bool RTLIB::RuntimeLibcallsInfo::invalidate(
Module &M, const PreservedAnalyses &PA,
ModuleAnalysisManager::Invalidator &) {
auto PAC = PA.getChecker<RuntimeLibraryAnalysis>();
return !PAC.preservedWhenStateless();
}