Skip to content

Commit 724d163

Browse files
fix windows build attempt
Created using spr 1.3.7
2 parents a67cbb3 + 12bc084 commit 724d163

File tree

6 files changed

+74
-34
lines changed

6 files changed

+74
-34
lines changed

llvm/lib/MC/MCObjectFileInfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,18 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
776776
".debug_loc.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
777777
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
778778
COFF::IMAGE_SCN_MEM_READ);
779+
DwarfLoclistsDWOSection = Ctx->getCOFFSection(
780+
".debug_loclists.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
781+
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
782+
COFF::IMAGE_SCN_MEM_READ);
779783
DwarfStrOffDWOSection = Ctx->getCOFFSection(
780784
".debug_str_offsets.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
781785
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
782786
COFF::IMAGE_SCN_MEM_READ);
787+
DwarfRnglistsDWOSection = Ctx->getCOFFSection(
788+
".debug_rnglists.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
789+
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
790+
COFF::IMAGE_SCN_MEM_READ);
783791
DwarfAddrSection = Ctx->getCOFFSection(
784792
".debug_addr", COFF::IMAGE_SCN_MEM_DISCARDABLE |
785793
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |

llvm/lib/Support/Windows/Path.inc

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ std::error_code status(int FD, file_status &Result) {
828828
}
829829

830830
std::error_code status(file_t FileHandle, file_status &Result) {
831-
return getStatus(FileHandle, Result);
831+
return getStatus(FileHandle.get(), Result);
832832
}
833833

834834
unsigned getUmask() { return 0; }
@@ -897,8 +897,8 @@ std::error_code mapped_file_region::init(sys::fs::file_t OrigFileHandle,
897897
break;
898898
}
899899

900-
HANDLE FileMappingHandle = ::CreateFileMappingW(OrigFileHandle, 0, flprotect,
901-
Hi_32(Size), Lo_32(Size), 0);
900+
HANDLE FileMappingHandle = ::CreateFileMappingW(
901+
OrigFileHandle.get(), 0, flprotect, Hi_32(Size), Lo_32(Size), 0);
902902
if (FileMappingHandle == NULL) {
903903
std::error_code ec = mapWindowsError(GetLastError());
904904
return ec;
@@ -942,7 +942,7 @@ std::error_code mapped_file_region::init(sys::fs::file_t OrigFileHandle,
942942
// are closed and the file is deleted, which may cause invalid data to be read
943943
// from the file.
944944
::CloseHandle(FileMappingHandle);
945-
if (!::DuplicateHandle(::GetCurrentProcess(), OrigFileHandle,
945+
if (!::DuplicateHandle(::GetCurrentProcess(), OrigFileHandle.get(),
946946
::GetCurrentProcess(), &FileHandle, 0, 0,
947947
DUPLICATE_SAME_ACCESS)) {
948948
std::error_code ec = mapWindowsError(GetLastError());
@@ -1006,18 +1006,18 @@ void mapped_file_region::unmapImpl() {
10061006
// sure we are on a local file system.
10071007
bool IsLocal = false;
10081008
SmallVector<wchar_t, 128> FinalPath;
1009-
if (!realPathFromHandle(FileHandle, FinalPath)) {
1009+
if (!realPathFromHandle(FileHandle.get(), FinalPath)) {
10101010
// Not checking the return value here - if the check fails, assume the
10111011
// file isn't local.
10121012
is_local_internal(FinalPath, IsLocal);
10131013
}
10141014
DoFlush = !IsLocal;
10151015
}
10161016
if (DoFlush)
1017-
::FlushFileBuffers(FileHandle);
1017+
::FlushFileBuffers(FileHandle.get());
10181018
}
10191019

1020-
::CloseHandle(FileHandle);
1020+
::CloseHandle(FileHandle.get());
10211021
}
10221022
}
10231023

@@ -1026,7 +1026,7 @@ void mapped_file_region::dontNeedImpl() {}
10261026
std::error_code mapped_file_region::sync() const {
10271027
if (!::FlushViewOfFile(Mapping, Size))
10281028
return mapWindowsError(GetLastError());
1029-
if (!::FlushFileBuffers(FileHandle))
1029+
if (!::FlushFileBuffers(FileHandle.get()))
10301030
return mapWindowsError(GetLastError());
10311031
return std::error_code();
10321032
}
@@ -1145,7 +1145,7 @@ std::error_code detail::directory_iterator_increment(detail::DirIterState &IT) {
11451145

11461146
ErrorOr<basic_file_status> directory_entry::status() const { return Status; }
11471147

1148-
static std::error_code nativeFileToFd(Expected<HANDLE> H, int &ResultFD,
1148+
static std::error_code nativeFileToFd(Expected<file_t> H, int &ResultFD,
11491149
OpenFlags Flags) {
11501150
int CrtOpenFlags = 0;
11511151
if (Flags & OF_Append)
@@ -1160,9 +1160,9 @@ static std::error_code nativeFileToFd(Expected<HANDLE> H, int &ResultFD,
11601160
if (!H)
11611161
return errorToErrorCode(H.takeError());
11621162

1163-
ResultFD = ::_open_osfhandle(intptr_t(*H), CrtOpenFlags);
1163+
ResultFD = ::_open_osfhandle(intptr_t(H->get()), CrtOpenFlags);
11641164
if (ResultFD == -1) {
1165-
::CloseHandle(*H);
1165+
::CloseHandle(H->get());
11661166
return mapWindowsError(ERROR_INVALID_HANDLE);
11671167
}
11681168
return std::error_code();
@@ -1264,9 +1264,9 @@ Expected<file_t> openNativeFile(const Twine &Name, CreationDisposition Disp,
12641264
SYSTEMTIME SystemTime;
12651265
GetSystemTime(&SystemTime);
12661266
if (SystemTimeToFileTime(&SystemTime, &FileTime) == 0 ||
1267-
SetFileTime(Result, NULL, &FileTime, NULL) == 0) {
1267+
SetFileTime(Result.get(), NULL, &FileTime, NULL) == 0) {
12681268
DWORD LastError = ::GetLastError();
1269-
::CloseHandle(Result);
1269+
::CloseHandle(Result.get());
12701270
return errorCodeToError(mapWindowsError(LastError));
12711271
}
12721272
}
@@ -1281,7 +1281,7 @@ std::error_code openFile(const Twine &Name, int &ResultFD,
12811281
if (!Result)
12821282
return errorToErrorCode(Result.takeError());
12831283

1284-
return nativeFileToFd(*Result, ResultFD, Flags);
1284+
return nativeFileToFd(std::move(Result), ResultFD, Flags);
12851285
}
12861286

12871287
static std::error_code directoryRealPath(const Twine &Name,
@@ -1292,15 +1292,15 @@ static std::error_code directoryRealPath(const Twine &Name,
12921292
if (EC)
12931293
return EC;
12941294

1295-
EC = realPathFromHandle(File, RealPath);
1296-
::CloseHandle(File);
1295+
EC = realPathFromHandle(File.get(), RealPath);
1296+
::CloseHandle(File.get());
12971297
return EC;
12981298
}
12991299

13001300
std::error_code openFileForRead(const Twine &Name, int &ResultFD,
13011301
OpenFlags Flags,
13021302
SmallVectorImpl<char> *RealPath) {
1303-
Expected<HANDLE> NativeFile = openNativeFileForRead(Name, Flags, RealPath);
1303+
Expected<file_t> NativeFile = openNativeFileForRead(Name, Flags, RealPath);
13041304
return nativeFileToFd(std::move(NativeFile), ResultFD, OF_None);
13051305
}
13061306

@@ -1311,13 +1311,13 @@ Expected<file_t> openNativeFileForRead(const Twine &Name, OpenFlags Flags,
13111311

13121312
// Fetch the real name of the file, if the user asked
13131313
if (Result && RealPath)
1314-
realPathFromHandle(*Result, *RealPath);
1314+
realPathFromHandle(Result->get(), *RealPath);
13151315

13161316
return Result;
13171317
}
13181318

13191319
file_t convertFDToNativeFile(int FD) {
1320-
return reinterpret_cast<HANDLE>(::_get_osfhandle(FD));
1320+
return file_t(reinterpret_cast<HANDLE>(::_get_osfhandle(FD)));
13211321
}
13221322

13231323
file_t getStdinHandle() { return ::GetStdHandle(STD_INPUT_HANDLE); }
@@ -1332,7 +1332,8 @@ Expected<size_t> readNativeFileImpl(file_t FileHandle,
13321332
DWORD BytesToRead =
13331333
std::min(size_t(std::numeric_limits<DWORD>::max()), Buf.size());
13341334
DWORD BytesRead = 0;
1335-
if (::ReadFile(FileHandle, Buf.data(), BytesToRead, &BytesRead, Overlap))
1335+
if (::ReadFile(FileHandle.get(), Buf.data(), BytesToRead, &BytesRead,
1336+
Overlap))
13361337
return BytesRead;
13371338
DWORD Err = ::GetLastError();
13381339
// EOF is not an error.
@@ -1363,7 +1364,7 @@ std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout,
13631364
auto Start = std::chrono::steady_clock::now();
13641365
auto End = Start + Timeout;
13651366
do {
1366-
if (::LockFileEx(File, Flags, 0, MAXDWORD, MAXDWORD, &OV))
1367+
if (::LockFileEx(File.get(), Flags, 0, MAXDWORD, MAXDWORD, &OV))
13671368
return std::error_code();
13681369
DWORD Error = ::GetLastError();
13691370
if (Error == ERROR_LOCK_VIOLATION) {
@@ -1381,7 +1382,7 @@ std::error_code lockFile(int FD, LockKind Kind) {
13811382
DWORD Flags = Kind == LockKind::Exclusive ? LOCKFILE_EXCLUSIVE_LOCK : 0;
13821383
OVERLAPPED OV = {};
13831384
file_t File = convertFDToNativeFile(FD);
1384-
if (::LockFileEx(File, Flags, 0, MAXDWORD, MAXDWORD, &OV))
1385+
if (::LockFileEx(File.get(), Flags, 0, MAXDWORD, MAXDWORD, &OV))
13851386
return std::error_code();
13861387
DWORD Error = ::GetLastError();
13871388
return mapWindowsError(Error);
@@ -1390,15 +1391,15 @@ std::error_code lockFile(int FD, LockKind Kind) {
13901391
std::error_code unlockFile(int FD) {
13911392
OVERLAPPED OV = {};
13921393
file_t File = convertFDToNativeFile(FD);
1393-
if (::UnlockFileEx(File, 0, MAXDWORD, MAXDWORD, &OV))
1394+
if (::UnlockFileEx(File.get(), 0, MAXDWORD, MAXDWORD, &OV))
13941395
return std::error_code();
13951396
return mapWindowsError(::GetLastError());
13961397
}
13971398

13981399
std::error_code closeFile(file_t &F) {
13991400
file_t TmpF = F;
14001401
F = file_t::Invalid;
1401-
if (!::CloseHandle(TmpF))
1402+
if (!::CloseHandle(TmpF.get()))
14021403
return mapWindowsError(::GetLastError());
14031404
return std::error_code();
14041405
}

llvm/test/CodeGen/X86/debug-loclists.ll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
33
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32
44

5+
; RUN: llc -mtriple=x86_64-pc-mingw -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
6+
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
7+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32
8+
59
; RUN: llc -dwarf64 -mtriple=x86_64-pc-linux -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
610
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
711
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF64
@@ -10,27 +14,31 @@
1014
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
1115
; RUN: FileCheck %s --check-prefixes=DWO,DWO32
1216

17+
; RUN: llc -dwarf-version=5 -split-dwarf-file=foo.dwo -mtriple=x86_64-pc-mingw -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
18+
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
19+
; RUN: FileCheck %s --check-prefixes=DWO,DWO32
20+
1321
; RUN: llc -dwarf64 -dwarf-version=5 -split-dwarf-file=foo.dwo -mtriple=x86_64-pc-linux -filetype=obj -function-sections -o %t -experimental-debug-variable-locations=true < %s
1422
; RUN: llvm-dwarfdump -v -debug-info -debug-loclists %t | \
1523
; RUN: FileCheck %s --check-prefixes=DWO,DWO64
1624

1725
; CHECK: DW_TAG_variable
1826
; DWARF32-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000018:
1927
; DWARF64-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x0000002c:
20-
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text._Z2f1ii": DW_OP_consts +5, DW_OP_stack_value)
28+
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text{{[.$]}}_Z2f1ii": DW_OP_consts +5, DW_OP_stack_value)
2129
; CHECK-NEXT: DW_AT_name {{.*}} "x"
2230

2331
; CHECK: DW_TAG_variable
2432
; DWARF32-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000020:
2533
; DWARF64-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000034:
26-
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text._Z2f1ii": DW_OP_consts +3, DW_OP_stack_value
27-
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text._Z2f1ii": DW_OP_consts +4, DW_OP_stack_value)
34+
; CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text{{[.$]}}_Z2f1ii": DW_OP_consts +3, DW_OP_stack_value
35+
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text{{[.$]}}_Z2f1ii": DW_OP_consts +4, DW_OP_stack_value)
2836
; CHECK-NEXT: DW_AT_name {{.*}} "y"
2937

3038
; CHECK: DW_TAG_variable
3139
; DWARF32-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x2) loclist = 0x00000031:
3240
; DWARF64-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x2) loclist = 0x00000045:
33-
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text._Z2f1ii": DW_OP_reg0 RAX)
41+
; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004) ".text{{[.$]}}_Z2f1ii": DW_OP_reg0 RAX)
3442
; CHECK-NEXT: DW_AT_name {{.*}} "r"
3543

3644
; CHECK: .debug_loclists contents:

llvm/test/DebugInfo/X86/convert-loclist.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
; RUN: llc -mtriple=x86_64 -split-dwarf-file=foo.dwo -filetype=asm -dwarf-op-convert=Enable < %s \
66
; RUN: | FileCheck --check-prefix=ASM %s
77

8+
; RUN: llc -mtriple=x86_64-mingw -filetype=obj < %s \
9+
; RUN: | llvm-dwarfdump -debug-info -debug-loclists - | FileCheck %s
10+
; RUN: llc -mtriple=x86_64-mingw -split-dwarf-file=foo.dwo -filetype=obj -dwarf-op-convert=Enable < %s \
11+
; RUN: | llvm-dwarfdump -debug-info -debug-loclists - | FileCheck --check-prefix=SPLIT --check-prefix=CHECK %s
12+
; RUN: llc -mtriple=x86_64-mingw -split-dwarf-file=foo.dwo -filetype=asm -dwarf-op-convert=Enable < %s \
13+
; RUN: | FileCheck --check-prefix=ASM %s
14+
815
; A bit of a brittle test - this is testing the specific DWO_id. The
916
; alternative would be to test two files with different DW_OP_convert values &
1017
; ensuring the DWO IDs differ when the DW_OP_convert parameter differs.

llvm/test/DebugInfo/X86/ranges_always_default.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
44
; RUN: | FileCheck --check-prefix=RANGE %s
55

6+
; RUN: llc -O0 %s -mtriple=x86_64-unknown-win32-gnu -filetype=obj -o - -minimize-addr-in-v5=Default \
7+
; RUN: -split-dwarf-file=test.dwo \
8+
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
9+
; RUN: | FileCheck --check-prefix=RANGE %s
10+
611
; RUN: llc -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - -minimize-addr-in-v5=Disabled \
712
; RUN: -split-dwarf-file=test.dwo \
813
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
914
; RUN: | FileCheck --check-prefix=NORANGE %s
1015

16+
; RUN: llc -O0 %s -mtriple=x86_64-unknown-win32-gnu -filetype=obj -o - -minimize-addr-in-v5=Disabled \
17+
; RUN: -split-dwarf-file=test.dwo \
18+
; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
19+
; RUN: | FileCheck --check-prefix=NORANGE %s
20+
1121
; A simpler example than used in ranges_always.ll, since this doesn't test all
1222
; the nuances of where minimizing ranges are useful. This is only testing the
1323
; defaulting behavior - specifically that the "ranges" version of the

llvm/test/DebugInfo/X86/split-dwarf-v5-ranges.ll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
; RUN: llc -split-dwarf-file=foo.dwo -mtriple=x86_64-unknown-linux-gnu -filetype=obj %s -o %t32
22
; RUN: llvm-dwarfdump -v -debug-info -debug-rnglists %t32 | \
3-
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32
3+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32,CHECK-ELF
4+
5+
; RUN: llc -split-dwarf-file=foo.dwo -mtriple=x86_64-unknown-win32-gnu -filetype=obj %s -o %t32
6+
; RUN: llvm-dwarfdump -v -debug-info -debug-rnglists %t32 | \
7+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF32,CHECK-COFF
48

59
; RUN: llc -dwarf64 -split-dwarf-file=foo.dwo -mtriple=x86_64-unknown-linux-gnu -filetype=obj %s -o %t64
610
; RUN: llvm-dwarfdump -v -debug-info -debug-rnglists %t64 | \
7-
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF64
11+
; RUN: FileCheck %s --check-prefixes=CHECK,DWARF64,CHECK-ELF
812

913
; CHECK: .debug_info contents:
1014
; CHECK: .debug_info.dwo contents:
1115
; CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x[[#%.8x,RNG_OFF:]]
12-
; CHECK: [0x0000000000000001, 0x000000000000000c) ".text"
13-
; CHECK: [0x000000000000000e, 0x0000000000000013) ".text")
16+
; CHECK-ELF: [0x[[#%.16x,BEGIN1:0x01]], 0x[[#%.16x,END1:0x0c]]) ".text"
17+
; CHECK-ELF: [0x[[#%.16x,BEGIN2:0x0e]], 0x[[#%.16x,END2:0x13]]) ".text")
18+
; CHECK-COFF: [0x[[#%.16x,BEGIN1:0x04]], 0x[[#%.16x,END1:0x0f]]) ".text"
19+
; CHECK-COFF: [0x[[#%.16x,BEGIN2:0x11]], 0x[[#%.16x,END2:0x17]]) ".text")
1420

1521
; CHECK: .debug_rnglists.dwo contents:
1622
; DWARF32: 0x00000000: range list header: length = 0x00000015, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000001
@@ -21,8 +27,8 @@
2127
; CHECK: ]
2228
; CHECK: ranges:
2329
; CHECK: 0x[[#RNG_OFF]]: [DW_RLE_base_addressx]: 0x0000000000000000
24-
; CHECK: 0x[[#RNG_OFF+2]]: [DW_RLE_offset_pair ]: 0x0000000000000001, 0x000000000000000c => [0x0000000000000001, 0x000000000000000c)
25-
; CHECK: 0x[[#RNG_OFF+5]]: [DW_RLE_offset_pair ]: 0x000000000000000e, 0x0000000000000013 => [0x000000000000000e, 0x0000000000000013)
30+
; CHECK: 0x[[#RNG_OFF+2]]: [DW_RLE_offset_pair ]: 0x[[#%.16x,BEGIN1]], 0x[[#%.16x,END1]] => [0x[[#%.16x,BEGIN1]], 0x[[#%.16x,END1]])
31+
; CHECK: 0x[[#RNG_OFF+5]]: [DW_RLE_offset_pair ]: 0x[[#%.16x,BEGIN2]], 0x[[#%.16x,END2]] => [0x[[#%.16x,BEGIN2]], 0x[[#%.16x,END2]])
2632
; CHECK: 0x[[#RNG_OFF+8]]: [DW_RLE_end_of_list ]
2733

2834
; Function Attrs: noinline optnone uwtable

0 commit comments

Comments
 (0)