LLVM  7.0.0svn
Comdat.cpp
Go to the documentation of this file.
1 //===- Comdat.cpp - Implement Metadata classes ----------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Comdat class (including the C bindings).
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm-c/Comdat.h"
15 #include "llvm/ADT/StringMap.h"
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/IR/Comdat.h"
18 #include "llvm/IR/GlobalObject.h"
19 #include "llvm/IR/Module.h"
20 
21 using namespace llvm;
22 
23 Comdat::Comdat(Comdat &&C) : Name(C.Name), SK(C.SK) {}
24 
25 Comdat::Comdat() = default;
26 
27 StringRef Comdat::getName() const { return Name->first(); }
28 
30  return wrap(unwrap(M)->getOrInsertComdat(Name));
31 }
32 
34  GlobalObject *G = unwrap<GlobalObject>(V);
35  return wrap(G->getComdat());
36 }
37 
39  GlobalObject *G = unwrap<GlobalObject>(V);
40  G->setComdat(unwrap(C));
41 }
42 
44  switch (unwrap(C)->getSelectionKind()) {
45  case Comdat::Any:
47  case Comdat::ExactMatch:
49  case Comdat::Largest:
53  case Comdat::SameSize:
55  }
56  llvm_unreachable("Invalid Comdat SelectionKind!");
57 }
58 
60  Comdat *Cd = unwrap(C);
61  switch (kind) {
64  break;
67  break;
70  break;
73  break;
76  break;
77  }
78 }
uint64_t CallInst * C
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:62
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:39
struct LLVMComdat * LLVMComdatRef
Definition: Types.h:140
The linker may choose any COMDAT.
Definition: Comdat.h:24
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:195
The linker may choose any COMDAT.
Definition: Comdat.h:35
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:25
LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C)
Definition: Comdat.cpp:43
void LLVMSetComdat(LLVMValueRef V, LLVMComdatRef C)
Assign the Comdat to the given global object.
Definition: Comdat.cpp:38
void setComdat(Comdat *C)
Definition: GlobalObject.h:103
No other Module may specify this COMDAT.
Definition: Comdat.h:38
StringRef getName() const
Definition: Comdat.cpp:27
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:36
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setSelectionKind(SelectionKind Val)
Definition: Comdat.h:46
LLVMComdatRef LLVMGetOrInsertComdat(LLVMModuleRef M, const char *Name)
Return the Comdat in the module with the specified name.
Definition: Comdat.cpp:29
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:211
The linker will choose the largest COMDAT.
Definition: Comdat.h:37
No other Module may specify this COMDAT.
Definition: Comdat.h:29
const Comdat * getComdat() const
Definition: GlobalObject.h:101
void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind kind)
Definition: Comdat.cpp:59
LLVMComdatRef LLVMGetComdat(LLVMValueRef V)
Get the Comdat assigned to the given global object.
Definition: Comdat.cpp:33
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:190
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:76
SelectionKind getSelectionKind() const
Definition: Comdat.h:45