Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: lib/LTO/LTOModule.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/LTO/LTOCodeGenerator.cpp ('k') | lib/MC/CMakeLists.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- LTOModule.cpp - LLVM Link Time Optimizer --------------------------===// 1 //===-- LTOModule.cpp - LLVM Link Time Optimizer --------------------------===//
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.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the Link Time Optimization library. This library is 10 // This file implements the Link Time Optimization library. This library is
(...skipping 14 matching lines...) Expand all
25 #include "llvm/MC/MCInstrInfo.h" 25 #include "llvm/MC/MCInstrInfo.h"
26 #include "llvm/MC/MCParser/MCAsmParser.h" 26 #include "llvm/MC/MCParser/MCAsmParser.h"
27 #include "llvm/MC/MCSection.h" 27 #include "llvm/MC/MCSection.h"
28 #include "llvm/MC/MCSubtargetInfo.h" 28 #include "llvm/MC/MCSubtargetInfo.h"
29 #include "llvm/MC/MCSymbol.h" 29 #include "llvm/MC/MCSymbol.h"
30 #include "llvm/MC/MCTargetAsmParser.h" 30 #include "llvm/MC/MCTargetAsmParser.h"
31 #include "llvm/MC/SubtargetFeature.h" 31 #include "llvm/MC/SubtargetFeature.h"
32 #include "llvm/Object/IRObjectFile.h" 32 #include "llvm/Object/IRObjectFile.h"
33 #include "llvm/Object/ObjectFile.h" 33 #include "llvm/Object/ObjectFile.h"
34 #include "llvm/Support/CommandLine.h" 34 #include "llvm/Support/CommandLine.h"
35 #include "llvm/Support/ErrorHandling.h" // @LOCALMOD
35 #include "llvm/Support/FileSystem.h" 36 #include "llvm/Support/FileSystem.h"
36 #include "llvm/Support/Host.h" 37 #include "llvm/Support/Host.h"
37 #include "llvm/Support/MemoryBuffer.h" 38 #include "llvm/Support/MemoryBuffer.h"
38 #include "llvm/Support/Path.h" 39 #include "llvm/Support/Path.h"
39 #include "llvm/Support/SourceMgr.h" 40 #include "llvm/Support/SourceMgr.h"
40 #include "llvm/Support/TargetRegistry.h" 41 #include "llvm/Support/TargetRegistry.h"
41 #include "llvm/Support/TargetSelect.h" 42 #include "llvm/Support/TargetSelect.h"
42 #include "llvm/Target/TargetLowering.h" 43 #include "llvm/Target/TargetLowering.h"
43 #include "llvm/Target/TargetLoweringObjectFile.h" 44 #include "llvm/Target/TargetLoweringObjectFile.h"
44 #include "llvm/Target/TargetRegisterInfo.h" 45 #include "llvm/Target/TargetRegisterInfo.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return nullptr; 163 return nullptr;
163 } 164 }
164 ErrorOr<Module *> MOrErr = parseBitcodeFile(*MBOrErr, *Context); 165 ErrorOr<Module *> MOrErr = parseBitcodeFile(*MBOrErr, *Context);
165 if (std::error_code EC = MOrErr.getError()) { 166 if (std::error_code EC = MOrErr.getError()) {
166 errMsg = EC.message(); 167 errMsg = EC.message();
167 return nullptr; 168 return nullptr;
168 } 169 }
169 std::unique_ptr<Module> M(MOrErr.get()); 170 std::unique_ptr<Module> M(MOrErr.get());
170 171
171 std::string TripleStr = M->getTargetTriple(); 172 std::string TripleStr = M->getTargetTriple();
173 // @LOCALMOD-BEGIN
174 // Pretend that we are ARM for name mangling and assembly conventions.
175 // https://code.google.com/p/nativeclient/issues/detail?id=2554
176 if (TripleStr == "le32-unknown-nacl") {
177 TripleStr = "armv7a-none-nacl-gnueabi";
178 }
179 // @LOCALMOD-END
172 if (TripleStr.empty()) 180 if (TripleStr.empty())
173 TripleStr = sys::getDefaultTargetTriple(); 181 TripleStr = sys::getDefaultTargetTriple();
174 llvm::Triple Triple(TripleStr); 182 llvm::Triple Triple(TripleStr);
175 183
176 // find machine architecture for this module 184 // find machine architecture for this module
177 const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg); 185 const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
178 if (!march) 186 if (!march)
179 return nullptr; 187 return nullptr;
180 188
181 // construct LTOModule, hand over ownership of module and target 189 // construct LTOModule, hand over ownership of module and target
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 addAsmGlobalSymbolUndef(Name); 571 addAsmGlobalSymbolUndef(Name);
564 else if (Flags & object::BasicSymbolRef::SF_Global) 572 else if (Flags & object::BasicSymbolRef::SF_Global)
565 addAsmGlobalSymbol(Name, LTO_SYMBOL_SCOPE_DEFAULT); 573 addAsmGlobalSymbol(Name, LTO_SYMBOL_SCOPE_DEFAULT);
566 else 574 else
567 addAsmGlobalSymbol(Name, LTO_SYMBOL_SCOPE_INTERNAL); 575 addAsmGlobalSymbol(Name, LTO_SYMBOL_SCOPE_INTERNAL);
568 continue; 576 continue;
569 } 577 }
570 578
571 auto *F = dyn_cast<Function>(GV); 579 auto *F = dyn_cast<Function>(GV);
572 if (IsUndefined) { 580 if (IsUndefined) {
581 // @LOCALMOD-BEGIN
582 // Bitcode modules may have declarations for functions or globals
583 // which are unused. Ignore them here so that gold does not mistake
584 // them for undefined symbols.
585 if (GV->use_empty())
586 continue;
587 // @LOCALMOD-END
588
573 addPotentialUndefinedSymbol(Sym, F != nullptr); 589 addPotentialUndefinedSymbol(Sym, F != nullptr);
574 continue; 590 continue;
575 } 591 }
576 592
577 if (F) { 593 if (F) {
578 addDefinedFunctionSymbol(Sym); 594 addDefinedFunctionSymbol(Sym);
579 continue; 595 continue;
580 } 596 }
581 597
582 if (isa<GlobalVariable>(GV)) { 598 if (isa<GlobalVariable>(GV)) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 if (!DepLibName.empty()) 638 if (!DepLibName.empty())
623 _deplibs.push_back(DepLibName.data()); 639 _deplibs.push_back(DepLibName.data());
624 else if (!Op.empty()) 640 else if (!Op.empty())
625 _linkeropts.push_back(Op.data()); 641 _linkeropts.push_back(Op.data());
626 } 642 }
627 } 643 }
628 } 644 }
629 645
630 // Add other interesting metadata here. 646 // Add other interesting metadata here.
631 } 647 }
OLDNEW
« no previous file with comments | « lib/LTO/LTOCodeGenerator.cpp ('k') | lib/MC/CMakeLists.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698