Skip to content

Commit 901be28

Browse files
committed
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/meinersbur/flang_runtime_move-files
2 parents 3477620 + b2a6556 commit 901be28

File tree

147 files changed

+6252
-5309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+6252
-5309
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Bug Fixes to Compiler Builtins
136136

137137
Bug Fixes to Attribute Support
138138
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
139+
- Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125
139140

140141
Bug Fixes to C++ Support
141142
^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
130130
}
131131
}
132132

133-
let Features = "sse", Header = "xmmintrin.h", Attributes = [NoThrow, Const] in {
134-
def _mm_prefetch : X86LibBuiltin<"void(void const *, int)">;
135-
}
136-
137133
// AVX
138134
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in {
139135
foreach Op = ["addsub", "hadd", "hsub", "max", "min"] in {
@@ -142,12 +138,6 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in
142138
}
143139
}
144140

145-
// PRFCHW
146-
let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in {
147-
def _m_prefetch : X86LibBuiltin<"void(void *)">;
148-
def _m_prefetchw : X86LibBuiltin<"void(void volatile const *)">;
149-
}
150-
151141

152142
// Mechanically ported builtins from the original `.def` file.
153143
//
@@ -156,6 +146,10 @@ let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in {
156146
// current formulation is based on what was easiest to recognize from the
157147
// pre-TableGen version.
158148

149+
let Features = "mmx", Attributes = [NoThrow, Const] in {
150+
def _mm_prefetch : X86NoPrefixBuiltin<"void(char const *, int)">;
151+
}
152+
159153
let Features = "sse", Attributes = [NoThrow] in {
160154
def ldmxcsr : X86Builtin<"void(unsigned int)">;
161155
}

clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ class GlobalImmutableSpaceRegion : public NonStaticGlobalSpaceRegion {
344344
};
345345

346346
/// The region containing globals which can be modified by calls to
347-
/// "internally" defined functions - (for now just) functions other then system
347+
/// "internally" defined functions - (for now just) functions other than system
348348
/// calls.
349349
class GlobalInternalSpaceRegion : public NonStaticGlobalSpaceRegion {
350350
friend class MemRegionManager;
@@ -1021,7 +1021,7 @@ class NonParamVarRegion : public VarRegion {
10211021
}
10221022
};
10231023

1024-
/// ParamVarRegion - Represents a region for paremters. Only parameters of the
1024+
/// ParamVarRegion - Represents a region for parameters. Only parameters of the
10251025
/// function in the current stack frame are represented as `ParamVarRegion`s.
10261026
/// Parameters of top-level analyzed functions as well as captured paremeters
10271027
/// by lambdas and blocks are repesented as `VarRegion`s.

clang/lib/Basic/Targets/NVPTX.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
6262
HasFloat16 = true;
6363

6464
if (TargetPointerWidth == 32)
65-
resetDataLayout("e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
66-
else if (Opts.NVPTXUseShortPointers)
6765
resetDataLayout(
68-
"e-p3:32:32-p4:32:32-p5:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
66+
"e-p:32:32-p6:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
67+
else if (Opts.NVPTXUseShortPointers)
68+
resetDataLayout("e-p3:32:32-p4:32:32-p5:32:32-p6:32:32-i64:64-i128:128-v16:"
69+
"16-v32:32-n16:32:64");
6970
else
70-
resetDataLayout("e-i64:64-i128:128-v16:16-v32:32-n16:32:64");
71+
resetDataLayout("e-p6:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
7172

7273
// If possible, get a TargetInfo for our host triple, so we can match its
7374
// types.

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15374,17 +15374,6 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1537415374
Function *F = CGM.getIntrinsic(Intrinsic::prefetch, Address->getType());
1537515375
return Builder.CreateCall(F, {Address, RW, Locality, Data});
1537615376
}
15377-
case X86::BI_m_prefetch:
15378-
case X86::BI_m_prefetchw: {
15379-
Value *Address = Ops[0];
15380-
// The 'w' suffix implies write.
15381-
Value *RW =
15382-
ConstantInt::get(Int32Ty, BuiltinID == X86::BI_m_prefetchw ? 1 : 0);
15383-
Value *Locality = ConstantInt::get(Int32Ty, 0x3);
15384-
Value *Data = ConstantInt::get(Int32Ty, 1);
15385-
Function *F = CGM.getIntrinsic(Intrinsic::prefetch, Address->getType());
15386-
return Builder.CreateCall(F, {Address, RW, Locality, Data});
15387-
}
1538815377
case X86::BI_mm_clflush: {
1538915378
return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse2_clflush),
1539015379
Ops[0]);

clang/lib/Format/QualifierAlignmentFixer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ static void rotateTokens(const SourceManager &SourceMgr,
132132
// Then move through the other tokens.
133133
auto *Tok = Begin;
134134
while (Tok != End) {
135-
if (!NewText.empty() && !endsWithSpace(NewText))
135+
if (!NewText.empty() && !endsWithSpace(NewText) &&
136+
Tok->isNot(tok::coloncolon)) {
136137
NewText += " ";
138+
}
137139

138140
NewText += Tok->TokenText;
139141
Tok = Tok->Next;
@@ -412,6 +414,14 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft(
412414
// The case `const long long volatile int` -> `const volatile long long int`
413415
// The case `long volatile long int const` -> `const volatile long long int`
414416
if (TypeToken->isTypeName(LangOpts)) {
417+
for (const auto *Prev = TypeToken->Previous;
418+
Prev && Prev->is(tok::coloncolon); Prev = Prev->Previous) {
419+
TypeToken = Prev;
420+
Prev = Prev->Previous;
421+
if (!(Prev && Prev->is(tok::identifier)))
422+
break;
423+
TypeToken = Prev;
424+
}
415425
const FormatToken *LastSimpleTypeSpecifier = TypeToken;
416426
while (isConfiguredQualifierOrType(
417427
LastSimpleTypeSpecifier->getPreviousNonComment(),

clang/lib/Headers/prfchwintrin.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
#ifndef __PRFCHWINTRIN_H
1515
#define __PRFCHWINTRIN_H
1616

17-
#if defined(__cplusplus)
18-
extern "C" {
19-
#endif
20-
2117
/// Loads a memory sequence containing the specified memory address into
2218
/// all data cache levels.
2319
///
@@ -30,7 +26,11 @@ extern "C" {
3026
///
3127
/// \param __P
3228
/// A pointer specifying the memory address to be prefetched.
33-
void _m_prefetch(void *__P);
29+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
30+
_m_prefetch(void *__P)
31+
{
32+
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
33+
}
3434

3535
/// Loads a memory sequence containing the specified memory address into
3636
/// the L1 data cache and sets the cache-coherency state to modified.
@@ -48,10 +48,13 @@ void _m_prefetch(void *__P);
4848
///
4949
/// \param __P
5050
/// A pointer specifying the memory address to be prefetched.
51-
void _m_prefetchw(volatile const void *__P);
52-
53-
#if defined(__cplusplus)
54-
} // extern "C"
55-
#endif
51+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
52+
_m_prefetchw(volatile const void *__P)
53+
{
54+
#pragma clang diagnostic push
55+
#pragma clang diagnostic ignored "-Wcast-qual"
56+
__builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
57+
#pragma clang diagnostic pop
58+
}
5659

5760
#endif /* __PRFCHWINTRIN_H */

clang/lib/Headers/xmmintrin.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,10 @@ _mm_storer_ps(float *__p, __m128 __a)
21972197
#define _MM_HINT_T2 1
21982198
#define _MM_HINT_NTA 0
21992199

2200-
#if 0
2200+
#ifndef _MSC_VER
2201+
/* FIXME: We have to #define this because "sel" must be a constant integer, and
2202+
Sema doesn't do any form of constant propagation yet. */
2203+
22012204
/// Loads one cache line of data from the specified address to a location
22022205
/// closer to the processor.
22032206
///
@@ -2222,10 +2225,6 @@ _mm_storer_ps(float *__p, __m128 __a)
22222225
/// be generated. \n
22232226
/// _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
22242227
/// be generated.
2225-
///
2226-
/// _mm_prefetch is implemented as a "library builtin" directly in Clang,
2227-
/// similar to how it is done in MSVC. Clang will warn if the user doesn't
2228-
/// include xmmintrin.h or immintrin.h.
22292228
#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \
22302229
((sel) >> 2) & 1, (sel) & 0x3))
22312230
#endif

clang/lib/Sema/SemaAttr.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ bool Sema::ConstantFoldAttrArgs(const AttributeCommonInfo &CI,
537537
Diag(Note.first, Note.second);
538538
return false;
539539
}
540-
assert(Eval.Val.hasValue());
541540
E = ConstantExpr::Create(Context, E, Eval.Val);
542541
}
543542

clang/test/CodeGen/target-data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@
160160

161161
// RUN: %clang_cc1 -triple nvptx-unknown -o - -emit-llvm %s | \
162162
// RUN: FileCheck %s -check-prefix=NVPTX
163-
// NVPTX: target datalayout = "e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64"
163+
// NVPTX: target datalayout = "e-p:32:32-p6:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64"
164164

165165
// RUN: %clang_cc1 -triple nvptx64-unknown -o - -emit-llvm %s | \
166166
// RUN: FileCheck %s -check-prefix=NVPTX64
167-
// NVPTX64: target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
167+
// NVPTX64: target datalayout = "e-p6:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64"
168168

169169
// RUN: %clang_cc1 -triple r600-unknown -o - -emit-llvm %s | \
170170
// RUN: FileCheck %s -check-prefix=R600

clang/test/CodeGenCXX/attr-annotate2.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@
44
// CHECK: @[[STR:.*]] = private unnamed_addr constant [45 x i8] c"_Generic selection expression should be fine\00", section "llvm.metadata"
55
// CHECK-NEXT: @[[FILENAME:.*]] = private unnamed_addr constant {{.*}}, section "llvm.metadata"
66
// CHECK-NEXT: @[[ARGS:.*]] = private unnamed_addr constant { i32 } zeroinitializer, section "llvm.metadata"
7+
// CHECK-NEXT: @[[STR2:.*]] = private unnamed_addr constant [14 x i8] c"void is undef\00", section "llvm.metadata"
8+
// CHECK-NEXT: @[[ARGS3:.*]] = private unnamed_addr constant { i8, i8, i32 } { i8 undef, i8 undef, i32 7 }, section "llvm.metadata"
9+
10+
711

812
// CHECK-LABEL: @_Z1fv(
913
// CHECK-NEXT: entry:
1014
// CHECK-NEXT: [[N:%.*]] = alloca i32, align 4
1115
// CHECK-NEXT: [[J:%.*]] = alloca i32, align 4
16+
// CHECK-NEXT: [[K:%.*]] = alloca i32, align 4
1217
// CHECK-NEXT: store i32 10, ptr [[N]], align 4
1318
// CHECK-NEXT: call void @llvm.var.annotation.p0.p0(ptr [[J]], ptr @[[STR]], ptr @[[FILENAME]], i32 {{.*}}, ptr @[[ARGS]])
1419
// CHECK-NEXT: store i32 0, ptr [[J]], align 4
20+
// CHECK-NEXT: call void @llvm.var.annotation.p0.p0(ptr [[K]], ptr @[[STR2]], ptr @[[FILENAME]], i32 {{.*}}, ptr @[[ARGS3]])
21+
// CHECK-NEXT: store i32 0, ptr [[K]], align 4
1522
// CHECK-NEXT: ret void
1623
//
1724
void f() {
1825
int n = 10;
1926
[[clang::annotate("_Generic selection expression should be fine", _Generic(n, int : 0, default : 1))]]
2027
int j = 0; // second arg should resolve to 0 fine
28+
29+
[[clang::annotate("void is undef", (void)2, (void)4, 7)]]
30+
int k = 0;
2131
}

clang/test/Preprocessor/arm-target-features.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,3 +1013,17 @@
10131013
// CHECK-MVE1_2: #define __ARM_FEATURE_MVE 1
10141014
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-MVE3 %s
10151015
// CHECK-MVE3: #define __ARM_FEATURE_MVE 3
1016+
1017+
// Cortex-R52 and Cortex-R52Plus correctly enable the `fpv5-sp-d16` FPU when compiling for the SP only version of the CPU.
1018+
// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52+nosimd+nofp.dp -mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52 %s
1019+
// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52plus+nosimd+nofp.dp -mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52 %s
1020+
// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52+nofp.dp -mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52 %s
1021+
// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52plus+nofp.dp -mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52 %s
1022+
// CHECK-R52: #define __ARM_FEATURE_FMA 1
1023+
// CHECK-R52: #define __ARM_FP 0x6
1024+
// CHECK-R52: #define __ARM_FPV5__ 1
1025+
// CHECK-R52: #define __ARM_VFPV2__ 1
1026+
// CHECK-R52-NEXT: #define __ARM_VFPV3__ 1
1027+
// CHECK-R52-NEXT: #define __ARM_VFPV4__ 1
1028+
// CHECK-R52-NOT: #define __ARM_NEON 1
1029+
// CHECK-R52-NOT: #define __ARM_NEON__

clang/test/SemaCXX/attr-annotate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,7 @@ constexpr int foldable_but_invalid() {
134134
template <typename T> [[clang::annotate()]] void f2() {}
135135
// expected-error@-1 {{'annotate' attribute takes at least 1 argument}}
136136
}
137+
138+
namespace test5 {
139+
void bir [[clang::annotate("B", (void)1)]] ();
140+
}

clang/unittests/Format/QualifierFixerTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,21 @@ TEST_F(QualifierFixerTest, WithCpp11Attribute) {
12911291
"[[maybe_unused]] constexpr static int A", Style);
12921292
}
12931293

1294+
TEST_F(QualifierFixerTest, WithQualifiedTypeName) {
1295+
auto Style = getLLVMStyle();
1296+
Style.QualifierAlignment = FormatStyle::QAS_Custom;
1297+
Style.QualifierOrder = {"constexpr", "type", "const"};
1298+
1299+
verifyFormat("constexpr ::int64_t x{1};", "::int64_t constexpr x{1};", Style);
1300+
verifyFormat("constexpr std::int64_t x{123};",
1301+
"std::int64_t constexpr x{123};", Style);
1302+
verifyFormat("constexpr ::std::int64_t x{123};",
1303+
"::std::int64_t constexpr x{123};", Style);
1304+
1305+
Style.TypeNames.push_back("bar");
1306+
verifyFormat("constexpr foo::bar x{12};", "foo::bar constexpr x{12};", Style);
1307+
}
1308+
12941309
TEST_F(QualifierFixerTest, DisableRegions) {
12951310
FormatStyle Style = getLLVMStyle();
12961311
Style.QualifierAlignment = FormatStyle::QAS_Custom;

libc/config/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
"value": false,
3131
"doc": "Use the same mode for double and long double in printf."
3232
},
33+
"LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320": {
34+
"value": false,
35+
"doc": "Use an alternative printf float implementation based on 320-bit floats"
36+
},
3337
"LIBC_CONF_PRINTF_DISABLE_FIXED_POINT": {
3438
"value": false,
3539
"doc": "Disable printing fixed point values in printf and friends."

libc/docs/configure.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ to learn about the defaults for your platform and target.
4343
- ``LIBC_CONF_PRINTF_DISABLE_WRITE_INT``: Disable handling of %n in printf format string.
4444
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_NO_SPECIALIZE_LD``: Use the same mode for double and long double in printf.
4545
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_DYADIC_FLOAT``: Use dyadic float for faster and smaller but less accurate printf doubles.
46+
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320``: Use an alternative printf float implementation based on 320-bit floats
4647
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE``: Use large table for better printf long double performance.
4748
* **"pthread" options**
4849
- ``LIBC_CONF_RAW_MUTEX_DEFAULT_SPIN_COUNT``: Default number of spins before blocking if a mutex is in contention (default to 100).

libc/src/__support/CPP/algorithm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ template <class T> LIBC_INLINE constexpr const T &min(const T &a, const T &b) {
2626
return (a < b) ? a : b;
2727
}
2828

29+
template <class T> LIBC_INLINE constexpr T abs(T a) { return a < 0 ? -a : a; }
30+
2931
template <class InputIt, class UnaryPred>
3032
LIBC_INLINE constexpr InputIt find_if_not(InputIt first, InputIt last,
3133
UnaryPred q) {

0 commit comments

Comments
 (0)