llvm.org GIT mirror llvm / ef15f2c
Untabify. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311875 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 2 years ago
20 changed file(s) with 120 addition(s) and 120 deletion(s). Raw diff Collapse all Expand all
360360 std::lock_guard Lock(SerializersMutex);
361361 // FIXME: Move capture Serialize once we have C++14.
362362 Serializers[ErrorInfoT::classID()] =
363 [KeyName, Serialize](ChannelT &C, const ErrorInfoBase &EIB) -> Error {
364 assert(EIB.dynamicClassID() == ErrorInfoT::classID() &&
365 "Serializer called for wrong error type");
366 if (auto Err = serializeSeq(C, *KeyName))
367 return Err;
368 return Serialize(C, static_cast(EIB));
369 };
363 [KeyName, Serialize](ChannelT &C, const ErrorInfoBase &EIB) -> Error {
364 assert(EIB.dynamicClassID() == ErrorInfoT::classID() &&
365 "Serializer called for wrong error type");
366 if (auto Err = serializeSeq(C, *KeyName))
367 return Err;
368 return Serialize(C, static_cast(EIB));
369 };
370370 }
371371 }
372372
533533 std::sort(GVEs.begin(), GVEs.end(),
534534 [](DwarfCompileUnit::GlobalExpr A, DwarfCompileUnit::GlobalExpr B) {
535535 if (A.Expr != B.Expr && A.Expr && B.Expr) {
536 auto FragmentA = A.Expr->getFragmentInfo();
537 auto FragmentB = B.Expr->getFragmentInfo();
538 if (FragmentA && FragmentB)
539 return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
540 }
536 auto FragmentA = A.Expr->getFragmentInfo();
537 auto FragmentB = B.Expr->getFragmentInfo();
538 if (FragmentA && FragmentB)
539 return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
540 }
541541 return false;
542542 });
543543 GVEs.erase(std::unique(GVEs.begin(), GVEs.end(),
145145 DwarfRegs.push_back(
146146 {Reg, std::min(Size, MaxSize - Offset), "sub-register"});
147147 if (Offset >= MaxSize)
148 break;
148 break;
149149
150150 // Mark it as emitted.
151151 Coverage.set(Offset, Offset + Size);
224224 bool removeModule(Module *M) override {
225225 for (auto I = LocalModules.begin(), E = LocalModules.end(); I != E; ++I) {
226226 if (I->get() == M) {
227 ShouldDelete[M] = false;
228 LocalModules.erase(I);
229 return true;
227 ShouldDelete[M] = false;
228 LocalModules.erase(I);
229 return true;
230230 }
231231 }
232232 return false;
13261326 assert((StrLoc.getPointer() != NULL) &&
13271327 "Argument to the function cannot be a NULL value");
13281328 const char *CharPtr = StrLoc.getPointer();
1329 while ((*CharPtr != '>') && (*CharPtr != '\n') &&
1330 (*CharPtr != '\r') && (*CharPtr != '\0')){
1331 if(*CharPtr == '!')
1332 CharPtr++;
1329 while ((*CharPtr != '>') && (*CharPtr != '\n') && (*CharPtr != '\r') &&
1330 (*CharPtr != '\0')) {
1331 if (*CharPtr == '!')
1332 CharPtr++;
13331333 CharPtr++;
13341334 }
13351335 if (*CharPtr == '>') {
499499 "past the end of the file");
500500 if (Error Err = checkOverlappingElement(Elements, Dysymtab.modtaboff,
501501 Dysymtab.nmodtab * sizeof_modtab,
502 "module table"))
502 "module table"))
503503 return Err;
504504 if (Dysymtab.extrefsymoff > FileSize)
505505 return malformedError("extrefsymoff field of LC_DYSYMTAB command " +
515515 "past the end of the file");
516516 if (Error Err = checkOverlappingElement(Elements, Dysymtab.extrefsymoff,
517517 Dysymtab.nextrefsyms *
518 sizeof(MachO::dylib_reference),
519 "reference table"))
518 sizeof(MachO::dylib_reference),
519 "reference table"))
520520 return Err;
521521 if (Dysymtab.indirectsymoff > FileSize)
522522 return malformedError("indirectsymoff field of LC_DYSYMTAB command " +
549549 "the file");
550550 if (Error Err = checkOverlappingElement(Elements, Dysymtab.extreloff,
551551 Dysymtab.nextrel *
552 sizeof(MachO::relocation_info),
553 "external relocation table"))
552 sizeof(MachO::relocation_info),
553 "external relocation table"))
554554 return Err;
555555 if (Dysymtab.locreloff > FileSize)
556556 return malformedError("locreloff field of LC_DYSYMTAB command " +
566566 "the file");
567567 if (Error Err = checkOverlappingElement(Elements, Dysymtab.locreloff,
568568 Dysymtab.nlocrel *
569 sizeof(MachO::relocation_info),
570 "local relocation table"))
569 sizeof(MachO::relocation_info),
570 "local relocation table"))
571571 return Err;
572572 *DysymtabLoadCmd = Load.Ptr;
573573 return Error::success();
30873087 Twine(error) + " for opcode at: 0x" +
30883088 Twine::utohexstr(OpcodeStart - Opcodes.begin()));
30893089 moveToEnd();
3090 return;
3090 return;
30913091 }
30923092 DEBUG_WITH_TYPE(
30933093 "mach-o-rebase",
31283128 Twine(error) + " for opcode at: 0x" +
31293129 Twine::utohexstr(OpcodeStart - Opcodes.begin()));
31303130 moveToEnd();
3131 return;
3131 return;
31323132 }
31333133 DEBUG_WITH_TYPE(
31343134 "mach-o-rebase",
31663166 Twine(error) + " for opcode at: 0x" +
31673167 Twine::utohexstr(OpcodeStart - Opcodes.begin()));
31683168 moveToEnd();
3169 return;
3169 return;
31703170 }
31713171 DEBUG_WITH_TYPE(
31723172 "mach-o-rebase",
32193219 Twine(error) + " for opcode at: 0x" +
32203220 Twine::utohexstr(OpcodeStart - Opcodes.begin()));
32213221 moveToEnd();
3222 return;
3222 return;
32233223 }
32243224 DEBUG_WITH_TYPE(
32253225 "mach-o-rebase",
37693769 Twine(error) + " for opcode at: 0x" +
37703770 Twine::utohexstr(OpcodeStart - Opcodes.begin()));
37713771 moveToEnd();
3772 return;
3772 return;
37733773 }
37743774 DEBUG_WITH_TYPE(
37753775 "mach-o-bind",
107107
108108 static constexpr uint32_t get_max_thread_name_length_impl() {
109109 #if defined(__NetBSD__)
110 return PTHREAD_MAX_NAMELEN_NP;
110 return PTHREAD_MAX_NAMELEN_NP;
111111 #elif defined(__APPLE__)
112 return 64;
112 return 64;
113113 #elif defined(__linux__)
114114 #if HAVE_PTHREAD_SETNAME_NP
115 return 16;
115 return 16;
116116 #else
117 return 0;
117 return 0;
118118 #endif
119119 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
120120 return 16;
252252 }
253253
254254 std::error_code create_hard_link(const Twine &to, const Twine &from) {
255 return create_link(to, from);
255 return create_link(to, from);
256256 }
257257
258258 std::error_code remove(const Twine &path, bool IgnoreNonExisting) {
495495 Elements.push_back(CI);
496496 if (CI != I)
497497 Changed = true;
498 } else
498 } else
499499 return nullptr;
500500
501501 if (!Changed)
3232
3333 // Assume wildcards for unspecified instrs.
3434 unsigned FirstOpcode =
35 FirstMI ? FirstMI->getOpcode()
36 : static_cast(AArch64::INSTRUCTION_LIST_END);
35 FirstMI ? FirstMI->getOpcode()
36 : static_cast(AArch64::INSTRUCTION_LIST_END);
3737 unsigned SecondOpcode = SecondMI.getOpcode();
3838
3939 if (ST.hasArithmeticBccFusion())
226226 Options.EABIVersion == EABI::Unknown) {
227227 // musl is compatible with glibc with regard to EABI version
228228 if ((TargetTriple.getEnvironment() == Triple::GNUEABI ||
229 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
230 TargetTriple.getEnvironment() == Triple::MuslEABI ||
231 TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
232 !(TargetTriple.isOSWindows() || TargetTriple.isOSDarwin()))
229 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
230 TargetTriple.getEnvironment() == Triple::MuslEABI ||
231 TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
232 !(TargetTriple.isOSWindows() || TargetTriple.isOSDarwin()))
233233 this->Options.EABIVersion = EABI::GNU;
234234 else
235235 this->Options.EABIVersion = EABI::EABI5;
242242 if (CallInst *CI = dyn_cast(J)) {
243243 // Inline ASM is okay, unless it clobbers the ctr register.
244244 if (InlineAsm *IA = dyn_cast(CI->getCalledValue())) {
245 if (asmClobbersCTR(IA))
246 return true;
245 if (asmClobbersCTR(IA))
246 return true;
247247 continue;
248248 }
249249
21332133 Args2.push_back(ExpType);
21342134 Args1.push_back(ExpType);
21352135 }
2136 AsanErrorCallbackSized[AccessIsWrite][Exp] =
2137 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2138 kAsanReportErrorTemplate + ExpStr + TypeStr + SuffixStr +
2139 EndingStr,
2140 FunctionType::get(IRB.getVoidTy(), Args2, false)));
2141
2142 AsanMemoryAccessCallbackSized[AccessIsWrite][Exp] =
2143 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2144 ClMemoryAccessCallbackPrefix + ExpStr + TypeStr + "N" + EndingStr,
2145 FunctionType::get(IRB.getVoidTy(), Args2, false)));
2146
2147 for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes;
2148 AccessSizeIndex++) {
2149 const std::string Suffix = TypeStr + itostr(1ULL << AccessSizeIndex);
2150 AsanErrorCallback[AccessIsWrite][Exp][AccessSizeIndex] =
2151 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2152 kAsanReportErrorTemplate + ExpStr + Suffix + EndingStr,
2153 FunctionType::get(IRB.getVoidTy(), Args1, false)));
2154
2155 AsanMemoryAccessCallback[AccessIsWrite][Exp][AccessSizeIndex] =
2156 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2157 ClMemoryAccessCallbackPrefix + ExpStr + Suffix + EndingStr,
2158 FunctionType::get(IRB.getVoidTy(), Args1, false)));
2159 }
2160 }
2136 AsanErrorCallbackSized[AccessIsWrite][Exp] =
2137 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2138 kAsanReportErrorTemplate + ExpStr + TypeStr + SuffixStr +
2139 EndingStr,
2140 FunctionType::get(IRB.getVoidTy(), Args2, false)));
2141
2142 AsanMemoryAccessCallbackSized[AccessIsWrite][Exp] =
2143 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2144 ClMemoryAccessCallbackPrefix + ExpStr + TypeStr + "N" + EndingStr,
2145 FunctionType::get(IRB.getVoidTy(), Args2, false)));
2146
2147 for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes;
2148 AccessSizeIndex++) {
2149 const std::string Suffix = TypeStr + itostr(1ULL << AccessSizeIndex);
2150 AsanErrorCallback[AccessIsWrite][Exp][AccessSizeIndex] =
2151 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2152 kAsanReportErrorTemplate + ExpStr + Suffix + EndingStr,
2153 FunctionType::get(IRB.getVoidTy(), Args1, false)));
2154
2155 AsanMemoryAccessCallback[AccessIsWrite][Exp][AccessSizeIndex] =
2156 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
2157 ClMemoryAccessCallbackPrefix + ExpStr + Suffix + EndingStr,
2158 FunctionType::get(IRB.getVoidTy(), Args1, false)));
2159 }
2160 }
21612161 }
21622162
21632163 const std::string MemIntrinCallbackPrefix =
40614061 uint64_t Size = Fragment.Size;
40624062 if (ExprFragment) {
40634063 uint64_t AbsEnd =
4064 ExprFragment->OffsetInBits + ExprFragment->SizeInBits;
4064 ExprFragment->OffsetInBits + ExprFragment->SizeInBits;
40654065 if (Start >= AbsEnd)
40664066 // No need to describe a SROAed padding.
40674067 continue;
6161 IndirectStubsManagerBuilder IndirectStubsMgrBuilder,
6262 bool InlineStubs)
6363 : TM(std::move(TM)), DL(this->TM->createDataLayout()),
64 CCMgr(std::move(CCMgr)),
65 ObjectLayer([]() { return std::make_shared(); }),
64 CCMgr(std::move(CCMgr)),
65 ObjectLayer([]() { return std::make_shared(); }),
6666 CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
6767 IRDumpLayer(CompileLayer, createDebugDumper()),
6868 CODLayer(IRDumpLayer, extractSingleFunction, *this->CCMgr,
619619 std::move(RemoteMM));
620620
621621 // Forward MCJIT's symbol resolution calls to the remote.
622 static_cast(RTDyldMM)->setResolver(
623 orc::createLambdaResolver(
624 [](const std::string &Name) { return nullptr; },
625 [&](const std::string &Name) {
626 if (auto Addr = ExitOnErr(R->getSymbolAddress(Name)))
627 return JITSymbol(Addr, JITSymbolFlags::Exported);
628 return JITSymbol(nullptr);
629 }
630 ));
622 static_cast(RTDyldMM)->setResolver(
623 orc::createLambdaResolver(
624 [](const std::string &Name) { return nullptr; },
625 [&](const std::string &Name) {
626 if (auto Addr = ExitOnErr(R->getSymbolAddress(Name)))
627 return JITSymbol(Addr, JITSymbolFlags::Exported);
628 return JITSymbol(nullptr);
629 }));
631630
632631 // Grab the target address of the JIT'd main function on the remote and call
633632 // it.
12251225
12261226 if (Disassemble) {
12271227 if (MachOOF->getHeader().filetype == MachO::MH_KEXT_BUNDLE &&
1228 MachOOF->getHeader().cputype == MachO::CPU_TYPE_ARM64)
1228 MachOOF->getHeader().cputype == MachO::CPU_TYPE_ARM64)
12291229 DisassembleMachO(FileName, MachOOF, "__TEXT_EXEC", "__text");
12301230 else
12311231 DisassembleMachO(FileName, MachOOF, "__TEXT", "__text");
60126012 xp = xar_iter_new();
60136013 if(!xp){
60146014 errs() << "Can't obtain an xar iterator for xar archive "
6015 << XarFilename.c_str() << "\n";
6015 << XarFilename.c_str() << "\n";
60166016 xar_close(xar);
60176017 return;
60186018 }
60256025 #if 0 // Useful for debugging.
60266026 outs() << "key: " << key << " value: " << val << "\n";
60276027 #endif
6028 if(strcmp(key, "name") == 0)
6029 member_name = val;
6030 if(strcmp(key, "type") == 0)
6031 member_type = val;
6032 if(strcmp(key, "data/size") == 0)
6033 member_size_string = val;
6028 if (strcmp(key, "name") == 0)
6029 member_name = val;
6030 if (strcmp(key, "type") == 0)
6031 member_type = val;
6032 if (strcmp(key, "data/size") == 0)
6033 member_size_string = val;
60346034 }
60356035 /*
60366036 * If we find a file with a name, date/size and type properties
60436043 char *endptr;
60446044 member_size = strtoul(member_size_string, &endptr, 10);
60456045 if (*endptr == '\0' && member_size != 0) {
6046 char *buffer = (char *) ::operator new (member_size);
6047 if (xar_extract_tobuffersz(xar, xf, &buffer, &member_size) == 0) {
6046 char *buffer = (char *)::operator new(member_size);
6047 if (xar_extract_tobuffersz(xar, xf, &buffer, &member_size) == 0) {
60486048 #if 0 // Useful for debugging.
60496049 outs() << "xar member: " << member_name << " extracted\n";
60506050 #endif
60516051 // Set the XarMemberName we want to see printed in the header.
6052 std::string OldXarMemberName;
6053 // If XarMemberName is already set this is nested. So
6054 // save the old name and create the nested name.
6055 if (!XarMemberName.empty()) {
6056 OldXarMemberName = XarMemberName;
6052 std::string OldXarMemberName;
6053 // If XarMemberName is already set this is nested. So
6054 // save the old name and create the nested name.
6055 if (!XarMemberName.empty()) {
6056 OldXarMemberName = XarMemberName;
60576057 XarMemberName =
6058 (Twine("[") + XarMemberName + "]" + member_name).str();
6059 } else {
6060 OldXarMemberName = "";
6061 XarMemberName = member_name;
6062 }
6063 // See if this is could be a xar file (nested).
6064 if (member_size >= sizeof(struct xar_header)) {
6058 (Twine("[") + XarMemberName + "]" + member_name).str();
6059 } else {
6060 OldXarMemberName = "";
6061 XarMemberName = member_name;
6062 }
6063 // See if this is could be a xar file (nested).
6064 if (member_size >= sizeof(struct xar_header)) {
60656065 #if 0 // Useful for debugging.
60666066 outs() << "could be a xar file: " << member_name << "\n";
60676067 #endif
6068 memcpy((char *)&XarHeader, buffer, sizeof(struct xar_header));
6068 memcpy((char *)&XarHeader, buffer, sizeof(struct xar_header));
60696069 if (sys::IsLittleEndianHost)
6070 swapStruct(XarHeader);
6071 if(XarHeader.magic == XAR_HEADER_MAGIC)
6072 DumpBitcodeSection(O, buffer, member_size, verbose,
6070 swapStruct(XarHeader);
6071 if (XarHeader.magic == XAR_HEADER_MAGIC)
6072 DumpBitcodeSection(O, buffer, member_size, verbose,
60736073 PrintXarHeader, PrintXarFileHeaders,
6074 XarMemberName);
6075 }
6076 XarMemberName = OldXarMemberName;
6077 }
6074 XarMemberName);
6075 }
6076 XarMemberName = OldXarMemberName;
6077 }
60786078 delete buffer;
60796079 }
60806080 }
67026702 if (!DisSymName.empty() && DisSymName == SymName) {
67036703 outs() << "-dis-symname: " << DisSymName << " not in the section\n";
67046704 return;
6705 }
6705 }
67066706 continue;
67076707 }
67086708 // The __mh_execute_header is special and we need to deal with that fact
14631463 EXPECT_TRUE(test.bitwiseIsEqual(expected));
14641464 for (unsigned j = 0, je = GetZeroTest[i].bitPatternLength; j < je; ++j) {
14651465 EXPECT_EQ(GetZeroTest[i].bitPattern[j],
1466 test.bitcastToAPInt().getRawData()[j]);
1466 test.bitcastToAPInt().getRawData()[j]);
14671467 }
14681468 }
14691469 }
8888 bool needsToReserveAllocationSpace() override { return true; }
8989
9090 void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign,
91 uintptr_t DataSizeRO, uint32_t RODataAlign,
92 uintptr_t DataSizeRW, uint32_t RWDataAlign) override {
91 uintptr_t DataSizeRO, uint32_t RODataAlign,
92 uintptr_t DataSizeRW,
93 uint32_t RWDataAlign) override {
9394 ReservedCodeSize = CodeSize;
9495 ReservedDataSizeRO = DataSizeRO;
9596 ReservedDataSizeRW = DataSizeRW;
3939
4040 // TEST 1: Verify commit case.
4141 SmallString<128> File1(TestDirectory);
42 File1.append("/file1");
42 File1.append("/file1");
4343 {
4444 ErrorOr> BufferOrErr =
4545 FileOutputBuffer::create(File1, 8192);
7878
7979 // TEST 3: Verify sizing down case.
8080 SmallString<128> File3(TestDirectory);
81 File3.append("/file3");
81 File3.append("/file3");
8282 {
8383 ErrorOr> BufferOrErr =
8484 FileOutputBuffer::create(File3, 8192000);
9999
100100 // TEST 4: Verify file can be made executable.
101101 SmallString<128> File4(TestDirectory);
102 File4.append("/file4");
102 File4.append("/file4");
103103 {
104104 ErrorOr> BufferOrErr =
105105 FileOutputBuffer::create(File4, 8192, FileOutputBuffer::F_executable);