comparison lib/CodeGen/MachineModuleInfoImpls.cpp @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents afa8332a0e37
children c2174574ed3a
comparison
equal deleted inserted replaced
120:1172e4bd9c6f 121:803732b1fca8
1 //===-- llvm/CodeGen/MachineModuleInfoImpls.cpp ---------------------------===// 1 //===- llvm/CodeGen/MachineModuleInfoImpls.cpp ----------------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
11 // MachineModuleInfoImpl. 11 // MachineModuleInfoImpl.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "llvm/CodeGen/MachineModuleInfoImpls.h" 15 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
16 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/MC/MCSymbol.h" 17 #include "llvm/MC/MCSymbol.h"
18
17 using namespace llvm; 19 using namespace llvm;
18 20
19 //===----------------------------------------------------------------------===// 21 //===----------------------------------------------------------------------===//
20 // MachineModuleInfoMachO 22 // MachineModuleInfoMachO
21 //===----------------------------------------------------------------------===// 23 //===----------------------------------------------------------------------===//
22 24
23 // Out of line virtual method. 25 // Out of line virtual method.
24 void MachineModuleInfoMachO::anchor() {} 26 void MachineModuleInfoMachO::anchor() {}
25 void MachineModuleInfoELF::anchor() {} 27 void MachineModuleInfoELF::anchor() {}
26 28
27 static int SortSymbolPair(const void *LHS, const void *RHS) { 29 using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
28 typedef std::pair<MCSymbol*, MachineModuleInfoImpl::StubValueTy> PairTy; 30 static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS) {
29 const MCSymbol *LHSS = ((const PairTy *)LHS)->first; 31 return LHS->first->getName().compare(RHS->first->getName());
30 const MCSymbol *RHSS = ((const PairTy *)RHS)->first;
31 return LHSS->getName().compare(RHSS->getName());
32 } 32 }
33 33
34 MachineModuleInfoImpl::SymbolListTy MachineModuleInfoImpl::getSortedStubs( 34 MachineModuleInfoImpl::SymbolListTy MachineModuleInfoImpl::getSortedStubs(
35 DenseMap<MCSymbol *, MachineModuleInfoImpl::StubValueTy> &Map) { 35 DenseMap<MCSymbol *, MachineModuleInfoImpl::StubValueTy> &Map) {
36 MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end()); 36 MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
37 37
38 if (!List.empty()) 38 array_pod_sort(List.begin(), List.end(), SortSymbolPair);
39 qsort(&List[0], List.size(), sizeof(List[0]), SortSymbolPair);
40 39
41 Map.clear(); 40 Map.clear();
42 return List; 41 return List;
43 } 42 }
44