Path: blob/main/contrib/llvm-project/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp
213799 views
//===- DeclareRuntimeLibcalls.cpp -----------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Insert declarations for all runtime library calls known for the target.9//10//===----------------------------------------------------------------------===//1112#include "llvm/Transforms/Utils/DeclareRuntimeLibcalls.h"13#include "llvm/IR/Module.h"14#include "llvm/IR/RuntimeLibcalls.h"1516using namespace llvm;1718PreservedAnalyses DeclareRuntimeLibcallsPass::run(Module &M,19ModuleAnalysisManager &MAM) {20RTLIB::RuntimeLibcallsInfo RTLCI(M.getTargetTriple());21LLVMContext &Ctx = M.getContext();2223for (RTLIB::LibcallImpl Impl : RTLCI.getLibcallImpls()) {24if (Impl == RTLIB::Unsupported)25continue;2627// TODO: Declare with correct type, calling convention, and attributes.2829FunctionType *FuncTy =30FunctionType::get(Type::getVoidTy(Ctx), {}, /*IsVarArgs=*/true);3132const char *FuncName = RTLCI.getLibcallImplName(Impl);33M.getOrInsertFunction(FuncName, FuncTy);34}3536return PreservedAnalyses::none();37}383940