Skip to content

Commit d8ab489

Browse files
committed
Merge branch 'main' (early part) into users/meinersbur/flang_runtime_move-files
2 parents 0c5ec72 + 1801fb4 commit d8ab489

File tree

36 files changed

+862
-348
lines changed

36 files changed

+862
-348
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4515,7 +4515,13 @@ Driver::getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
45154515
ToolChain::getOpenMPTriple(Arg->getValue(0)) == TC->getTriple()) {
45164516
Arg->claim();
45174517
unsigned Index = Args.getBaseArgs().MakeIndex(Arg->getValue(1));
4518+
unsigned Prev = Index;
45184519
ExtractedArg = getOpts().ParseOneArg(Args, Index);
4520+
if (!ExtractedArg || Index > Prev + 1) {
4521+
TC->getDriver().Diag(diag::err_drv_invalid_Xopenmp_target_with_args)
4522+
<< Arg->getAsString(Args);
4523+
continue;
4524+
}
45194525
Arg = ExtractedArg.get();
45204526
}
45214527

clang/lib/Driver/ToolChain.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,8 +1596,10 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
15961596
Prev = Index;
15971597
std::unique_ptr<Arg> XOpenMPTargetArg(Opts.ParseOneArg(Args, Index));
15981598
if (!XOpenMPTargetArg || Index > Prev + 1) {
1599-
getDriver().Diag(diag::err_drv_invalid_Xopenmp_target_with_args)
1600-
<< A->getAsString(Args);
1599+
if (!A->isClaimed()) {
1600+
getDriver().Diag(diag::err_drv_invalid_Xopenmp_target_with_args)
1601+
<< A->getAsString(Args);
1602+
}
16011603
continue;
16021604
}
16031605
if (XOpenMPTargetNoTriple && XOpenMPTargetArg &&

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ bool arm::isARMAProfile(const llvm::Triple &Triple) {
5252
return llvm::ARM::parseArchProfile(Arch) == llvm::ARM::ProfileKind::A;
5353
}
5454

55+
/// Is the triple {arm,armeb,thumb,thumbeb}-none-none-{eabi,eabihf} ?
56+
bool arm::isARMEABIBareMetal(const llvm::Triple &Triple) {
57+
auto arch = Triple.getArch();
58+
if (arch != llvm::Triple::arm && arch != llvm::Triple::thumb &&
59+
arch != llvm::Triple::armeb && arch != llvm::Triple::thumbeb)
60+
return false;
61+
62+
if (Triple.getVendor() != llvm::Triple::UnknownVendor)
63+
return false;
64+
65+
if (Triple.getOS() != llvm::Triple::UnknownOS)
66+
return false;
67+
68+
if (Triple.getEnvironment() != llvm::Triple::EABI &&
69+
Triple.getEnvironment() != llvm::Triple::EABIHF)
70+
return false;
71+
72+
return true;
73+
}
74+
5575
// Get Arch/CPU from args.
5676
void arm::getARMArchCPUFromArgs(const ArgList &Args, llvm::StringRef &Arch,
5777
llvm::StringRef &CPU, bool FromAs) {

clang/lib/Driver/ToolChains/Arch/ARM.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ int getARMSubArchVersionNumber(const llvm::Triple &Triple);
7575
bool isARMMProfile(const llvm::Triple &Triple);
7676
bool isARMAProfile(const llvm::Triple &Triple);
7777
bool isARMBigEndian(const llvm::Triple &Triple, const llvm::opt::ArgList &Args);
78+
bool isARMEABIBareMetal(const llvm::Triple &Triple);
7879

7980
} // end namespace arm
8081
} // end namespace tools

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -128,27 +128,6 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
128128
}
129129
}
130130

131-
/// Is the triple {arm,armeb,thumb,thumbeb}-none-none-{eabi,eabihf} ?
132-
static bool isARMBareMetal(const llvm::Triple &Triple) {
133-
if (Triple.getArch() != llvm::Triple::arm &&
134-
Triple.getArch() != llvm::Triple::thumb &&
135-
Triple.getArch() != llvm::Triple::armeb &&
136-
Triple.getArch() != llvm::Triple::thumbeb)
137-
return false;
138-
139-
if (Triple.getVendor() != llvm::Triple::UnknownVendor)
140-
return false;
141-
142-
if (Triple.getOS() != llvm::Triple::UnknownOS)
143-
return false;
144-
145-
if (Triple.getEnvironment() != llvm::Triple::EABI &&
146-
Triple.getEnvironment() != llvm::Triple::EABIHF)
147-
return false;
148-
149-
return true;
150-
}
151-
152131
/// Is the triple {aarch64.aarch64_be}-none-elf?
153132
static bool isAArch64BareMetal(const llvm::Triple &Triple) {
154133
if (Triple.getArch() != llvm::Triple::aarch64 &&
@@ -267,7 +246,7 @@ void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple,
267246
}
268247

269248
bool BareMetal::handlesTarget(const llvm::Triple &Triple) {
270-
return isARMBareMetal(Triple) || isAArch64BareMetal(Triple) ||
249+
return arm::isARMEABIBareMetal(Triple) || isAArch64BareMetal(Triple) ||
271250
isRISCVBareMetal(Triple) || isPPCBareMetal(Triple);
272251
}
273252

@@ -561,7 +540,7 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
561540
// The R_ARM_TARGET2 relocation must be treated as R_ARM_REL32 on arm*-*-elf
562541
// and arm*-*-eabi (the default is R_ARM_GOT_PREL, used on arm*-*-linux and
563542
// arm*-*-*bsd).
564-
if (isARMBareMetal(TC.getTriple()))
543+
if (arm::isARMEABIBareMetal(TC.getTriple()))
565544
CmdArgs.push_back("--target2=rel");
566545

567546
CmdArgs.push_back("-o");

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Arch/SystemZ.h"
2020
#include "Arch/VE.h"
2121
#include "Arch/X86.h"
22+
#include "BareMetal.h"
2223
#include "HIPAMD.h"
2324
#include "Hexagon.h"
2425
#include "MSP430.h"
@@ -151,6 +152,9 @@ static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args,
151152
}
152153
}
153154

155+
if (arm::isARMEABIBareMetal(Triple))
156+
return false;
157+
154158
return true;
155159
}
156160

clang/test/Driver/frame-pointer-elim.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,58 @@
162162
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
163163
// RUN: not %clang -### --target=riscv64-linux-android -mbig-endian -O1 -S %s 2>&1 | \
164164
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
165+
166+
// On ARM backend bare metal targets, frame pointer is omitted
167+
// RUN: %clang -### --target=arm-arm-none-eabi -S %s 2>&1 | \
168+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
169+
// RUN: %clang -### --target=arm-arm-none-eabihf -S %s 2>&1 | \
170+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
171+
// RUN: %clang -### --target=arm-arm-none-eabi -S -fno-omit-frame-pointer %s 2>&1 | \
172+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
173+
// RUN: %clang -### --target=arm-arm-none-eabihf -S -fno-omit-frame-pointer %s 2>&1 | \
174+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
175+
// RUN: %clang -### --target=arm-arm-none-eabi -S -O1 %s 2>&1 | \
176+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
177+
// RUN: %clang -### --target=arm-arm-none-eabihf -S -O1 %s 2>&1 | \
178+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
179+
// RUN: %clang -### --target=arm-arm-none-eabi -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
180+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
181+
// RUN: %clang -### --target=arm-arm-none-eabihf -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
182+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
183+
// RUN: %clang -### --target=armeb-arm-none-eabi -S %s 2>&1 | \
184+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
185+
// RUN: %clang -### --target=thumb-arm-none-eabi -S %s 2>&1 | \
186+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
187+
// RUN: %clang -### --target=thumbeb-arm-none-eabi -S %s 2>&1 | \
188+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
189+
190+
// Check that for Apple bare metal targets, we're keeping frame pointers by default
191+
// RUN: %clang -### --target=thumbv6m-apple-none-macho -S %s 2>&1 | \
192+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
193+
// RUN: %clang -### --target=thumbv6m-apple-none-macho -S -fno-omit-frame-pointer %s 2>&1 | \
194+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
195+
// RUN: %clang -### --target=arm-apple-none-macho -S %s 2>&1 | \
196+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
197+
// RUN: %clang -### --target=arm-apple-none-macho -S -fno-omit-frame-pointer %s 2>&1 | \
198+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
199+
// RUN: %clang -### --target=thumbv6m-apple-none-macho -S -O1 %s 2>&1 | \
200+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
201+
// RUN: %clang -### --target=thumbv6m-apple-none-macho -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
202+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
203+
// RUN: %clang -### --target=arm-apple-none-macho -S -O1 %s 2>&1 | \
204+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
205+
// RUN: %clang -### --target=arm-apple-none-macho -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
206+
// RUN: FileCheck --check-prefix=KEEP-ALL %s
207+
208+
// AArch64 bare metal targets behave like hosted targets
209+
// RUN: %clang -### --target=aarch64-none-elf -S %s 2>&1 | \
210+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
211+
// RUN: %clang -### --target=aarch64-none-elf -S -O1 %s 2>&1 | \
212+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
213+
// RUN: %clang -### --target=aarch64-none-elf -S -fno-omit-frame-pointer %s 2>&1 | \
214+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
215+
// RUN: %clang -### --target=aarch64-none-elf -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
216+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
217+
165218
void f0() {}
166219
void f1() { f0(); }

clang/test/Driver/openmp-offload.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@
8484

8585
/// Check -Xopenmp-target triggers error when an option requiring arguments is passed to it.
8686
// RUN: not %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
87-
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
87+
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR_0 %s
8888

89-
// CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported
89+
// CHK-FOPENMP-TARGET-NESTED-ERROR_0: error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported
90+
91+
/// Check -Xopenmp-target= triggers error when an option requiring arguments is passed to it.
92+
// RUN: not %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
93+
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR_1 %s
94+
95+
// CHK-FOPENMP-TARGET-NESTED-ERROR_1: error: invalid -Xopenmp-target argument: '-Xopenmp-target=powerpc64le-ibm-linux-gnu -Xopenmp-target', options requiring arguments are unsupported
9096

9197
/// ###########################################################################
9298

libcxx/include/__memory/allocator_traits.h

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4444

4545
// __pointer
4646
template <class _Tp>
47-
using __pointer_member = typename _Tp::pointer;
47+
using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
4848

4949
template <class _Tp, class _Alloc>
50-
using __pointer = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;
50+
using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;
5151

5252
// __const_pointer
5353
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
@@ -58,7 +58,7 @@ struct __const_pointer {
5858
template <class _Tp, class _Ptr, class _Alloc>
5959
struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
6060
#ifdef _LIBCPP_CXX03_LANG
61-
using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
61+
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
6262
#else
6363
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
6464
#endif
@@ -96,10 +96,10 @@ struct __const_void_pointer<_Ptr, _Alloc, false> {
9696

9797
// __size_type
9898
template <class _Tp>
99-
using __size_type_member = typename _Tp::size_type;
99+
using __size_type_member _LIBCPP_NODEBUG = typename _Tp::size_type;
100100

101101
template <class _Alloc, class _DiffType>
102-
using __size_type = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
102+
using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
103103

104104
// __alloc_traits_difference_type
105105
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);
@@ -114,33 +114,37 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {
114114

115115
// __propagate_on_container_copy_assignment
116116
template <class _Tp>
117-
using __propagate_on_container_copy_assignment_member = typename _Tp::propagate_on_container_copy_assignment;
117+
using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG =
118+
typename _Tp::propagate_on_container_copy_assignment;
118119

119120
template <class _Alloc>
120-
using __propagate_on_container_copy_assignment =
121+
using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG =
121122
__detected_or_t<false_type, __propagate_on_container_copy_assignment_member, _Alloc>;
122123

123124
// __propagate_on_container_move_assignment
124125
template <class _Tp>
125-
using __propagate_on_container_move_assignment_member = typename _Tp::propagate_on_container_move_assignment;
126+
using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG =
127+
typename _Tp::propagate_on_container_move_assignment;
126128

127129
template <class _Alloc>
128-
using __propagate_on_container_move_assignment =
130+
using __propagate_on_container_move_assignment _LIBCPP_NODEBUG =
129131
__detected_or_t<false_type, __propagate_on_container_move_assignment_member, _Alloc>;
130132

131133
// __propagate_on_container_swap
132134
template <class _Tp>
133-
using __propagate_on_container_swap_member = typename _Tp::propagate_on_container_swap;
135+
using __propagate_on_container_swap_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_swap;
134136

135137
template <class _Alloc>
136-
using __propagate_on_container_swap = __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
138+
using __propagate_on_container_swap _LIBCPP_NODEBUG =
139+
__detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
137140

138141
// __is_always_equal
139142
template <class _Tp>
140-
using __is_always_equal_member = typename _Tp::is_always_equal;
143+
using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal;
141144

142145
template <class _Alloc>
143-
using __is_always_equal = __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;
146+
using __is_always_equal _LIBCPP_NODEBUG =
147+
__detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;
144148

145149
// __allocator_traits_rebind
146150
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -165,7 +169,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {
165169
_LIBCPP_SUPPRESS_DEPRECATED_POP
166170

167171
template <class _Alloc, class _Tp>
168-
using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
172+
using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
169173

170174
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
171175

@@ -355,12 +359,12 @@ template <class _Traits, class _Tp>
355359
using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
356360
#else
357361
template <class _Traits, class _Tp>
358-
using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;
362+
using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>::other;
359363
#endif
360364

361365
template <class _Alloc>
362366
struct __check_valid_allocator : true_type {
363-
using _Traits = std::allocator_traits<_Alloc>;
367+
using _Traits _LIBCPP_NODEBUG = std::allocator_traits<_Alloc>;
364368
static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value,
365369
"[allocator.requirements] states that rebinding an allocator to the same type should result in the "
366370
"original allocator");

libcxx/include/__type_traits/detected_or.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020

2121
template <class _Default, class _Void, template <class...> class _Op, class... _Args>
2222
struct __detector {
23-
using type = _Default;
23+
using type _LIBCPP_NODEBUG = _Default;
2424
};
2525

2626
template <class _Default, template <class...> class _Op, class... _Args>
2727
struct __detector<_Default, __void_t<_Op<_Args...> >, _Op, _Args...> {
28-
using type = _Op<_Args...>;
28+
using type _LIBCPP_NODEBUG = _Op<_Args...>;
2929
};
3030

3131
template <class _Default, template <class...> class _Op, class... _Args>
32-
using __detected_or_t = typename __detector<_Default, void, _Op, _Args...>::type;
32+
using __detected_or_t _LIBCPP_NODEBUG = typename __detector<_Default, void, _Op, _Args...>::type;
3333

3434
_LIBCPP_END_NAMESPACE_STD
3535

0 commit comments

Comments
 (0)