LLVM  10.0.0svn
Comdat.cpp
Go to the documentation of this file.
1 //===- Comdat.cpp - Implement Metadata classes ----------------------------===//
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 // This file implements the Comdat class (including the C bindings).
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm-c/Comdat.h"
14 #include "llvm/ADT/StringMap.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/IR/Comdat.h"
17 #include "llvm/IR/GlobalObject.h"
18 #include "llvm/IR/Module.h"
19 
20 using namespace llvm;
21 
22 Comdat::Comdat(Comdat &&C) : Name(C.Name), SK(C.SK) {}
23 
24 Comdat::Comdat() = default;
25 
26 StringRef Comdat::getName() const { return Name->first(); }
27 
29  return wrap(unwrap(M)->getOrInsertComdat(Name));
30 }
31 
33  GlobalObject *G = unwrap<GlobalObject>(V);
34  return wrap(G->getComdat());
35 }
36 
38  GlobalObject *G = unwrap<GlobalObject>(V);
39  G->setComdat(unwrap(C));
40 }
41 
43  switch (unwrap(C)->getSelectionKind()) {
44  case Comdat::Any:
46  case Comdat::ExactMatch:
48  case Comdat::Largest:
52  case Comdat::SameSize:
54  }
55  llvm_unreachable("Invalid Comdat SelectionKind!");
56 }
57 
59  Comdat *Cd = unwrap(C);
60  switch (kind) {
63  break;
66  break;
69  break;
72  break;
75  break;
76  }
77 }
uint64_t CallInst * C
This class represents lattice values for constants.
Definition: AllocatorList.h:23
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:62
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVMComdatSelectionKind
Definition: Comdat.h:23
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:31
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM...
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:38
struct LLVMComdat * LLVMComdatRef
Definition: Types.h:154
The linker may choose any COMDAT.
Definition: Comdat.h:24
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:204
The linker may choose any COMDAT.
Definition: Comdat.h:34
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:25
LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C)
Definition: Comdat.cpp:42
void LLVMSetComdat(LLVMValueRef V, LLVMComdatRef C)
Assign the Comdat to the given global object.
Definition: Comdat.cpp:37
void setComdat(Comdat *C)
Definition: GlobalObject.h:107
No other Module may specify this COMDAT.
Definition: Comdat.h:37
StringRef getName() const
Definition: Comdat.cpp:26
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:35
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setSelectionKind(SelectionKind Val)
Definition: Comdat.h:45
LLVMComdatRef LLVMGetOrInsertComdat(LLVMModuleRef M, const char *Name)
Return the Comdat in the module with the specified name.
Definition: Comdat.cpp:28
The linker will choose the largest COMDAT.
Definition: Comdat.h:27
Module.h This file contains the declarations for the Module class.
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
The linker will choose the largest COMDAT.
Definition: Comdat.h:36
No other Module may specify this COMDAT.
Definition: Comdat.h:29
const Comdat * getComdat() const
Definition: GlobalObject.h:105
void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind kind)
Definition: Comdat.cpp:58
LLVMComdatRef LLVMGetComdat(LLVMValueRef V)
Get the Comdat assigned to the given global object.
Definition: Comdat.cpp:32
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:199
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:76
SelectionKind getSelectionKind() const
Definition: Comdat.h:44