LLVM
22.0.0git
include
llvm
IR
Comdat.h
Go to the documentation of this file.
1
//===- llvm/IR/Comdat.h - Comdat definitions --------------------*- 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
/// @file
10
/// This file contains the declaration of the Comdat class, which represents a
11
/// single COMDAT in LLVM.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_IR_COMDAT_H
16
#define LLVM_IR_COMDAT_H
17
18
#include "
llvm-c/Types.h
"
19
#include "
llvm/ADT/SmallPtrSet.h
"
20
#include "
llvm/Support/CBindingWrapping.h
"
21
#include "
llvm/Support/Compiler.h
"
22
23
namespace
llvm
{
24
25
class
GlobalObject;
26
class
raw_ostream;
27
class
StringRef;
28
template
<
typename
ValueTy>
class
StringMapEntry;
29
30
// This is a Name X SelectionKind pair. The reason for having this be an
31
// independent object instead of just adding the name and the SelectionKind
32
// to a GlobalObject is that it is invalid to have two Comdats with the same
33
// name but different SelectionKind. This structure makes that unrepresentable.
34
class
Comdat
{
35
public
:
36
enum
SelectionKind
{
37
Any
,
///< The linker may choose any COMDAT.
38
ExactMatch
,
///< The data referenced by the COMDAT must be the same.
39
Largest
,
///< The linker will choose the largest COMDAT.
40
NoDeduplicate
,
///< No deduplication is performed.
41
SameSize
,
///< The data referenced by the COMDAT must be the same size.
42
};
43
44
Comdat
(
const
Comdat
&) =
delete
;
45
LLVM_ABI
Comdat
(
Comdat
&&
C
);
46
47
SelectionKind
getSelectionKind
()
const
{
return
SK; }
48
void
setSelectionKind
(
SelectionKind
Val) { SK = Val; }
49
LLVM_ABI
StringRef
getName
()
const
;
50
LLVM_ABI
void
print
(
raw_ostream
&
OS
,
bool
IsForDebug =
false
)
const
;
51
LLVM_ABI
void
dump
()
const
;
52
const
SmallPtrSetImpl<GlobalObject *>
&
getUsers
()
const
{
return
Users; }
53
54
private
:
55
friend
class
Module
;
56
friend
class
GlobalObject
;
57
58
Comdat
();
59
void
addUser(
GlobalObject
*GO);
60
void
removeUser(
GlobalObject
*GO);
61
62
// Points to the map in Module.
63
StringMapEntry<Comdat>
*
Name
=
nullptr
;
64
SelectionKind
SK =
Any
;
65
// Globals using this comdat.
66
SmallPtrSet<GlobalObject *, 2>
Users
;
67
};
68
69
// Create wrappers for C Binding types (see CBindingWrapping.h).
70
DEFINE_SIMPLE_CONVERSION_FUNCTIONS
(
Comdat
,
LLVMComdatRef
)
71
72
inline
raw_ostream
&operator<<(
raw_ostream
&
OS
,
const
Comdat
&
C
) {
73
C
.print(
OS
);
74
return
OS
;
75
}
76
77
}
// end namespace llvm
78
79
#endif
// LLVM_IR_COMDAT_H
const
aarch64 promote const
Definition:
AArch64PromoteConstant.cpp:228
inline
always inline
Definition:
AlwaysInliner.cpp:161
CBindingWrapping.h
DEFINE_SIMPLE_CONVERSION_FUNCTIONS
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Definition:
CBindingWrapping.h:19
Compiler.h
LLVM_ABI
#define LLVM_ABI
Definition:
Compiler.h:213
Name
std::string Name
Definition:
ELFObjHandler.cpp:77
Users
iv Induction Variable Users
Definition:
IVUsers.cpp:48
OS
raw_pwrite_stream & OS
Definition:
SampleProfWriter.cpp:51
SmallPtrSet.h
This file defines the SmallPtrSet class.
Types.h
llvm::Comdat
Definition:
Comdat.h:34
llvm::Comdat::Comdat
Comdat(const Comdat &)=delete
llvm::Comdat::print
LLVM_ABI void print(raw_ostream &OS, bool IsForDebug=false) const
Definition:
AsmWriter.cpp:5105
llvm::Comdat::getName
LLVM_ABI StringRef getName() const
Definition:
Comdat.cpp:28
llvm::Comdat::dump
LLVM_ABI void dump() const
Definition:
AsmWriter.cpp:5491
llvm::Comdat::getUsers
const SmallPtrSetImpl< GlobalObject * > & getUsers() const
Definition:
Comdat.h:52
llvm::Comdat::SelectionKind
SelectionKind
Definition:
Comdat.h:36
llvm::Comdat::Largest
@ Largest
The linker will choose the largest COMDAT.
Definition:
Comdat.h:39
llvm::Comdat::SameSize
@ SameSize
The data referenced by the COMDAT must be the same size.
Definition:
Comdat.h:41
llvm::Comdat::Any
@ Any
The linker may choose any COMDAT.
Definition:
Comdat.h:37
llvm::Comdat::NoDeduplicate
@ NoDeduplicate
No deduplication is performed.
Definition:
Comdat.h:40
llvm::Comdat::ExactMatch
@ ExactMatch
The data referenced by the COMDAT must be the same.
Definition:
Comdat.h:38
llvm::Comdat::setSelectionKind
void setSelectionKind(SelectionKind Val)
Definition:
Comdat.h:48
llvm::Comdat::getSelectionKind
SelectionKind getSelectionKind() const
Definition:
Comdat.h:47
llvm::GlobalObject
Definition:
GlobalObject.h:28
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:
Module.h:67
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition:
SmallPtrSet.h:380
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition:
SmallPtrSet.h:541
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition:
StringMapEntry.h:102
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:55
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:
raw_ostream.h:53
LLVMComdatRef
struct LLVMComdat * LLVMComdatRef
Definition:
Types.h:155
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:
CallingConv.h:34
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
Generated on Sat Aug 30 2025 05:06:42 for LLVM by
1.9.6