summarylogtreecommitdiffstats
path: root/clang-4-patchset.patch
blob: 9f6ad635cbdac82146bdf4ef5a544f29f560287a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
diff --git a/build.sh b/build.sh
index f5cab1e..b0751c2 100755
--- a/build.sh
+++ b/build.sh
@@ -671,6 +671,11 @@ while :; do
             __ClangMinorVersion=9
             ;;
 
+        clang4.0)
+            __ClangMajorVersion=4
+            __ClangMinorVersion=0
+            ;;
+
         ninja)
             __UseNinja=1
             ;;
diff --git a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
index 247c700..f0c2176 100644
--- a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
+++ b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
@@ -55,14 +55,15 @@ if(NOT ENABLE_LLDBPLUGIN)
 endif()
 
 # Check for LLDB library
-find_library(LLDB NAMES LLDB lldb lldb-3.8 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH)
-find_library(LLDB NAMES LLDB lldb lldb-3.8 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm)
+find_library(LLDB NAMES LLDB lldb lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH)
+find_library(LLDB NAMES LLDB lldb lldb-4.0 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm)
 if(LLDB STREQUAL LLDB-NOTFOUND)
     if(REQUIRE_LLDBPLUGIN)
-        message(FATAL_ERROR "Cannot find lldb-3.5, lldb-3.6 or lldb-3.8. Try installing lldb-3.6-dev (or the appropriate package for your platform)")
+        set(MESSAGE_MODE FATAL_ERROR)
     else()
-        message(WARNING "Cannot find lldb-3.5,lldb-3.6 or lldb-3.8. Try installing lldb-3.6-dev (or the appropriate package for your platform)")
+        set(MESSAGE_MODE WARNING)
     endif()
+    message(${MESSAGE_MODE} "Cannot find lldb-3.5, lldb-3.6, lldb-3.8, lldb-3.9 or lldb-4.0. Try installing lldb-3.6-dev (or the appropriate package for your platform)")
     return()
 endif()
 
diff --git a/src/debug/di/dbgtransportmanager.cpp b/src/debug/di/dbgtransportmanager.cpp
index 77a3548..8c1079d 100644
--- a/src/debug/di/dbgtransportmanager.cpp
+++ b/src/debug/di/dbgtransportmanager.cpp
@@ -102,7 +102,7 @@ HRESULT DbgTransportTarget::GetTransportForProcess(DWORD                   dwPID
     entry->m_cProcessRef++;
     _ASSERTE(entry->m_cProcessRef > 0);
     _ASSERTE(entry->m_transport != NULL);
-    _ASSERTE(entry->m_hProcess > 0);
+    _ASSERTE((intptr_t)entry->m_hProcess > 0);
     
     *ppTransport = entry->m_transport;
     if (!DuplicateHandle(GetCurrentProcess(), 
@@ -139,7 +139,7 @@ void DbgTransportTarget::ReleaseTransport(DbgTransportSession *pTransport)
 
         _ASSERTE(entry->m_cProcessRef > 0);
         _ASSERTE(entry->m_transport != NULL);
-        _ASSERTE(entry->m_hProcess > 0);
+        _ASSERTE((intptr_t)entry->m_hProcess > 0);
 
         if (entry->m_transport == pTransport)
         {
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 745b24f..08de1fa 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -20356,7 +20356,7 @@ size_t gc_heap::update_brick_table (uint8_t* tree, size_t current_brick,
     dprintf (3, ("tree: %Ix, current b: %Ix, x: %Ix, plug_end: %Ix",
         tree, current_brick, x, plug_end));
 
-    if (tree > 0)
+    if (tree != NULL)
     {
         dprintf (3, ("b- %Ix->%Ix pointing to tree %Ix", 
             current_brick, (size_t)(tree - brick_address (current_brick)), tree));
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index 9e97edc..7d25940 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -5303,6 +5303,7 @@ inline WCHAR *PAL_wcsstr(WCHAR *_S, const WCHAR *_P)
 }
 #endif
 
+#if !__has_builtin(_rotl)
 /*++
 Function:
 _rotl
@@ -5320,12 +5321,15 @@ unsigned int __cdecl _rotl(unsigned int value, int shift)
     retval = (value << shift) | (value >> (sizeof(int) * CHAR_BIT - shift));
     return retval;
 }
+#endif // !__has_builtin(_rotl)
 
 // On 64 bit unix, make the long an int.
 #ifdef BIT64
 #define _lrotl _rotl
 #endif // BIT64
 
+#if !__has_builtin(_rotr)
+
 /*++
 Function:
 _rotr
@@ -5344,6 +5348,8 @@ unsigned int __cdecl _rotr(unsigned int value, int shift)
     return retval;
 }
 
+#endif // !__has_builtin(_rotr)
+
 PALIMPORT int __cdecl abs(int);
 #ifndef PAL_STDCPP_COMPAT
 PALIMPORT LONG __cdecl labs(LONG);
diff --git a/src/pal/inc/pal_mstypes.h b/src/pal/inc/pal_mstypes.h
index 0ca2871..0aa35ae 100644
--- a/src/pal/inc/pal_mstypes.h
+++ b/src/pal/inc/pal_mstypes.h
@@ -556,7 +556,7 @@ typedef LONG_PTR SSIZE_T, *PSSIZE_T;
 #endif
 
 #ifndef SSIZE_T_MIN
-#define SSIZE_T_MIN I64(-9223372036854775808)
+#define SSIZE_T_MIN I64(0x8000000000000000)
 #endif
 
 #ifndef PAL_STDCPP_COMPAT
diff --git a/src/vm/amd64/unixstubs.cpp b/src/vm/amd64/unixstubs.cpp
index 2904149..76d3cf1 100644
--- a/src/vm/amd64/unixstubs.cpp
+++ b/src/vm/amd64/unixstubs.cpp
@@ -37,7 +37,7 @@ extern "C"
               "  mov %%edx, 12(%[result])\n" \
             : "=a"(eax) /*output in eax*/\
             : "a"(arg), [result]"r"(result) /*inputs - arg in eax, result in any register*/\
-            : "eax", "rbx", "ecx", "edx", "memory" /* registers that are clobbered, *result is clobbered */
+            : "rbx", "ecx", "edx", "memory" /* registers that are clobbered, *result is clobbered */
           );
         return eax;
     }
@@ -52,7 +52,7 @@ extern "C"
               "  mov %%edx, 12(%[result])\n" \
             : "=a"(eax) /*output in eax*/\
             : "c"(arg1), "a"(arg2), [result]"r"(result) /*inputs - arg1 in ecx, arg2 in eax, result in any register*/\
-            : "eax", "rbx", "ecx", "edx", "memory" /* registers that are clobbered, *result is clobbered */
+            : "rbx", "edx", "memory" /* registers that are clobbered, *result is clobbered */
           );
         return eax;
     }
@@ -63,7 +63,7 @@ extern "C"
         __asm("  xgetbv\n" \
             : "=a"(eax) /*output in eax*/\
             : "c"(0) /*inputs - 0 in ecx*/\
-            : "eax", "edx" /* registers that are clobbered*/
+            : "edx" /* registers that are clobbered*/
           );
         // check OS has enabled both XMM and YMM state support
         return ((eax & 0x06) == 0x06) ? 1 : 0;
--- a/src/pal/inc/rt/intsafe.h
+++ b/src/pal/inc/rt/intsafe.h
@@ -18,26 +18,6 @@
 
 #include <specstrings.h>    // for IN, etc.
 
-
-#if defined(_AMD64_)
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define UnsignedMultiply128 _umul128
-ULONG64
-UnsignedMultiply128 (
-    IN ULONG64  Multiplier,
-    IN ULONG64  Multiplicand,
-    OUT ULONG64 *HighProduct
-    );
-#ifdef _MSC_VER
-#pragma intrinsic(_umul128)
-#endif // _MSC_VER
-#ifdef __cplusplus
-}
-#endif
-#endif // _AMD64_
-
 #ifndef FEATURE_PAL
 
 #ifdef  _WIN64
@@ -434,7 +414,7 @@
     OUT ULONG* pulResult)
 {
     *pulResult = (ULONG)uOperand;
-    
+
     return S_OK;
 }
 
@@ -552,7 +532,7 @@
     OUT UINT* puResult)
 {
     *puResult = (UINT)ulOperand;
-    
+
     return S_OK;
 }
 
@@ -673,13 +653,13 @@
 {
     HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
     *pulResult = ULONG_ERROR;
-    
+
     if (ullOperand <= ULONG_MAX)
     {
         *pulResult = (ULONG)ullOperand;
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -727,13 +707,13 @@
 {
     HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
     *puResult = UINT_ERROR;
-    
+
     if (ullOperand <= UINT_MAX)
     {
         *puResult = (UINT)ullOperand;
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1120,7 +1100,7 @@
         *pusResult = (usAugend + usAddend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1147,7 +1127,7 @@
         *puResult = (uAugend + uAddend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1174,7 +1154,7 @@
         *pulResult = (ulAugend + ulAddend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1223,7 +1203,7 @@
         *pResult = (Augend + Addend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1250,7 +1230,7 @@
         *pullResult = (ullAugend + ullAddend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1272,7 +1252,7 @@
         *pusResult = (usMinuend - usSubtrahend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1300,7 +1280,7 @@
         *puResult = (uMinuend - uSubtrahend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1327,7 +1307,7 @@
         *pulResult = (ulMinuend - ulSubtrahend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1377,7 +1357,7 @@
         *pResult = (Minuend - Subtrahend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1404,7 +1384,7 @@
         *pullResult = (ullMinuend - ullSubtrahend);
         hr = S_OK;
     }
-    
+
     return hr;
 }
 
@@ -1419,7 +1399,7 @@
     OUT USHORT* pusResult)
 {
     ULONG ulResult = ((ULONG)usMultiplicand) * (ULONG)usMultiplier;
-    
+
     return ULongToUShort(ulResult, pusResult);
 }
 
@@ -1444,23 +1424,6 @@
 }
 
 //
-// UINT_PTR multiplication
-//
-#ifdef _WIN64
-#define UIntPtrMult     ULongLongMult
-#else
-__inline
-HRESULT
-UIntPtrMult(
-    IN UINT_PTR ulMultiplicand,
-    IN UINT_PTR ulMultiplier,
-    OUT UINT_PTR* pulResult)
-{
-	return UIntMult((UINT)ulMultiplicand, (UINT)ulMultiplier, (UINT*)pulResult);
-}
-#endif // _WIN64
-
-//
 // ULONG multiplication
 //
 __inline
@@ -1471,27 +1434,9 @@
     OUT ULONG* pulResult)
 {
     ULONGLONG ull64Result = UInt32x32To64(ulMultiplicand, ulMultiplier);
-    
-    return ULongLongToULong(ull64Result, pulResult);
-}
 
-//
-// ULONG_PTR multiplication
-//
-#ifdef _WIN64
-#define ULongPtrMult    ULongLongMult
-#else
-__inline
-HRESULT
-ULongPtrMult(
-    IN ULONG_PTR ulMultiplicand,
-    IN ULONG_PTR ulMultiplier,
-    OUT ULONG_PTR* pulResult)
-{
-	return ULongMult((ULONG)ulMultiplicand, (ULONG)ulMultiplier, (ULONG*)pulResult);
+    return ULongLongToULong(ull64Result, pulResult);
 }
-#endif // _WIN64
-
 
 //
 // DWORD multiplication
@@ -1503,114 +1448,4 @@
 //
 #define DWordPtrMult	ULongPtrMult
 
-//
-// size_t multiplication
-//
-#define SizeTMult		UIntPtrMult
-
-//
-// SIZE_T multiplication
-//
-#define SIZETMult		ULongPtrMult
-
-//
-// ULONGLONG multiplication
-//
-__inline
-HRESULT
-ULongLongMult(
-    IN ULONGLONG ullMultiplicand,
-    IN ULONGLONG ullMultiplier,
-    OUT ULONGLONG* pullResult)
-{
-    HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
-#ifdef _AMD64_
-    ULONGLONG u64ResultHigh;
-    ULONGLONG u64ResultLow;
-    
-    *pullResult = ULONGLONG_ERROR;
-    
-    u64ResultLow = UnsignedMultiply128(ullMultiplicand, ullMultiplier, &u64ResultHigh);
-    if (u64ResultHigh == 0)
-    {
-        *pullResult = u64ResultLow;
-        hr = S_OK;
-    }
-#else
-    // 64x64 into 128 is like 32.32 x 32.32.
-    //
-    // a.b * c.d = a*(c.d) + .b*(c.d) = a*c + a*.d + .b*c + .b*.d
-    // back in non-decimal notation where A=a*2^32 and C=c*2^32:  
-    // A*C + A*d + b*C + b*d
-    // So there are four components to add together.
-    //   result = (a*c*2^64) + (a*d*2^32) + (b*c*2^32) + (b*d)
-    //
-    // a * c must be 0 or there would be bits in the high 64-bits
-    // a * d must be less than 2^32 or there would be bits in the high 64-bits
-    // b * c must be less than 2^32 or there would be bits in the high 64-bits
-    // then there must be no overflow of the resulting values summed up.
-    
-    ULONG dw_a;
-    ULONG dw_b;
-    ULONG dw_c;
-    ULONG dw_d;
-    ULONGLONG ad = 0;
-    ULONGLONG bc = 0;
-    ULONGLONG bd = 0;
-    ULONGLONG ullResult = 0;
-    
-    *pullResult = ULONGLONG_ERROR;
-
-    dw_a = (ULONG)(ullMultiplicand >> 32);
-    dw_c = (ULONG)(ullMultiplier >> 32);
-
-    // common case -- if high dwords are both zero, no chance for overflow
-    if ((dw_a == 0) && (dw_c == 0))
-    {
-        dw_b = (DWORD)ullMultiplicand;
-        dw_d = (DWORD)ullMultiplier;
-
-        *pullResult = (((ULONGLONG)dw_b) * (ULONGLONG)dw_d);
-        hr = S_OK;
-    }
-    else
-    {
-        // a * c must be 0 or there would be bits set in the high 64-bits
-        if ((dw_a == 0) ||
-            (dw_c == 0))
-        {
-            dw_d = (DWORD)ullMultiplier;
-
-            // a * d must be less than 2^32 or there would be bits set in the high 64-bits
-            ad = (((ULONGLONG)dw_a) * (ULONGLONG)dw_d);
-            if ((ad & HIDWORD_MASK) == 0)
-            {
-                dw_b = (DWORD)ullMultiplicand;
-
-                // b * c must be less than 2^32 or there would be bits set in the high 64-bits
-                bc = (((ULONGLONG)dw_b) * (ULONGLONG)dw_c);
-                if ((bc & HIDWORD_MASK) == 0)
-                {
-                    // now sum them all up checking for overflow.
-                    // shifting is safe because we already checked for overflow above
-                    if (SUCCEEDED(ULongLongAdd(bc << 32, ad << 32, &ullResult)))                        
-                    {
-                        // b * d
-                        bd = (((ULONGLONG)dw_b) * (ULONGLONG)dw_d);
-                    
-                        if (SUCCEEDED(ULongLongAdd(ullResult, bd, &ullResult)))
-                        {
-                            *pullResult = ullResult;
-                            hr = S_OK;
-                        }
-                    }
-                }
-            }
-        }
-    }
-#endif // _AMD64_  
-    
-    return hr;
-}
-
 #endif // _INTSAFE_H_INCLUDED_