clang 23.0.0git
ModuleLinker.h
Go to the documentation of this file.
1//===--- ModuleLinker.h - Shared bitcode link helpers ----------*- C++ -*-===//
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#ifndef LLVM_CLANG_CODEGEN_MODULELINKER_H
10#define LLVM_CLANG_CODEGEN_MODULELINKER_H
11
12#include "llvm/ADT/SmallVector.h"
13#include <memory>
14
15namespace llvm {
16class Function;
17class LLVMContext;
18class Module;
19} // namespace llvm
20
21namespace clang {
22class CodeGenOptions;
24class LangOptions;
25class TargetOptions;
26
27/// Info about a module to link into the module currently being generated.
28/// Shared between the classic clang CodeGen path and the ClangIR path.
29struct LinkModule {
30 std::unique_ptr<llvm::Module> Module;
33 unsigned LinkFlags;
34};
35
36/// Load every bitcode file listed in CodeGenOpts.LinkBitcodeFiles into
37/// \p LinkModules. Returns true on error (diagnostic already reported).
38/// Appends to \p LinkModules; does not clear it.
39bool loadLinkModules(CompilerInstance &CI, llvm::LLVMContext &Ctx,
41
42namespace CodeGen {
43/// Adds attributes to \p F according to our \p CodeGenOpts and \p LangOpts, as
44/// though we had emitted it ourselves. We remove any attributes on F that
45/// conflict with the attributes we add here.
46///
47/// This is useful for adding attrs to bitcode modules that you want to link
48/// with but don't control, such as CUDA's libdevice. When linking with such
49/// a bitcode library, you might want to set e.g. its functions'
50/// denormal_fp_math attribute to match the attr of the functions you're
51/// codegen'ing. Otherwise, LLVM will interpret the bitcode module's lack of
52/// denormal-fp-math attrs as tantamount to denormal-fp-math=ieee, and then LLVM
53/// will propagate denormal-fp-math=ieee up to every transitive caller of a
54/// function in the bitcode library!
55///
56/// With the exception of fast-math attrs, this will only make the attributes
57/// on the function more conservative. But it's unsafe to call this on a
58/// function which relies on particular fast-math attributes for correctness.
59/// It's up to you to ensure that this is safe.
60void mergeDefaultFunctionDefinitionAttributes(llvm::Function &F,
61 const CodeGenOptions &CodeGenOpts,
62 const LangOptions &LangOpts,
63 const TargetOptions &TargetOpts,
64 bool WillInternalize);
65} // namespace CodeGen
66
67} // namespace clang
68
69#endif
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Options for controlling the target.
void mergeDefaultFunctionDefinitionAttributes(llvm::Function &F, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, const TargetOptions &TargetOpts, bool WillInternalize)
Adds attributes to F according to our CodeGenOpts and LangOpts, as though we had emitted it ourselves...
Definition CGCall.cpp:2307
The JSON file list parser is used to communicate input to InstallAPI.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Definition Linkage.h:54
bool loadLinkModules(CompilerInstance &CI, llvm::LLVMContext &Ctx, llvm::SmallVectorImpl< LinkModule > &LinkModules)
Load every bitcode file listed in CodeGenOpts.LinkBitcodeFiles into LinkModules.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
Info about a module to link into the module currently being generated.
std::unique_ptr< llvm::Module > Module