LLVM  14.0.0git
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 }
LLVMSameSizeComdatSelectionKind
@ LLVMSameSizeComdatSelectionKind
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:36
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
Comdat.h
llvm::Comdat::getName
StringRef getName() const
Definition: Comdat.cpp:26
llvm::Comdat::ExactMatch
@ ExactMatch
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:35
StringRef.h
llvm::Comdat::NoDeduplicate
@ NoDeduplicate
No deduplication is performed.
Definition: Comdat.h:37
Module.h
GlobalObject.h
llvm::Comdat::Largest
@ Largest
The linker will choose the largest COMDAT.
Definition: Comdat.h:36
LLVMLargestComdatSelectionKind
@ LLVMLargestComdatSelectionKind
The linker will choose the largest COMDAT.
Definition: Comdat.h:33
LLVMExactMatchComdatSelectionKind
@ LLVMExactMatchComdatSelectionKind
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:31
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalObject
Definition: GlobalObject.h:28
llvm::Comdat::Any
@ Any
The linker may choose any COMDAT.
Definition: Comdat.h:34
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:256
llvm::Comdat::SameSize
@ SameSize
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:38
LLVMSetComdatSelectionKind
void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind kind)
Definition: Comdat.cpp:58
StringMap.h
llvm::Comdat
Definition: Comdat.h:31
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
LLVMComdatSelectionKind
LLVMComdatSelectionKind
Definition: Comdat.h:29
Comdat.h
LLVMGetComdatSelectionKind
LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C)
Definition: Comdat.cpp:42
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:251
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
LLVMSetComdat
void LLVMSetComdat(LLVMValueRef V, LLVMComdatRef C)
Assign the Comdat to the given global object.
Definition: Comdat.cpp:37
LLVMAnyComdatSelectionKind
@ LLVMAnyComdatSelectionKind
The linker may choose any COMDAT.
Definition: Comdat.h:30
LLVMGetComdat
LLVMComdatRef LLVMGetComdat(LLVMValueRef V)
Get the Comdat assigned to the given global object.
Definition: Comdat.cpp:32
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
LLVMGetOrInsertComdat
LLVMComdatRef LLVMGetOrInsertComdat(LLVMModuleRef M, const char *Name)
Return the Comdat in the module with the specified name.
Definition: Comdat.cpp:28
llvm::Comdat::setSelectionKind
void setSelectionKind(SelectionKind Val)
Definition: Comdat.h:45
LLVMNoDeduplicateComdatSelectionKind
@ LLVMNoDeduplicateComdatSelectionKind
No deduplication is performed.
Definition: Comdat.h:35
LLVMValueRef
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:75
LLVMComdatRef
struct LLVMComdat * LLVMComdatRef
Definition: Types.h:153
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61