llvm.org GIT mirror llvm / 4d651e4
Fix Clang-tidy modernize-use-nullptr warnings in source directories and generated files; other minor cleanups. Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13321 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249482 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 5 years ago
26 changed file(s) with 113 addition(s) and 125 deletion(s). Raw diff Collapse all Expand all
4040 #include "llvm/IR/Module.h"
4141 #include "llvm/Pass.h"
4242 #include "llvm/Support/CommandLine.h"
43
4344 using namespace llvm;
4445
4546 // A handy option for disabling scoped no-alias functionality. The same effect
5657 const MDNode *Node;
5758
5859 public:
59 AliasScopeNode() : Node(0) {}
60 AliasScopeNode() : Node(nullptr) {}
6061 explicit AliasScopeNode(const MDNode *N) : Node(N) {}
6162
6263 /// getNode - Get the MDNode for this AliasScopeNode.
6970 return dyn_cast_or_null(Node->getOperand(1));
7071 }
7172 };
72 } // End of anonymous namespace
73 } // end of anonymous namespace
7374
7475 AliasResult ScopedNoAliasAAResult::alias(const MemoryLocation &LocA,
7576 const MemoryLocation &LocB) {
99 // The machine combiner pass uses machine trace metrics to ensure the combined
1010 // instructions does not lengthen the critical path or the resource depth.
1111 //===----------------------------------------------------------------------===//
12
1213 #define DEBUG_TYPE "machine-combiner"
1314
1415 #include "llvm/ADT/Statistic.h"
121122 MachineCombiner::getDepth(SmallVectorImpl &InsInstrs,
122123 DenseMap &InstrIdxForVirtReg,
123124 MachineTraceMetrics::Trace BlockTrace) {
124
125125 SmallVector InstrDepth;
126126 assert(TSchedModel.hasInstrSchedModelOrItineraries() &&
127127 "Missing machine model\n");
180180 /// \returns Latency of \p NewRoot
181181 unsigned MachineCombiner::getLatency(MachineInstr *Root, MachineInstr *NewRoot,
182182 MachineTraceMetrics::Trace BlockTrace) {
183
184183 assert(TSchedModel.hasInstrSchedModelOrItineraries() &&
185184 "Missing machine model\n");
186185
228227 SmallVectorImpl &InsInstrs,
229228 DenseMap &InstrIdxForVirtReg,
230229 bool NewCodeHasLessInsts) {
231
232230 assert(TSchedModel.hasInstrSchedModelOrItineraries() &&
233231 "Missing machine model\n");
234232 // NewRoot is the last instruction in the \p InsInstrs vector.
273271 InstrsSC.push_back(SC);
274272 }
275273 }
274
276275 /// True when the new instructions do not increase resource length
277276 bool MachineCombiner::preservesResourceLen(
278277 MachineBasicBlock *MBB, MachineTraceMetrics::Trace BlockTrace,
424423 TSchedModel.init(SchedModel, &STI, TII);
425424 MRI = &MF.getRegInfo();
426425 Traces = &getAnalysis();
427 MinInstr = 0;
426 MinInstr = nullptr;
428427 OptSize = MF.getFunction()->optForSize();
429428
430429 DEBUG(dbgs() << getPassName() << ": " << MF.getName() << '\n');
6565 static inline bool classof(const ELFObjectFile *v) {
6666 return v->isDyldType();
6767 }
68
6968 };
7069
7170
186185 return createELFDebugObject(Obj, *this);
187186 }
188187
189 } // namespace
188 } // anonymous namespace
190189
191190 namespace llvm {
192191
771770 // relocation) without a .toc directive. In this case just use the
772771 // first section (which is usually the .odp) since the code won't
773772 // reference the .toc base directly.
774 Rel.SymbolName = NULL;
773 Rel.SymbolName = nullptr;
775774 Rel.SectionID = 0;
776775
777776 // The TOC consists of sections .got, .toc, .tocbss, .plt in that
17361735 GOTSectionID = Sections.size();
17371736 // Reserve a section id. We'll allocate the section later
17381737 // once we know the total size
1739 Sections.push_back(SectionEntry(".got", 0, 0, 0));
1738 Sections.push_back(SectionEntry(".got", nullptr, 0, 0));
17401739 }
17411740 uint64_t StartOffset = CurrentGOTIndex * getGOTEntrySize();
17421741 CurrentGOTIndex += no;
2020 #include "llvm/IR/LLVMContext.h"
2121 #include "llvm/IR/Type.h"
2222 #include
23
2324 using namespace llvm;
2425
2526 ValueSymbolTable *BasicBlock::getValueSymbolTable() {
3536 // Explicit instantiation of SymbolTableListTraits since some of the methods
3637 // are not in the public header file...
3738 template class llvm::SymbolTableListTraits;
38
3939
4040 BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
4141 BasicBlock *InsertBefore)
244244
245245 BasicBlock *BasicBlock::getUniqueSuccessor() {
246246 succ_iterator SI = succ_begin(this), E = succ_end(this);
247 if (SI == E) return NULL; // No successors
247 if (SI == E) return nullptr; // No successors
248248 BasicBlock *SuccBB = *SI;
249249 ++SI;
250250 for (;SI != E; ++SI) {
251251 if (*SI != SuccBB)
252 return NULL;
252 return nullptr;
253253 // The same successor appears multiple times in the successor list.
254254 // This is OK.
255255 }
2828 #include
2929 #include
3030 #include
31
3132 using namespace llvm;
3233
3334 //===----------------------------------------------------------------------===//
7980
8081 return new RandomNumberGenerator(Salt);
8182 }
82
8383
8484 /// getNamedValue - Return the first global value in the module with
8585 /// the specified name, of arbitrary type. This method returns null
480480 PICLevel::Level Module::getPICLevel() const {
481481 auto *Val = cast_or_null(getModuleFlag("PIC Level"));
482482
483 if (Val == NULL)
483 if (!Val)
484484 return PICLevel::Default;
485485
486486 return static_cast(
2626 #include "llvm/Support/Path.h"
2727 #include "llvm/Support/SourceMgr.h"
2828 #include "llvm/Support/raw_ostream.h"
29
2930 using namespace llvm;
3031
3132 static inline uint64_t ScaleAddrDelta(MCContext &Context, uint64_t AddrDelta) {
243244 std::pair
244245 MCDwarfLineTableHeader::Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
245246 ArrayRef StandardOpcodeLengths) const {
246
247247 MCContext &context = MCOS->getContext();
248248
249249 // Create a symbol at the beginning of the line table.
841841 LineSectionSymbol = MCOS->getDwarfLineTableSymbol(0);
842842 MCSymbol *AbbrevSectionSymbol = nullptr;
843843 MCSymbol *InfoSectionSymbol = nullptr;
844 MCSymbol *RangesSectionSymbol = NULL;
844 MCSymbol *RangesSectionSymbol = nullptr;
845845
846846 // Create end symbols for each section, and remove empty sections
847847 MCOS->getContext().finalizeDwarfSections(*MCOS);
14571457 bool IsSignalFrame;
14581458 bool IsSimple;
14591459 };
1460 }
1460 } // anonymous namespace
14611461
14621462 namespace llvm {
14631463 template <>
14841484 LHS.IsSimple == RHS.IsSimple;
14851485 }
14861486 };
1487 }
1487 } // namespace llvm
14881488
14891489 void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
14901490 bool IsEH) {
1616 #include "llvm/MC/MCSectionELF.h"
1717 #include "llvm/MC/MCSectionMachO.h"
1818 #include "llvm/Support/COFF.h"
19
1920 using namespace llvm;
2021
2122 static bool useCompactUnwind(const Triple &T) {
258259 FDECFIEncoding = dwarf::DW_EH_PE_pcrel |
259260 ((CMModel == CodeModel::Large) ? dwarf::DW_EH_PE_sdata8
260261 : dwarf::DW_EH_PE_sdata4);
261
262262 break;
263263 default:
264264 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
576576 assert(T.isOSWindows() && "Windows is the only supported COFF target");
577577 if (T.getArch() == Triple::x86_64) {
578578 // On Windows 64 with SEH, the LSDA is emitted into the .xdata section
579 LSDASection = 0;
579 LSDASection = nullptr;
580580 } else {
581581 LSDASection = Ctx->getCOFFSection(".gcc_except_table",
582582 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
7474 char fullpath[PATH_MAX];
7575
7676 snprintf(fullpath, PATH_MAX, "%s/%s", dir, bin);
77 if (realpath(fullpath, ret) == NULL)
78 return (1);
77 if (!realpath(fullpath, ret))
78 return 1;
7979 if (stat(fullpath, &sb) != 0)
80 return (1);
81
82 return (0);
80 return 1;
81
82 return 0;
8383 }
8484
8585 static char *
9090 /* First approach: absolute path. */
9191 if (bin[0] == '/') {
9292 if (test_dir(ret, "/", bin) == 0)
93 return (ret);
94 return (NULL);
93 return ret;
94 return nullptr;
9595 }
9696
9797 /* Second approach: relative path. */
98 if (strchr(bin, '/') != NULL) {
98 if (strchr(bin, '/')) {
9999 char cwd[PATH_MAX];
100 if (getcwd(cwd, PATH_MAX) == NULL)
101 return (NULL);
100 if (!getcwd(cwd, PATH_MAX))
101 return nullptr;
102102 if (test_dir(ret, cwd, bin) == 0)
103 return (ret);
104 return (NULL);
103 return ret;
104 return nullptr;
105105 }
106106
107107 /* Third approach: $PATH */
108 if ((pv = getenv("PATH")) == NULL)
109 return (NULL);
108 if ((pv = getenv("PATH")) == nullptr)
109 return nullptr;
110110 s = pv = strdup(pv);
111 if (pv == NULL)
112 return (NULL);
113 while ((t = strsep(&s, ":")) != NULL) {
111 if (!pv)
112 return nullptr;
113 while ((t = strsep(&s, ":")) != nullptr) {
114114 if (test_dir(ret, t, bin) == 0) {
115115 free(pv);
116 return (ret);
116 return ret;
117117 }
118118 }
119119 free(pv);
120 return (NULL);
120 return nullptr;
121121 }
122122 #endif // __FreeBSD__ || __NetBSD__ || __FreeBSD_kernel__
123123
152152 return std::string(exe_path, len);
153153 } else {
154154 // Fall back to the classical detection.
155 if (getprogpath(exe_path, argv0) != NULL)
156 return exe_path;
155 if (getprogpath(exe_path, argv0))
156 return exe_path;
157157 }
158158 #elif defined(HAVE_DLFCN_H)
159159 // Use dladdr to get executable path if available.
2020 #include "llvm/Support/Debug.h"
2121 #include "llvm/Target/CostTable.h"
2222 #include "llvm/Target/TargetLowering.h"
23
2324 using namespace llvm;
2425
2526 #define DEBUG_TYPE "x86tti"
6162
6263 if (ST->is64Bit())
6364 return 64;
65
6466 return 32;
65
6667 }
6768
6869 unsigned X86TTIImpl::getMaxInterleaveFactor(unsigned VF) {
879880 // Scalarization
880881 int MaskSplitCost = getScalarizationOverhead(MaskTy, false, true);
881882 int ScalarCompareCost = getCmpSelInstrCost(
882 Instruction::ICmp, Type::getInt8Ty(getGlobalContext()), NULL);
883 Instruction::ICmp, Type::getInt8Ty(getGlobalContext()), nullptr);
883884 int BranchCost = getCFInstrCost(Instruction::Br);
884885 int MaskCmpCost = NumElem * (BranchCost + ScalarCompareCost);
885886
897898 if (LT.second != TLI->getValueType(DL, SrcVTy).getSimpleVT() &&
898899 LT.second.getVectorNumElements() == NumElem)
899900 // Promotion requires expand/truncate for data and a shuffle for mask.
900 Cost += getShuffleCost(TTI::SK_Alternate, SrcVTy, 0, 0) +
901 getShuffleCost(TTI::SK_Alternate, MaskTy, 0, 0);
901 Cost += getShuffleCost(TTI::SK_Alternate, SrcVTy, 0, nullptr) +
902 getShuffleCost(TTI::SK_Alternate, MaskTy, 0, nullptr);
902903
903904 else if (LT.second.getVectorNumElements() > NumElem) {
904905 VectorType *NewMaskTy = VectorType::get(MaskTy->getVectorElementType(),
106106 for (uint64_t B : Bits)
107107 OS << B << ' ';
108108 OS << "}\n";
109 return;
110109 }
111110
112111 BitSetInfo BitSetBuilder::build() {
261260 bool runOnModule(Module &M) override;
262261 };
263262
264 } // namespace
263 } // anonymous namespace
265264
266265 INITIALIZE_PASS_BEGIN(LowerBitSets, "lowerbitsets",
267266 "Lower bitset metadata", false, false)
609608 BSI.print(dbgs());
610609 });
611610
612 ByteArrayInfo *BAI = 0;
611 ByteArrayInfo *BAI = nullptr;
613612
614613 // Lower each call to llvm.bitset.test for this bitset.
615614 for (CallInst *CI : BitSetTestCallSites[BS]) {
112112 #include "llvm/Support/ErrorHandling.h"
113113 #include "llvm/Support/raw_ostream.h"
114114 #include
115
115116 using namespace llvm;
116117
117118 #define DEBUG_TYPE "mergefunc"
464465 F = G;
465466 }
466467
467 void release() { F = 0; }
468 void release() { F = nullptr; }
468469 };
469 }
470 } // end anonymous namespace
470471
471472 int FunctionComparator::cmpNumbers(uint64_t L, uint64_t R) const {
472473 if (L < R) return -1;
534535 }
535536 return 0;
536537 }
538
537539 int FunctionComparator::cmpRangeMetadata(const MDNode* L,
538540 const MDNode* R) const {
539541 if (L == R)
769771 /// defines total ordering among the types set.
770772 /// See method declaration comments for more details.
771773 int FunctionComparator::cmpTypes(Type *TyL, Type *TyR) const {
772
773774 PointerType *PTyL = dyn_cast(TyL);
774775 PointerType *PTyR = dyn_cast(TyR);
775776
11631164
11641165 // Test whether the two functions have equivalent behaviour.
11651166 int FunctionComparator::compare() {
1166
11671167 sn_mapL.clear();
11681168 sn_mapR.clear();
11691169
13991399 bool HasGlobalAliases;
14001400 };
14011401
1402 } // end anonymous namespace
1402 } // end anonymous namespace
14031403
14041404 char MergeFunctions::ID = 0;
14051405 INITIALIZE_PASS(MergeFunctions, "mergefunc", "Merge Functions", false, false)
215215 Max = KnownOne|UnknownBits;
216216 }
217217
218
219
220218 /// FoldCmpLoadFromIndexedGlobal - Called we see this pattern:
221219 /// cmp pred (load (gep GV, ...)), cmpcst
222220 /// where GV is a global variable with a constant initializer. Try to simplify
370368 }
371369 }
372370
373
374371 // If this element is in range, update our magic bitvector.
375372 if (i < 64 && IsTrueForElt)
376373 MagicBitvector |= 1ULL << i;
468465 return new ICmpInst(ICmpInst::ICMP_UGT, Idx, End);
469466 }
470467
471
472468 // If a magic bitvector captures the entire comparison state
473469 // of this load, replace it with computation that does:
474470 // ((magic_cst >> i) & 1) != 0
494490
495491 return nullptr;
496492 }
497
498493
499494 /// EvaluateGEPOffsetExpression - Return a value that can be used to compare
500495 /// the *offset* implied by a GEP to zero. For example, if we have &A[i], we
560555 Offset += Size*CI->getSExtValue();
561556 }
562557 }
563
564
565558
566559 // Okay, we know we have a single variable index, which must be a
567560 // pointer/array/vector index. If there is no offset, life is simple, return
850843 // to the same result value.
851844 HiOverflow = AddWithOverflow(HiBound, LoBound, RangeSize, false);
852845 }
853
854846 } else if (DivRHS->getValue().isStrictlyPositive()) { // Divisor is > 0.
855847 if (CmpRHSV == 0) { // (X / pos) op 0
856848 // Can't overflow. e.g. X/2 op 0 --> [-1, 2)
994986 assert(Res && "This div/cst should have folded!");
995987 return Res;
996988 }
997
998989
999990 // If we are comparing against bits always shifted out, the
1000991 // comparison cannot succeed.
25132504 default:
25142505 return APInt::getAllOnesValue(BitWidth);
25152506 }
2516
25172507 }
25182508
25192509 /// \brief Check if the order of \p Op0 and \p Op1 as operand in an ICmpInst
29502940 ConstantInt::get(X->getType(),
29512941 CI->countTrailingZeros()));
29522942 }
2953
29542943 break;
29552944 }
29562945 case ICmpInst::ICMP_NE: {
29952984 ConstantInt::get(X->getType(),
29962985 CI->countTrailingZeros()));
29972986 }
2998
29992987 break;
30002988 }
30012989 case ICmpInst::ICMP_ULT:
31483136 // comparison into the select arms, which will cause one to be
31493137 // constant folded and the select turned into a bitwise or.
31503138 Value *Op1 = nullptr, *Op2 = nullptr;
3151 ConstantInt *CI = 0;
3139 ConstantInt *CI = nullptr;
31523140 if (Constant *C = dyn_cast(LHSI->getOperand(1))) {
31533141 Op1 = ConstantExpr::getICmp(I.getPredicate(), C, RHSC);
31543142 CI = dyn_cast(Op1);
728728 Instruction *ThenTerm, Value *ValueIfFalse);
729729 };
730730
731 } // namespace
731 } // anonymous namespace
732732
733733 char AddressSanitizer::ID = 0;
734734 INITIALIZE_PASS_BEGIN(
958958 // If initialization order checking is disabled, a simple access to a
959959 // dynamically initialized global is always valid.
960960 GlobalVariable *G = dyn_cast(GetUnderlyingObject(Addr, DL));
961 if (G != NULL && (!ClInitializers || GlobalIsLinkerInitialized(G)) &&
961 if (G && (!ClInitializers || GlobalIsLinkerInitialized(G)) &&
962962 isSafeAccess(ObjSizeVis, Addr, TypeSize)) {
963963 NumOptimizedAccessesToGlobalVar++;
964964 return;
18041804 unpoisonDynamicAllocas();
18051805 }
18061806
1807 if (AllocaVec.size() == 0) return;
1807 if (AllocaVec.empty()) return;
18081808
18091809 int StackMallocIdx = -1;
18101810 DebugLoc EntryDebugLocation;
290290 };
291291
292292 static const PlatformMemoryMapParams Linux_MIPS_MemoryMapParams = {
293 NULL,
293 nullptr,
294294 &Linux_MIPS64_MemoryMapParams,
295295 };
296296
297297 static const PlatformMemoryMapParams Linux_PowerPC_MemoryMapParams = {
298 NULL,
298 nullptr,
299299 &Linux_PowerPC64_MemoryMapParams,
300300 };
301301
302302 static const PlatformMemoryMapParams Linux_ARM_MemoryMapParams = {
303 NULL,
303 nullptr,
304304 &Linux_AArch64_MemoryMapParams,
305305 };
306306
383383 friend struct VarArgAMD64Helper;
384384 friend struct VarArgMIPS64Helper;
385385 };
386 } // namespace
386 } // anonymous namespace
387387
388388 char MemorySanitizer::ID = 0;
389389 INITIALIZE_PASS(MemorySanitizer, "msan",
405405 return new GlobalVariable(M, StrConst->getType(), /*isConstant=*/false,
406406 GlobalValue::PrivateLinkage, StrConst, "");
407407 }
408
409408
410409 /// \brief Insert extern declaration of runtime-provided functions and globals.
411410 void MemorySanitizer::initializeCallbacks(Module &M) {
31043103 return new VarArgNoOpHelper(Func, Msan, Visitor);
31053104 }
31063105
3107 } // namespace
3106 } // anonymous namespace
31083107
31093108 bool MemorySanitizer::runOnFunction(Function &F) {
31103109 if (&F == MsanCtorFunction)
277277 UnsafeStackPtr = new GlobalVariable(
278278 /*Module=*/M, /*Type=*/StackPtrTy,
279279 /*isConstant=*/false, /*Linkage=*/GlobalValue::ExternalLinkage,
280 /*Initializer=*/0, /*Name=*/kUnsafeStackPtrVar,
280 /*Initializer=*/nullptr, /*Name=*/kUnsafeStackPtrVar,
281281 /*InsertBefore=*/nullptr,
282282 /*ThreadLocalMode=*/GlobalValue::InitialExecTLSModel);
283283 } else {
618618 return true;
619619 }
620620
621 } // end anonymous namespace
621 } // anonymous namespace
622622
623623 char SafeStack::ID = 0;
624624 INITIALIZE_TM_PASS_BEGIN(SafeStack, "safe-stack",
9191 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
9292 #include "llvm/Transforms/Utils/SSAUpdater.h"
9393 #include
94
9495 using namespace llvm;
9596
9697 #define DEBUG_TYPE "mldst-motion"
237238 /// being loaded or protect against the load from happening
238239 /// it is considered a hoist barrier.
239240 ///
240
241241 bool MergedLoadStoreMotion::isLoadHoistBarrierInRange(const Instruction& Start,
242242 const Instruction& End,
243243 LoadInst* LI) {
395395 /// value being stored or protect against the store from
396396 /// happening it is considered a sink barrier.
397397 ///
398
399398 bool MergedLoadStoreMotion::isStoreSinkBarrierInRange(const Instruction &Start,
400399 const Instruction &End,
401400 MemoryLocation Loc) {
439438 PHINode *MergedLoadStoreMotion::getPHIOperand(BasicBlock *BB, StoreInst *S0,
440439 StoreInst *S1) {
441440 // Create a phi if the values mismatch.
442 PHINode *NewPN = 0;
441 PHINode *NewPN = nullptr;
443442 Value *Opd1 = S0->getValueOperand();
444443 Value *Opd2 = S1->getValueOperand();
445444 if (Opd1 != Opd2) {
560559 }
561560 return MergedStores;
562561 }
562
563563 ///
564564 /// \brief Run the transformation for each function
565565 ///
4040 #include "llvm/Transforms/Utils/Local.h"
4141 #include "llvm/Support/CommandLine.h"
4242 #include
43
4344 using namespace llvm;
4445
4546 static cl::opt
120121 }
121122 }
122123 };
123 }
124 } // anonymous namespace
124125
125126 /// Get or create a target for the branch from ResumeInsts.
126127 BasicBlock *LandingPadInliningInfo::getInnerResumeDest() {
612613 for (unsigned i = 0, ie = PtrArgs.size(); i != ie; ++i) {
613614 SmallVector Objects;
614615 GetUnderlyingObjects(const_cast(PtrArgs[i]),
615 Objects, DL, /* MaxLookup = */ 0);
616 Objects, DL, /* LI = */ nullptr);
616617
617618 for (Value *O : Objects)
618619 ObjSet.insert(O);
14501451 }
14511452 }
14521453
1453
14541454 // Add a branch to the merge points and remove return instructions.
14551455 DebugLoc Loc;
14561456 for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
149149 Function *F = Header->getParent();
150150 LoopBlocksDFS::RPOIterator BlockBegin = LoopBlocks.beginRPO();
151151 LoopBlocksDFS::RPOIterator BlockEnd = LoopBlocks.endRPO();
152 Loop *NewLoop = 0;
152 Loop *NewLoop = nullptr;
153153 Loop *ParentLoop = L->getParentLoop();
154154 if (!UnrollProlog) {
155155 NewLoop = new Loop();
9595 };
9696
9797 static void Warning(const Twine &Msg) { errs() << "warning: " + Msg + "\n"; }
98 }
98 } // anonymous namespace
9999
100100 /// Reset the parser state coresponding to the current object
101101 /// file. This is to be called after an object file is finished
184184 {MachO::N_LBRAC, "N_LBRAC"}, {MachO::N_EXCL, "N_EXCL"},
185185 {MachO::N_RBRAC, "N_RBRAC"}, {MachO::N_BCOMM, "N_BCOMM"},
186186 {MachO::N_ECOMM, "N_ECOMM"}, {MachO::N_ECOML, "N_ECOML"},
187 {MachO::N_LENG, "N_LENG"}, {0, 0}};
187 {MachO::N_LENG, "N_LENG"}, {0, nullptr}};
188188
189189 static const char *getDarwinStabString(uint8_t NType) {
190190 for (unsigned i = 0; DarwinStabNames[i].Name; i++) {
191191 if (DarwinStabNames[i].NType == NType)
192192 return DarwinStabNames[i].Name;
193193 }
194 return 0;
194 return nullptr;
195195 }
196196
197197 void MachODebugMapParser::dumpSymTabHeader(raw_ostream &OS, StringRef Arch) {
208208 uint32_t StringIndex, uint8_t Type,
209209 uint8_t SectionIndex, uint16_t Flags,
210210 uint64_t Value) {
211
212211 // Index
213212 OS << '[' << format_decimal(Index, 6) << "] "
214213 // n_strx
470469 MachODebugMapParser Parser(InputFile, Archs, PrependPath, false);
471470 return Parser.dumpStab();
472471 }
473 }
474 }
472 } // namespace dsymutil
473 } // namespace llvm
4343 #include
4444 #include
4545 #include
46
4647 using namespace llvm;
4748 using namespace object;
4849
158159 bool HadError = false;
159160
160161 std::string ToolName;
161 }
162 } // anonymous namespace
162163
163164 static void error(Twine Message, Twine Path = Twine()) {
164165 HadError = true;
181182 StringRef Name;
182183 BasicSymbolRef Sym;
183184 };
184 }
185 } // anonymous namespace
185186
186187 static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) {
187188 bool ADefined = !(A.Sym.getFlags() & SymbolRef::SF_Undefined);
438439 {MachO::N_ECOMM, "ECOMM"},
439440 {MachO::N_ECOML, "ECOML"},
440441 {MachO::N_LENG, "LENG"},
441 {0, 0}};
442 {0, nullptr}};
443
442444 static const char *getDarwinStabString(uint8_t NType) {
443445 for (unsigned i = 0; DarwinStabNames[i].Name; i++) {
444446 if (DarwinStabNames[i].NType == NType)
445447 return DarwinStabNames[i].Name;
446448 }
447 return 0;
449 return nullptr;
448450 }
449451
450452 // darwinPrintStab() prints the n_sect, n_desc along with a symbolic name of
11491151 return;
11501152 }
11511153 error("unrecognizable file type", Filename);
1152 return;
11531154 }
11541155
11551156 int main(int argc, char **argv) {
None //===- MCJITTest.cpp - Unit tests for the MCJIT ---------------------------===//
0 //===- MCJITTest.cpp - Unit tests for the MCJIT -----------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
478478
479479 Module = LLVMModuleCreateWithName("testModule");
480480 LLVMSetTarget(Module, HostTriple.c_str());
481 LLVMTypeRef FunctionType = LLVMFunctionType(LLVMInt32Type(), NULL, 0, 0);
481 LLVMTypeRef FunctionType = LLVMFunctionType(LLVMInt32Type(), nullptr, 0, 0);
482482 LLVMValueRef MappedFn = LLVMAddFunction(Module, "mapped_fn", FunctionType);
483483
484484 Function = LLVMAddFunction(Module, "test_fn", FunctionType);
485485 LLVMBasicBlockRef Entry = LLVMAppendBasicBlock(Function, "");
486486 LLVMBuilderRef Builder = LLVMCreateBuilder();
487487 LLVMPositionBuilderAtEnd(Builder, Entry);
488 LLVMValueRef RetVal = LLVMBuildCall(Builder, MappedFn, NULL, 0, "");
488 LLVMValueRef RetVal = LLVMBuildCall(Builder, MappedFn, nullptr, 0, "");
489489 LLVMBuildRet(Builder, RetVal);
490490 LLVMDisposeBuilder(Builder);
491491
None //===- MCJITMultipeModuleTest.cpp - Unit tests for the MCJIT---------------===//
0 //===- MCJITMultipeModuleTest.cpp - Unit tests for the MCJIT-----*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
222222 EXPECT_EQ(GVA, TheJIT->FindGlobalVariableNamed("GVA"));
223223 EXPECT_EQ(GVB, TheJIT->FindGlobalVariableNamed("GVB"));
224224 EXPECT_EQ(GVC, TheJIT->FindGlobalVariableNamed("GVC",true));
225 EXPECT_EQ(NULL, TheJIT->FindGlobalVariableNamed("GVC"));
225 EXPECT_EQ(nullptr, TheJIT->FindGlobalVariableNamed("GVC"));
226226
227227 uint64_t FBPtr = TheJIT->getFunctionAddress(FB->getName().str());
228228 TheJIT->finalizeObject();
419419 EXPECT_EQ(FB1, TheJIT->FindFunctionNamed(FB1->getName().data()));
420420 }
421421
422 }
422 } // end anonymous namespace
None //===- MCJITTest.cpp - Unit tests for the MCJIT ---------------------------===//
0 //===- MCJITTest.cpp - Unit tests for the MCJIT -----------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
195195 void *A = TheJIT->getPointerToFunction(Foo);
196196 void *B = TheJIT->getPointerToFunction(Foo);
197197
198 EXPECT_TRUE(A != 0) << "Failed lookup - test not correctly configured.";
198 EXPECT_TRUE(A != nullptr) << "Failed lookup - test not correctly configured.";
199199 EXPECT_EQ(A, B) << "Repeat calls to getPointerToFunction fail.";
200200 }
201201
280280 EXPECT_FALSE(std::find(I, E, "Foo2") == E);
281281 }
282282
283 }
283 } // end anonymous namespace
None //===- MCJITTestBase.h - Common base class for MCJIT Unit tests ----------===//
0 //===- MCJITTestBase.h - Common base class for MCJIT Unit tests -*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1111 // systems.
1212 //
1313 //===----------------------------------------------------------------------===//
14
1514
1615 #ifndef LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTBASE_H
1716 #define LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTBASE_H
159158 // }
160159 // NOTE: if Helper is left as the default parameter, Helper == recursive_add.
161160 Function *insertAccumulateFunction(Module *M,
162 Function *Helper = 0,
163 StringRef Name = "accumulate") {
161 Function *Helper = nullptr,
162 StringRef Name = "accumulate") {
164163 Function *Result = startFunction(M, Name);
165 if (Helper == 0)
164 if (!Helper)
166165 Helper = Result;
167166
168167 BasicBlock *BaseCase = BasicBlock::Create(Context, "", Result);
198197 Function *&FB1, Function *&FB2) {
199198 // Define FB1 in B.
200199 B.reset(createEmptyModule("B"));
201 FB1 = insertAccumulateFunction(B.get(), 0, "FB1");
200 FB1 = insertAccumulateFunction(B.get(), nullptr, "FB1");
202201
203202 // Declare FB1 in A (as an external).
204203 A.reset(createEmptyModule("A"));
233232 FC = insertSimpleCallFunction(C.get(), FBExtern_in_C);
234233 }
235234
236
237235 // Module A { Function FA },
238236 // Populates Modules A and B:
239237 // Module B { Function FB }
277275 FC = insertSimpleCallFunction(C.get(), FAExtern_in_C);
278276 }
279277 };
280
281278
282279 class MCJITTestBase : public MCJITTestAPICommon, public TrivialModuleBuilder {
283280 protected:
347344
348345 } // namespace llvm
349346
350 #endif
347 #endif // LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTBASE_H
2525 #include
2626 #include
2727 #include
28
2829 using namespace llvm;
2930
3031 #define DEBUG_TYPE "subtarget-emitter"
104105 Records(R), SchedModels(TGT.getSchedModels()), Target(TGT.getName()) {}
105106
106107 void run(raw_ostream &o);
107
108108 };
109 } // End anonymous namespace
109 } // end anonymous namespace
110110
111111 //
112112 // Enumeration - Emit the specified class as an enumeration.
11981198 << " " << (SchedModels.schedClassEnd()
11991199 - SchedModels.schedClassBegin()) << ",\n";
12001200 else
1201 OS << " 0, 0, 0, 0, // No instruction-level machine model.\n";
1201 OS << " nullptr, nullptr, 0, 0,"
1202 << " // No instruction-level machine model.\n";
12021203 if (PI->hasItineraries())
12031204 OS << " " << PI->ItinsDef->getName() << "};\n";
12041205 else
14131414
14141415 OS << "namespace llvm {\n";
14151416 Enumeration(OS, "SubtargetFeature");
1416 OS << "} // End llvm namespace \n";
1417 OS << "} // end llvm namespace\n";
14171418 OS << "#endif // GET_SUBTARGETINFO_ENUM\n\n";
14181419
14191420 OS << "\n#ifdef GET_SUBTARGETINFO_MC_DESC\n";
14601461 OS << "0, 0, 0";
14611462 OS << ");\n}\n\n";
14621463
1463 OS << "} // End llvm namespace \n";
1464 OS << "} // end llvm namespace\n";
14641465
14651466 OS << "#endif // GET_SUBTARGETINFO_MC_DESC\n\n";
14661467
14901491 << " DFAPacketizer *createDFAPacketizer(const InstrItineraryData *IID)"
14911492 << " const;\n"
14921493 << "};\n";
1493 OS << "} // End llvm namespace \n";
1494 OS << "} // end llvm namespace\n";
14941495
14951496 OS << "#endif // GET_SUBTARGETINFO_HEADER\n\n";
14961497
15421543
15431544 EmitSchedModelHelpers(ClassName, OS);
15441545
1545 OS << "} // End llvm namespace \n";
1546 OS << "} // end llvm namespace\n";
15461547
15471548 OS << "#endif // GET_SUBTARGETINFO_CTOR\n\n";
15481549 }
15541555 SubtargetEmitter(RK, CGTarget).run(OS);
15551556 }
15561557
1557 } // End llvm namespace
1558 } // end llvm namespace
410410 f.write('} AvailableComponents[%d] = {\n' % len(entries))
411411 for name,library_name,required_names,is_installed in entries:
412412 if library_name is None:
413 library_name_as_cstr = '0'
413 library_name_as_cstr = 'nullptr'
414414 else:
415415 library_name_as_cstr = '"lib%s.a"' % library_name
416 f.write(' { "%s", %s, %d, { %s } },\n' % (
417 name, library_name_as_cstr, is_installed,
416 if is_installed:
417 is_installed_as_cstr = 'true'
418 else:
419 is_installed_as_cstr = 'false'
420 f.write(' { "%s", %s, %s, { %s } },\n' % (
421 name, library_name_as_cstr, is_installed_as_cstr,
418422 ', '.join('"%s"' % dep
419423 for dep in required_names)))
420424 f.write('};\n')