Re: r274110 - [AVX512] Zero extend cmp intrinsic return value.
This change codgens to something really awful now. Can you take a look? .section __TEXT,__text,regular,pure_instructions .section __TEXT,__literal8,8byte_literals .p2align 3 LCPI0_0: .quad -1 .section __TEXT,__const .p2align 6 LCPI0_1: .quad 0 .quad 1 .quad 2 .quad 3 .quad 8 .quad 8 .quad 8 .quad 8 .section __TEXT,__text,regular,pure_instructions .globl _test_mm_cmpeq_epu32_mask .p2align 4, 0x90 _test_mm_cmpeq_epu32_mask: vpcmpeqd %xmm1, %xmm0, %k1 vpbroadcastq LCPI0_0(%rip), %zmm0 {%k1} {z} vpxord %zmm1, %zmm1, %zmm1 vmovdqa64 LCPI0_1(%rip), %zmm2 vpermt2q %zmm1, %zmm2, %zmm0 vpsllq $63, %zmm0, %zmm0 vptestmq %zmm0, %zmm0, %k0 kmovw %k0, %eax retq ~Craig On Wed, Jun 29, 2016 at 1:14 AM, Igor Breger via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ibreger > Date: Wed Jun 29 03:14:17 2016 > New Revision: 274110 > > URL: http://llvm.org/viewvc/llvm-project?rev=274110&view=rev > Log: > [AVX512] Zero extend cmp intrinsic return value. > > Differential Revision: http://reviews.llvm.org/D21746 > > Modified: > cfe/trunk/lib/CodeGen/CGBuiltin.cpp > cfe/trunk/test/CodeGen/avx512vl-builtins.c > > Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=274110&r1=274109&r2=274110&view=diff > > == > --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jun 29 03:14:17 2016 > @@ -6460,8 +6460,8 @@ static Value *EmitX86MaskedCompare(CodeG >Indices[i] = i; > for (unsigned i = NumElts; i != 8; ++i) >Indices[i] = NumElts; > -Cmp = CGF.Builder.CreateShuffleVector(Cmp, > UndefValue::get(Cmp->getType()), > - Indices); > +Cmp = CGF.Builder.CreateShuffleVector( > +Cmp, llvm::Constant::getNullValue(Cmp->getType()), Indices); >} >return CGF.Builder.CreateBitCast(Cmp, > IntegerType::get(CGF.getLLVMContext(), > > Modified: cfe/trunk/test/CodeGen/avx512vl-builtins.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vl-builtins.c?rev=274110&r1=274109&r2=274110&view=diff > > == > --- cfe/trunk/test/CodeGen/avx512vl-builtins.c (original) > +++ cfe/trunk/test/CodeGen/avx512vl-builtins.c Wed Jun 29 03:14:17 2016 > @@ -8,6 +8,7 @@ > __mmask8 test_mm_cmpeq_epu32_mask(__m128i __a, __m128i __b) { >// CHECK-LABEL: @test_mm_cmpeq_epu32_mask >// CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}} > + // CHECK: shufflevector <4 x i1> %{{.*}}, <4 x i1> zeroinitializer, <8 > x i32> >return (__mmask8)_mm_cmpeq_epu32_mask(__a, __b); > } > > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r274425 - [X86] Replace 128-bit and 256 masked vpermilps/vpermilpd builtins with native IR.
Author: ctopper Date: Sat Jul 2 00:36:43 2016 New Revision: 274425 URL: http://llvm.org/viewvc/llvm-project?rev=274425&view=rev Log: [X86] Replace 128-bit and 256 masked vpermilps/vpermilpd builtins with native IR. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/Headers/avx512vlintrin.h cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/avx512vl-builtins.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=274425&r1=274424&r2=274425&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Jul 2 00:36:43 2016 @@ -1800,10 +1800,6 @@ TARGET_BUILTIN(__builtin_ia32_vpermt2var TARGET_BUILTIN(__builtin_ia32_vpermt2varpd512_maskz, "V8dV8LLiV8dV8dUc","","avx512f") TARGET_BUILTIN(__builtin_ia32_vpermt2varps512_maskz, "V16fV16iV16fV16fUs","","avx512f") TARGET_BUILTIN(__builtin_ia32_vpermt2varq512_maskz, "V8LLiV8LLiV8LLiV8LLiUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_vpermilpd_mask, "V2dV2dIiV2dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_vpermilpd256_mask, "V4dV4dIiV4dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_vpermilps_mask, "V4fV4fIiV4fUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_vpermilps256_mask, "V8fV8fIiV8fUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_vpermilvarpd_mask, "V2dV2dV2LLiV2dUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_vpermilvarpd256_mask, "V4dV4dV4LLiV4dUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_vpermilvarps_mask, "V4fV4fV4iV4fUc","","avx512vl") Modified: cfe/trunk/lib/Headers/avx512vlintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=274425&r1=274424&r2=274425&view=diff == --- cfe/trunk/lib/Headers/avx512vlintrin.h (original) +++ cfe/trunk/lib/Headers/avx512vlintrin.h Sat Jul 2 00:36:43 2016 @@ -6700,43 +6700,44 @@ _mm256_maskz_rcp14_ps (__mmask8 __U, __m } #define _mm_mask_permute_pd(W, U, X, C) __extension__ ({ \ - (__m128d)__builtin_ia32_vpermilpd_mask((__v2df)(__m128d)(X), (int)(C), \ - (__v2df)(__m128d)(W), \ - (__mmask8)(U)); }) + (__m128d)__builtin_ia32_selectpd_128((__mmask8)(U), \ + (__v2df)_mm_permute_pd((X), (C)), \ + (__v2df)(__m128d)(W)); }) #define _mm_maskz_permute_pd(U, X, C) __extension__ ({ \ - (__m128d)__builtin_ia32_vpermilpd_mask((__v2df)(__m128d)(X), (int)(C), \ - (__v2df)_mm_setzero_pd(), \ - (__mmask8)(U)); }) + (__m128d)__builtin_ia32_selectpd_128((__mmask8)(U), \ + (__v2df)_mm_permute_pd((X), (C)), \ + (__v2df)_mm_setzero_pd()); }) #define _mm256_mask_permute_pd(W, U, X, C) __extension__ ({ \ - (__m256d)__builtin_ia32_vpermilpd256_mask((__v4df)(__m256d)(X), (int)(C), \ -(__v4df)(__m256d)(W), \ -(__mmask8)(U)); }) + (__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_permute_pd((X), (C)), \ + (__v4df)(__m256d)(W)); }) #define _mm256_maskz_permute_pd(U, X, C) __extension__ ({ \ - (__m256d)__builtin_ia32_vpermilpd256_mask((__v4df)(__m256d)(X), (int)(C), \ -(__v4df)_mm256_setzero_pd(), \ -(__mmask8)(U)); }) + (__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_permute_pd((X), (C)), \ + (__v4df)_mm256_setzero_pd()); }) #define _mm_mask_permute_ps(W, U, X, C) __extension__ ({ \ - (__m128)__builtin_ia32_vpermilps_mask((__v4sf)(__m128)(X), (int)(C), \ -(__v4sf)(__m128)(W), (__mmask8)(U)); }) + (__m128)__builtin_ia32_selectps_128((__mmask8)(U), \ + (__v4sf)_mm_permute_ps((X), (C)), \ + (__v4sf)(__m128)(W)); }) #define _mm_maskz_permute_ps(U, X, C) __extension__ ({ \ - (__m128)__builtin_ia32_vpermilps_mask((__v4sf)(__m128)(X), (int)(C), \ -(__v4sf)_mm_setzero_ps(), \ -(__mmask8)(U)); }) + (__m128)__builtin_ia32_selectps_128((__mmask8)(U), \ + (__v4sf)_mm_permute_ps((X), (C)), \ + (__v4sf)_mm_setzero_ps()); }) #define _mm256_mask_permute_ps(W, U, X, C) __extension__
[libcxx] r274424 - Add unordered_map::insert benchmark test and rename file
Author: ericwf Date: Sat Jul 2 00:30:54 2016 New Revision: 274424 URL: http://llvm.org/viewvc/llvm-project?rev=274424&view=rev Log: Add unordered_map::insert benchmark test and rename file Added: libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp Removed: libcxx/trunk/benchmarks/set_find.pass.cpp Removed: libcxx/trunk/benchmarks/set_find.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/set_find.pass.cpp?rev=274423&view=auto == --- libcxx/trunk/benchmarks/set_find.pass.cpp (original) +++ libcxx/trunk/benchmarks/set_find.pass.cpp (removed) @@ -1,29 +0,0 @@ -#include -#include -#include - -#include "benchmark/benchmark_api.h" - -template -std::vector getInputs(size_t N) { -std::vector inputs; -for (size_t i=0; i < N; ++i) { -inputs.push_back(i); -} -return inputs; -} - -template -void BM_SetLookup(benchmark::State& st, Container c, Inputs const& in) { -c.insert(in.begin(), in.end()); -const auto end = in.end(); -while (st.KeepRunning()) { -for (auto it = in.begin(); it != end; ++it) { -benchmark::DoNotOptimize(c.find(*it++)); -} -} -} -BENCHMARK_CAPTURE(BM_SetLookup, uint32_lookup, -std::unordered_set{}, getInputs(1024)); - -BENCHMARK_MAIN() Added: libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp?rev=274424&view=auto == --- libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp (added) +++ libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp Sat Jul 2 00:30:54 2016 @@ -0,0 +1,44 @@ +#include +#include +#include + +#include "benchmark/benchmark_api.h" + +template +std::vector getInputs(size_t N) { +std::vector inputs; +for (size_t i=0; i < N; ++i) { +inputs.push_back(i); +} +return inputs; +} + +template +void BM_SetInsert(benchmark::State& st, Container c, Inputs const& in) { +const auto end = in.end(); +while (st.KeepRunning()) { +c.clear(); +for (auto it = in.begin(); it != end; ++it) { +benchmark::DoNotOptimize(c.insert(*it)); +} +benchmark::DoNotOptimize(c); +} +} +BENCHMARK_CAPTURE(BM_SetInsert, uint32_insert, +std::unordered_set{}, getInputs(1024)); + +template +void BM_SetFind(benchmark::State& st, Container c, Inputs const& in) { +c.insert(in.begin(), in.end()); +const auto end = in.end(); +while (st.KeepRunning()) { +for (auto it = in.begin(); it != end; ++it) { +benchmark::DoNotOptimize(c.find(*it)); +} +} +} +BENCHMARK_CAPTURE(BM_SetFind, uint32_lookup, +std::unordered_set{}, getInputs(1024)); + + +BENCHMARK_MAIN() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274423 - Improve performance of unordered_set::find by 45%. Add benchmarks.
Author: ericwf Date: Sat Jul 2 00:19:59 2016 New Revision: 274423 URL: http://llvm.org/viewvc/llvm-project?rev=274423&view=rev Log: Improve performance of unordered_set::find by 45%. Add benchmarks. This patch improves the performance of unordered_set's find by 45% when the value exists within the set. __hash_tables find method needs to check if it's reached the end of the bucket by constraining the hash of the current node and checking it against the bucket index. However constraining the hash is an expensive operations and it can be avoided if the two unconstrained hashes are equal. This patch applies that optimization. This patch also adds a top level directory called benchmarks. 'benchmarks/' is intended to store any/all benchmarks written for the standard library. Currently nothing is done with files under 'benchmarks/' but I would like to move towards introducing a formal format and test runner. Added: libcxx/trunk/benchmarks/ libcxx/trunk/benchmarks/set_find.pass.cpp Modified: libcxx/trunk/include/__hash_table Added: libcxx/trunk/benchmarks/set_find.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/set_find.pass.cpp?rev=274423&view=auto == --- libcxx/trunk/benchmarks/set_find.pass.cpp (added) +++ libcxx/trunk/benchmarks/set_find.pass.cpp Sat Jul 2 00:19:59 2016 @@ -0,0 +1,29 @@ +#include +#include +#include + +#include "benchmark/benchmark_api.h" + +template +std::vector getInputs(size_t N) { +std::vector inputs; +for (size_t i=0; i < N; ++i) { +inputs.push_back(i); +} +return inputs; +} + +template +void BM_SetLookup(benchmark::State& st, Container c, Inputs const& in) { +c.insert(in.begin(), in.end()); +const auto end = in.end(); +while (st.KeepRunning()) { +for (auto it = in.begin(); it != end; ++it) { +benchmark::DoNotOptimize(c.find(*it++)); +} +} +} +BENCHMARK_CAPTURE(BM_SetLookup, uint32_lookup, +std::unordered_set{}, getInputs(1024)); + +BENCHMARK_MAIN() Modified: libcxx/trunk/include/__hash_table URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=274423&r1=274422&r2=274423&view=diff == --- libcxx/trunk/include/__hash_table (original) +++ libcxx/trunk/include/__hash_table Sat Jul 2 00:19:59 2016 @@ -2201,7 +2201,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc> if (__nd != nullptr) { for (__nd = __nd->__next_; __nd != nullptr && - __constrain_hash(__nd->__hash_, __bc) == __chash; +(__hash == __nd->__hash_ +|| __constrain_hash(__nd->__hash_, __bc) == __chash); __nd = __nd->__next_) { if (key_eq()(__nd->__value_, __k)) @@ -2230,7 +2231,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc> if (__nd != nullptr) { for (__nd = __nd->__next_; __nd != nullptr && - __constrain_hash(__nd->__hash_, __bc) == __chash; +(__hash == __nd->__hash_ +|| __constrain_hash(__nd->__hash_, __bc) == __chash); __nd = __nd->__next_) { if (key_eq()(__nd->__value_, __k)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect
comicfans44 added a comment. neither did I commited to LLVM ... so I'll wait. http://reviews.llvm.org/D21946 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274422 - Handle std::get(...) for std::tuple<>
Author: ericwf Date: Fri Jul 1 22:46:08 2016 New Revision: 274422 URL: http://llvm.org/viewvc/llvm-project?rev=274422&view=rev Log: Handle std::get(...) for std::tuple<> Modified: libcxx/trunk/include/tuple libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp Modified: libcxx/trunk/include/tuple URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=274422&r1=274421&r2=274422&view=diff == --- libcxx/trunk/include/tuple (original) +++ libcxx/trunk/include/tuple Fri Jul 1 22:46:08 2016 @@ -1013,6 +1013,11 @@ struct __find_exactly_one_checked { static_assert(value != __ambiguous,"type occurs more than once in type list"); }; +template +struct __find_exactly_one_checked<_T1> { +static_assert(!is_same<_T1, _T1>::value, "type not in empty type list"); +}; + } // namespace __find_detail; template Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp?rev=274422&r1=274421&r2=274422&view=diff == --- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp (original) +++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp Fri Jul 1 22:46:08 2016 @@ -20,6 +20,9 @@ void test_bad_index() { (void)std::get(t1); // expected-note {{requested here}} (void)std::get(t1); // expected-note {{requested here}} // expected-error@tuple:* 2 {{type occurs more than once}} +std::tuple<> t0; +(void)std::get(t0); // expected-node {{requested here}} +// expected-error@tuple:* 1 {{type not in empty type list}} } void test_bad_return_type() { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274419 - Remove workarounds for C++17 inline variable ABI break. It has been fixed in clang.
Author: ericwf Date: Fri Jul 1 22:21:58 2016 New Revision: 274419 URL: http://llvm.org/viewvc/llvm-project?rev=274419&view=rev Log: Remove workarounds for C++17 inline variable ABI break. It has been fixed in clang. Modified: libcxx/trunk/src/chrono.cpp libcxx/trunk/src/experimental/filesystem/path.cpp Modified: libcxx/trunk/src/chrono.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274419&r1=274418&r2=274419&view=diff == --- libcxx/trunk/src/chrono.cpp (original) +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 22:21:58 2016 @@ -32,9 +32,6 @@ namespace chrono // system_clock const bool system_clock::is_steady; -// Make is_steady non-discardable in C++17 -// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) -static const bool& __is_steady_force_use1 __attribute__((used)) = system_clock::is_steady; system_clock::time_point system_clock::now() _NOEXCEPT @@ -71,10 +68,6 @@ system_clock::from_time_t(time_t t) _NOE // instead. const bool steady_clock::is_steady; -// Make is_steady non-discardable in C++17 -// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) -static const bool& __is_steady_force_use2 __attribute__((used)) = steady_clock::is_steady; - #ifdef CLOCK_MONOTONIC Modified: libcxx/trunk/src/experimental/filesystem/path.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/path.cpp?rev=274419&r1=274418&r2=274419&view=diff == --- libcxx/trunk/src/experimental/filesystem/path.cpp (original) +++ libcxx/trunk/src/experimental/filesystem/path.cpp Fri Jul 1 22:21:58 2016 @@ -13,10 +13,6 @@ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM _LIBCPP_CONSTEXPR path::value_type path::preferred_separator; -// Make preferred_separator non-discardable in C++17 -// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) -static const path::value_type& -__preferred_sep_force_use __attribute__((used)) = path::preferred_separator; namespace { namespace parser { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274418 - Rewrite std::get(...) helper using constexpr functions.
Author: ericwf Date: Fri Jul 1 22:18:30 2016 New Revision: 274418 URL: http://llvm.org/viewvc/llvm-project?rev=274418&view=rev Log: Rewrite std::get(...) helper using constexpr functions. Added: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp Removed: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp Modified: libcxx/trunk/include/tuple Modified: libcxx/trunk/include/tuple URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=274418&r1=274417&r2=274418&view=diff == --- libcxx/trunk/include/tuple (original) +++ libcxx/trunk/include/tuple Fri Jul 1 22:18:30 2016 @@ -986,39 +986,39 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT } #if _LIBCPP_STD_VER > 11 -// get by type -template -struct __find_exactly_one_t_helper; - -// -- find exactly one -template -struct __find_exactly_one_t_checker { -static constexpr size_t value = _Idx; -// Check the rest of the list to make sure there's only one -static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" ); -}; - - -template -struct __find_exactly_one_t_helper <_T1, _Idx> { -static constexpr size_t value = -1; -}; - -template -struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> { -static constexpr size_t value = -std::conditional< -std::is_same<_T1, _Head>::value, -__find_exactly_one_t_checker<_T1, _Idx, _Args...>, -__find_exactly_one_t_helper <_T1, _Idx+1, _Args...> ->::type::value; -}; + +namespace __find_detail { + +static constexpr size_t __not_found = -1; +static constexpr size_t __ambiguous = __not_found - 1; + +inline _LIBCPP_INLINE_VISIBILITY +constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) { +return !__matches ? __res : +(__res == __not_found ? __curr_i : __ambiguous); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) { + return __i == _Nx ? __not_found : + __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]); +} + +template +struct __find_exactly_one_checked { + static constexpr bool __matches[] = {is_same<_T1, _Args>::value...}; +static constexpr size_t value = __find_detail::__find_idx(0, __matches); +static_assert (value != __not_found, "type not found in type list" ); +static_assert(value != __ambiguous,"type occurs more than once in type list"); +}; + +} // namespace __find_detail; template -struct __find_exactly_one_t { -static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value; -static_assert ( value != -1, "type not found in type list" ); -}; +struct __find_exactly_one_t +: public __find_detail::__find_exactly_one_checked<_T1, _Args...> { +}; template inline _LIBCPP_INLINE_VISIBILITY Added: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp?rev=274418&view=auto == --- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp (added) +++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp Fri Jul 1 22:18:30 2016 @@ -0,0 +1,35 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include + +struct UserType {}; + +void test_bad_index() { +std::tuple t1; +(void)std::get(t1); // expected-error@tuple:* {{type not found}} +(void)std::get(t1); // expected-note {{requested here}} +(void)std::get(t1); // expected-note {{requested here}} +// expected-error@tuple:* 2 {{type occurs more than once}} +} + +void test_bad_return_type() { +typedef std::unique_ptr upint; +std::tuple t; +upint p = std::get(t); // expected-error{{deleted copy constructor}} +} + +int main() +{ +test_bad_index(); +test_bad_return_type(); +} Removed: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/
Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect
zturner added a comment. In http://reviews.llvm.org/D21946#473070, @comicfans44 wrote: > I've not commited to cfe before, so I think I havn't commit access permission. If you've committed anywhere in LLVM, you should have commit access to cfe. Feel free to give it a try, as I won't be able to commit until Wednesday of next week at the earliest anyway due to the upcoming holiday. http://reviews.llvm.org/D21946 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect
comicfans44 added a comment. I've not commited to cfe before, so I think I havn't commit access permission. http://reviews.llvm.org/D21946 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect
zturner accepted this revision. zturner added a comment. This revision is now accepted and ready to land. Looks good, do you have commit access to commit this? http://reviews.llvm.org/D21946 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r274416 - PR28394: For compatibility with c++11 and c++14, if a static constexpr data
Author: rsmith Date: Fri Jul 1 20:32:16 2016 New Revision: 274416 URL: http://llvm.org/viewvc/llvm-project?rev=274416&view=rev Log: PR28394: For compatibility with c++11 and c++14, if a static constexpr data member is redundantly redeclared outside the class definition in code built in c++17 mode, ensure we emit a non-discardable definition of the data member for c++11 and c++14 compilations to use. Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/CodeGenCXX/cxx1z-inline-variables.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=274416&r1=274415&r2=274416&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jul 1 20:32:16 2016 @@ -2528,7 +2528,21 @@ public: /// \brief Returns true if this is an inline-initialized static data member /// which is treated as a definition for MSVC compatibility. bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const; - + + enum class InlineVariableDefinitionKind { +None,///< Not an inline variable. +Weak,///< Weak definition of inline variable. +WeakUnknown, ///< Weak for now, might become strong later in this TU. +Strong ///< Strong definition. + }; + /// \brief Determine whether a definition of this inline variable should + /// be treated as a weak or strong definition. For compatibility with + /// C++14 and before, for a constexpr static data member, if there is an + /// out-of-line declaration of the member, we may promote it from weak to + /// strong. + InlineVariableDefinitionKind + getInlineVariableDefinitionKind(const VarDecl *VD) const; + private: const ASTRecordLayout & getObjCLayout(const ObjCInterfaceDecl *D, Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=274416&r1=274415&r2=274416&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jul 1 20:32:16 2016 @@ -5146,6 +5146,27 @@ bool ASTContext::isMSStaticDataMemberInl !VD->getFirstDecl()->isOutOfLine() && VD->getFirstDecl()->hasInit(); } +ASTContext::InlineVariableDefinitionKind +ASTContext::getInlineVariableDefinitionKind(const VarDecl *VD) const { + if (!VD->isInline()) +return InlineVariableDefinitionKind::None; + + // In almost all cases, it's a weak definition. + auto *First = VD->getFirstDecl(); + if (!First->isConstexpr() || First->isInlineSpecified() || + !VD->isStaticDataMember()) +return InlineVariableDefinitionKind::Weak; + + // If there's a file-context declaration in this translation unit, it's a + // non-discardable definition. + for (auto *D : VD->redecls()) +if (D->getLexicalDeclContext()->isFileContext()) + return InlineVariableDefinitionKind::Strong; + + // If we've not seen one yet, we don't know. + return InlineVariableDefinitionKind::WeakUnknown; +} + static inline std::string charUnitsToString(const CharUnits &CU) { return llvm::itostr(CU.getQuantity()); @@ -8494,9 +8515,21 @@ static GVALinkage basicGVALinkageForVari if (Context.isMSStaticDataMemberInlineDefinition(VD)) return GVA_DiscardableODR; - GVALinkage StrongLinkage = GVA_StrongExternal; - if (VD->isInline()) + // Most non-template variables have strong linkage; inline variables are + // linkonce_odr or (occasionally, for compatibility) weak_odr. + GVALinkage StrongLinkage; + switch (Context.getInlineVariableDefinitionKind(VD)) { + case ASTContext::InlineVariableDefinitionKind::None: +StrongLinkage = GVA_StrongExternal; +break; + case ASTContext::InlineVariableDefinitionKind::Weak: + case ASTContext::InlineVariableDefinitionKind::WeakUnknown: StrongLinkage = GVA_DiscardableODR; +break; + case ASTContext::InlineVariableDefinitionKind::Strong: +StrongLinkage = GVA_StrongODR; +break; + } switch (VD->getTemplateSpecializationKind()) { case TSK_Undeclared: Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=274416&r1=274415&r2=274416&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Jul 1 20:32:16 2016 @@ -1447,6 +1447,12 @@ bool CodeGenModule::MayBeEmittedEagerly( // Implicit template instantiations may change linkage if they are later // explicitly instantiated, so they should not be emitted eagerly. return false; + if (const auto *VD = dyn_cast(Global)) +if (Context.getInlineVa
Re: [PATCH] D21030: [Sema] Fix rejects-valid where parameter pack was not expanded in type alias
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM http://reviews.llvm.org/D21030 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15075: No error for conflict between inputs\outputs and clobber list
ahatanak added inline comments. Comment at: include/clang/Basic/TargetInfo.h:585 @@ +584,3 @@ + StringRef + TargetInfo::getNormalizedGCCRegisterName(StringRef Name, + bool ReturnCannonical = false) const; This gives build errors. TargetInfo:: isn't needed here. Comment at: lib/Headers/Intrin.h:843 @@ -842,4 +842,3 @@ __movsb(unsigned char *__dst, unsigned char const *__src, size_t __n) { - __asm__("rep movsb" : : "D"(__dst), "S"(__src), "c"(__n) -: "%edi", "%esi", "%ecx"); + __asm__("rep movsb" : : "D"(__dst), "S"(__src), "c"(__n) :); } If this is an unrelated bug that you discovered while working on this patch, you should probably send a separate patch to the list and contact the author. Comment at: lib/Sema/SemaStmtAsm.cpp:179 @@ +178,3 @@ +case 'a': + return "ax"; +case 'b': I don't think things specific to x86 should appear in SemaStmtAsm.cpp. Also, is it possible to use X86TargetInfo::convertConstraint? http://reviews.llvm.org/D15075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274414 - Cleanup SFINAE in tuple, and add tests for reference assignment
Author: ericwf Date: Fri Jul 1 20:25:46 2016 New Revision: 274414 URL: http://llvm.org/viewvc/llvm-project?rev=274414&view=rev Log: Cleanup SFINAE in tuple, and add tests for reference assignment Modified: libcxx/trunk/include/__tuple libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp Modified: libcxx/trunk/include/__tuple URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=274414&r1=274413&r2=274414&view=diff == --- libcxx/trunk/include/__tuple (original) +++ libcxx/trunk/include/__tuple Fri Jul 1 20:25:46 2016 @@ -335,11 +335,11 @@ struct __make_tuple_types_flat<_Tuple<_T template struct __make_tuple_types_flat, __tuple_indices<_Idx...>> { - using _Array = array<_Vt, _Np>; - + template + using __value_type = _Vt; template > using __apply_quals = __tuple_types< - typename _ApplyFn::template __apply::type>... + typename _ApplyFn::template __apply<__value_type<_Idx>>... >; }; @@ -371,32 +371,19 @@ template using __all = is_same<__all_dummy<_Pred...>, __all_dummy<(_Pred, true)...>>; struct __tuple_sfinae_base { - template - static auto __test_constructible(__tuple_types<_FromArgs...>, __tuple_types<_ToArgs...>) --> __all::value - , bool>::type{true}...>; - static auto __test_constructible(...) -> false_type; - template - using __constructible = decltype(__test_constructible(_Types1{}, _Types2{})); - - template - static auto __test_convertible(__tuple_types<_FromArgs...>, __tuple_types<_ToArgs...>) --> __all::value - , bool>::type{true}...>; - static auto __test_convertible(...) -> false_type; - template - using __convertible = decltype(__test_convertible(_Types1{}, _Types2{})); - - template - static auto __test_assignable(__tuple_types<_FromArgs...>, __tuple_types<_ToArgs...>) --> __all::value - , bool>::type{true}...>; - static auto __test_assignable(...) -> false_type; - template - using __assignable = decltype(__test_assignable(_Types1{}, _Types2{})); + template class _Trait, +class ..._LArgs, class ..._RArgs> + static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>) +-> __all::value, bool>::type{true}...>; + template class> + static auto __do_test(...) -> false_type; + + template + using __constructible = decltype(__do_test(_ToArgs{}, _FromArgs{})); + template + using __convertible = decltype(__do_test(_FromArgs{}, _ToArgs{})); + template + using __assignable = decltype(__do_test(_ToArgs{}, _FromArgs{})); }; // __tuple_convertible @@ -440,7 +427,7 @@ template struct __tuple_assignable<_Tp, _Up, true, true> : public __tuple_sfinae_base::__assignable< typename __make_tuple_types<_Tp>::type -, typename __make_tuple_types<_Up>::type +, typename __make_tuple_types<_Up&>::type > {}; Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp?rev=274414&r1=274413&r2=274414&view=diff == --- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp Fri Jul 1 20:25:46 2016 @@ -74,4 +74,16 @@ int main() assert(std::get<1>(t1) == int('a')); assert(std::get<2>(t1).id_ == 2); } +{ +// Test that tuple evaluates correctly applies an lvalue reference +// before evaluating is_assignable (ie 'is_assignable') +// instead of evaluating 'is_assignable' which is false. +int x = 42; +int y = 43; +std::tuple t(std::move(x)); +std::tuple t2(y); +t = t2; +assert(std::get<0>(t) == 43); +assert(&std::get<0>(t) == &x); +} } Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp?rev=274414&r1=274413&r2=274414&view=diff == --- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp Fri Jul 1 20:25:46 2016 @@ -37,6 +37,13 @@ struct D explicit D(int i) : B(i) {} }; +struct E { + E() = default; + E& operator=(int val) { + return *this; + } +}; + int main() { { @@ -88,4 +95,16 @@ int main() assert(std::get<1>(t1) == int('a')); assert(std::get<2>(t1
[libcxx] r274413 - Make tuple_constructible and family lazy again.
Author: ericwf Date: Fri Jul 1 19:58:17 2016 New Revision: 274413 URL: http://llvm.org/viewvc/llvm-project?rev=274413&view=rev Log: Make tuple_constructible and family lazy again. Added: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/test_lazy_sfinae.pass.cpp Modified: libcxx/trunk/include/__tuple Modified: libcxx/trunk/include/__tuple URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=274413&r1=274412&r2=274413&view=diff == --- libcxx/trunk/include/__tuple (original) +++ libcxx/trunk/include/__tuple Fri Jul 1 19:58:17 2016 @@ -373,21 +373,27 @@ using __all = is_same<__all_dummy<_Pred. struct __tuple_sfinae_base { template static auto __test_constructible(__tuple_types<_FromArgs...>, __tuple_types<_ToArgs...>) --> __all::value...>; +-> __all::value + , bool>::type{true}...>; static auto __test_constructible(...) -> false_type; template using __constructible = decltype(__test_constructible(_Types1{}, _Types2{})); template static auto __test_convertible(__tuple_types<_FromArgs...>, __tuple_types<_ToArgs...>) --> __all::value...>; +-> __all::value + , bool>::type{true}...>; static auto __test_convertible(...) -> false_type; template using __convertible = decltype(__test_convertible(_Types1{}, _Types2{})); template static auto __test_assignable(__tuple_types<_FromArgs...>, __tuple_types<_ToArgs...>) --> __all::value...>; +-> __all::value + , bool>::type{true}...>; static auto __test_assignable(...) -> false_type; template using __assignable = decltype(__test_assignable(_Types1{}, _Types2{})); Added: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/test_lazy_sfinae.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/test_lazy_sfinae.pass.cpp?rev=274413&view=auto == --- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/test_lazy_sfinae.pass.cpp (added) +++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/test_lazy_sfinae.pass.cpp Fri Jul 1 19:58:17 2016 @@ -0,0 +1,102 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// template class tuple; + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +template +struct ConstructibleFromT { + ConstructibleFromT() = default; + ConstructibleFromT(ConstructFrom v) : value(v) {} + ConstructFrom value; +}; + +template +struct CtorAssertsT { + bool defaulted; + CtorAssertsT() : defaulted(true) {} + template + constexpr CtorAssertsT(T) : defaulted(false) { + static_assert(!std::is_same::value, ""); + } +}; + +template +struct AllowAssertT { + AllowAssertT() = default; + AllowAssertT(AllowT) {} + template + constexpr AllowAssertT(U) { + static_assert(!std::is_same::value, ""); + } +}; + +// Construct a tuple from pair where T1 and T2 +// are not constructible from ints but T1 is constructible from std::pair. +// This considers the following constructors: +// (1) tuple(TupleLike) -> checks is_constructible +// (2) tuple(UTypes...) -> checks is_constructible> +//and is_default_constructible +// The point of this test is to ensure that the consideration of (1) +// short circuits before evaluating is_constructible, which +// will cause a static assertion. +void test_tuple_like_lazy_sfinae() { +#if defined(_LIBCPP_VERSION) +// This test requires libc++'s reduced arity initialization. +using T1 = ConstructibleFromT>; +using T2 = CtorAssertsT; +std::pair p(42, 100); +std::tuple t(p); +assert(std::get<0>(t).value == p); +assert(std::get<1>(t).defaulted); +#endif +} + + +struct NonConstCopyable { + NonConstCopyable() = default; + explicit NonConstCopyable(int v) : value(v) {} + NonConstCopyable(NonConstCopyable&) = default; + NonConstCopyable(NonConstCopyable const&) = delete; + int value; +}; + +template +struct BlowsUpOnConstCopy { + BlowsUpOnConstCopy() = default; + constexpr BlowsUpOnConstCopy(BlowsUpOnConstCopy const&) { + static_assert(!std::is_same::value, ""); + } + BlowsUpOnConstCopy(BlowsUpOnConstCopy&) = default; +}; + +// Test the following constructors: +// (1) tuple(Types const&...) +// (2) tuple(UTypes&&...) +// Test that (1) short circuits before evaluating the copy constructor of the +// second argument. Constructor (2) should be selected. +void test_const_Types_lazy_sfinae() +{ +NonConstCopyable v(42); +BlowsUpOnConstCopy b; +
Re: [PATCH] D21857: [Driver][OpenMP] Add support to create jobs for unbundling actions.
sfantao updated this revision to Diff 62591. sfantao added a comment. - Fix format. http://reviews.llvm.org/D21857 Files: include/clang/Driver/Action.h include/clang/Driver/Tool.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/Tool.cpp lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -176,7 +176,7 @@ // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] // // Compile for the x86 device. @@ -187,7 +187,7 @@ // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] // // Generate host object from the BC file and link using the linker script. @@ -202,20 +202,20 @@ // Check the linker script contains what we expect. // // CHK-LKS: TARGET(binary) -// CHK-LKS: INPUT({{.+}}.out-device-openmp-powerpc64le-ibm-linux-gnu) -// CHK-LKS: INPUT({{.+}}.out-device-openmp-x86_64-pc-linux-gnu) +// CHK-LKS: INPUT({{.+}}.out-openmp-powerpc64le-ibm-linux-gnu) +// CHK-LKS: INPUT({{.+}}.out-openmp-x86_64-pc-linux-gnu) // CHK-LKS: SECTIONS // CHK-LKS: { // CHK-LKS: .omp_offloading : // CHK-LKS: ALIGN(0x10) // CHK-LKS: { // CHK-LKS: . = ALIGN(0x10); // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.powerpc64le-ibm-linux-gnu = .); -// CHK-LKS: {{.+}}.out-device-openmp-powerpc64le-ibm-linux-gnu +// CHK-LKS: {{.+}}.out-openmp-powerpc64le-ibm-linux-gnu // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.powerpc64le-ibm-linux-gnu = .); // CHK-LKS: . = ALIGN(0x10); // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64-pc-linux-gnu = .); -// CHK-LKS: {{.+}}.out-device-openmp-x86_64-pc-linux-gnu +// CHK-LKS: {{.+}}.out-openmp-x86_64-pc-linux-gnu // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64-pc-linux-gnu = .); // CHK-LKS: } // CHK-LKS: .omp_offloading.entries : @@ -343,3 +343,92 @@ // CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]" // CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]" // CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" + +/// ### + +/// Check separate compilation with offloading - unbundling jobs construct +// RUN: touch %t.i +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBJOBS %s +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBJOBS-ST %s +// RUN: touch %t.o +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.o 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBJOBS2 %s +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.o -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBJOBS2-ST %s + +// Unbundle and create host
Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.
sfantao updated this revision to Diff 62590. sfantao added a comment. - Start static function name with caps. http://reviews.llvm.org/D21856 Files: include/clang/Driver/Action.h include/clang/Driver/ToolChain.h lib/Driver/Action.cpp lib/Driver/ToolChain.cpp lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -309,3 +309,37 @@ // CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp) // CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp) +/// ### + +/// Check separate compilation with offloading - bundling jobs construct +// RUN: %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUJOBS %s +// RUN: %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUJOBS-ST %s + +// Create host BC. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// Create target 1 object. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" + +// Create target 2 object. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" + +// Create host object and bundle. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "-x" "ir" "[[HOSTBC]]" +// CHK-BUJOBS: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]" +// CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" Index: lib/Driver/Tools.h === --- lib/Driver/Tools.h +++ lib/Driver/Tools.h @@ -135,6 +135,19 @@ const char *LinkingOutput) const override; }; +/// Offload bundler tool. +class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool { +public: + OffloadBundler(const ToolChain &TC) + : Tool("offload bundler", "clang-offload
Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.
sfantao updated this revision to Diff 62589. sfantao added a comment. - Rebase http://reviews.llvm.org/D21853 Files: include/clang/Driver/Action.h include/clang/Driver/Types.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/Types.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -255,4 +255,57 @@ // CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object // CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp) // CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp) -// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) \ No newline at end of file +// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) + +/// ### + +/// Check separate compilation with offloading - unbundling actions +// RUN: touch %t.i +// RUN: %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBACTIONS %s + +// CHK-UBACTIONS: 0: input, "somelib", object, (host-openmp) +// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp) +// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, cpp-output, (host-openmp) +// CHK-UBACTIONS: 3: compiler, {2}, ir, (host-openmp) +// CHK-UBACTIONS: 4: backend, {3}, assembler, (host-openmp) +// CHK-UBACTIONS: 5: assembler, {4}, object, (host-openmp) +// CHK-UBACTIONS: 6: linker, {0, 5}, image, (host-openmp) +// CHK-UBACTIONS: 7: input, "somelib", object, (device-openmp) +// CHK-UBACTIONS: 8: compiler, {2}, ir, (device-openmp) +// CHK-UBACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, ir +// CHK-UBACTIONS: 10: backend, {9}, assembler, (device-openmp) +// CHK-UBACTIONS: 11: assembler, {10}, object, (device-openmp) +// CHK-UBACTIONS: 12: linker, {7, 11}, image, (device-openmp) +// CHK-UBACTIONS: 13: input, "somelib", object, (device-openmp) +// CHK-UBACTIONS: 14: compiler, {2}, ir, (device-openmp) +// CHK-UBACTIONS: 15: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {14}, ir +// CHK-UBACTIONS: 16: backend, {15}, assembler, (device-openmp) +// CHK-UBACTIONS: 17: assembler, {16}, object, (device-openmp) +// CHK-UBACTIONS: 18: linker, {13, 17}, image, (device-openmp) +// CHK-UBACTIONS: 19: offload, "host-openmp (powerpc64le--linux)" {6}, "device-openmp (powerpc64le-ibm-linux-gnu)" {12}, "device-openmp (x86_64-pc-linux-gnu)" {18}, image + +/// ### + +/// Check separate compilation with offloading - unbundling/bundling actions +// RUN: touch %t.i +// RUN: %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBUACTIONS %s + +// CHK-UBUACTIONS: 0: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp) +// CHK-UBUACTIONS: 1: clang-offload-unbundler, {0}, cpp-output, (host-openmp) +// CHK-UBUACTIONS: 2: compiler, {1}, ir, (host-openmp) +// CHK-UBUACTIONS: 3: compiler, {1}, ir, (device-openmp) +// CHK-UBUACTIONS: 4: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {3}, ir +// CHK-UBUACTIONS: 5: backend, {4}, assembler, (device-openmp) +// CHK-UBUACTIONS: 6: assembler, {5}, object, (device-openmp) +// CHK-UBUACTIONS: 7: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {6}, object +// CHK-UBUACTIONS: 8: compiler, {1}, ir, (device-openmp) +// CHK-UBUACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir +// CHK-UBUACTIONS: 10: backend, {9}, assembler, (device-openmp) +// CHK-UBUACTIONS: 11: assembler, {10}, object, (device-openmp) +// CHK-UBUACTIONS: 12: offload, "device-openmp (x86_64-pc-linux-gnu)" {11}, object +// CHK-UBUACTIONS: 13: backend, {2}, assembler, (host-openmp) +// CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp) +// CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp) + Index: lib/Driver/Types.cpp === --- lib/Driver/Types.cpp +++ lib/Driver/Types.cpp @@ -153,6 +153,10 @@ } } +bool types::isSrcFile(ID Id) { + return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID; +} + types::ID types::lookupTypeForExtension(const char *Ext) { return llvm::StringSwitch(Ext) .Case("c", TY_C) Index: lib/Driver/ToolChain.cpp === --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -264,6 +264,7 @@
Re: [PATCH] D21852: [Driver][OpenMP] Update actions builder to create bundling action when necessary.
sfantao updated this revision to Diff 62587. sfantao added a comment. - Rebase http://reviews.llvm.org/D21852 Files: include/clang/Driver/Action.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -228,3 +228,31 @@ // CHK-LKS: } // CHK-LKS: } // CHK-LKS: INSERT BEFORE .data + + +/// ### + +/// Check separate compilation with offloading - bundling actions +// RUN: %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUACTIONS %s + +// CHK-BUACTIONS: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp) +// CHK-BUACTIONS: 1: preprocessor, {0}, cpp-output, (host-openmp) +// CHK-BUACTIONS: 2: compiler, {1}, ir, (host-openmp) +// CHK-BUACTIONS: 3: input, "[[INPUT]]", c, (device-openmp) +// CHK-BUACTIONS: 4: preprocessor, {3}, cpp-output, (device-openmp) +// CHK-BUACTIONS: 5: compiler, {4}, ir, (device-openmp) +// CHK-BUACTIONS: 6: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {5}, ir +// CHK-BUACTIONS: 7: backend, {6}, assembler, (device-openmp) +// CHK-BUACTIONS: 8: assembler, {7}, object, (device-openmp) +// CHK-BUACTIONS: 9: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, object +// CHK-BUACTIONS: 10: input, "[[INPUT]]", c, (device-openmp) +// CHK-BUACTIONS: 11: preprocessor, {10}, cpp-output, (device-openmp) +// CHK-BUACTIONS: 12: compiler, {11}, ir, (device-openmp) +// CHK-BUACTIONS: 13: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {12}, ir +// CHK-BUACTIONS: 14: backend, {13}, assembler, (device-openmp) +// CHK-BUACTIONS: 15: assembler, {14}, object, (device-openmp) +// CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object +// CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp) +// CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp) +// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) \ No newline at end of file Index: lib/Driver/ToolChain.cpp === --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -262,6 +262,10 @@ case Action::VerifyPCHJobClass: case Action::BackendJobClass: return getClang(); + + case Action::OffloadBundlingJobClass: +// FIXME: Add a tool for the bundling actions. +return nullptr; } llvm_unreachable("Invalid tool kind."); Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1549,6 +1549,9 @@ /// found. virtual bool initialize() { return false; } +/// Return true if the builder can use bundling/unbundling. +virtual bool canUseBundlerUnbundler() const { return false; } + /// Return true if this builder is valid. We have a valid builder if we have /// associated device tool chains. bool isValid() { return !ToolChains.empty(); } @@ -1870,6 +1873,26 @@ return ABRT_Success; } +void appendTopLevelActions(ActionList &AL) override { + if (OpenMPDeviceActions.empty()) +return; + + // We should always have an action for each input. + assert(OpenMPDeviceActions.size() == ToolChains.size() && + "Number of OpenMP actions and toolchains do not match."); + + // Append all device actions followed by the proper offload action. + auto TI = ToolChains.begin(); + for (auto *A : OpenMPDeviceActions) { +OffloadAction::DeviceDependences Dep; +Dep.add(*A, **TI, /*BoundArch=*/nullptr, Action::OFK_OpenMP); +AL.push_back(C.MakeAction(Dep, A->getType())); +++TI; + } + // We no longer need the action stored in this builder. + OpenMPDeviceActions.clear(); +} + void appendLinkDependences(OffloadAction::DeviceDependences &DA) override { assert(ToolChains.size() == DeviceLinkerInputs.size() && "Toolchains and linker inputs sizes do not match."); @@ -1896,6 +1919,11 @@ DeviceLinkerInputs.resize(ToolChains.size()); return false; } + +bool canUseBundlerUnbundler() const override { + // OpenMP should use bundled files whenever possible. + return true; +} }; /// @@ -1905,6 +1933,9 @@ /// Specialized builders being used by this offloading action builder. SmallVector SpecializedBuilders; + /// Flag set to true if all valid builders allow file bundling/unbundling. + bool CanUseBundler; + public: OffloadingActionBuilder(Compilation &C, DerivedArgList &Args, const
Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.
sfantao updated this revision to Diff 62584. sfantao added a comment. - Start staic function name with caps. http://reviews.llvm.org/D21851 Files: test/Driver/clang-offload-bundler.c tools/clang-offload-bundler/ClangOffloadBundler.cpp Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp === --- tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -75,14 +75,23 @@ /// Magic string that marks the existence of offloading data. #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__" +/// Path to the current binary. +static std::string BundlerExecutable; + /// Obtain the offload kind and real machine triple out of the target /// information specified by the user. static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind, StringRef &Triple) { auto KindTriplePair = Target.split('-'); OffloadKind = KindTriplePair.first; Triple = KindTriplePair.second; } +static StringRef getTriple(StringRef Target) { + StringRef OffloadKind; + StringRef Triple; + getOffloadKindAndTriple(Target, OffloadKind, Triple); + return Triple; +} static bool hasHostKind(StringRef Target) { StringRef OffloadKind; StringRef Triple; @@ -113,37 +122,37 @@ /// \a OS. virtual void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) = 0; /// Write the marker that closes a bundle for the triple \a TargetTriple to \a - /// OS. - virtual void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0; + /// OS. Return true if any error was found. + virtual bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0; /// Write the bundle from \a Input into \a OS. virtual void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0; FileHandler() {} virtual ~FileHandler() {} }; -// Handler for binary files. The bundled file will have the following format -// (all integers are stored in little-endian format): -// -// "OFFLOAD_BUNDLER_MAGIC_STR" (ASCII encoding of the string) -// -// NumberOfOffloadBundles (8-byte integer) -// -// OffsetOfBundle1 (8-byte integer) -// SizeOfBundle1 (8-byte integer) -// NumberOfBytesInTripleOfBundle1 (8-byte integer) -// TripleOfBundle1 (byte length defined before) -// -// ... -// -// OffsetOfBundleN (8-byte integer) -// SizeOfBundleN (8-byte integer) -// NumberOfBytesInTripleOfBundleN (8-byte integer) -// TripleOfBundleN (byte length defined before) -// -// Bundle1 -// ... -// BundleN +/// Handler for binary files. The bundled file will have the following format +/// (all integers are stored in little-endian format): +/// +/// "OFFLOAD_BUNDLER_MAGIC_STR" (ASCII encoding of the string) +/// +/// NumberOfOffloadBundles (8-byte integer) +/// +/// OffsetOfBundle1 (8-byte integer) +/// SizeOfBundle1 (8-byte integer) +/// NumberOfBytesInTripleOfBundle1 (8-byte integer) +/// TripleOfBundle1 (byte length defined before) +/// +/// ... +/// +/// OffsetOfBundleN (8-byte integer) +/// SizeOfBundleN (8-byte integer) +/// NumberOfBytesInTripleOfBundleN (8-byte integer) +/// TripleOfBundleN (byte length defined before) +/// +/// Bundle1 +/// ... +/// BundleN /// Read 8-byte integers to/from a buffer in little-endian format. static uint64_t Read8byteIntegerFromBuffer(StringRef Buffer, size_t pos) { @@ -300,24 +309,241 @@ } } void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) {} - void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {} + bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) { +return false; + } void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) { OS.write(Input.getBufferStart(), Input.getBufferSize()); } BinaryFileHandler() : FileHandler() {} ~BinaryFileHandler() {} }; -// Handler for text files. The bundled file will have the following format. -// -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ triple" -// Bundle 1 -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ triple" -// ... -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ triple" -// Bundle N -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ triple" +/// Handler for object files. The bundles are organized by sections with a +/// designated name. +/// +/// In order to bundle we create an IR file with the content of each section and +/// use incremental linking to produce the resulting object. We also add section +/// with a single byte to state the name of the component the main object file +/// (the one we are bundling into) refers to. +/// +/// To unbundle, we use just copy the contents of the designated section. If the +/// requested bundle refer to the main object file, we just copy it with no +/// changes. +class ObjectFileHandler final : public FileHandler { + + /// The object file we are currently dealing with. + ObjectFile &Obj; + + /// Return the input file contents. + StringRef getInputFileContents() con
Re: [PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.
sfantao updated this revision to Diff 62583. sfantao added a comment. - Rebase. http://reviews.llvm.org/D21848 Files: include/clang/Driver/Compilation.h include/clang/Driver/ToolChain.h lib/Driver/Compilation.cpp lib/Driver/Driver.cpp lib/Driver/MSVCToolChain.cpp lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -169,25 +169,25 @@ // // Compile for the powerpc device. -/ -// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] // // Compile for the x86 device. // -// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] // // Generate host object from the BC file and link using the linker script. @@ -228,5 +228,3 @@ // CHK-LKS: } // CHK-LKS: } // CHK-LKS: INSERT BEFORE .data - - Index: lib/Driver/ToolChains.h === --- lib/Driver/ToolChains.h +++ lib/Driver/ToolChains.h @@ -208,6 +208,9 @@ bool isPIEDefault() const override; bool isPICDefaultForced() const override; bool IsIntegratedAssemblerDefault() const override; + llvm::opt::DerivedArgList * + TranslateArgs(const llvm::opt::DerivedArgList &Args, const char *BoundArch, +Action::OffloadKind DeviceOffloadKind) const override; protected: Tool *getTool(Action::ActionClass AC) const override; @@ -306,8 +309,8 @@ bool HasNativeLLVMSupport() const override; llvm::opt::DerivedArgList * - TranslateArgs(const llvm::opt::DerivedArgList &Args, -const char *BoundArch) const override; + TranslateArgs(const llvm::opt::DerivedArgList &Args, const ch
Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.
sfantao updated this revision to Diff 62582. sfantao added a comment. - Rebase. http://reviews.llvm.org/D21847 Files: lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -138,3 +138,95 @@ // CHK-PHASES-FILES: 38: assembler, {37}, object, (device-openmp) // CHK-PHASES-FILES: 39: linker, {26, 32, 38}, image, (device-openmp) // CHK-PHASES-FILES: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {11}, "device-openmp (x86_64-pc-linux-gnu)" {25}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, image + + +/// ### + +/// Check of the commands passed to each tool when using valid OpenMP targets. +/// Here we also check that offloading does not break the use of integrated +/// assembler. It does however preclude the merge of the host compile and +/// backend phases. There are also two offloading specific options: +/// -fopenmp-is-device: will tell the frontend that it will generate code for a +/// target. +/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by +/// the target code generation to gather information about which declaration +/// really need to be emitted. +/// +// RUN: %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-COMMANDS %s +// Run the save temp test in a temporary folder as the linker script will be +// created there. +// RUN: cd %T && \ +// RUN: %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-COMMANDS-ST %s +// RUN: FileCheck -check-prefix=CHK-LKS %s --input-file %t.lk +// +// Generate host BC file. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" +// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]" +// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// +// Compile for the powerpc device. +/ +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" +// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] + +// +// Compile for the x86 device. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" +// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] + +// +// Generate host object from the BC file and link using the linker script. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[
r274409 - Add TargetInfo for 32-bit and 64-bit RenderScript
Author: pirama Date: Fri Jul 1 19:05:42 2016 New Revision: 274409 URL: http://llvm.org/viewvc/llvm-project?rev=274409&view=rev Log: Add TargetInfo for 32-bit and 64-bit RenderScript Summary: The TargetInfo for 'renderscript32' and 'renderscript64' ArchTypes are subclasses of ARMleTargetInfo and AArch64leTargetInfo respectively. RenderScript32TargetInfo modifies the ARM ABI to set LongWidth and LongAlign to be 64-bits. Other than this modification, the underlying TargetInfo base classes is initialized as if they have "armv7" and "aarch64" architecture type respectively. Reviewers: rsmith, echristo Subscribers: aemerson, tberghammer, cfe-commits, danalbert, mehdi_amini, srhines Differential Revision: http://reviews.llvm.org/D21334 Added: cfe/trunk/test/CodeGen/renderscript.c Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=274409&r1=274408&r2=274409&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Fri Jul 1 19:05:42 2016 @@ -8071,6 +8071,42 @@ public: return true; } }; + +// 32-bit RenderScript is armv7 with width and align of 'long' set to 8-bytes +class RenderScript32TargetInfo : public ARMleTargetInfo { +public: + RenderScript32TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : ARMleTargetInfo(llvm::Triple("armv7", Triple.getVendorName(), + Triple.getOSName(), + Triple.getEnvironmentName()), +Opts) { +LongWidth = LongAlign = 64; + } + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override { +Builder.defineMacro("__RENDERSCRIPT__"); +ARMleTargetInfo::getTargetDefines(Opts, Builder); + } +}; + +// 64-bit RenderScript is aarch64 +class RenderScript64TargetInfo : public AArch64leTargetInfo { +public: + RenderScript64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(), + Triple.getOSName(), + Triple.getEnvironmentName()), +Opts) {} + + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override { +Builder.defineMacro("__RENDERSCRIPT__"); +AArch64leTargetInfo::getTargetDefines(Opts, Builder); + } +}; + } // end anonymous namespace //===--===// @@ -8499,6 +8535,11 @@ static TargetInfo *AllocateTarget(const if (!(Triple == llvm::Triple("wasm64-unknown-unknown"))) return nullptr; return new WebAssemblyOSTargetInfo(Triple, Opts); + + case llvm::Triple::renderscript32: +return new LinuxTargetInfo(Triple, Opts); + case llvm::Triple::renderscript64: +return new LinuxTargetInfo(Triple, Opts); } } Added: cfe/trunk/test/CodeGen/renderscript.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/renderscript.c?rev=274409&view=auto == --- cfe/trunk/test/CodeGen/renderscript.c (added) +++ cfe/trunk/test/CodeGen/renderscript.c Fri Jul 1 19:05:42 2016 @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS32 +// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS64 +// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-ARM + +// Ensure that the bitcode has the correct triple +// CHECK-RS32: target triple = "armv7-none-linux-gnueabi" +// CHECK-RS64: target triple = "aarch64-none-linux-android" +// CHECK-ARM: target triple = "armv7-none-linux-gnueabi" + +// Ensure that long data type has 8-byte size and alignment in RenderScript +#ifdef __RENDERSCRIPT__ +#define LONG_WIDTH_AND_ALIGN 8 +#else +#define LONG_WIDTH_AND_ALIGN 4 +#endif + +_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); +_Static_assert(_Alignof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); + +// CHECK-RS32: i64 @test_long(i64 %v) +// CHECK-RS64: i64 @test_long(i64 %v) +// CHECK-ARM: i32 @test_long(i32 %v) +long test_long(long v) { + return v + 1; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21334: Add TargetInfo for 32-bit and 64-bit RenderScript
This revision was automatically updated to reflect the committed changes. Closed by commit rL274409: Add TargetInfo for 32-bit and 64-bit RenderScript (authored by pirama). Changed prior to commit: http://reviews.llvm.org/D21334?vs=62520&id=62581#toc Repository: rL LLVM http://reviews.llvm.org/D21334 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/CodeGen/renderscript.c Index: cfe/trunk/test/CodeGen/renderscript.c === --- cfe/trunk/test/CodeGen/renderscript.c +++ cfe/trunk/test/CodeGen/renderscript.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS32 +// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS64 +// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-ARM + +// Ensure that the bitcode has the correct triple +// CHECK-RS32: target triple = "armv7-none-linux-gnueabi" +// CHECK-RS64: target triple = "aarch64-none-linux-android" +// CHECK-ARM: target triple = "armv7-none-linux-gnueabi" + +// Ensure that long data type has 8-byte size and alignment in RenderScript +#ifdef __RENDERSCRIPT__ +#define LONG_WIDTH_AND_ALIGN 8 +#else +#define LONG_WIDTH_AND_ALIGN 4 +#endif + +_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); +_Static_assert(_Alignof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); + +// CHECK-RS32: i64 @test_long(i64 %v) +// CHECK-RS64: i64 @test_long(i64 %v) +// CHECK-ARM: i32 @test_long(i32 %v) +long test_long(long v) { + return v + 1; +} Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -8071,6 +8071,42 @@ return true; } }; + +// 32-bit RenderScript is armv7 with width and align of 'long' set to 8-bytes +class RenderScript32TargetInfo : public ARMleTargetInfo { +public: + RenderScript32TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : ARMleTargetInfo(llvm::Triple("armv7", Triple.getVendorName(), + Triple.getOSName(), + Triple.getEnvironmentName()), +Opts) { +LongWidth = LongAlign = 64; + } + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override { +Builder.defineMacro("__RENDERSCRIPT__"); +ARMleTargetInfo::getTargetDefines(Opts, Builder); + } +}; + +// 64-bit RenderScript is aarch64 +class RenderScript64TargetInfo : public AArch64leTargetInfo { +public: + RenderScript64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(), + Triple.getOSName(), + Triple.getEnvironmentName()), +Opts) {} + + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override { +Builder.defineMacro("__RENDERSCRIPT__"); +AArch64leTargetInfo::getTargetDefines(Opts, Builder); + } +}; + } // end anonymous namespace //===--===// @@ -8499,6 +8535,11 @@ if (!(Triple == llvm::Triple("wasm64-unknown-unknown"))) return nullptr; return new WebAssemblyOSTargetInfo(Triple, Opts); + + case llvm::Triple::renderscript32: +return new LinuxTargetInfo(Triple, Opts); + case llvm::Triple::renderscript64: +return new LinuxTargetInfo(Triple, Opts); } } Index: cfe/trunk/test/CodeGen/renderscript.c === --- cfe/trunk/test/CodeGen/renderscript.c +++ cfe/trunk/test/CodeGen/renderscript.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS32 +// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS64 +// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-ARM + +// Ensure that the bitcode has the correct triple +// CHECK-RS32: target triple = "armv7-none-linux-gnueabi" +// CHECK-RS64: target triple = "aarch64-none-linux-android" +// CHECK-ARM: target triple = "armv7-none-linux-gnueabi" + +// Ensure that long data type has 8-byte size and alignment in RenderScript +#ifdef __RENDERSCRIPT__ +#define LONG_WIDTH_AND_ALIGN 8 +#else +#define LONG_WIDTH_AND_ALIGN 4 +#endif + +_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); +_Static_assert(_Alignof(long) == LONG_W
Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.
sfantao updated this revision to Diff 62580. sfantao added a comment. - Rebase http://reviews.llvm.org/D21845 Files: lib/Driver/Driver.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -35,3 +35,106 @@ // RUN: %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s // CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored. + +/// ### + +/// Check the phases graph when using a single target, different from the host. +/// We should have an offload action joining the host compile and device +/// preprocessor and another one joining the device linking outputs to the host +/// action. +// RUN: %clang -ccc-print-phases -fopenmp -target powerpc64le-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PHASES %s +// CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp) +// CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp) +// CHK-PHASES: 2: compiler, {1}, ir, (host-openmp) +// CHK-PHASES: 3: backend, {2}, assembler, (host-openmp) +// CHK-PHASES: 4: assembler, {3}, object, (host-openmp) +// CHK-PHASES: 5: linker, {4}, image, (host-openmp) +// CHK-PHASES: 6: input, "[[INPUT]]", c, (device-openmp) +// CHK-PHASES: 7: preprocessor, {6}, cpp-output, (device-openmp) +// CHK-PHASES: 8: compiler, {7}, ir, (device-openmp) +// CHK-PHASES: 9: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir +// CHK-PHASES: 10: backend, {9}, assembler, (device-openmp) +// CHK-PHASES: 11: assembler, {10}, object, (device-openmp) +// CHK-PHASES: 12: linker, {11}, image, (device-openmp) +// CHK-PHASES: 13: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {5}, "device-openmp (x86_64-pc-linux-gnu)" {12}, image + +/// ### + +/// Check the phases when using multiple targets. Here we also add a library to +/// make sure it is treated as input by the device. +// RUN: %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PHASES-LIB %s +// CHK-PHASES-LIB: 0: input, "somelib", object, (host-openmp) +// CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-openmp) +// CHK-PHASES-LIB: 2: preprocessor, {1}, cpp-output, (host-openmp) +// CHK-PHASES-LIB: 3: compiler, {2}, ir, (host-openmp) +// CHK-PHASES-LIB: 4: backend, {3}, assembler, (host-openmp) +// CHK-PHASES-LIB: 5: assembler, {4}, object, (host-openmp) +// CHK-PHASES-LIB: 6: linker, {0, 5}, image, (host-openmp) +// CHK-PHASES-LIB: 7: input, "somelib", object, (device-openmp) +// CHK-PHASES-LIB: 8: input, "[[INPUT]]", c, (device-openmp) +// CHK-PHASES-LIB: 9: preprocessor, {8}, cpp-output, (device-openmp) +// CHK-PHASES-LIB: 10: compiler, {9}, ir, (device-openmp) +// CHK-PHASES-LIB: 11: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {10}, ir +// CHK-PHASES-LIB: 12: backend, {11}, assembler, (device-openmp) +// CHK-PHASES-LIB: 13: assembler, {12}, object, (device-openmp) +// CHK-PHASES-LIB: 14: linker, {7, 13}, image, (device-openmp) +// CHK-PHASES-LIB: 15: input, "somelib", object, (device-openmp) +// CHK-PHASES-LIB: 16: input, "[[INPUT]]", c, (device-openmp) +// CHK-PHASES-LIB: 17: preprocessor, {16}, cpp-output, (device-openmp) +// CHK-PHASES-LIB: 18: compiler, {17}, ir, (device-openmp) +// CHK-PHASES-LIB: 19: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {18}, ir +// CHK-PHASES-LIB: 20: backend, {19}, assembler, (device-openmp) +// CHK-PHASES-LIB: 21: assembler, {20}, object, (device-openmp) +// CHK-PHASES-LIB: 22: linker, {15, 21}, image, (device-openmp) +// CHK-PHASES-LIB: 23: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {6}, "device-openmp (x86_64-pc-linux-gnu)" {14}, "device-openmp (powerpc64-ibm-linux-gnu)" {22}, image + + +/// ### + +/// Check the phases when using multiple targets and multiple source files +// RUN: echo " " > %t.c +// RUN: %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s %t.c 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PHASES-FILES %s +// CHK-PHASES-FILES: 0: input, "somelib", object, (host-openmp) +// CHK-PHASES-FILES: 1: input, "[[INPUT1:.+\.c]]", c, (host-openmp) +// CHK-PHASES-FILES: 2: preprocessor, {1}, cpp-output, (host-op
Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.
sfantao updated this revision to Diff 62577. sfantao added a comment. - Rebase http://reviews.llvm.org/D21843 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Action.h include/clang/Driver/Driver.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- /dev/null +++ test/Driver/openmp-offload.c @@ -0,0 +1,37 @@ +/// +/// Perform several driver tests for OpenMP offloading +/// + +/// ### + +/// Check whether an invalid OpenMP target is specified: +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-INVALID-TARGET %s +// RUN: %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-INVALID-TARGET %s +// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd' + +/// ### + +/// Check warning for empty -fopenmp-targets +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets= %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s +// RUN: %clang -### -fopenmp -fopenmp-targets= %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s +// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets=' + +/// ### + +/// Check error for no -fopenmp option +// RUN: %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s +// RUN: %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s +// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading. + +/// ### + +/// Check warning for duplicate offloading targets. +// RUN: %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s +// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored. Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2999,72 +2999,23 @@ CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins")); } -namespace { -enum OpenMPRuntimeKind { - /// An unknown OpenMP runtime. We can't generate effective OpenMP code - /// without knowing what runtime to target. - OMPRT_Unknown, - - /// The LLVM OpenMP runtime. When completed and integrated, this will become - /// the default for Clang. - OMPRT_OMP, - - /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for - /// this runtime but can swallow the pragmas, and find and link against the - /// runtime library itself. - OMPRT_GOMP, - - /// The legacy name for the LLVM OpenMP runtime from when it was the Intel - /// OpenMP runtime. We support this mode for users with existing dependencies - /// on this runtime library name. - OMPRT_IOMP5 -}; -} - -/// Compute the desired OpenMP runtime from the flag provided. -static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain &TC, - const ArgList &Args) { - StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME); - - const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ); - if (A) -RuntimeName = A->getValue(); - - auto RT = llvm::StringSwitch(RuntimeName) -.Case("libomp", OMPRT_OMP) -.Case("libgomp", OMPRT_GOMP) -.Case("libiomp5", OMPRT_IOMP5) -.Default(OMPRT_Unknown); - - if (RT == OMPRT_Unknown) { -if (A) - TC.getDriver().Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); -else - // FIXME: We could use a nicer diagnostic here. - TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp"; - } - - return RT; -} - static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, const ArgList &Args) { if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, options::OPT_fno_openmp, false)) return; - switch (getOpenMPRuntime(TC, Args)) { - case OMPRT_OMP: + switch (TC.getDriver().getOpenMPRuntime(Args)) { + case Driver::OMPRT_OMP: CmdArgs.push_back("-lomp"); break; - case OMPRT_GOMP: + case Driver::OMPRT_GOMP: CmdArgs.push_back("-lgomp")
Re: [PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.
sfantao updated this revision to Diff 62575. sfantao added a comment. - Rebase http://reviews.llvm.org/D21840 Files: include/clang/Driver/Action.h lib/Driver/Driver.cpp Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1894,7 +1894,7 @@ // Create the offload action with all dependences. When an offload action // is created the kinds are propagated to the host action, so we don't have -// to do that explicitely here. +// to do that explicitly here. OffloadAction::HostDependence HDep( *HostAction, *C.getSingleOffloadToolChain(), /*BoundArch*/ nullptr, ActiveOffloadKinds); @@ -2328,142 +2328,293 @@ } } } -/// Collapse an offloading action looking for a job of the given type. The input -/// action is changed to the input of the collapsed sequence. If we effectively -/// had a collapse return the corresponding offloading action, otherwise return -/// null. -template -static OffloadAction *collapseOffloadingAction(Action *&CurAction) { - if (!CurAction) -return nullptr; - if (auto *OA = dyn_cast(CurAction)) { -if (OA->hasHostDependence()) - if (auto *HDep = dyn_cast(OA->getHostDependence())) { -CurAction = HDep; -return OA; - } -if (OA->hasSingleDeviceDependence()) - if (auto *DDep = dyn_cast(OA->getSingleDeviceDependence())) { -CurAction = DDep; -return OA; + +namespace { +/// Utility class to control the collapse of dependent actions and select the +/// tools accordingly. +class ToolSelector final { + /// The tool chain this selector refers to. + const ToolChain &TC; + + /// The compilation this selector refers to. + const Compilation &C; + + /// The base action this selector refers to. + const JobAction *BaseAction; + + /// Set to true if the current toolchain refers to host actions. + bool IsHostSelector; + + /// Set to true if save-temps and embed-bitcode functionalities are active. + bool SaveTemps; + bool EmbedBitcode; + + /// Get dependence action or null if that does not exist. If \a CanBeCollapsed + /// is false, that action must be legal to collapse or null will be returned. + const JobAction *getDependenceAction(const ActionList &Inputs, + ActionList &SavedOffloadAction, + bool CanBeCollapsed = true) { +// An option can be collapsed only if it has a single input. +if (Inputs.size() != 1) + return nullptr; + +Action *CurAction = *Inputs.begin(); +if (!CurAction->isCollapsingWithDependingActionLegal() && CanBeCollapsed) + return nullptr; + +// If the input action is an offload action. Look through it and save any +// offload action that can be dropped in the event of a collapse. +if (auto *OA = dyn_cast(CurAction)) { + // If the depending action is a device action, we will attempt to collapse + // only with other device actions. Otherwise, we would do the same but + // with host actions only. + if (!IsHostSelector) { +if (OA->hasSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)) { + CurAction = + OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true); + if (!CurAction->isCollapsingWithDependingActionLegal() && + CanBeCollapsed) +return nullptr; + SavedOffloadAction.push_back(OA); + return dyn_cast(CurAction); +} + } else if (OA->hasHostDependence()) { +CurAction = OA->getHostDependence(); +if (!CurAction->isCollapsingWithDependingActionLegal() && +CanBeCollapsed) + return nullptr; +SavedOffloadAction.push_back(OA); +return dyn_cast(CurAction); } + return nullptr; +} + +return dyn_cast(CurAction); } - return nullptr; -} -// Returns a Tool for a given JobAction. In case the action and its -// predecessors can be combined, updates Inputs with the inputs of the -// first combined action. If one of the collapsed actions is a -// CudaHostAction, updates CollapsedCHA with the pointer to it so the -// caller can deal with extra handling such action requires. -static const Tool *selectToolForJob(Compilation &C, bool SaveTemps, -bool EmbedBitcode, const ToolChain *TC, -const JobAction *JA, -const ActionList *&Inputs, -ActionList &CollapsedOffloadAction) { - const Tool *ToolForJob = nullptr; - CollapsedOffloadAction.clear(); - - // See if we should look for a compiler with an integrated assembler. We match - // bottom up, so what we are actually looking for is an assembler job with a - // compiler input. - - // Look through offload actions between assembler and backend actions. - Action *BackendJA = (isa(JA) &&
Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder
sfantao updated this revision to Diff 62573. sfantao added a comment. - Rebase http://reviews.llvm.org/D18172 Files: include/clang/Driver/Compilation.h lib/Driver/Driver.cpp Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1387,131 +1387,521 @@ } } -// For each unique --cuda-gpu-arch= argument creates a TY_CUDA_DEVICE -// input action and then wraps each in CudaDeviceAction paired with -// appropriate GPU arch name. In case of partial (i.e preprocessing -// only) or device-only compilation, each device action is added to /p -// Actions and /p Current is released. Otherwise the function creates -// and returns a new CudaHostAction which wraps /p Current and device -// side actions. -static Action *buildCudaActions(Compilation &C, DerivedArgList &Args, -const Arg *InputArg, Action *HostAction, -ActionList &Actions) { - Arg *PartialCompilationArg = Args.getLastArg( - options::OPT_cuda_host_only, options::OPT_cuda_device_only, - options::OPT_cuda_compile_host_device); - bool CompileHostOnly = - PartialCompilationArg && - PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only); - bool CompileDeviceOnly = - PartialCompilationArg && - PartialCompilationArg->getOption().matches(options::OPT_cuda_device_only); - - if (CompileHostOnly) { +namespace { +/// Provides a convenient interface for different programming models to generate +/// the required device actions. +class OffloadingActionBuilder final { + /// Flag used to trace errors in the builder. + bool IsValid = false; + + /// The compilation that is using this builder. + Compilation &C; + + /// The derived arguments associated with this builder. + DerivedArgList &Args; + + /// Map between an input argument and the offload kinds used to process it. + std::map InputArgToOffloadKindMap; + + /// Builder interface. It doesn't build anything or keep any state. + class DeviceActionBuilder { + public: +typedef llvm::SmallVector PhasesTy; + +enum ActionBuilderReturnCode { + // The builder acted successfully on the current action. + ABRT_Success, + // The builder didn't have to act on the current action. + ABRT_Inactive, + // The builder was successful and requested the host action to not be + // generated. + ABRT_Ignore_Host, +}; + + protected: +/// Compilation associated with this builder. +Compilation &C; + +/// Tool chains associated with this builder. The same programming +/// model may have associated one or more tool chains. +SmallVector ToolChains; + +/// The derived arguments associated with this builder. +DerivedArgList &Args; + +/// The inputs associated with this builder. +const Driver::InputList &Inputs; + +/// The associated offload kind. +Action::OffloadKind AssociatedOffloadKind = Action::OFK_None; + + public: +DeviceActionBuilder(Compilation &C, DerivedArgList &Args, +const Driver::InputList &Inputs, +Action::OffloadKind AssociatedOffloadKind) +: C(C), Args(Args), Inputs(Inputs), + AssociatedOffloadKind(AssociatedOffloadKind) {} +virtual ~DeviceActionBuilder() {} + +/// Fill up the array \a DA with all the device dependences that should be +/// added to the provided host action \a HostAction. By default it is +/// inactive. +virtual ActionBuilderReturnCode +getDeviceDepences(OffloadAction::DeviceDependences &DA, phases::ID CurPhase, + phases::ID FinalPhase, PhasesTy &Phases) { + return ABRT_Inactive; +} + +/// Update the state to include the provided host action \a HostAction as a +/// dependency of the current device action. By default it is inactive. +virtual ActionBuilderReturnCode addDeviceDepences(Action *HostAction) { + return ABRT_Inactive; +} + +/// Append top level actions generated by the builder. Return true if errors +/// were found. +virtual void appendTopLevelActions(ActionList &AL) {} + +/// Append linker actions generated by the builder. Return true if errors +/// were found. +virtual void appendLinkDependences(OffloadAction::DeviceDependences &DA) {} + +/// Initialize the builder. Return true if any initialization errors are +/// found. +virtual bool initialize() { return false; } + +/// Return true if this builder is valid. We have a valid builder if we have +/// associated device tool chains. +bool isValid() { return !ToolChains.empty(); } + +/// Return the associated offload kind. +Action::OffloadKind getAssociatedOffloadKind() { + return AssociatedOffloadKind; +} + }; + + /// \brief CUDA action builder. It injects device code in the host backend + /// action. + class CudaActionBuilder final : p
Re: [PATCH] D18171: [CUDA][OpenMP] Create generic offload action
sfantao updated this revision to Diff 62572. sfantao added a comment. - Rebase http://reviews.llvm.org/D18171 Files: include/clang/Driver/Action.h include/clang/Driver/Compilation.h include/clang/Driver/Driver.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h lib/Driver/Tools.cpp lib/Driver/Tools.h lib/Frontend/CreateInvocationFromCommandLine.cpp Index: lib/Frontend/CreateInvocationFromCommandLine.cpp === --- lib/Frontend/CreateInvocationFromCommandLine.cpp +++ lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -60,25 +60,25 @@ } // We expect to get back exactly one command job, if we didn't something - // failed. CUDA compilation is an exception as it creates multiple jobs. If - // that's the case, we proceed with the first job. If caller needs particular - // CUDA job, it should be controlled via --cuda-{host|device}-only option - // passed to the driver. + // failed. Offload compilation is an exception as it creates multiple jobs. If + // that's the case, we proceed with the first job. If caller needs a + // particular job, it should be controlled via options (e.g. + // --cuda-{host|device}-only for CUDA) passed to the driver. const driver::JobList &Jobs = C->getJobs(); - bool CudaCompilation = false; + bool OffloadCompilation = false; if (Jobs.size() > 1) { for (auto &A : C->getActions()){ // On MacOSX real actions may end up being wrapped in BindArchAction if (isa(A)) A = *A->input_begin(); - if (isa(A)) { -CudaCompilation = true; + if (isa(A)) { +OffloadCompilation = true; break; } } } if (Jobs.size() == 0 || !isa(*Jobs.begin()) || - (Jobs.size() > 1 && !CudaCompilation)) { + (Jobs.size() > 1 && !OffloadCompilation)) { SmallString<256> Msg; llvm::raw_svector_ostream OS(Msg); Jobs.Print(OS, "; ", true); Index: lib/Driver/Tools.h === --- lib/Driver/Tools.h +++ lib/Driver/Tools.h @@ -57,8 +57,7 @@ const Driver &D, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, - const InputInfoList &Inputs, - const ToolChain *AuxToolChain) const; + const InputInfoList &Inputs) const; void AddAArch64TargetArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -288,12 +288,45 @@ !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput); } +/// Add the C++ include args of other offloading toolchains. If this is a host +/// job, the device toolchains are added. If this is a device job, the host +/// toolchains will be added. +static void addExtraOffloadCXXStdlibIncludeArgs(Compilation &C, +const JobAction &JA, +const ArgList &Args, +ArgStringList &CmdArgs) { + + if (JA.isHostOffloading(Action::OFK_Cuda)) +C.getSingleOffloadToolChain() +->AddClangCXXStdlibIncludeArgs(Args, CmdArgs); + else if (JA.isDeviceOffloading(Action::OFK_Cuda)) +C.getSingleOffloadToolChain() +->AddClangCXXStdlibIncludeArgs(Args, CmdArgs); + + // TODO: Add support for other programming models here. +} + +/// Add the include args that are specific of each offloading programming model. +static void addExtraOffloadSpecificIncludeArgs(Compilation &C, + const JobAction &JA, + const ArgList &Args, + ArgStringList &CmdArgs) { + + if (JA.isHostOffloading(Action::OFK_Cuda)) +C.getSingleOffloadToolChain()->AddCudaIncludeArgs( +Args, CmdArgs); + else if (JA.isDeviceOffloading(Action::OFK_Cuda)) +C.getSingleOffloadToolChain()->AddCudaIncludeArgs( +Args, CmdArgs); + + // TODO: Add support for other programming models here. +} + void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, const Driver &D, const ArgList &Args, ArgStringList &CmdArgs, const InputInfo &Output, -const InputInfoList &Inputs, -const ToolChain *AuxToolChain) const { +const InputInfoList &Inputs) const { Arg *A; const bool I
[libcxx] r274408 - Add another workaround for C++17 inline variable ABI breakage.
Author: ericwf Date: Fri Jul 1 18:41:48 2016 New Revision: 274408 URL: http://llvm.org/viewvc/llvm-project?rev=274408&view=rev Log: Add another workaround for C++17 inline variable ABI breakage. Modified: libcxx/trunk/src/experimental/filesystem/path.cpp Modified: libcxx/trunk/src/experimental/filesystem/path.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/path.cpp?rev=274408&r1=274407&r2=274408&view=diff == --- libcxx/trunk/src/experimental/filesystem/path.cpp (original) +++ libcxx/trunk/src/experimental/filesystem/path.cpp Fri Jul 1 18:41:48 2016 @@ -13,7 +13,10 @@ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM _LIBCPP_CONSTEXPR path::value_type path::preferred_separator; - +// Make preferred_separator non-discardable in C++17 +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) +static const path::value_type& +__preferred_sep_force_use __attribute__((used)) = path::preferred_separator; namespace { namespace parser { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r274403 - Work around ABI break caused by C++17 inline variables.
On Fri, Jul 1, 2016 at 4:37 PM, Eric Fiselier wrote: > The attribute is ignored unless it is placed on the in-class declaration > of the member. It has no effect when applied to the explicit definition. > Ugh, right, attributes added after the definition aren't well-treated. Seems reasonable to me for us to emit a strong definition of the variable (linkonce_odr -> weak_odr) if it has an out-of-line declaration, for compatibility with cases like this. That way you wouldn't need this change at all. > I would rather keep the workaround internal than make the change in the > headers. > Oh, sure, changing the header would definitely be the wrong thing. > On Fri, Jul 1, 2016 at 5:34 PM, Richard Smith > wrote: > >> On Fri, Jul 1, 2016 at 4:22 PM, Eric Fiselier via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: ericwf >>> Date: Fri Jul 1 18:22:25 2016 >>> New Revision: 274403 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev >>> Log: >>> Work around ABI break caused by C++17 inline variables. >>> >>> Modified: >>> libcxx/trunk/src/chrono.cpp >>> >>> Modified: libcxx/trunk/src/chrono.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff >>> >>> == >>> --- libcxx/trunk/src/chrono.cpp (original) >>> +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 18:22:25 2016 >>> @@ -6,7 +6,7 @@ >>> // Source Licenses. See LICENSE.TXT for details. >>> // >>> >>> >>> //===--===// >>> - >>> +#define _LIBCPP_BUILDING_CHRONO >>> #include "chrono" >>> #include "cerrno"// errno >>> #include "system_error" // __throw_system_error >>> @@ -32,6 +32,9 @@ namespace chrono >>> // system_clock >>> >>> const bool system_clock::is_steady; >>> >> >> Can you mark this as __attribute__((used)) instead of adding a separate >> use? >> >> >>> +// Make is_steady non-discardable in C++17 >>> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) >>> +static const bool& __is_steady_force_use1 __attribute__((used)) = >>> system_clock::is_steady; >>> >>> system_clock::time_point >>> system_clock::now() _NOEXCEPT >>> @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE >>> // instead. >>> >>> const bool steady_clock::is_steady; >>> +// Make is_steady non-discardable in C++17 >>> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) >>> +static const bool& __is_steady_force_use2 __attribute__((used)) = >>> steady_clock::is_steady; >>> + >>> >>> #ifdef CLOCK_MONOTONIC >>> >>> >>> >>> ___ >>> cfe-commits mailing list >>> cfe-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >>> >> >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21871: [libcxx] [test] Make vector.bool/construct_default.pass.cpp more portable.
STL_MSFT abandoned this revision. STL_MSFT added a comment. Nah, they can totally be noexcept like the primary template. Usually we don't strengthen beyond the WP, but the wording is so clearly defective here, I'll go ahead and do this. No test changes necessary now. http://reviews.llvm.org/D21871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect
comicfans44 created this revision. comicfans44 added reviewers: zturner, majnemer. comicfans44 added a subscriber: cfe-commits. 1. readFullStringValue returns bool, should not compared with ERROR_SUCCESS 2. RegQueryValueExW string may contain null terminating char ,should be trimmed these leads getSystemRegistryString return incorrect result, and following getWindows10SDKVersion gives incorrect result for string append, prevents correct SDK detected. http://reviews.llvm.org/D21946 Files: lib/Driver/MSVCToolChain.cpp Index: lib/Driver/MSVCToolChain.cpp === --- lib/Driver/MSVCToolChain.cpp +++ lib/Driver/MSVCToolChain.cpp @@ -113,6 +113,9 @@ if (result == ERROR_SUCCESS) { std::wstring WideValue(reinterpret_cast(buffer.data()), valueSize / sizeof(wchar_t)); +if (valueSize && WideValue.back() == L'\0') { +WideValue.pop_back(); +} // The destination buffer must be empty as an invariant of the conversion // function; but this function is sometimes called in a loop that passes in // the same buffer, however. Simply clear it out so we can overwrite it. @@ -190,8 +193,7 @@ lResult = RegOpenKeyExA(hTopKey, bestName.c_str(), 0, KEY_READ | KEY_WOW64_32KEY, &hKey); if (lResult == ERROR_SUCCESS) { -lResult = readFullStringValue(hKey, valueName, value); -if (lResult == ERROR_SUCCESS) { +if (readFullStringValue(hKey, valueName, value)) { bestValue = dvalue; if (phValue) *phValue = bestName; @@ -208,8 +210,7 @@ lResult = RegOpenKeyExA(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); if (lResult == ERROR_SUCCESS) { - lResult = readFullStringValue(hKey, valueName, value); - if (lResult == ERROR_SUCCESS) + if (readFullStringValue(hKey, valueName, value)) returnValue = true; if (phValue) phValue->clear(); Index: lib/Driver/MSVCToolChain.cpp === --- lib/Driver/MSVCToolChain.cpp +++ lib/Driver/MSVCToolChain.cpp @@ -113,6 +113,9 @@ if (result == ERROR_SUCCESS) { std::wstring WideValue(reinterpret_cast(buffer.data()), valueSize / sizeof(wchar_t)); +if (valueSize && WideValue.back() == L'\0') { +WideValue.pop_back(); +} // The destination buffer must be empty as an invariant of the conversion // function; but this function is sometimes called in a loop that passes in // the same buffer, however. Simply clear it out so we can overwrite it. @@ -190,8 +193,7 @@ lResult = RegOpenKeyExA(hTopKey, bestName.c_str(), 0, KEY_READ | KEY_WOW64_32KEY, &hKey); if (lResult == ERROR_SUCCESS) { -lResult = readFullStringValue(hKey, valueName, value); -if (lResult == ERROR_SUCCESS) { +if (readFullStringValue(hKey, valueName, value)) { bestValue = dvalue; if (phValue) *phValue = bestName; @@ -208,8 +210,7 @@ lResult = RegOpenKeyExA(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); if (lResult == ERROR_SUCCESS) { - lResult = readFullStringValue(hKey, valueName, value); - if (lResult == ERROR_SUCCESS) + if (readFullStringValue(hKey, valueName, value)) returnValue = true; if (phValue) phValue->clear(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274407 - Remove accidental change committed in r274403.
Author: ericwf Date: Fri Jul 1 18:31:55 2016 New Revision: 274407 URL: http://llvm.org/viewvc/llvm-project?rev=274407&view=rev Log: Remove accidental change committed in r274403. Modified: libcxx/trunk/src/chrono.cpp Modified: libcxx/trunk/src/chrono.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274407&r1=274406&r2=274407&view=diff == --- libcxx/trunk/src/chrono.cpp (original) +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 18:31:55 2016 @@ -6,7 +6,7 @@ // Source Licenses. See LICENSE.TXT for details. // //===--===// -#define _LIBCPP_BUILDING_CHRONO + #include "chrono" #include "cerrno"// errno #include "system_error" // __throw_system_error ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r274403 - Work around ABI break caused by C++17 inline variables.
The attribute is ignored unless it is placed on the in-class declaration of the member. It has no effect when applied to the explicit definition. I would rather keep the workaround internal than make the change in the headers. On Fri, Jul 1, 2016 at 5:34 PM, Richard Smith wrote: > On Fri, Jul 1, 2016 at 4:22 PM, Eric Fiselier via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: ericwf >> Date: Fri Jul 1 18:22:25 2016 >> New Revision: 274403 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev >> Log: >> Work around ABI break caused by C++17 inline variables. >> >> Modified: >> libcxx/trunk/src/chrono.cpp >> >> Modified: libcxx/trunk/src/chrono.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff >> >> == >> --- libcxx/trunk/src/chrono.cpp (original) >> +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 18:22:25 2016 >> @@ -6,7 +6,7 @@ >> // Source Licenses. See LICENSE.TXT for details. >> // >> >> >> //===--===// >> - >> +#define _LIBCPP_BUILDING_CHRONO >> #include "chrono" >> #include "cerrno"// errno >> #include "system_error" // __throw_system_error >> @@ -32,6 +32,9 @@ namespace chrono >> // system_clock >> >> const bool system_clock::is_steady; >> > > Can you mark this as __attribute__((used)) instead of adding a separate > use? > > >> +// Make is_steady non-discardable in C++17 >> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) >> +static const bool& __is_steady_force_use1 __attribute__((used)) = >> system_clock::is_steady; >> >> system_clock::time_point >> system_clock::now() _NOEXCEPT >> @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE >> // instead. >> >> const bool steady_clock::is_steady; >> +// Make is_steady non-discardable in C++17 >> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) >> +static const bool& __is_steady_force_use2 __attribute__((used)) = >> steady_clock::is_steady; >> + >> >> #ifdef CLOCK_MONOTONIC >> >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21857: [Driver][OpenMP] Add support to create jobs for unbundling actions.
sfantao updated this revision to Diff 62569. sfantao marked 2 inline comments as done. sfantao added a comment. - Change name of static function, format comments and remove \brief. http://reviews.llvm.org/D21857 Files: include/clang/Driver/Action.h include/clang/Driver/Tool.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/Tool.cpp lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -176,7 +176,7 @@ // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] // // Compile for the x86 device. @@ -187,7 +187,7 @@ // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] // // Generate host object from the BC file and link using the linker script. @@ -202,20 +202,20 @@ // Check the linker script contains what we expect. // // CHK-LKS: TARGET(binary) -// CHK-LKS: INPUT({{.+}}.out-device-openmp-powerpc64le-ibm-linux-gnu) -// CHK-LKS: INPUT({{.+}}.out-device-openmp-x86_64-pc-linux-gnu) +// CHK-LKS: INPUT({{.+}}.out-openmp-powerpc64le-ibm-linux-gnu) +// CHK-LKS: INPUT({{.+}}.out-openmp-x86_64-pc-linux-gnu) // CHK-LKS: SECTIONS // CHK-LKS: { // CHK-LKS: .omp_offloading : // CHK-LKS: ALIGN(0x10) // CHK-LKS: { // CHK-LKS: . = ALIGN(0x10); // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.powerpc64le-ibm-linux-gnu = .); -// CHK-LKS: {{.+}}.out-device-openmp-powerpc64le-ibm-linux-gnu +// CHK-LKS: {{.+}}.out-openmp-powerpc64le-ibm-linux-gnu // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.powerpc64le-ibm-linux-gnu = .); // CHK-LKS: . = ALIGN(0x10); // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64-pc-linux-gnu = .); -// CHK-LKS: {{.+}}.out-device-openmp-x86_64-pc-linux-gnu +// CHK-LKS: {{.+}}.out-openmp-x86_64-pc-linux-gnu // CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64-pc-linux-gnu = .); // CHK-LKS: } // CHK-LKS: .omp_offloading.entries : @@ -343,3 +343,92 @@ // CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]" // CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]" // CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" + +/// ### + +/// Check separate compilation with offloading - unbundling jobs construct +// RUN: touch %t.i +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBJOBS %s +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBJOBS-ST %s +// RUN: touch %t.o +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.o 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBJOBS2 %s +// RUN: %clang -### -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.o -save-te
Re: [PATCH] D21857: [Driver][OpenMP] Add support to create jobs for unbundling actions.
sfantao added a comment. Hi Alexey, thanks for the review! Comment at: include/clang/Driver/Tool.h:132-140 @@ -131,1 +131,11 @@ const char *LinkingOutput) const = 0; + /// ConstructJob - Construct jobs to perform the action \p JA, + /// writing to the \p Outputs and with \p Inputs, and add the jobs to + /// \p C. The default implementation assumes a single output and is expected + /// to be overloaded for the tools that support multiple inputs. + /// + /// \param TCArgs - The argument list for this toolchain, with any + /// tool chain specific translations applied. + /// \param LinkingOutput - If this output will eventually feed the + /// linker, then this is the final output name of the linked image. + virtual void ConstructJob(Compilation &C, const JobAction &JA, ABataev wrote: > Please, format properly. Remove the name of the function and '-' signs after > params Ok, I was following the format used for the other version of the is function. http://reviews.llvm.org/D21857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r274403 - Work around ABI break caused by C++17 inline variables.
On Fri, Jul 1, 2016 at 4:22 PM, Eric Fiselier via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ericwf > Date: Fri Jul 1 18:22:25 2016 > New Revision: 274403 > > URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev > Log: > Work around ABI break caused by C++17 inline variables. > > Modified: > libcxx/trunk/src/chrono.cpp > > Modified: libcxx/trunk/src/chrono.cpp > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff > > == > --- libcxx/trunk/src/chrono.cpp (original) > +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 18:22:25 2016 > @@ -6,7 +6,7 @@ > // Source Licenses. See LICENSE.TXT for details. > // > > > //===--===// > - > +#define _LIBCPP_BUILDING_CHRONO > #include "chrono" > #include "cerrno"// errno > #include "system_error" // __throw_system_error > @@ -32,6 +32,9 @@ namespace chrono > // system_clock > > const bool system_clock::is_steady; > Can you mark this as __attribute__((used)) instead of adding a separate use? > +// Make is_steady non-discardable in C++17 > +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) > +static const bool& __is_steady_force_use1 __attribute__((used)) = > system_clock::is_steady; > > system_clock::time_point > system_clock::now() _NOEXCEPT > @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE > // instead. > > const bool steady_clock::is_steady; > +// Make is_steady non-discardable in C++17 > +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) > +static const bool& __is_steady_force_use2 __attribute__((used)) = > steady_clock::is_steady; > + > > #ifdef CLOCK_MONOTONIC > > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation
silvas added inline comments. Comment at: lib/Driver/Tools.cpp:3560 @@ +3559,3 @@ +if (PGOTrainArg->getOption().matches(options::OPT_fpgo_train_EQ)) { + if (StringRef(PGOTrainArg->getValue()) == "source-cfg") +CmdArgs.push_back("-fprofile-instrument=clang"); davidxl wrote: > I think it is better to make the selector 'source' vs 'cfg'. > > -fpgo-train=source > -fpgo-train=cfg So would `-fpgo-train=cfg` enable icall instrumentation or not? My thinking is that down the road we will have one flag for each independent instrumentation capability (and of course some are mutually incompatible). This mirrors what the sanitizers do. For example, we would have: `-fpgo-train=optimizer-cfg` --> IR edge profiling `-fpgo-train=optimizer-icall` --> IR icall value profiling `-fpgo-train=optimizer-...` --> other independent instrumentation we can do in IR instrumentation. `-fpgo-train=source-cfg` --> FE edge profiling `-fpgo-train=source-icall` --> FE icall profiling (if that even exists; I see some code but there is no user-visible flag) `-fpgo-train=source-...` --> other FE instrumentation. We can then have `-fpgo-train=optimizer` enable e.g. `-fpgo-train=optimizer-cfg,optimizer-icall`. We can also have `-fpgo-train=source` enable e.g. `-fpgo-train=source-cfg`. Since instrumentation can have different overheads or different runtime requirements, users may want to disable some instrumentation. Repository: rL LLVM http://reviews.llvm.org/D21823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274404 - Turn off ASAN's odr-violation diagnostics for now. See PR28391
Author: ericwf Date: Fri Jul 1 18:25:47 2016 New Revision: 274404 URL: http://llvm.org/viewvc/llvm-project?rev=274404&view=rev Log: Turn off ASAN's odr-violation diagnostics for now. See PR28391 Modified: libcxx/trunk/test/libcxx/test/config.py Modified: libcxx/trunk/test/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=274404&r1=274403&r2=274404&view=diff == --- libcxx/trunk/test/libcxx/test/config.py (original) +++ libcxx/trunk/test/libcxx/test/config.py Fri Jul 1 18:25:47 2016 @@ -607,6 +607,9 @@ class Configuration(object): self.cxx.flags += ['-fsanitize=address'] if llvm_symbolizer is not None: self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer +# FIXME: Turn ODR violation back on after PR28391 is resolved +# https://llvm.org/bugs/show_bug.cgi?id=28391 +self.env['ASAN_OPTIONS'] = 'detect_odr_violation=0' self.config.available_features.add('asan') self.config.available_features.add('sanitizer-new-delete') elif san == 'Memory' or san == 'MemoryWithOrigins': ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r274403 - Work around ABI break caused by C++17 inline variables.
Author: ericwf Date: Fri Jul 1 18:22:25 2016 New Revision: 274403 URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev Log: Work around ABI break caused by C++17 inline variables. Modified: libcxx/trunk/src/chrono.cpp Modified: libcxx/trunk/src/chrono.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff == --- libcxx/trunk/src/chrono.cpp (original) +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 18:22:25 2016 @@ -6,7 +6,7 @@ // Source Licenses. See LICENSE.TXT for details. // //===--===// - +#define _LIBCPP_BUILDING_CHRONO #include "chrono" #include "cerrno"// errno #include "system_error" // __throw_system_error @@ -32,6 +32,9 @@ namespace chrono // system_clock const bool system_clock::is_steady; +// Make is_steady non-discardable in C++17 +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) +static const bool& __is_steady_force_use1 __attribute__((used)) = system_clock::is_steady; system_clock::time_point system_clock::now() _NOEXCEPT @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE // instead. const bool steady_clock::is_steady; +// Make is_steady non-discardable in C++17 +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) +static const bool& __is_steady_force_use2 __attribute__((used)) = steady_clock::is_steady; + #ifdef CLOCK_MONOTONIC ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r274401 - [CodeView] Include MSVC style names for unnamed types
Author: majnemer Date: Fri Jul 1 18:12:54 2016 New Revision: 274401 URL: http://llvm.org/viewvc/llvm-project?rev=274401&view=rev Log: [CodeView] Include MSVC style names for unnamed types The CodeView printer expects to be able to generate fully qualified names from the debug info graph. This means that we need to include the MSVC-style name in the debug info for anonymous types. Added: cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274401&r1=274400&r2=274401&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jul 1 18:12:54 2016 @@ -259,20 +259,56 @@ StringRef CGDebugInfo::getSelectorName(S } StringRef CGDebugInfo::getClassName(const RecordDecl *RD) { - // quick optimization to avoid having to intern strings that are already - // stored reliably elsewhere - if (!isa(RD)) -return RD->getName(); - - SmallString<128> Name; - { + if (isa(RD)) { +SmallString<128> Name; llvm::raw_svector_ostream OS(Name); RD->getNameForDiagnostic(OS, CGM.getContext().getPrintingPolicy(), /*Qualified*/ false); + +// Copy this name on the side and use its reference. +return internString(Name); + } + + // quick optimization to avoid having to intern strings that are already + // stored reliably elsewhere + if (const IdentifierInfo *II = RD->getIdentifier()) +return II->getName(); + + // The CodeView printer in LLVM wants to see the names of unnamed types: it is + // used to reconstruct the fully qualified type names. + if (CGM.getCodeGenOpts().EmitCodeView) { +if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) { + assert(RD->getDeclContext() == D->getDeclContext() && + "Typedef should not be in another decl context!"); + assert(D->getDeclName().getAsIdentifierInfo() && + "Typedef was not named!"); + return D->getDeclName().getAsIdentifierInfo()->getName(); +} + +if (CGM.getLangOpts().CPlusPlus) { + StringRef Name; + + ASTContext &Context = CGM.getContext(); + if (const DeclaratorDecl *DD = Context.getDeclaratorForUnnamedTagDecl(RD)) +// Anonymous types without a name for linkage purposes have their +// declarator mangled in if they have one. +Name = DD->getName(); + else if (const TypedefNameDecl *TND = + Context.getTypedefNameForUnnamedTagDecl(RD)) +// Anonymous types without a name for linkage purposes have their +// associate typedef mangled in if they have one. +Name = TND->getName(); + + if (!Name.empty()) { +SmallString<256> UnnamedType("http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp?rev=274401&view=auto == --- cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp (added) +++ cfe/trunk/test/CodeGenCXX/debug-info-ms-anonymous-tag.cpp Fri Jul 1 18:12:54 2016 @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple x86_64-pc-win32 -debug-info-kind=limited -gcodeview %s -emit-llvm -o - | FileCheck %s + +typedef struct { +} test1; + +test1 gv1; +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "test1" + +struct { +} test2; +void *use_test2 = &test2; + +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "" + +typedef struct { +} *test3; +test3 gv3; +void *use_test3 = &gv3; + +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.
sfantao updated this revision to Diff 62567. sfantao added a comment. - Use StringRef instead of std::string, fix comments and mark class final. http://reviews.llvm.org/D21856 Files: include/clang/Driver/Action.h include/clang/Driver/ToolChain.h lib/Driver/Action.cpp lib/Driver/ToolChain.cpp lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -309,3 +309,37 @@ // CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp) // CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp) +/// ### + +/// Check separate compilation with offloading - bundling jobs construct +// RUN: %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUJOBS %s +// RUN: %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUJOBS-ST %s + +// Create host BC. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// Create target 1 object. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" + +// Create target 2 object. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" + +// Create host object and bundle. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "-x" "ir" "[[HOSTBC]]" +// CHK-BUJOBS: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]" +// CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" Index: lib/Driver/Tools.h === --- lib/Driver/Tools.h +++ lib/Driver/Tools.h @@ -135,6 +135,19 @@ const char *LinkingOutput) const override; }; +/// Offload bundler tool. +class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool { +public: + OffloadBundler(const ToolChain &TC) + : Too
Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.
sfantao updated this revision to Diff 62565. sfantao added a comment. - Add Ctor dropped by mistake in the previous diff. http://reviews.llvm.org/D21853 Files: include/clang/Driver/Action.h include/clang/Driver/Types.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/Types.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -255,4 +255,57 @@ // CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object // CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp) // CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp) -// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) \ No newline at end of file +// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) + +/// ### + +/// Check separate compilation with offloading - unbundling actions +// RUN: touch %t.i +// RUN: %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBACTIONS %s + +// CHK-UBACTIONS: 0: input, "somelib", object, (host-openmp) +// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp) +// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, cpp-output, (host-openmp) +// CHK-UBACTIONS: 3: compiler, {2}, ir, (host-openmp) +// CHK-UBACTIONS: 4: backend, {3}, assembler, (host-openmp) +// CHK-UBACTIONS: 5: assembler, {4}, object, (host-openmp) +// CHK-UBACTIONS: 6: linker, {0, 5}, image, (host-openmp) +// CHK-UBACTIONS: 7: input, "somelib", object, (device-openmp) +// CHK-UBACTIONS: 8: compiler, {2}, ir, (device-openmp) +// CHK-UBACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, ir +// CHK-UBACTIONS: 10: backend, {9}, assembler, (device-openmp) +// CHK-UBACTIONS: 11: assembler, {10}, object, (device-openmp) +// CHK-UBACTIONS: 12: linker, {7, 11}, image, (device-openmp) +// CHK-UBACTIONS: 13: input, "somelib", object, (device-openmp) +// CHK-UBACTIONS: 14: compiler, {2}, ir, (device-openmp) +// CHK-UBACTIONS: 15: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {14}, ir +// CHK-UBACTIONS: 16: backend, {15}, assembler, (device-openmp) +// CHK-UBACTIONS: 17: assembler, {16}, object, (device-openmp) +// CHK-UBACTIONS: 18: linker, {13, 17}, image, (device-openmp) +// CHK-UBACTIONS: 19: offload, "host-openmp (powerpc64le--linux)" {6}, "device-openmp (powerpc64le-ibm-linux-gnu)" {12}, "device-openmp (x86_64-pc-linux-gnu)" {18}, image + +/// ### + +/// Check separate compilation with offloading - unbundling/bundling actions +// RUN: touch %t.i +// RUN: %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBUACTIONS %s + +// CHK-UBUACTIONS: 0: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp) +// CHK-UBUACTIONS: 1: clang-offload-unbundler, {0}, cpp-output, (host-openmp) +// CHK-UBUACTIONS: 2: compiler, {1}, ir, (host-openmp) +// CHK-UBUACTIONS: 3: compiler, {1}, ir, (device-openmp) +// CHK-UBUACTIONS: 4: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {3}, ir +// CHK-UBUACTIONS: 5: backend, {4}, assembler, (device-openmp) +// CHK-UBUACTIONS: 6: assembler, {5}, object, (device-openmp) +// CHK-UBUACTIONS: 7: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {6}, object +// CHK-UBUACTIONS: 8: compiler, {1}, ir, (device-openmp) +// CHK-UBUACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir +// CHK-UBUACTIONS: 10: backend, {9}, assembler, (device-openmp) +// CHK-UBUACTIONS: 11: assembler, {10}, object, (device-openmp) +// CHK-UBUACTIONS: 12: offload, "device-openmp (x86_64-pc-linux-gnu)" {11}, object +// CHK-UBUACTIONS: 13: backend, {2}, assembler, (host-openmp) +// CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp) +// CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp) + Index: lib/Driver/Types.cpp === --- lib/Driver/Types.cpp +++ lib/Driver/Types.cpp @@ -153,6 +153,10 @@ } } +bool types::isSrcFile(ID Id) { + return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID; +} + types::ID types::lookupTypeForExtension(const char *Ext) { return llvm::StringSwitch(Ext) .Case("c", TY_C) Index: lib/Driver/ToolChain.cpp === --- lib/Driver/ToolChain.cpp +++ l
Re: [PATCH] D21453: Add support for attribute "overallocated"
ahatanak updated this revision to Diff 62560. ahatanak added a comment. The new patch defines a new attribute "flexible_array", which gets attached to the last array member of a struct. I made changes to clang to treat arrays marked "flexible_array" as C99's flexible array members where it made sense to do so. There are several places where C99's flexible arrays and "flexible_array" are treated differently. For example, the attribute doesn't change the way arguments are passed or values are returned from a function. It doesn't change objective-c's type encoding either. http://reviews.llvm.org/D21453 Files: include/clang/AST/Decl.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/AttributeList.h lib/AST/Decl.cpp lib/AST/ExprConstant.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenTBAA.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/object-size.c test/CodeGenCXX/catch-undef-behavior.cpp test/SemaCXX/flexible-array-attr.cpp Index: test/SemaCXX/flexible-array-attr.cpp === --- /dev/null +++ test/SemaCXX/flexible-array-attr.cpp @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +int g0[16] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fields}} + +struct S0 { + int a[4]; + int foo1() __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fields}} +}; + +struct S1 { + int a[4]; + int *b __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}} +}; + +struct S2 { + int a[4]; + int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to the last member of a struct}} + int c[4]; +}; + +struct S3 { + int a[4]; + int b[] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}} +}; + +struct S4 { + int a[4]; + int b[0] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to array members that have at least one element}} +}; + +template +struct S5 { + int a[4]; + int b[N] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}} +}; + +struct S6 { + int a[4]; + int b[1] __attribute__((flexible_array)); +}; + +struct S7 : S6 { // expected-error {{base class 'S6' has a flexible array member}} +}; + +struct S8 { + int a; + S6 s6; // expected-error {{struct with a member marked 'flexible_array' cannot be nested}} +}; + +union U0 { + int a[4]; + int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to members of structs or classes}} +}; + +int lambda_capture(S6 a) { // expected-note {{'a' declared here}} + return [a](){ return 0; }(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}} +} Index: test/CodeGenCXX/catch-undef-behavior.cpp === --- test/CodeGenCXX/catch-undef-behavior.cpp +++ test/CodeGenCXX/catch-undef-behavior.cpp @@ -327,6 +327,17 @@ return incomplete[n]; } +struct FlexibleArray { + int a1[4]; + int a2[4] __attribute__((flexible_array)); +}; + +// CHECK-LABEL: @_Z14flexible_array +int flexible_array(FlexibleArray *p, int n) { + // CHECK-NOT: call void @__ubsan_handle_out_of_bounds( + return p->a2[n]; +} + typedef __attribute__((ext_vector_type(4))) int V4I; // CHECK-LABEL: @_Z12vector_index int vector_index(V4I v, int n) { Index: test/CodeGen/object-size.c === --- test/CodeGen/object-size.c +++ test/CodeGen/object-size.c @@ -517,3 +517,19 @@ // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) gi = __builtin_object_size(&dsv[9].snd[0], 1); } + +struct S0 { + int a[16]; + int b[16] __attribute__((flexible_array)); +}; + +// CHECK-LABEL: @test32 +void test32() { + struct S0 *s0; + + // CHECK: store i32 64, i32* @gi + gi = __builtin_object_size(s0->a, 1); + + // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) + gi = __builtin_object_size(s0->b, 1); +} Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -457,6 +457,7 @@ void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) { VisitTagDecl(D); Record.push_back(D->hasFlexibleArrayMember()); + Record.push_back(D->hasFlexibleArrayAttr()); Record.push_back(D->isAnonymousStructOrUnion()); Record.push_back(D->hasObjec
Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries
timshen added a comment. ...and r274396 to remove all of the checks for symbolic labels, which are not generated by release builds, nor controlled by a runtime-flag. Repository: rL LLVM http://reviews.llvm.org/D20499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r274396 - Removes CHECKs for symbolic label names (as Debug Clang will generate).
Author: timshen Date: Fri Jul 1 17:50:00 2016 New Revision: 274396 URL: http://llvm.org/viewvc/llvm-project?rev=274396&view=rev Log: Removes CHECKs for symbolic label names (as Debug Clang will generate). Differential Revision: http://reviews.llvm.org/D20499 Modified: cfe/trunk/test/CodeGen/temporary-lifetime.cpp Modified: cfe/trunk/test/CodeGen/temporary-lifetime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/temporary-lifetime.cpp?rev=274396&r1=274395&r2=274396&view=diff == --- cfe/trunk/test/CodeGen/temporary-lifetime.cpp (original) +++ cfe/trunk/test/CodeGen/temporary-lifetime.cpp Fri Jul 1 17:50:00 2016 @@ -87,11 +87,14 @@ void Test3() { // CHECK-DTOR-LABEL: Test3 // CHECK-DTOR: call void @llvm.lifetime.start // CHECK-DTOR: call void @llvm.lifetime.start - // CHECK-DTOR: if.then: + + // if.then: // CHECK-DTOR: call void @llvm.lifetime.end - // CHECK-DTOR: cleanup{{.*}}: + + // cleanup: // CHECK-DTOR: call void @llvm.lifetime.end - // CHECK-DTOR: cleanup{{.*}}: + + // cleanup: // CHECK-DTOR: call void @llvm.lifetime.end // CHECK-DTOR: } const A &a = A{}; @@ -105,9 +108,11 @@ void Test3() { void Test4() { // CHECK-DTOR-LABEL: Test4 // CHECK-DTOR: call void @llvm.lifetime.start - // CHECK-DTOR: for.cond.cleanup: + + // for.cond.cleanup: // CHECK-DTOR: call void @llvm.lifetime.end - // CHECK-DTOR: for.body: + + // for.body: // CHECK-DTOR: } for (const A &a = A{}; a;) { Foo(a); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.
sfantao added a comment. Hi Alexey, Thanks for the review! Comment at: lib/Driver/Action.cpp:133 @@ +132,3 @@ +/// we assume 'host'. +std::string Action::getOffloadKindName(OffloadKind Kind) { + switch (Kind) { ABataev wrote: > 1. Maybe it is enough to return just StringRef, rather than std::string > 2. This can be made 'static' True, it can be a `StringRef`. This function is already marked static in its declaration. http://reviews.llvm.org/D21856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.
sfantao updated this revision to Diff 62561. sfantao marked 3 inline comments as done. sfantao added a comment. - Use StringRef instead of string and mark bundler tool as final. http://reviews.llvm.org/D21856 Files: include/clang/Driver/Action.h include/clang/Driver/ToolChain.h lib/Driver/Action.cpp lib/Driver/ToolChain.cpp lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -309,3 +309,37 @@ // CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp) // CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp) +/// ### + +/// Check separate compilation with offloading - bundling jobs construct +// RUN: %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUJOBS %s +// RUN: %clang -### -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUJOBS-ST %s + +// Create host BC. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// Create target 1 object. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" + +// Create target 2 object. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" + +// Create host object and bundle. +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "-x" "ir" "[[HOSTBC]]" +// CHK-BUJOBS: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTASM:.+\.s]]" "-x" "ir" "[[HOSTBC]]" +// CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "[[HOSTOBJ:.+\.o]]" "[[HOSTASM]]" +// CHK-BUJOBS-ST: clang-offload-bundler" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=[[RES:.+\.o]]" "-inputs=[[T1OBJ]],[[T2OBJ]],[[HOSTOBJ]]" Index: lib/Driver/Tools.h === --- lib/Driver/Tools.h +++ lib/Driver/Tools.h @@ -135,6 +135,19 @@ const char *LinkingOutput) const override; }; +/// Offload bundler tool. +class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool { +public: + OffloadBundler(
Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.
sfantao updated this revision to Diff 62558. sfantao marked 3 inline comments as done. sfantao added a comment. - Mark classes 'final' and set defalt initializers. http://reviews.llvm.org/D21853 Files: include/clang/Driver/Action.h include/clang/Driver/Types.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/Types.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -255,4 +255,57 @@ // CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object // CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp) // CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp) -// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) \ No newline at end of file +// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) + +/// ### + +/// Check separate compilation with offloading - unbundling actions +// RUN: touch %t.i +// RUN: %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBACTIONS %s + +// CHK-UBACTIONS: 0: input, "somelib", object, (host-openmp) +// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp) +// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, cpp-output, (host-openmp) +// CHK-UBACTIONS: 3: compiler, {2}, ir, (host-openmp) +// CHK-UBACTIONS: 4: backend, {3}, assembler, (host-openmp) +// CHK-UBACTIONS: 5: assembler, {4}, object, (host-openmp) +// CHK-UBACTIONS: 6: linker, {0, 5}, image, (host-openmp) +// CHK-UBACTIONS: 7: input, "somelib", object, (device-openmp) +// CHK-UBACTIONS: 8: compiler, {2}, ir, (device-openmp) +// CHK-UBACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, ir +// CHK-UBACTIONS: 10: backend, {9}, assembler, (device-openmp) +// CHK-UBACTIONS: 11: assembler, {10}, object, (device-openmp) +// CHK-UBACTIONS: 12: linker, {7, 11}, image, (device-openmp) +// CHK-UBACTIONS: 13: input, "somelib", object, (device-openmp) +// CHK-UBACTIONS: 14: compiler, {2}, ir, (device-openmp) +// CHK-UBACTIONS: 15: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {14}, ir +// CHK-UBACTIONS: 16: backend, {15}, assembler, (device-openmp) +// CHK-UBACTIONS: 17: assembler, {16}, object, (device-openmp) +// CHK-UBACTIONS: 18: linker, {13, 17}, image, (device-openmp) +// CHK-UBACTIONS: 19: offload, "host-openmp (powerpc64le--linux)" {6}, "device-openmp (powerpc64le-ibm-linux-gnu)" {12}, "device-openmp (x86_64-pc-linux-gnu)" {18}, image + +/// ### + +/// Check separate compilation with offloading - unbundling/bundling actions +// RUN: touch %t.i +// RUN: %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-UBUACTIONS %s + +// CHK-UBUACTIONS: 0: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp) +// CHK-UBUACTIONS: 1: clang-offload-unbundler, {0}, cpp-output, (host-openmp) +// CHK-UBUACTIONS: 2: compiler, {1}, ir, (host-openmp) +// CHK-UBUACTIONS: 3: compiler, {1}, ir, (device-openmp) +// CHK-UBUACTIONS: 4: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {3}, ir +// CHK-UBUACTIONS: 5: backend, {4}, assembler, (device-openmp) +// CHK-UBUACTIONS: 6: assembler, {5}, object, (device-openmp) +// CHK-UBUACTIONS: 7: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {6}, object +// CHK-UBUACTIONS: 8: compiler, {1}, ir, (device-openmp) +// CHK-UBUACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir +// CHK-UBUACTIONS: 10: backend, {9}, assembler, (device-openmp) +// CHK-UBUACTIONS: 11: assembler, {10}, object, (device-openmp) +// CHK-UBUACTIONS: 12: offload, "device-openmp (x86_64-pc-linux-gnu)" {11}, object +// CHK-UBUACTIONS: 13: backend, {2}, assembler, (host-openmp) +// CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp) +// CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp) + Index: lib/Driver/Types.cpp === --- lib/Driver/Types.cpp +++ lib/Driver/Types.cpp @@ -153,6 +153,10 @@ } } +bool types::isSrcFile(ID Id) { + return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID; +} + types::ID types::lookupTypeForExtension(const char *Ext) { return llvm::StringSwitch(Ext) .Case("c", TY_C) Index: lib/Driver/ToolChain.cpp
Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.
sfantao added a comment. Hi Alexey, Thanks for the review! Comment at: include/clang/Driver/Types.h:78 @@ +77,3 @@ + /// compilation phase is a preprocessor one. + bool isSrcFile(ID Id); + ABataev wrote: > 'const'? `isSrcFile` is not member of a class. It is an externally visible function of the namespace `types`, therefore can't mark it const. http://reviews.llvm.org/D21853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r274392 - C++14 init-capture: error out instead of crashing.
Author: mren Date: Fri Jul 1 17:27:16 2016 New Revision: 274392 URL: http://llvm.org/viewvc/llvm-project?rev=274392&view=rev Log: C++14 init-capture: error out instead of crashing. When we have template arguments, we have a function and a pattern, the variable in init-capture belongs to the pattern decl when checking if the lhs of "max = current" is modifiable: auto find = [max = init](auto current) { max = current; }; In function isReferenceToNonConstCapture, we handle the case where the decl context for the variable is not part of the current context. Instead of crashing, we emit an error message: cannot assign to a variable captured by copy in a non-mutable lambda rdar://26997922 Modified: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=274392&r1=274391&r2=274392&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul 1 17:27:16 2016 @@ -9653,7 +9653,16 @@ static NonConstCaptureKind isReferenceTo // Decide whether the first capture was for a block or a lambda. DeclContext *DC = S.CurContext, *Prev = nullptr; - while (DC != var->getDeclContext()) { + // Decide whether the first capture was for a block or a lambda. + while (DC) { +// For init-capture, it is possible that the variable belongs to the +// template pattern of the current context. +if (auto *FD = dyn_cast(DC)) + if (var->isInitCapture() && + FD->getTemplateInstantiationPattern() == var->getDeclContext()) +break; +if (DC == var->getDeclContext()) + break; Prev = DC; DC = DC->getParent(); } Modified: cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp?rev=274392&r1=274391&r2=274392&view=diff == --- cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp Fri Jul 1 17:27:16 2016 @@ -196,3 +196,13 @@ namespace N3922 { auto a = [x{X()}] { return x.n; }; // ok auto b = [x = {X()}] {}; // expected-error{{}} } + +namespace init_capture_non_mutable { +void test(double weight) { + double init; + auto find = [max = init](auto current) { +max = current; // expected-error{{cannot assign to a variable captured by copy in a non-mutable lambda}} + }; + find(weight); // expected-note {{in instantiation of function template specialization}} +} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21852: [Driver][OpenMP] Update actions builder to create bundling action when necessary.
sfantao updated this revision to Diff 62553. sfantao added a comment. - Rebase. - Fix format. http://reviews.llvm.org/D21852 Files: include/clang/Driver/Action.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -228,3 +228,31 @@ // CHK-LKS: } // CHK-LKS: } // CHK-LKS: INSERT BEFORE .data + + +/// ### + +/// Check separate compilation with offloading - bundling actions +// RUN: %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-BUACTIONS %s + +// CHK-BUACTIONS: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp) +// CHK-BUACTIONS: 1: preprocessor, {0}, cpp-output, (host-openmp) +// CHK-BUACTIONS: 2: compiler, {1}, ir, (host-openmp) +// CHK-BUACTIONS: 3: input, "[[INPUT]]", c, (device-openmp) +// CHK-BUACTIONS: 4: preprocessor, {3}, cpp-output, (device-openmp) +// CHK-BUACTIONS: 5: compiler, {4}, ir, (device-openmp) +// CHK-BUACTIONS: 6: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {5}, ir +// CHK-BUACTIONS: 7: backend, {6}, assembler, (device-openmp) +// CHK-BUACTIONS: 8: assembler, {7}, object, (device-openmp) +// CHK-BUACTIONS: 9: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, object +// CHK-BUACTIONS: 10: input, "[[INPUT]]", c, (device-openmp) +// CHK-BUACTIONS: 11: preprocessor, {10}, cpp-output, (device-openmp) +// CHK-BUACTIONS: 12: compiler, {11}, ir, (device-openmp) +// CHK-BUACTIONS: 13: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {12}, ir +// CHK-BUACTIONS: 14: backend, {13}, assembler, (device-openmp) +// CHK-BUACTIONS: 15: assembler, {14}, object, (device-openmp) +// CHK-BUACTIONS: 16: offload, "device-openmp (x86_64-pc-linux-gnu)" {15}, object +// CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp) +// CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp) +// CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp) \ No newline at end of file Index: lib/Driver/ToolChain.cpp === --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -262,6 +262,10 @@ case Action::VerifyPCHJobClass: case Action::BackendJobClass: return getClang(); + + case Action::OffloadBundlingJobClass: +// FIXME: Add a tool for the bundling actions. +return nullptr; } llvm_unreachable("Invalid tool kind."); Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1549,6 +1549,9 @@ /// found. virtual bool initialize() { return false; } +/// Return true if the builder can use bundling/unbundling. +virtual bool canUseBundlerUnbundler() const { return false; } + /// Return true if this builder is valid. We have a valid builder if we have /// associated device tool chains. bool isValid() { return !ToolChains.empty(); } @@ -1870,6 +1873,26 @@ return ABRT_Success; } +void appendTopLevelActions(ActionList &AL) override { + if (OpenMPDeviceActions.empty()) +return; + + // We should always have an action for each input. + assert(OpenMPDeviceActions.size() == ToolChains.size() && + "Number of OpenMP actions and toolchains do not match."); + + // Append all device actions followed by the proper offload action. + auto TI = ToolChains.begin(); + for (auto *A : OpenMPDeviceActions) { +OffloadAction::DeviceDependences Dep; +Dep.add(*A, **TI, /*BoundArch=*/nullptr, Action::OFK_OpenMP); +AL.push_back(C.MakeAction(Dep, A->getType())); +++TI; + } + // We no longer need the action stored in this builder. + OpenMPDeviceActions.clear(); +} + void appendLinkDependences(OffloadAction::DeviceDependences &DA) override { assert(ToolChains.size() == DeviceLinkerInputs.size() && "Toolchains and linker inputs sizes do not match."); @@ -1896,6 +1919,11 @@ DeviceLinkerInputs.resize(ToolChains.size()); return false; } + +bool canUseBundlerUnbundler() const override { + // OpenMP should use bundled files whenever possible. + return true; +} }; /// @@ -1905,6 +1933,9 @@ /// Specialized builders being used by this offloading action builder. SmallVector SpecializedBuilders; + /// Flag set to true if all valid builders allow file bundling/unbundling. + bool CanUseBundler; + public: OffloadingActionBuilder(Compilation &C, DerivedArgList &Args,
Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.
sfantao added a comment. Hi Alexey, Thanks for the review! Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:345 @@ +344,3 @@ + /// return the triple by reference. + bool isOffloadSection(SectionRef CurSection, StringRef &OffloadTriple) { +StringRef SectionName; ABataev wrote: > 'const'? or 'static'? It can be static. Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:450 @@ +449,3 @@ + BitcodeFileName)) + llvm_unreachable("Error trying to create temporary file!"); + ABataev wrote: > Not sure that this a good solution to crash the compiler in this case. I > think it must exit gracefully. Ok, replaced the unreachable code with logic to emit an error and exist the tool. Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:468 @@ +467,3 @@ + sys::fs::remove(BitcodeFileName); + llvm_unreachable("Can't find clang in path!"); +} ABataev wrote: > Again, maybe just emit an error an exit? Emitting an error now. http://reviews.llvm.org/D21851 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.
sfantao updated this revision to Diff 62550. sfantao marked 6 inline comments as done. sfantao added a comment. - Remove \brief and return errors instead of crashing when temporary tiles can't be created. http://reviews.llvm.org/D21851 Files: test/Driver/clang-offload-bundler.c tools/clang-offload-bundler/ClangOffloadBundler.cpp Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp === --- tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -75,14 +75,23 @@ /// Magic string that marks the existence of offloading data. #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__" +/// Path to the current binary. +static std::string BundlerExecutable; + /// Obtain the offload kind and real machine triple out of the target /// information specified by the user. static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind, StringRef &Triple) { auto KindTriplePair = Target.split('-'); OffloadKind = KindTriplePair.first; Triple = KindTriplePair.second; } +static StringRef getTriple(StringRef Target) { + StringRef OffloadKind; + StringRef Triple; + getOffloadKindAndTriple(Target, OffloadKind, Triple); + return Triple; +} static bool hasHostKind(StringRef Target) { StringRef OffloadKind; StringRef Triple; @@ -113,37 +122,37 @@ /// \a OS. virtual void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) = 0; /// Write the marker that closes a bundle for the triple \a TargetTriple to \a - /// OS. - virtual void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0; + /// OS. Return true if any error was found. + virtual bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0; /// Write the bundle from \a Input into \a OS. virtual void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0; FileHandler() {} virtual ~FileHandler() {} }; -// Handler for binary files. The bundled file will have the following format -// (all integers are stored in little-endian format): -// -// "OFFLOAD_BUNDLER_MAGIC_STR" (ASCII encoding of the string) -// -// NumberOfOffloadBundles (8-byte integer) -// -// OffsetOfBundle1 (8-byte integer) -// SizeOfBundle1 (8-byte integer) -// NumberOfBytesInTripleOfBundle1 (8-byte integer) -// TripleOfBundle1 (byte length defined before) -// -// ... -// -// OffsetOfBundleN (8-byte integer) -// SizeOfBundleN (8-byte integer) -// NumberOfBytesInTripleOfBundleN (8-byte integer) -// TripleOfBundleN (byte length defined before) -// -// Bundle1 -// ... -// BundleN +/// Handler for binary files. The bundled file will have the following format +/// (all integers are stored in little-endian format): +/// +/// "OFFLOAD_BUNDLER_MAGIC_STR" (ASCII encoding of the string) +/// +/// NumberOfOffloadBundles (8-byte integer) +/// +/// OffsetOfBundle1 (8-byte integer) +/// SizeOfBundle1 (8-byte integer) +/// NumberOfBytesInTripleOfBundle1 (8-byte integer) +/// TripleOfBundle1 (byte length defined before) +/// +/// ... +/// +/// OffsetOfBundleN (8-byte integer) +/// SizeOfBundleN (8-byte integer) +/// NumberOfBytesInTripleOfBundleN (8-byte integer) +/// TripleOfBundleN (byte length defined before) +/// +/// Bundle1 +/// ... +/// BundleN /// Read 8-byte integers to/from a buffer in little-endian format. static uint64_t Read8byteIntegerFromBuffer(StringRef Buffer, size_t pos) { @@ -300,24 +309,241 @@ } } void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) {} - void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {} + bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) { +return false; + } void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) { OS.write(Input.getBufferStart(), Input.getBufferSize()); } BinaryFileHandler() : FileHandler() {} ~BinaryFileHandler() {} }; -// Handler for text files. The bundled file will have the following format. -// -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ triple" -// Bundle 1 -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ triple" -// ... -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ triple" -// Bundle N -// "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ triple" +/// Handler for object files. The bundles are organized by sections with a +/// designated name. +/// +/// In order to bundle we create an IR file with the content of each section and +/// use incremental linking to produce the resulting object. We also add section +/// with a single byte to state the name of the component the main object file +/// (the one we are bundling into) refers to. +/// +/// To unbundle, we use just copy the contents of the designated section. If the +/// requested bundle refer to the main object file, we just copy it with no +/// changes. +class ObjectFileHandler final : public FileHandler { + + /// The object file we are currently dealing with. +
Re: [PATCH] D21334: Add TargetInfo for 32-bit and 64-bit RenderScript
echristo added a comment. In http://reviews.llvm.org/D21334#472548, @pirama wrote: > Reformatted with clang-format for just the parts I added. I ignored > clang-format-suggested changes in code unrelated to this patch. Yep. > Is there a policy or practise on periodically fixing format-related issues? > If > not, I can format this file in an one-off basis in a separate patch. In general just format the lines you change and surrounding ones if it makes sense to reflow a function. Thanks! -eric http://reviews.llvm.org/D21334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries
timshen added a comment. Also committed r274387 to remove unnecessary CHECks. It seems to cause problems in certain platforms. Repository: rL LLVM http://reviews.llvm.org/D20499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r274387 - Remove unncessary CHECKs from r274385
Author: timshen Date: Fri Jul 1 16:16:58 2016 New Revision: 274387 URL: http://llvm.org/viewvc/llvm-project?rev=274387&view=rev Log: Remove unncessary CHECKs from r274385 Modified: cfe/trunk/test/CodeGen/temporary-lifetime.cpp Modified: cfe/trunk/test/CodeGen/temporary-lifetime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/temporary-lifetime.cpp?rev=274387&r1=274386&r2=274387&view=diff == --- cfe/trunk/test/CodeGen/temporary-lifetime.cpp (original) +++ cfe/trunk/test/CodeGen/temporary-lifetime.cpp Fri Jul 1 16:16:58 2016 @@ -85,7 +85,6 @@ void Test2() { void Test3() { // CHECK-DTOR-LABEL: Test3 - // CHECK-DTOR: entry: // CHECK-DTOR: call void @llvm.lifetime.start // CHECK-DTOR: call void @llvm.lifetime.start // CHECK-DTOR: if.then: @@ -105,7 +104,6 @@ void Test3() { void Test4() { // CHECK-DTOR-LABEL: Test4 - // CHECK-DTOR: entry: // CHECK-DTOR: call void @llvm.lifetime.start // CHECK-DTOR: for.cond.cleanup: // CHECK-DTOR: call void @llvm.lifetime.end ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation
davidxl added inline comments. Comment at: include/clang/Driver/Options.td:507 @@ +506,3 @@ +Group, Flags<[DriverOption]>, MetaVarName<"">, +HelpText<"Set to be the default profile output file (overridden by LLVM_PROFILE_FILE env var)">; +def fpgo_apply_EQ : Joined<["-"], "fpgo-apply=">, Why is it called 'default' output? The default output is the one used why user does not specify any name. Why not just -fpgo-train-output=... ? Comment at: lib/Driver/Tools.cpp:3560 @@ +3559,3 @@ +if (PGOTrainArg->getOption().matches(options::OPT_fpgo_train_EQ)) { + if (StringRef(PGOTrainArg->getValue()) == "source-cfg") +CmdArgs.push_back("-fprofile-instrument=clang"); I think it is better to make the selector 'source' vs 'cfg'. -fpgo-train=source -fpgo-train=cfg Repository: rL LLVM http://reviews.llvm.org/D21823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries
This revision was automatically updated to reflect the committed changes. timshen marked an inline comment as done. Closed by commit rL274385: [Temporary, Lifetime] Add lifetime marks for temporaries (authored by timshen). Changed prior to commit: http://reviews.llvm.org/D20499?vs=62433&id=62543#toc Repository: rL LLVM http://reviews.llvm.org/D20499 Files: cfe/trunk/lib/CodeGen/CGCleanup.cpp cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/EHScopeStack.h cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp cfe/trunk/test/CodeGen/temporary-lifetime.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp Index: cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp === --- cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp +++ cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 %s -fexceptions -fcxx-exceptions -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck %s + +// lifetime.end should be invoked even if the destructor doesn't run due to an +// exception thrown from previous ctor call. + +struct A { A(); ~A(); }; +A Baz(const A&); + +void Test1() { + // CHECK-LABEL: @_Z5Test1v( + // CHECK: getelementptr + // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* [[TMP:[^ ]+]]) + // CHECK-NEXT: getelementptr + // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* [[TMP1:[^ ]+]]) + + // Normal exit + // CHECK: call void @llvm.lifetime.end(i64 1, i8* [[TMP1]]) + // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* [[TMP]]) + + // Exception exit + // CHECK: call void @llvm.lifetime.end(i64 1, i8* [[TMP1]]) + // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* [[TMP]]) + Baz(Baz(A())); +} Index: cfe/trunk/test/CodeGen/temporary-lifetime.cpp === --- cfe/trunk/test/CodeGen/temporary-lifetime.cpp +++ cfe/trunk/test/CodeGen/temporary-lifetime.cpp @@ -0,0 +1,165 @@ +// RUN: %clang_cc1 %s -std=c++11 -O1 -DWITH_DTOR -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-DTOR %s +// RUN: %clang_cc1 %s -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-NO-DTOR %s + +struct A { + A(); +#ifdef WITH_DTOR + ~A(); +#endif + char a[1024]; + operator bool() const; +}; + +template +void Foo(T &&); + +template +void Bar(T &&); + +template +T Baz(); + +void Test1() { + // CHECK-DTOR-LABEL: Test1 + // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]]) + // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]]) + // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_ + // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]]) + // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]]) + // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]]) + // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]]) + // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_ + // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]]) + // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]]) + // CHECK-DTOR: } + + // CHECK-NO-DTOR-LABEL: Test1 + // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]]) + // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]]) + // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_ + // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]]) + // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]]) + // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]]) + // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_ + // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]]) + // CHECK-NO-DTOR: } + { +const A &a = A{}; +Foo(a); + } + { +const A &a = A{}; +Foo(a); + } +} + +void Test2() { + // CHECK-DTOR-LABEL: Test2 + // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]]) + // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]]) + // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_ + // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]]) + // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]]) + // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_ + // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]]) + // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]]) + // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]]) + // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]]) + // CHECK-DTOR: } + + // CHECK-NO-DTOR-LABEL: Test2 + // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]]) + // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]]) + // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvO
r274385 - [Temporary, Lifetime] Add lifetime marks for temporaries
Author: timshen Date: Fri Jul 1 16:08:47 2016 New Revision: 274385 URL: http://llvm.org/viewvc/llvm-project?rev=274385&view=rev Log: [Temporary, Lifetime] Add lifetime marks for temporaries With all MaterializeTemporaryExprs coming with a ExprWithCleanups, it's easy to add correct lifetime.end marks into the right RunCleanupsScope. Differential Revision: http://reviews.llvm.org/D20499 Added: cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp cfe/trunk/test/CodeGen/temporary-lifetime.cpp Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/EHScopeStack.h cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=274385&r1=274384&r2=274385&view=diff == --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Fri Jul 1 16:08:47 2016 @@ -188,6 +188,7 @@ void *EHScopeStack::pushCleanup(CleanupK bool IsNormalCleanup = Kind & NormalCleanup; bool IsEHCleanup = Kind & EHCleanup; bool IsActive = !(Kind & InactiveCleanup); + bool IsLifetimeMarker = Kind & LifetimeMarker; EHCleanupScope *Scope = new (Buffer) EHCleanupScope(IsNormalCleanup, IsEHCleanup, @@ -200,6 +201,8 @@ void *EHScopeStack::pushCleanup(CleanupK InnermostNormalCleanup = stable_begin(); if (IsEHCleanup) InnermostEHScope = stable_begin(); + if (IsLifetimeMarker) +Scope->setLifetimeMarker(); return Scope->getCleanupBuffer(); } Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=274385&r1=274384&r2=274385&view=diff == --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Jul 1 16:08:47 2016 @@ -529,19 +529,6 @@ namespace { CGF.EmitCall(FnInfo, CleanupFn, ReturnValueSlot(), Args); } }; - - /// A cleanup to call @llvm.lifetime.end. - class CallLifetimeEnd final : public EHScopeStack::Cleanup { -llvm::Value *Addr; -llvm::Value *Size; - public: -CallLifetimeEnd(Address addr, llvm::Value *size) - : Addr(addr.getPointer()), Size(size) {} - -void Emit(CodeGenFunction &CGF, Flags flags) override { - CGF.EmitLifetimeEnd(Size, Addr); -} - }; } // end anonymous namespace /// EmitAutoVarWithLifetime - Does the setup required for an automatic @@ -1406,13 +1393,10 @@ void CodeGenFunction::EmitAutoVarCleanup // Make sure we call @llvm.lifetime.end. This needs to happen // *last*, so the cleanup needs to be pushed *first*. - if (emission.useLifetimeMarkers()) { -EHStack.pushCleanup(NormalAndEHCleanup, + if (emission.useLifetimeMarkers()) +EHStack.pushCleanup(NormalEHLifetimeMarker, emission.getAllocatedAddress(), emission.getSizeForLifetimeMarkers()); -EHCleanupScope &cleanup = cast(*EHStack.begin()); -cleanup.setLifetimeMarker(); - } // Check the type for a cleanup. if (QualType::DestructionKind dtorKind = D.getType().isDestructedType()) Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=274385&r1=274384&r2=274385&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Jul 1 16:08:47 2016 @@ -11,13 +11,14 @@ // //===--===// -#include "CodeGenFunction.h" #include "CGCXXABI.h" #include "CGCall.h" +#include "CGCleanup.h" #include "CGDebugInfo.h" #include "CGObjCRuntime.h" #include "CGOpenMPRuntime.h" #include "CGRecordLayout.h" +#include "CodeGenFunction.h" #include "CodeGenModule.h" #include "TargetInfo.h" #include "clang/AST/ASTContext.h" @@ -423,6 +424,23 @@ EmitMaterializeTemporaryExpr(const Mater EmitAnyExprToMem(E, Object, Qualifiers(), /*IsInit*/true); } } else { +switch (M->getStorageDuration()) { +case SD_Automatic: +case SD_FullExpression: + if (auto *Size = EmitLifetimeStart( + CGM.getDataLayout().getTypeAllocSize(Object.getElementType()), + Object.getPointer())) { +if (M->getStorageDuration() == SD_Automatic) + pushCleanupAfterFullExpr(NormalEHLifetimeMarker, +Object, Size); +else + pushFullExprCleanup(NormalEHLifetimeMarker, Object, + Size); + } + break; +default: + b
Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool
sfantao updated this revision to Diff 62540. sfantao added a comment. - Remove \brief when not needed. http://reviews.llvm.org/D13909 Files: test/CMakeLists.txt test/Driver/clang-offload-bundler.c tools/CMakeLists.txt tools/clang-offload-bundler/CMakeLists.txt tools/clang-offload-bundler/ClangOffloadBundler.cpp Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp === --- /dev/null +++ tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -0,0 +1,670 @@ +//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +/// +/// \file +/// \brief This file implements a clang-offload-bundler that bundles different +/// files that relate with the same source code but different targets into a +/// single one. Also the implements the opposite functionality, i.e. unbundle +/// files previous created by this tool. +/// +//===--===// + +#include "clang/Basic/FileManager.h" +#include "clang/Basic/Version.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" +#include "llvm/Object/Binary.h" +#include "llvm/Object/ELFObjectFile.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/Signals.h" + +using namespace llvm; +using namespace llvm::object; + +static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden); + +// Mark all our options with this category, everything else (except for -version +// and -help) will be hidden. +static cl::OptionCategory +ClangOffloadBundlerCategory("clang-offload-bundler options"); + +static cl::list +InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore, + cl::desc("[,...]"), + cl::cat(ClangOffloadBundlerCategory)); +static cl::list +OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore, +cl::desc("[,...]"), +cl::cat(ClangOffloadBundlerCategory)); +static cl::list +TargetNames("targets", cl::CommaSeparated, cl::OneOrMore, +cl::desc("[-,...]"), +cl::cat(ClangOffloadBundlerCategory)); +static cl::opt +FilesType("type", cl::Required, + cl::desc("Type of the files to be bundled/unbundled.\n" + "Current supported types are:\n" + " i - cpp-output\n" + " ii - c++-cpp-output\n" + " ll - llvm\n" + " bc - llvm-bc\n" + " s - assembler\n" + " o - object\n" + " gch - precompiled-header\n" + " ast - clang AST file"), + cl::cat(ClangOffloadBundlerCategory)); +static cl::opt +Unbundle("unbundle", + cl::desc("Unbundle bundled file into several output files.\n"), + cl::init(false), cl::cat(ClangOffloadBundlerCategory)); + +/// Magic string that marks the existence of offloading data. +#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__" + +/// Obtain the offload kind and real machine triple out of the target +/// information specified by the user. +static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind, +StringRef &Triple) { + auto KindTriplePair = Target.split('-'); + OffloadKind = KindTriplePair.first; + Triple = KindTriplePair.second; +} +static bool hasHostKind(StringRef Target) { + StringRef OffloadKind; + StringRef Triple; + getOffloadKindAndTriple(Target, OffloadKind, Triple); + return OffloadKind == "host"; +} + +/// Generic file handler interface. +class FileHandler { +public: + /// Update the file handler with information from the header of the bundled + /// file + virtual void ReadHeader(MemoryBuffer &Input) = 0; + /// Read the marker of the next bundled to be read in the file. The triple of + /// the target associated with that bundled is returned. An empty string is + /// returned if there are no more bundles to be read. + virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0; + /// Read the marker that closes the current bundle. + virtual void ReadBundleEnd(MemoryBuffer &Input) = 0; + /// Read the current bundle and write the result into the stream \a OS. + virtual void ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0; + + /// Write the header of the bundled fi
Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool
sfantao added a comment. Hi Alexey, Thanks for the review! Comment at: test/Driver/clang-offload-bundler.c:14 @@ +13,3 @@ +// +// RUN: touch %t.empty + ABataev wrote: > Hmm, will it work on Windows? Maybe it is better just to add an empty test > file? I see many other tests in clang using it. There used to be a directive `//requires-shell` but I don't think that is being used now. Should I go ahead and create an empty file? Unfortunately, it is not easy for me to try these things on Windows. Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:477-478 @@ +476,4 @@ + auto Input = InputBuffers.begin(); + for (auto Triple = TargetNames.begin(); Triple < TargetNames.end(); + ++Triple, ++Input) { +FH.get()->WriteBundleStart(OutputFile, *Triple); ABataev wrote: > for (auto &Triple : TargetNames) > Ok, moved the iterator `Input` to the end of the loop body. Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:513-514 @@ +512,4 @@ + auto Output = OutputFileNames.begin(); + for (auto Triple = TargetNames.begin(); Triple < TargetNames.end(); + ++Triple, ++Output) +Worklist[*Triple] = *Output; ABataev wrote: > for (auto &Triple : TargetNames) Ok, moved `Output` iterator to the bottom of the loop body. http://reviews.llvm.org/D13909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool
sfantao updated this revision to Diff 62538. sfantao marked 9 inline comments as done. sfantao added a comment. - Merge branch 'master' into patch-D13909 - Remove unecessary returns and fix iterators. http://reviews.llvm.org/D13909 Files: test/CMakeLists.txt test/Driver/clang-offload-bundler.c tools/CMakeLists.txt tools/clang-offload-bundler/CMakeLists.txt tools/clang-offload-bundler/ClangOffloadBundler.cpp Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp === --- /dev/null +++ tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -0,0 +1,671 @@ +//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +/// +/// \file +/// \brief This file implements a clang-offload-bundler that bundles different +/// files that relate with the same source code but different targets into a +/// single one. Also the implements the opposite functionality, i.e. unbundle +/// files previous created by this tool. +/// +//===--===// + +#include "clang/Basic/FileManager.h" +#include "clang/Basic/Version.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" +#include "llvm/Object/Binary.h" +#include "llvm/Object/ELFObjectFile.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/Signals.h" + +using namespace llvm; +using namespace llvm::object; + +static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden); + +// Mark all our options with this category, everything else (except for -version +// and -help) will be hidden. +static cl::OptionCategory +ClangOffloadBundlerCategory("clang-offload-bundler options"); + +static cl::list +InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore, + cl::desc("[,...]"), + cl::cat(ClangOffloadBundlerCategory)); +static cl::list +OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore, +cl::desc("[,...]"), +cl::cat(ClangOffloadBundlerCategory)); +static cl::list +TargetNames("targets", cl::CommaSeparated, cl::OneOrMore, +cl::desc("[-,...]"), +cl::cat(ClangOffloadBundlerCategory)); +static cl::opt +FilesType("type", cl::Required, + cl::desc("Type of the files to be bundled/unbundled.\n" + "Current supported types are:\n" + " i - cpp-output\n" + " ii - c++-cpp-output\n" + " ll - llvm\n" + " bc - llvm-bc\n" + " s - assembler\n" + " o - object\n" + " gch - precompiled-header\n" + " ast - clang AST file"), + cl::cat(ClangOffloadBundlerCategory)); +static cl::opt +Unbundle("unbundle", + cl::desc("Unbundle bundled file into several output files.\n"), + cl::init(false), cl::cat(ClangOffloadBundlerCategory)); + +/// \brief Magic string that marks the existence of offloading data. +#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__" + +/// \brief Obtain the offload kind and real machine triple out of the target +/// information specified by the user. +static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind, +StringRef &Triple) { + auto KindTriplePair = Target.split('-'); + OffloadKind = KindTriplePair.first; + Triple = KindTriplePair.second; +} +static bool hasHostKind(StringRef Target) { + StringRef OffloadKind; + StringRef Triple; + getOffloadKindAndTriple(Target, OffloadKind, Triple); + return OffloadKind == "host"; +} + +/// \brief Generic file handler interface. +class FileHandler { +public: + /// \brief Update the file handler with information from the header of the + /// bundled file + virtual void ReadHeader(MemoryBuffer &Input) = 0; + /// \brief Read the marker of the next bundled to be read in the file. The + /// triple of the target associated with that bundled is returned. An empty + /// string is returned if there are no more bundles to be read. + virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0; + /// \brief Read the marker that closes the current bundle. + virtual void ReadBundleEnd(MemoryBuffer &Input) = 0; + /// \brief Read the current bundle and write the
[PATCH] D21936: [clang-tidy] UnnecessaryValueParamCheck - only warn for virtual methods
flx created this revision. flx added reviewers: alexfh, sbenza. flx added a subscriber: cfe-commits. flx set the repository for this revision to rL LLVM. As changing virtual methods could break method overrides disable applying the fix and just warn. Repository: rL LLVM http://reviews.llvm.org/D21936 Files: clang-tidy/performance/UnnecessaryValueParamCheck.cpp test/clang-tidy/performance-unnecessary-value-param.cpp Index: test/clang-tidy/performance-unnecessary-value-param.cpp === --- test/clang-tidy/performance-unnecessary-value-param.cpp +++ test/clang-tidy/performance-unnecessary-value-param.cpp @@ -224,3 +224,16 @@ ExpensiveToCopyType B; B = A; } + +struct VirtualMethodWarningOnly { + virtual void methodWithExpensiveValueParam(ExpensiveToCopyType T) {} + // CHECK-MESSAGES: [[@LINE-1]]:66: warning: the parameter 'T' is copied + // CHECK-FIXES: virtual void methodWithExpensiveValueParam(ExpensiveToCopyType T) {} + virtual ~VirtualMethodWarningOnly() {} +}; + +struct PositiveNonVirualMethod { + void method(const ExpensiveToCopyType T) {} + // CHECK-MESSAGES: [[@LINE-1]]:41: warning: the const qualified parameter 'T' is copied + // CHECK-FIXES: void method(const ExpensiveToCopyType& T) {} +}; Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp === --- clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -118,8 +118,10 @@ "invocation but only used as a const reference; " "consider making it a const reference") << paramNameOrIndex(Param->getName(), Index); - // Do not propose fixes in macros since we cannot place them correctly. - if (Param->getLocStart().isMacroID()) + // Do not propose fixes in macros since we cannot place them correctly, or if + // function is virtual as it might break overrides. + const auto *Method = llvm::dyn_cast(Function); + if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual())) return; for (const auto *FunctionDecl = Function; FunctionDecl != nullptr; FunctionDecl = FunctionDecl->getPreviousDecl()) { Index: test/clang-tidy/performance-unnecessary-value-param.cpp === --- test/clang-tidy/performance-unnecessary-value-param.cpp +++ test/clang-tidy/performance-unnecessary-value-param.cpp @@ -224,3 +224,16 @@ ExpensiveToCopyType B; B = A; } + +struct VirtualMethodWarningOnly { + virtual void methodWithExpensiveValueParam(ExpensiveToCopyType T) {} + // CHECK-MESSAGES: [[@LINE-1]]:66: warning: the parameter 'T' is copied + // CHECK-FIXES: virtual void methodWithExpensiveValueParam(ExpensiveToCopyType T) {} + virtual ~VirtualMethodWarningOnly() {} +}; + +struct PositiveNonVirualMethod { + void method(const ExpensiveToCopyType T) {} + // CHECK-MESSAGES: [[@LINE-1]]:41: warning: the const qualified parameter 'T' is copied + // CHECK-FIXES: void method(const ExpensiveToCopyType& T) {} +}; Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp === --- clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -118,8 +118,10 @@ "invocation but only used as a const reference; " "consider making it a const reference") << paramNameOrIndex(Param->getName(), Index); - // Do not propose fixes in macros since we cannot place them correctly. - if (Param->getLocStart().isMacroID()) + // Do not propose fixes in macros since we cannot place them correctly, or if + // function is virtual as it might break overrides. + const auto *Method = llvm::dyn_cast(Function); + if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual())) return; for (const auto *FunctionDecl = Function; FunctionDecl != nullptr; FunctionDecl = FunctionDecl->getPreviousDecl()) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver
jvesely added a subscriber: jvesely. Comment at: cfe/trunk/include/clang/Driver/Options.td:381 @@ +380,3 @@ +def cl_unsafe_math_optimizations : Flag<["-"], "cl-unsafe-math-optimizations">, Group, Flags<[CC1Option]>, + HelpText<"OpenCL only. Allow unsafe floating-point optimizations. Also implies -cl-no-signed-zeros and -cl-mad-enable.">; +def cl_fast_relaxed_math : Flag<["-"], "cl-fast-relaxed-math">, Group, Flags<[CC1Option]>, It'd be nice if you added cl-no-signed-zeros since it's mentioned here Repository: rL LLVM http://reviews.llvm.org/D21031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation
jakev added a comment. In http://reviews.llvm.org/D21823#470516, @xur wrote: > (1) It seems the original options of -fprofile-instr-generate and > -fprofile-instr-use will be kept. Is so, what is the guideline to use these > two sets of options. Sorry I'm not sure I understand what you're asking, but it's my understanding that we would simply detail the lack of interoperability between the existing set of flags and the ones added by this patch. > Also, we need some documentations for the new user-visible > options. I'm happy to add some info to the Clang UserManual in this patch if everyone is happy with the flag names. > (2) One difference b/w -fprofile-instr-generate/-fprofile-instr-use and the > new options is -fpgo-train={source-cfg | optimizer-cfg} can coexist with > -fpgo-apply=. I don't think they work as intended in current > implementation. I would suggest to not allow it. Sure, I've updated the patch to not allow this. Repository: rL LLVM http://reviews.llvm.org/D21823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation
jakev updated this revision to Diff 62527. jakev added a comment. Don't allow `-fpgo-train` and `-fpgo-apply` together. Add `-fpgo-train-default-output=*` to set the default profile output file. Repository: rL LLVM http://reviews.llvm.org/D21823 Files: include/clang/Driver/Options.td lib/Driver/ToolChain.cpp lib/Driver/Tools.cpp test/Driver/clang_f_opts.c Index: test/Driver/clang_f_opts.c === --- test/Driver/clang_f_opts.c +++ test/Driver/clang_f_opts.c @@ -97,23 +97,42 @@ // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s +// RUN: %clang -### -S -fpgo-train=source-cfg %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s +// RUN: %clang -### -S -fpgo-train=optimizer-cfg %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s +// RUN: %clang -### -S -fpgo-train-default-output=file %s 2>&1 | FileCheck -check-prefix=CHECK-DEFAULT-AND-TRAIN %s +// RUN: %clang -### -S -fpgo-train=source-cfg -fpgo-train-default-output=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s +// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fpgo-train-default-output=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s +// RUN: %clang -### -S -fpgo-train=source-cfg -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s +// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s +// RUN: %clang -### -S -fpgo-train=source-cfg -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-TRAIN-GEN %s +// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-TRAIN-GEN %s +// RUN: %clang -### -S -fpgo-train=source-cfg -fpgo-apply=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s +// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fpgo-apply=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" +// CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm" // CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|}}default.profraw" // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw" // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' +// CHECK-NO-MIX-TRAIN-GEN: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' // CHECK-DISABLE-GEN-NOT: "-fprofile-instrument=clang" // CHECK-DISABLE-USE-NOT: "-fprofile-instr-use" // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with '-fprofile-instr-generate' +// CHECK-DEFAULT-AND-TRAIN: '-fpgo-train-default-output' only allowed with '-fpgo-train' // CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping" // RUN: %clang -### -S -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s // RUN: %clang -### -S -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s // RUN: mkdir -p %t.d/some/dir // RUN: %clang -### -S -fprofile-use=%t.d/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-DIR %s // RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s +// RUN: %clang -### -S -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s +// RUN: %clang -### -S -fpgo-train=source-cfg -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s +// RUN: %clang -### -S -fpgo-train=optimizer-cfg -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s +// RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-APPLY-USE %s // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata" // CHECK-PROFILE-USE-DIR: "-fprofile-instrument-use-path={{.*}}.d/some/dir{{/|}}default.profdata" // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof" +// CHECK-NO-MIX-APPLY-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -3468,6 +3468,28 @@ static void addPGOAndCoverageFlags(Compilation &C, const Driver &D, const InputInfo &Output, const ArgLi
Re: [PATCH] D21706: [libcxx] refactor for throw
weimingz added inline comments. Comment at: include/exception:262 @@ -261,3 +261,3 @@ _LIBCPP_INLINE_VISIBILITY -inline void __libcpp_throw(_Exception const& __e) { +inline __attribute__((noreturn)) void __libcpp_throw(_Exception const& __e) { #ifndef _LIBCPP_NO_EXCEPTIONS mclow.lists wrote: > I thought that we were going to add a macro for the "no return if no > exceptions" something like this? #ifndef __LIBCPP_NO_EXCEPTIONS #define NORETURN_EXP __attribute__((noreturn)) #else #define NORETURN_EXP #endif inline NORETURN_EXP void __libcpp_throw(_Exception const& __e) { ... } Comment at: src/future.cpp:96 @@ -96,4 +95,3 @@ if (__has_value()) -throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __libcpp_throw(future_error(make_error_code(future_errc::promise_already_satisfied))); __state_ |= __constructed | ready; mclow.lists wrote: > Is the indentation right here? (or is phab lying to me?) It looks ok here. The first underscore is on the same column as "__has_value" (the line above). 4 space indention Comment at: src/locale.cpp:527 @@ -528,3 +526,3 @@ #else // _LIBCPP_NO_EXCEPTIONS : __locale_(new __imp(*other.__locale_, name, c)) #endif mclow.lists wrote: > Did you miss one here? The reason I skipeed this and two or three other similar cases is the constructor expects the function __libcpp_throw() to return a pointer. http://reviews.llvm.org/D21706 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21303: [clang-tidy] Adds performance-returning-type check.
Prazek added a reviewer: rsmith. Prazek added a comment. Adding Richard who was working on standard defect report that deprived sense of this check. There are some corner cases that are not in the standard and probably won't be handled in the future that we could handle still. http://reviews.llvm.org/D21303 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder
sfantao added a comment. In http://reviews.llvm.org/D18172#472152, @jlebar wrote: > Yeah, I'd say that in the absence of a rule, consistency with surrounding > code is king. Otherwise we're sending a message when we don't mean to be. > > I'm not at my machine, but my recollection is that most of the driver uses > final sparingly. But whatever the convention is we should do that, I think. True, `final` is not widely used in the driver. Again, I don't feel strongly about doing this one way or the other. For the moment, I'll update the diffs according to what Alexey requested. If you guys decide that I should do that differently, I'm happy to go to back to each review and update it accordingly. Thanks again! Samuel http://reviews.llvm.org/D18172 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
This revision was automatically updated to reflect the committed changes. Closed by commit rL274380: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const… (authored by flx). Changed prior to commit: http://reviews.llvm.org/D20277?vs=62524&id=62530#toc Repository: rL LLVM http://reviews.llvm.org/D20277 Files: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.h clang-tools-extra/trunk/clang-tidy/utils/Matchers.h clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h clang-tools-extra/trunk/docs/clang-tidy/checks/performance-unnecessary-value-param.rst clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -12,6 +12,10 @@ #include "../utils/DeclRefExprUtils.h" #include "../utils/FixItHintUtils.h" #include "../utils/Matchers.h" +#include "../utils/TypeTraits.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Lex/Lexer.h" +#include "clang/Lex/Preprocessor.h" using namespace clang::ast_matchers; @@ -27,8 +31,22 @@ .str(); } +template +bool isSubset(const S &SubsetCandidate, const S &SupersetCandidate) { + for (const auto &E : SubsetCandidate) +if (SupersetCandidate.count(E) == 0) + return false; + return true; +} + } // namespace +UnnecessaryValueParamCheck::UnnecessaryValueParamCheck( +StringRef Name, ClangTidyContext *Context) +: ClangTidyCheck(Name, Context), + IncludeStyle(utils::IncludeSorter::parseIncludeStyle( + Options.get("IncludeStyle", "llvm"))) {} + void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) { const auto ExpensiveValueParamDecl = parmVarDecl(hasType(hasCanonicalType(allOf(matchers::isExpensiveToCopy(), @@ -58,12 +76,39 @@ // Do not trigger on non-const value parameters when: // 1. they are in a constructor definition since they can likely trigger //misc-move-constructor-init which will suggest to move the argument. - // 2. they are not only used as const. if (!IsConstQualified && (llvm::isa(Function) || -!Function->doesThisDeclarationHaveABody() || -!utils::decl_ref_expr::isOnlyUsedAsConst( -*Param, *Function->getBody(), *Result.Context))) +!Function->doesThisDeclarationHaveABody())) return; + + auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs( + *Param, *Function->getBody(), *Result.Context); + auto ConstDeclRefExprs = utils::decl_ref_expr::constReferenceDeclRefExprs( + *Param, *Function->getBody(), *Result.Context); + // 2. they are not only used as const. + if (!isSubset(AllDeclRefExprs, ConstDeclRefExprs)) +return; + + // If the parameter is non-const, check if it has a move constructor and is + // only referenced once to copy-construct another object or whether it has a + // move assignment operator and is only referenced once when copy-assigned. + // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary + // copy. + if (!IsConstQualified) { +auto CanonicalType = Param->getType().getCanonicalType(); +if (AllDeclRefExprs.size() == 1 && +((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) && + utils::decl_ref_expr::isCopyConstructorArgument( + **AllDeclRefExprs.begin(), *Function->getBody(), + *Result.Context)) || + (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) && + utils::decl_ref_expr::isCopyAssignmentArgument( + **AllDeclRefExprs.begin(), *Function->getBody(), + *Result.Context { + handleMoveFix(*Param, **AllDeclRefExprs.begin(), *Result.Context); + return; +} + } + auto Diag = diag(Param->getLocation(), IsConstQualified ? "the const qualified parameter %0 is " @@ -86,6 +131,40 @@ } } +void UnnecessaryValueParamCheck::registerPPCallbacks( +CompilerInstance &Compiler) { + Inserter.reset(new utils::IncludeInserter( + Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle)); + Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks()); +} + +void UnnecessaryValueParamCheck::storeOptions( +ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IncludeStyle", +utils::IncludeSorter::toString(IncludeStyle)); +} +
[clang-tools-extra] r274380 - [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
Author: flx Date: Fri Jul 1 15:12:15 2016 New Revision: 274380 URL: http://llvm.org/viewvc/llvm-project?rev=274380&view=rev Log: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved. Summary: Make check more useful in the following two cases: The parameter is passed by non-const value, has a non-deleted move constructor and is only referenced once in the function as argument to the type's copy constructor. The parameter is passed by non-const value, has a non-deleted move assignment operator and is only referenced once in the function as argument of the the type's copy assignment operator. In this case suggest a fix to move the parameter which avoids the unnecessary copy and is closest to what the user might have intended. Reviewers: alexfh, sbenza Subscribers: cfe-commits, Prazek Differential Revision: http://reviews.llvm.org/D20277 Modified: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.h clang-tools-extra/trunk/clang-tidy/utils/Matchers.h clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h clang-tools-extra/trunk/docs/clang-tidy/checks/performance-unnecessary-value-param.rst clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Modified: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=274380&r1=274379&r2=274380&view=diff == --- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp Fri Jul 1 15:12:15 2016 @@ -12,6 +12,10 @@ #include "../utils/DeclRefExprUtils.h" #include "../utils/FixItHintUtils.h" #include "../utils/Matchers.h" +#include "../utils/TypeTraits.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Lex/Lexer.h" +#include "clang/Lex/Preprocessor.h" using namespace clang::ast_matchers; @@ -27,8 +31,22 @@ std::string paramNameOrIndex(StringRef N .str(); } +template +bool isSubset(const S &SubsetCandidate, const S &SupersetCandidate) { + for (const auto &E : SubsetCandidate) +if (SupersetCandidate.count(E) == 0) + return false; + return true; +} + } // namespace +UnnecessaryValueParamCheck::UnnecessaryValueParamCheck( +StringRef Name, ClangTidyContext *Context) +: ClangTidyCheck(Name, Context), + IncludeStyle(utils::IncludeSorter::parseIncludeStyle( + Options.get("IncludeStyle", "llvm"))) {} + void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) { const auto ExpensiveValueParamDecl = parmVarDecl(hasType(hasCanonicalType(allOf(matchers::isExpensiveToCopy(), @@ -58,12 +76,39 @@ void UnnecessaryValueParamCheck::check(c // Do not trigger on non-const value parameters when: // 1. they are in a constructor definition since they can likely trigger //misc-move-constructor-init which will suggest to move the argument. - // 2. they are not only used as const. if (!IsConstQualified && (llvm::isa(Function) || -!Function->doesThisDeclarationHaveABody() || -!utils::decl_ref_expr::isOnlyUsedAsConst( -*Param, *Function->getBody(), *Result.Context))) +!Function->doesThisDeclarationHaveABody())) return; + + auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs( + *Param, *Function->getBody(), *Result.Context); + auto ConstDeclRefExprs = utils::decl_ref_expr::constReferenceDeclRefExprs( + *Param, *Function->getBody(), *Result.Context); + // 2. they are not only used as const. + if (!isSubset(AllDeclRefExprs, ConstDeclRefExprs)) +return; + + // If the parameter is non-const, check if it has a move constructor and is + // only referenced once to copy-construct another object or whether it has a + // move assignment operator and is only referenced once when copy-assigned. + // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary + // copy. + if (!IsConstQualified) { +auto CanonicalType = Param->getType().getCanonicalType(); +if (AllDeclRefExprs.size() == 1 && +((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) && + utils::decl_ref_expr::isCopyConstructorArgument( + **AllDeclRefExprs.begin(), *Function->getBody(), + *Result.Context)) || + (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) && +
Re: [PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.
sfantao added a comment. Hi Alexey, Thanks for the review! Comment at: include/clang/Driver/Compilation.h:73 @@ +72,3 @@ + /// architecture, and device offload kind. + struct TCArgsKey { +const ToolChain *TC; ABataev wrote: > 1. 'final' > 2. default initializers for fields. I added the default initializers but that required me to add a Ctor so that initializer lists work when this struct is built. Comment at: include/clang/Driver/Compilation.h:206 @@ +205,3 @@ + const llvm::opt::DerivedArgList & + getArgsForToolChain(const ToolChain *TC, const char *BoundArch, + Action::OffloadKind DeviceOffloadKind); ABataev wrote: > 'const' function? This one can't be marked const has it potentially changes the cache of translated arguments. http://reviews.llvm.org/D21848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.
sfantao updated this revision to Diff 62528. sfantao marked 3 inline comments as done. sfantao added a comment. - Add default initializers to toolchain arguments key and use range based iterator in Dtor. http://reviews.llvm.org/D21848 Files: include/clang/Driver/Compilation.h include/clang/Driver/ToolChain.h lib/Driver/Compilation.cpp lib/Driver/Driver.cpp lib/Driver/MSVCToolChain.cpp lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -169,25 +169,25 @@ // // Compile for the powerpc device. -/ -// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] // // Compile for the x86 device. // -// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" -// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] +// CHK-COMMANDS-ST: ld" {{.*}}"-shared" "-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] // // Generate host object from the BC file and link using the linker script. @@ -228,5 +228,3 @@ // CHK-LKS: } // CHK-LKS: } // CHK-LKS: INSERT BEFORE .data - - Index: lib/Driver/ToolChains.h === --- lib/Driver/ToolChains.h +++ lib/Driver/ToolChains.h @@ -208,6 +208,9 @@ bool isPIEDefault() const override; bool isPICDefaultForced() const override; bool IsIntegratedAssemblerDefault() const override; + llvm::opt::DerivedArgList * + TranslateArgs(const llvm::opt::DerivedArgList &Args, const char *BoundArch, +Action::OffloadKind DeviceOffloadKind) const override; protected: Tool *getTool(Action::ActionClass AC) const override; @@ -306,8 +309,8 @@ bool HasNativeLLVMSupport() const override; llvm::opt::DerivedArgList * - TranslateArgs(const llvm::opt::DerivedArgList &A
Re: [PATCH] D21706: [libcxx] refactor for throw
mclow.lists added a comment. This is getting close. A nit, and a couple of non-trivial comments. Comment at: include/exception:262 @@ -261,3 +261,3 @@ _LIBCPP_INLINE_VISIBILITY -inline void __libcpp_throw(_Exception const& __e) { +inline __attribute__((noreturn)) void __libcpp_throw(_Exception const& __e) { #ifndef _LIBCPP_NO_EXCEPTIONS I thought that we were going to add a macro for the "no return if no exceptions" Comment at: src/future.cpp:96 @@ -96,4 +95,3 @@ if (__has_value()) -throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __libcpp_throw(future_error(make_error_code(future_errc::promise_already_satisfied))); __state_ |= __constructed | ready; Is the indentation right here? (or is phab lying to me?) Comment at: src/locale.cpp:527 @@ -528,3 +526,3 @@ #else // _LIBCPP_NO_EXCEPTIONS : __locale_(new __imp(*other.__locale_, name, c)) #endif Did you miss one here? http://reviews.llvm.org/D21706 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.
sfantao updated this revision to Diff 62525. sfantao added a comment. - Remove \brief from one comment. http://reviews.llvm.org/D21847 Files: lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -138,3 +138,95 @@ // CHK-PHASES-FILES: 38: assembler, {37}, object, (device-openmp) // CHK-PHASES-FILES: 39: linker, {26, 32, 38}, image, (device-openmp) // CHK-PHASES-FILES: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {11}, "device-openmp (x86_64-pc-linux-gnu)" {25}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, image + + +/// ### + +/// Check of the commands passed to each tool when using valid OpenMP targets. +/// Here we also check that offloading does not break the use of integrated +/// assembler. It does however preclude the merge of the host compile and +/// backend phases. There are also two offloading specific options: +/// -fopenmp-is-device: will tell the frontend that it will generate code for a +/// target. +/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by +/// the target code generation to gather information about which declaration +/// really need to be emitted. +/// +// RUN: %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-COMMANDS %s +// Run the save temp test in a temporary folder as the linker script will be +// created there. +// RUN: cd %T && \ +// RUN: %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-COMMANDS-ST %s +// RUN: FileCheck -check-prefix=CHK-LKS %s --input-file %t.lk +// +// Generate host BC file. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" +// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]" +// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// +// Compile for the powerpc device. +/ +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" +// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] + +// +// Compile for the x86 device. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" +// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] + +// +// Generate host object from the BC file and link using the linker script. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"
r274379 - [Driver] Delete some dead code (NFC)
Author: vedantk Date: Fri Jul 1 14:41:20 2016 New Revision: 274379 URL: http://llvm.org/viewvc/llvm-project?rev=274379&view=rev Log: [Driver] Delete some dead code (NFC) Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274379&r1=274378&r2=274379&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 1 14:41:20 2016 @@ -1738,9 +1738,6 @@ static void getSparcTargetFeatures(const void Clang::AddSparcTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { - //const Driver &D = getToolChain().getDriver(); - std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args); - sparc::FloatABI FloatABI = sparc::getSparcFloatABI(getToolChain().getDriver(), Args); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
flx added inline comments. Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:34 @@ -29,1 +33,3 @@ +template bool isSetDifferenceEmpty(const S &S1, const S &S2) { + for (const auto &E : S1) alexfh wrote: > +1 to `isSubset`. And please add a comment explaining what should be a subset > of what for this function to return `true`. Omitted the comment by making the parameter names very explicit. Comment at: clang-tidy/utils/Matchers.h:50 @@ +49,3 @@ +AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst) { + return ast_matchers::referenceType(ast_matchers::pointee( + ast_matchers::qualType(ast_matchers::isConstQualified(; alexfh wrote: > How about `using ast_matchers;` in this function to make the statement easier > to read? Used `using namespace ast_matchers;`. http://reviews.llvm.org/D20277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
flx updated this revision to Diff 62524. flx marked 5 inline comments as done. flx added a comment. Thanks for the review. I addressed all remaining comments. http://reviews.llvm.org/D20277 Files: clang-tidy/performance/UnnecessaryValueParamCheck.cpp clang-tidy/performance/UnnecessaryValueParamCheck.h clang-tidy/utils/DeclRefExprUtils.cpp clang-tidy/utils/DeclRefExprUtils.h clang-tidy/utils/Matchers.h clang-tidy/utils/TypeTraits.cpp clang-tidy/utils/TypeTraits.h docs/clang-tidy/checks/performance-unnecessary-value-param.rst test/clang-tidy/performance-unnecessary-value-param.cpp Index: test/clang-tidy/performance-unnecessary-value-param.cpp === --- test/clang-tidy/performance-unnecessary-value-param.cpp +++ test/clang-tidy/performance-unnecessary-value-param.cpp @@ -1,5 +1,7 @@ // RUN: %check_clang_tidy %s performance-unnecessary-value-param %t +// CHECK-FIXES: #include + struct ExpensiveToCopyType { const ExpensiveToCopyType & constReference() const { return *this; @@ -30,6 +32,15 @@ void constMethod() const; }; +struct ExpensiveMovableType { + ExpensiveMovableType(); + ExpensiveMovableType(ExpensiveMovableType &&); + ExpensiveMovableType(const ExpensiveMovableType &) = default; + ExpensiveMovableType &operator=(const ExpensiveMovableType &) = default; + ExpensiveMovableType &operator=(ExpensiveMovableType &&); + ~ExpensiveMovableType(); +}; + void positiveExpensiveConstValue(const ExpensiveToCopyType Obj); // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj); void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) { @@ -180,3 +191,36 @@ void NegativeMoveOnlyTypePassedByValue(MoveOnlyType M) { M.constMethod(); } + +void PositiveMoveOnCopyConstruction(ExpensiveMovableType E) { + auto F = E; + // CHECK-MESSAGES: [[@LINE-1]]:12: warning: parameter 'E' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] + // CHECK-FIXES: auto F = std::move(E); +} + +void PositiveConstRefNotMoveSinceReferencedMultipleTimes(ExpensiveMovableType E) { + // CHECK-MESSAGES: [[@LINE-1]]:79: warning: the parameter 'E' is copied + // CHECK-FIXES: void PositiveConstRefNotMoveSinceReferencedMultipleTimes(const ExpensiveMovableType& E) { + auto F = E; + auto G = E; +} + +void PositiveMoveOnCopyAssignment(ExpensiveMovableType E) { + ExpensiveMovableType F; + F = E; + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: parameter 'E' is passed by value + // CHECK-FIXES: F = std::move(E); +} + +void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) { + // CHECK-MESSAGES: [[@LINE-1]]:63: warning: the parameter 'T' is copied + // CHECK-FIXES: void PositiveConstRefNotMoveConstructible(const ExpensiveToCopyType& T) { + auto U = T; +} + +void PositiveConstRefNotMoveAssignable(ExpensiveToCopyType A) { + // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the parameter 'A' is copied + // CHECK-FIXES: void PositiveConstRefNotMoveAssignable(const ExpensiveToCopyType& A) { + ExpensiveToCopyType B; + B = A; +} Index: docs/clang-tidy/checks/performance-unnecessary-value-param.rst === --- docs/clang-tidy/checks/performance-unnecessary-value-param.rst +++ docs/clang-tidy/checks/performance-unnecessary-value-param.rst @@ -10,7 +10,7 @@ which means they are not trivially copyable or have a non-trivial copy constructor or destructor. -To ensure that it is safe to replace the value paramater with a const reference +To ensure that it is safe to replace the value parameter with a const reference the following heuristic is employed: 1. the parameter is const qualified; @@ -31,3 +31,25 @@ Value.ConstMethd(); ExpensiveToCopy Copy(Value); } + +If the parameter is not const, only copied or assigned once and has a +non-trivial move-constructor or move-assignment operator respectively the check +will suggest to move it. + +Example: + +.. code-block:: c++ + + void setValue(string Value) { +Field = Value; + } + +Will become: + +.. code-block:: c++ + + #include + + void setValue(string Value) { +Field = std::move(Value); + } Index: clang-tidy/utils/TypeTraits.h === --- clang-tidy/utils/TypeTraits.h +++ clang-tidy/utils/TypeTraits.h @@ -29,6 +29,12 @@ bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl, const ASTContext &Context); +/// Returns true if `Type` has a non-trivial move constructor. +bool hasNonTrivialMoveConstructor(QualType Type); + +/// Return true if `Type` has a non-trivial move assignment operator. +bool hasNonTrivialMoveAssignment(QualType Type); + } // type_traits } // namespace utils } // namespace tidy Index: clang-tidy/utils/TypeTraits.cpp ==
Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.
jlebar added a comment. Hi, Alexy. Would you mind not asking for 'final' in additional reviews until we've resolved this thread elsewhere? Feel free to find me on IRC if you want to talk about it synchronously. Thanks! http://reviews.llvm.org/D21845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.
sfantao added a comment. Hi Alexey, Thanks for the review! Addressed the comments in the new diff. http://reviews.llvm.org/D21847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.
sfantao updated this revision to Diff 62523. sfantao marked an inline comment as done. sfantao added a comment. - Use llvm::sys::path::replace_extension to deal with the extension of the linker script. http://reviews.llvm.org/D21847 Files: lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -138,3 +138,95 @@ // CHK-PHASES-FILES: 38: assembler, {37}, object, (device-openmp) // CHK-PHASES-FILES: 39: linker, {26, 32, 38}, image, (device-openmp) // CHK-PHASES-FILES: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {11}, "device-openmp (x86_64-pc-linux-gnu)" {25}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, image + + +/// ### + +/// Check of the commands passed to each tool when using valid OpenMP targets. +/// Here we also check that offloading does not break the use of integrated +/// assembler. It does however preclude the merge of the host compile and +/// backend phases. There are also two offloading specific options: +/// -fopenmp-is-device: will tell the frontend that it will generate code for a +/// target. +/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by +/// the target code generation to gather information about which declaration +/// really need to be emitted. +/// +// RUN: %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-COMMANDS %s +// Run the save temp test in a temporary folder as the linker script will be +// created there. +// RUN: cd %T && \ +// RUN: %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-COMMANDS-ST %s +// RUN: FileCheck -check-prefix=CHK-LKS %s --input-file %t.lk +// +// Generate host BC file. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" +// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]" +// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" + +// +// Compile for the powerpc device. +/ +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]" +// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]] + +// +// Compile for the x86 device. +// +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]" +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]" +// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]] + +// +// Generate host object from the BC file and link using the linker s
r274378 - [libclang] Sync-up the way top-level decls in an ASTUnit are handled with how decls in a DeclContext are handled.
Author: akirtzidis Date: Fri Jul 1 14:10:54 2016 New Revision: 274378 URL: http://llvm.org/viewvc/llvm-project?rev=274378&view=rev Log: [libclang] Sync-up the way top-level decls in an ASTUnit are handled with how decls in a DeclContext are handled. rdar://19775013 Modified: cfe/trunk/test/Index/properties-class-extensions.m cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/CursorVisitor.h Modified: cfe/trunk/test/Index/properties-class-extensions.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/properties-class-extensions.m?rev=274378&r1=274377&r2=274378&view=diff == --- cfe/trunk/test/Index/properties-class-extensions.m (original) +++ cfe/trunk/test/Index/properties-class-extensions.m Fri Jul 1 14:10:54 2016 @@ -70,7 +70,7 @@ // CHECK-NOT: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28] // CHECK: properties-class-extensions.m:19:26: ObjCInstanceMethodDecl=setBar::19:26 Extent=[19:26 - 19:29] // CHECK: properties-class-extensions.m:19:26: ParmDecl=bar:19:26 (Definition) Extent=[19:26 - 19:29] -// CHECK: properties-class-extensions.m:24:8: ObjCInterfaceDecl=Rdar8467189_Bar:24:8 Extent=[24:1 - 24:23] +// CHECK-NOT: properties-class-extensions.m:24:8: ObjCInterfaceDecl=Rdar8467189_Bar:24:8 // CHECK: properties-class-extensions.m:24:8: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[24:8 - 24:23] // CHECK: properties-class-extensions.m:25:11: ObjCProtocolDecl=Rdar8467189_FooProtocol:25:11 (Definition) Extent=[25:1 - 27:5] // CHECK: properties-class-extensions.m:26:39: ObjCPropertyDecl=Rdar8467189_Bar:26:39 [readonly,] Extent=[26:1 - 26:54] Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=274378&r1=274377&r2=274378&view=diff == --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jul 1 14:10:54 2016 @@ -523,8 +523,10 @@ bool CursorVisitor::VisitChildren(CXCurs for (ASTUnit::top_level_iterator TL = CXXUnit->top_level_begin(), TLEnd = CXXUnit->top_level_end(); TL != TLEnd; ++TL) { -if (Visit(MakeCXCursor(*TL, TU, RegionOfInterest), true)) - return true; +const Optional V = handleDeclForVisitation(*TL); +if (!V.hasValue()) + continue; +return V.getValue(); } } else if (VisitDeclContext( CXXUnit->getASTContext().getTranslationUnitDecl())) @@ -621,42 +623,50 @@ bool CursorVisitor::VisitDeclContext(Dec Decl *D = *I; if (D->getLexicalDeclContext() != DC) continue; -CXCursor Cursor = MakeCXCursor(D, TU, RegionOfInterest); - -// Ignore synthesized ivars here, otherwise if we have something like: -// @synthesize prop = _prop; -// and '_prop' is not declared, we will encounter a '_prop' ivar before -// encountering the 'prop' synthesize declaration and we will think that -// we passed the region-of-interest. -if (ObjCIvarDecl *ivarD = dyn_cast(D)) { - if (ivarD->getSynthesize()) -continue; -} - -// FIXME: ObjCClassRef/ObjCProtocolRef for forward class/protocol -// declarations is a mismatch with the compiler semantics. -if (Cursor.kind == CXCursor_ObjCInterfaceDecl) { - ObjCInterfaceDecl *ID = cast(D); - if (!ID->isThisDeclarationADefinition()) -Cursor = MakeCursorObjCClassRef(ID, ID->getLocation(), TU); - -} else if (Cursor.kind == CXCursor_ObjCProtocolDecl) { - ObjCProtocolDecl *PD = cast(D); - if (!PD->isThisDeclarationADefinition()) -Cursor = MakeCursorObjCProtocolRef(PD, PD->getLocation(), TU); -} - -const Optional &V = shouldVisitCursor(Cursor); +const Optional V = handleDeclForVisitation(D); if (!V.hasValue()) continue; -if (!V.getValue()) - return false; -if (Visit(Cursor, true)) - return true; +return V.getValue(); } return false; } +Optional CursorVisitor::handleDeclForVisitation(const Decl *D) { + CXCursor Cursor = MakeCXCursor(D, TU, RegionOfInterest); + + // Ignore synthesized ivars here, otherwise if we have something like: + // @synthesize prop = _prop; + // and '_prop' is not declared, we will encounter a '_prop' ivar before + // encountering the 'prop' synthesize declaration and we will think that + // we passed the region-of-interest. + if (auto *ivarD = dyn_cast(D)) { +if (ivarD->getSynthesize()) + return None; + } + + // FIXME: ObjCClassRef/ObjCProtocolRef for forward class/protocol + // declarations is a mismatch with the compiler semantics. + if (Cursor.kind == CXCursor_ObjCInterfaceDecl) { +auto *ID = cast(D); +if (!ID->isThisDeclarationADefi
Re: [PATCH] D21334: Add TargetInfo for 32-bit and 64-bit RenderScript
pirama updated this revision to Diff 62520. pirama added a comment. Reformatted with clang-format for just the parts I added. I ignored clang-format-suggested changes in code unrelated to this patch. Is there a policy or practise on periodically fixing format-related issues? If not, I can format this file in an one-off basis in a separate patch. http://reviews.llvm.org/D21334 Files: lib/Basic/Targets.cpp test/CodeGen/renderscript.c Index: test/CodeGen/renderscript.c === --- /dev/null +++ test/CodeGen/renderscript.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS32 +// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS64 +// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-ARM + +// Ensure that the bitcode has the correct triple +// CHECK-RS32: target triple = "armv7-none-linux-gnueabi" +// CHECK-RS64: target triple = "aarch64-none-linux-android" +// CHECK-ARM: target triple = "armv7-none-linux-gnueabi" + +// Ensure that long data type has 8-byte size and alignment in RenderScript +#ifdef __RENDERSCRIPT__ +#define LONG_WIDTH_AND_ALIGN 8 +#else +#define LONG_WIDTH_AND_ALIGN 4 +#endif + +_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); +_Static_assert(_Alignof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); + +// CHECK-RS32: i64 @test_long(i64 %v) +// CHECK-RS64: i64 @test_long(i64 %v) +// CHECK-ARM: i32 @test_long(i32 %v) +long test_long(long v) { + return v + 1; +} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -7992,6 +7992,42 @@ return true; } }; + +// 32-bit RenderScript is armv7 with width and align of 'long' set to 8-bytes +class RenderScript32TargetInfo : public ARMleTargetInfo { +public: + RenderScript32TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : ARMleTargetInfo(llvm::Triple("armv7", Triple.getVendorName(), + Triple.getOSName(), + Triple.getEnvironmentName()), +Opts) { +LongWidth = LongAlign = 64; + } + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override { +Builder.defineMacro("__RENDERSCRIPT__"); +ARMleTargetInfo::getTargetDefines(Opts, Builder); + } +}; + +// 64-bit RenderScript is aarch64 +class RenderScript64TargetInfo : public AArch64leTargetInfo { +public: + RenderScript64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(), + Triple.getOSName(), + Triple.getEnvironmentName()), +Opts) {} + + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override { +Builder.defineMacro("__RENDERSCRIPT__"); +AArch64leTargetInfo::getTargetDefines(Opts, Builder); + } +}; + } // end anonymous namespace //===--===// @@ -8420,6 +8456,11 @@ if (!(Triple == llvm::Triple("wasm64-unknown-unknown"))) return nullptr; return new WebAssemblyOSTargetInfo(Triple, Opts); + + case llvm::Triple::renderscript32: +return new LinuxTargetInfo(Triple, Opts); + case llvm::Triple::renderscript64: +return new LinuxTargetInfo(Triple, Opts); } } Index: test/CodeGen/renderscript.c === --- /dev/null +++ test/CodeGen/renderscript.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS32 +// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS64 +// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-ARM + +// Ensure that the bitcode has the correct triple +// CHECK-RS32: target triple = "armv7-none-linux-gnueabi" +// CHECK-RS64: target triple = "aarch64-none-linux-android" +// CHECK-ARM: target triple = "armv7-none-linux-gnueabi" + +// Ensure that long data type has 8-byte size and alignment in RenderScript +#ifdef __RENDERSCRIPT__ +#define LONG_WIDTH_AND_ALIGN 8 +#else +#define LONG_WIDTH_AND_ALIGN 4 +#endif + +_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); +_Static_assert(_Alignof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); + +// CHECK-RS32: i64 @test_lo
Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.
sfantao added a comment. Hi Alexey, Thanks for the review! Addressed your comment in the new diff. Also removed `\brief` from the comments. http://reviews.llvm.org/D21845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.
sfantao updated this revision to Diff 62519. sfantao marked an inline comment as done. sfantao added a comment. - Mark class as final and remove \brief from comments. http://reviews.llvm.org/D21845 Files: lib/Driver/Driver.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -35,3 +35,106 @@ // RUN: %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s // CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored. + +/// ### + +/// Check the phases graph when using a single target, different from the host. +/// We should have an offload action joining the host compile and device +/// preprocessor and another one joining the device linking outputs to the host +/// action. +// RUN: %clang -ccc-print-phases -fopenmp -target powerpc64le-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PHASES %s +// CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp) +// CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp) +// CHK-PHASES: 2: compiler, {1}, ir, (host-openmp) +// CHK-PHASES: 3: backend, {2}, assembler, (host-openmp) +// CHK-PHASES: 4: assembler, {3}, object, (host-openmp) +// CHK-PHASES: 5: linker, {4}, image, (host-openmp) +// CHK-PHASES: 6: input, "[[INPUT]]", c, (device-openmp) +// CHK-PHASES: 7: preprocessor, {6}, cpp-output, (device-openmp) +// CHK-PHASES: 8: compiler, {7}, ir, (device-openmp) +// CHK-PHASES: 9: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir +// CHK-PHASES: 10: backend, {9}, assembler, (device-openmp) +// CHK-PHASES: 11: assembler, {10}, object, (device-openmp) +// CHK-PHASES: 12: linker, {11}, image, (device-openmp) +// CHK-PHASES: 13: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {5}, "device-openmp (x86_64-pc-linux-gnu)" {12}, image + +/// ### + +/// Check the phases when using multiple targets. Here we also add a library to +/// make sure it is treated as input by the device. +// RUN: %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PHASES-LIB %s +// CHK-PHASES-LIB: 0: input, "somelib", object, (host-openmp) +// CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-openmp) +// CHK-PHASES-LIB: 2: preprocessor, {1}, cpp-output, (host-openmp) +// CHK-PHASES-LIB: 3: compiler, {2}, ir, (host-openmp) +// CHK-PHASES-LIB: 4: backend, {3}, assembler, (host-openmp) +// CHK-PHASES-LIB: 5: assembler, {4}, object, (host-openmp) +// CHK-PHASES-LIB: 6: linker, {0, 5}, image, (host-openmp) +// CHK-PHASES-LIB: 7: input, "somelib", object, (device-openmp) +// CHK-PHASES-LIB: 8: input, "[[INPUT]]", c, (device-openmp) +// CHK-PHASES-LIB: 9: preprocessor, {8}, cpp-output, (device-openmp) +// CHK-PHASES-LIB: 10: compiler, {9}, ir, (device-openmp) +// CHK-PHASES-LIB: 11: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {10}, ir +// CHK-PHASES-LIB: 12: backend, {11}, assembler, (device-openmp) +// CHK-PHASES-LIB: 13: assembler, {12}, object, (device-openmp) +// CHK-PHASES-LIB: 14: linker, {7, 13}, image, (device-openmp) +// CHK-PHASES-LIB: 15: input, "somelib", object, (device-openmp) +// CHK-PHASES-LIB: 16: input, "[[INPUT]]", c, (device-openmp) +// CHK-PHASES-LIB: 17: preprocessor, {16}, cpp-output, (device-openmp) +// CHK-PHASES-LIB: 18: compiler, {17}, ir, (device-openmp) +// CHK-PHASES-LIB: 19: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {18}, ir +// CHK-PHASES-LIB: 20: backend, {19}, assembler, (device-openmp) +// CHK-PHASES-LIB: 21: assembler, {20}, object, (device-openmp) +// CHK-PHASES-LIB: 22: linker, {15, 21}, image, (device-openmp) +// CHK-PHASES-LIB: 23: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {6}, "device-openmp (x86_64-pc-linux-gnu)" {14}, "device-openmp (powerpc64-ibm-linux-gnu)" {22}, image + + +/// ### + +/// Check the phases when using multiple targets and multiple source files +// RUN: echo " " > %t.c +// RUN: %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s %t.c 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PHASES-FILES %s +// CHK-PHASES-FILES: 0: input, "somelib", object, (host-openmp) +// CHK-PHASES-FILES: 1: input, "[[INPUT1:.+\
Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.
sfantao updated this revision to Diff 62518. sfantao added a comment. - Add code dropped accidently in the previous diff. http://reviews.llvm.org/D21843 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Action.h include/clang/Driver/Driver.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- /dev/null +++ test/Driver/openmp-offload.c @@ -0,0 +1,37 @@ +/// +/// Perform several driver tests for OpenMP offloading +/// + +/// ### + +/// Check whether an invalid OpenMP target is specified: +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-INVALID-TARGET %s +// RUN: %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-INVALID-TARGET %s +// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd' + +/// ### + +/// Check warning for empty -fopenmp-targets +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets= %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s +// RUN: %clang -### -fopenmp -fopenmp-targets= %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s +// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets=' + +/// ### + +/// Check error for no -fopenmp option +// RUN: %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s +// RUN: %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s +// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading. + +/// ### + +/// Check warning for duplicate offloading targets. +// RUN: %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s +// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored. Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2999,72 +2999,23 @@ CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins")); } -namespace { -enum OpenMPRuntimeKind { - /// An unknown OpenMP runtime. We can't generate effective OpenMP code - /// without knowing what runtime to target. - OMPRT_Unknown, - - /// The LLVM OpenMP runtime. When completed and integrated, this will become - /// the default for Clang. - OMPRT_OMP, - - /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for - /// this runtime but can swallow the pragmas, and find and link against the - /// runtime library itself. - OMPRT_GOMP, - - /// The legacy name for the LLVM OpenMP runtime from when it was the Intel - /// OpenMP runtime. We support this mode for users with existing dependencies - /// on this runtime library name. - OMPRT_IOMP5 -}; -} - -/// Compute the desired OpenMP runtime from the flag provided. -static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain &TC, - const ArgList &Args) { - StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME); - - const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ); - if (A) -RuntimeName = A->getValue(); - - auto RT = llvm::StringSwitch(RuntimeName) -.Case("libomp", OMPRT_OMP) -.Case("libgomp", OMPRT_GOMP) -.Case("libiomp5", OMPRT_IOMP5) -.Default(OMPRT_Unknown); - - if (RT == OMPRT_Unknown) { -if (A) - TC.getDriver().Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); -else - // FIXME: We could use a nicer diagnostic here. - TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp"; - } - - return RT; -} - static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, const ArgList &Args) { if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, options::OPT_fno_openmp, false)) return; - switch (getOpenMPRuntime(TC, Args)) { - case OMPRT_OMP: + switch (TC.getDriver().getOpenMPRuntime(Args)) { + case Driver::OMPRT_OMP: CmdArgs.push_back("-lomp"); break; - case OMPRT_GOMP: + case Driver::O
Re: [PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.
sfantao added a comment. Hi Alexey, Thanks for the review! Comment at: lib/Driver/Driver.cpp:2416 @@ +2415,3 @@ + /// be collapsed with it. + struct JobActionInfoTy { +// \brief The action this info refers to. ABataev wrote: > I think this can be marked 'final' and add 'nullptr' as a default initializer > for 'JA' field Yep, I'm doing that now. Comment at: lib/Driver/Driver.cpp:2426 @@ +2425,3 @@ + /// in the action info array. + void appendCollapsedOffloadAction(ActionList &CollapsedOffloadAction, +ArrayRef &ActionInfo, ABataev wrote: > I think this function can be marked as 'static', no? You're right, using static now. http://reviews.llvm.org/D21840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.
sfantao added a comment. Hi Alexey, Thanks for the review! Comment at: lib/Driver/Driver.cpp:464-468 @@ +463,7 @@ + RuntimeName = A->getValue(); +HasCompatibleOpenMP = llvm::StringSwitch(RuntimeName) + .Case("libomp", true) + .Case("libgomp", false) + .Case("libiomp5", true) + .Default(false); + } ABataev wrote: > I don't like the fact that we have similar string comparisons in different > files. This must be handled in a single place. Ok, that makes sense. I moved the ownership of `OpenMPRuntimeKind` to the `Driver`, given that the Driver was being retrieved in `Tools.cpp` in order to emit the diagnostics. http://reviews.llvm.org/D21843 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.
sfantao updated this revision to Diff 62516. sfantao marked an inline comment as done. sfantao added a comment. - Check the OpenMP flags only in one place for purposes of obtaining the runtime kind. http://reviews.llvm.org/D21843 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Action.h include/clang/Driver/Driver.h lib/Driver/Action.cpp lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- /dev/null +++ test/Driver/openmp-offload.c @@ -0,0 +1,37 @@ +/// +/// Perform several driver tests for OpenMP offloading +/// + +/// ### + +/// Check whether an invalid OpenMP target is specified: +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-INVALID-TARGET %s +// RUN: %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-INVALID-TARGET %s +// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd' + +/// ### + +/// Check warning for empty -fopenmp-targets +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets= %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s +// RUN: %clang -### -fopenmp -fopenmp-targets= %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s +// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets=' + +/// ### + +/// Check error for no -fopenmp option +// RUN: %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s +// RUN: %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s +// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading. + +/// ### + +/// Check warning for duplicate offloading targets. +// RUN: %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s +// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored. Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2999,72 +2999,23 @@ CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins")); } -namespace { -enum OpenMPRuntimeKind { - /// An unknown OpenMP runtime. We can't generate effective OpenMP code - /// without knowing what runtime to target. - OMPRT_Unknown, - - /// The LLVM OpenMP runtime. When completed and integrated, this will become - /// the default for Clang. - OMPRT_OMP, - - /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for - /// this runtime but can swallow the pragmas, and find and link against the - /// runtime library itself. - OMPRT_GOMP, - - /// The legacy name for the LLVM OpenMP runtime from when it was the Intel - /// OpenMP runtime. We support this mode for users with existing dependencies - /// on this runtime library name. - OMPRT_IOMP5 -}; -} - -/// Compute the desired OpenMP runtime from the flag provided. -static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain &TC, - const ArgList &Args) { - StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME); - - const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ); - if (A) -RuntimeName = A->getValue(); - - auto RT = llvm::StringSwitch(RuntimeName) -.Case("libomp", OMPRT_OMP) -.Case("libgomp", OMPRT_GOMP) -.Case("libiomp5", OMPRT_IOMP5) -.Default(OMPRT_Unknown); - - if (RT == OMPRT_Unknown) { -if (A) - TC.getDriver().Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); -else - // FIXME: We could use a nicer diagnostic here. - TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp"; - } - - return RT; -} - static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, const ArgList &Args) { if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, options::OPT_fno_openmp, false)) return; - switch (getOpenMPRuntime(TC, Args)) { - case OMPRT_OMP: + switch (TC.getDriver().getOpenMPRuntime(Args)) { + case Driver::OMPRT_OMP:
Re: [cfe-dev] RFC: Default language standard mode policy
On Thu, Jun 30, 2016 at 01:41:00PM -0700, Richard Smith wrote: > On Thu, Jun 30, 2016 at 2:02 AM, David Chisnall > wrote: > > > On 29 Jun 2016, at 23:07, Richard Smith via cfe-dev < > > cfe-...@lists.llvm.org> wrote: > > > > > > Yes, those are real problems, but it's not reasonable for us to keep the > > default at C++98/03 forever. GCC has already taken the plunge here, so a > > lot of open-source code that doesn't work in C++11 onwards already > > explicitly specifies an appropriate -std= flag. > > > > > > > Could you clarify exactly what the issue is? Currently, if I have some > > legacy C++98 code, the odds are that it just compiles with ${CXX}. If I > > have new C++11 or C++14 code, then its build system likely sticks on the > > required -std= flag and it builds independent of what the compiler default > > is. > > > > Why should new C++ code pay this tax to use the language that is currently > called C++, that is taught as C++, that is covered by books on C++, and so > on? C++98 is increasingly the odd one out, and it's the one where an > explicit -std= flag should be required. Well, if the C++ language wouldn't change in backwards incompatible ways, we wouldn't have this discussion. As I said before, the compiler authors are not the one paying the price for the breakage they introduce. We've been moderately good with LLVM/Clang to not introduce miscompiled code in the name of exploiting random UB. Changing the C++ version falls into pretty much the same category. I don't even understand your point about paying a "tax" for using newer C++ features. I find it pretty much the reverse actually. It clearly documents requirements and makes them auditable as well. Given the complex compatibility/implementation status of C++ across different systems, that's a good thing and not something bad. Joerg ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21706: [libcxx] refactor for throw
weimingz updated this revision to Diff 62515. weimingz marked 5 inline comments as done. weimingz added a comment. fix issues per Noel's suggestion http://reviews.llvm.org/D21706 Files: include/__functional_03 include/__locale include/array include/bitset include/complex include/deque include/exception include/experimental/dynarray include/experimental/optional include/fstream include/functional include/future include/locale include/map include/memory include/regex include/string include/unordered_map include/vector src/debug.cpp src/experimental/memory_resource.cpp src/future.cpp src/hash.cpp src/ios.cpp src/locale.cpp src/new.cpp src/string.cpp src/system_error.cpp src/thread.cpp src/typeinfo.cpp Index: src/typeinfo.cpp === --- src/typeinfo.cpp +++ src/typeinfo.cpp @@ -52,15 +52,11 @@ // because bad_cast and bad_typeid are defined in his higher level library void __cxxabiv1::__cxa_bad_typeid() { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_typeid(); -#endif + __libcpp_throw(std::bad_typeid()); } void __cxxabiv1::__cxa_bad_cast() { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_cast(); -#endif + __libcpp_throw(std::bad_cast()); } #endif Index: src/thread.cpp === --- src/thread.cpp +++ src/thread.cpp @@ -53,10 +53,9 @@ if (ec == 0) __t_ = 0; } -#ifndef _LIBCPP_NO_EXCEPTIONS if (ec) -throw system_error(error_code(ec, system_category()), "thread::join failed"); -#endif // _LIBCPP_NO_EXCEPTIONS +__libcpp_throw(system_error(error_code(ec, system_category()), + "thread::join failed")); } void @@ -69,10 +68,9 @@ if (ec == 0) __t_ = 0; } -#ifndef _LIBCPP_NO_EXCEPTIONS if (ec) -throw system_error(error_code(ec, system_category()), "thread::detach failed"); -#endif // _LIBCPP_NO_EXCEPTIONS +__libcpp_throw(system_error(error_code(ec, system_category()), + "thread::detach failed")); } unsigned Index: src/system_error.cpp === --- src/system_error.cpp +++ src/system_error.cpp @@ -253,12 +253,7 @@ void __throw_system_error(int ev, const char* what_arg) { -#ifndef _LIBCPP_NO_EXCEPTIONS -throw system_error(error_code(ev, system_category()), what_arg); -#else -(void)ev; -(void)what_arg; -#endif +__libcpp_throw(system_error(error_code(ev, system_category()), what_arg)); } _LIBCPP_END_NAMESPACE_STD Index: src/string.cpp === --- src/string.cpp +++ src/string.cpp @@ -32,28 +32,16 @@ namespace { -template -inline -void throw_helper( const string& msg ) -{ -#ifndef _LIBCPP_NO_EXCEPTIONS -throw T( msg ); -#else -fprintf(stderr, "%s\n", msg.c_str()); -abort(); -#endif -} - inline void throw_from_string_out_of_range( const string& func ) { -throw_helper(func + ": out of range"); +__libcpp_throw(out_of_range(func + ": out of range")); } inline void throw_from_string_invalid_arg( const string& func ) { -throw_helper(func + ": no conversion"); +__libcpp_throw(invalid_argument(func + ": no conversion")); } // as_integer Index: src/new.cpp === --- src/new.cpp +++ src/new.cpp @@ -56,7 +56,7 @@ nh(); else #ifndef _LIBCPP_NO_EXCEPTIONS -throw std::bad_alloc(); +__libcpp_throw(std::bad_alloc()); #else break; #endif Index: src/locale.cpp === --- src/locale.cpp +++ src/locale.cpp @@ -436,10 +436,8 @@ const locale::facet* locale::__imp::use_facet(long id) const { -#ifndef _LIBCPP_NO_EXCEPTIONS if (!has_facet(id)) -throw bad_cast(); -#endif // _LIBCPP_NO_EXCEPTIONS +__libcpp_throw(bad_cast()); return facets_[static_cast(id)]; } @@ -528,6 +526,7 @@ #else // _LIBCPP_NO_EXCEPTIONS : __locale_(new __imp(*other.__locale_, name, c)) #endif + { __locale_->__add_shared(); } @@ -646,22 +645,18 @@ : collate(refs), __l(newlocale(LC_ALL_MASK, n, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) -throw runtime_error("collate_byname::collate_byname" -" failed to construct for " + string(n)); -#endif // _LIBCPP_NO_EXCEPTIONS +__libcpp_throw(runtime_error("collate_byname::collate_byname" +" failed to construct for " + string(n))); } collate_byname::collate_byname(const string& name, size_t refs) : collate(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (_
Re: [PATCH] D5896: Emit more intrinsics for builtin functions
arsenm closed this revision. arsenm added a comment. r274370 http://reviews.llvm.org/D5896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r274370 - Emit more intrinsics for builtin functions
Author: arsenm Date: Fri Jul 1 12:38:14 2016 New Revision: 274370 URL: http://llvm.org/viewvc/llvm-project?rev=274370&view=rev Log: Emit more intrinsics for builtin functions This is important for building libclc. Since r273039 tests are failing due to now emitting calls to these functions instead of emitting the DAG node. The libm function names are implemented for OpenCL, and should call the locally defined versions, so -fno-builtin is used. The IR Some functions use the __builtins and expect the intrinsics to be emitted. Without this we end up with nobuiltin calls to intrinsics or to unsupported library calls. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/builtins.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=274370&r1=274369&r2=274370&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 1 12:38:14 2016 @@ -217,6 +217,51 @@ static Value *MakeAtomicCmpXchgValue(Cod ValueType); } +// Emit a simple mangled intrinsic that has 1 argument and a return type +// matching the argument type. +static Value *emitUnaryBuiltin(CodeGenFunction &CGF, + const CallExpr *E, + unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + + Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, Src0); +} + +// Emit an intrinsic that has 2 operands of the same type as its result. +static Value *emitBinaryBuiltin(CodeGenFunction &CGF, +const CallExpr *E, +unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); + + Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, { Src0, Src1 }); +} + +// Emit an intrinsic that has 3 operands of the same type as its result. +static Value *emitTernaryBuiltin(CodeGenFunction &CGF, + const CallExpr *E, + unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); + llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); + + Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); +} + +// Emit an intrinsic that has 1 float or double operand, and 1 integer. +static Value *emitFPIntBuiltin(CodeGenFunction &CGF, + const CallExpr *E, + unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); + + Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, {Src0, Src1}); +} + /// EmitFAbs - Emit a call to @llvm.fabs(). static Value *EmitFAbs(CodeGenFunction &CGF, Value *V) { Value *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType()); @@ -286,40 +331,6 @@ static llvm::Value *EmitOverflowIntrinsi return CGF.Builder.CreateExtractValue(Tmp, 0); } -// Emit a simple mangled intrinsic that has 1 argument and a return type -// matching the argument type. -static Value *emitUnaryBuiltin(CodeGenFunction &CGF, - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, Src0); -} - -// Emit an intrinsic that has 3 float or double operands. -static Value *emitTernaryFPBuiltin(CodeGenFunction &CGF, - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, {Src0, Src1, Src2}); -} - -// Emit an intrinsic that has 1 float or double operand, and 1 integer. -static Value *emitFPIntBuiltin(CodeGenFunction &CGF, - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, {Src0, Src1}); -} - namespace { struct WidthAndSignedness { unsigned Width; @@ -497,9 +508,7 @@ RValue CodeGenFunction::EmitBuiltinExpr( case Builtin::BI__builtin_f
Re: [PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.
sfantao updated this revision to Diff 62507. sfantao marked 7 inline comments as done. sfantao added a comment. - Fix comments. - Mark functions properly with const and static. - Remove \brief. http://reviews.llvm.org/D21840 Files: include/clang/Driver/Action.h lib/Driver/Driver.cpp Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1894,7 +1894,7 @@ // Create the offload action with all dependences. When an offload action // is created the kinds are propagated to the host action, so we don't have -// to do that explicitely here. +// to do that explicitly here. OffloadAction::HostDependence HDep( *HostAction, *C.getSingleOffloadToolChain(), /*BoundArch*/ nullptr, ActiveOffloadKinds); @@ -2328,142 +2328,292 @@ } } } -/// Collapse an offloading action looking for a job of the given type. The input -/// action is changed to the input of the collapsed sequence. If we effectively -/// had a collapse return the corresponding offloading action, otherwise return -/// null. -template -static OffloadAction *collapseOffloadingAction(Action *&CurAction) { - if (!CurAction) -return nullptr; - if (auto *OA = dyn_cast(CurAction)) { -if (OA->hasHostDependence()) - if (auto *HDep = dyn_cast(OA->getHostDependence())) { -CurAction = HDep; -return OA; - } -if (OA->hasSingleDeviceDependence()) - if (auto *DDep = dyn_cast(OA->getSingleDeviceDependence())) { -CurAction = DDep; -return OA; + +namespace { +/// Utility class to control the collapse of dependent actions and select the +/// tools accordingly. +class ToolSelector final { + /// The tool chain this selector refers to. + const ToolChain &TC; + + /// The compilation this selector refers to. + const Compilation &C; + + /// The base action this selector refers to. + const JobAction *BaseAction; + + /// Set to true if the current toolchain refers to host actions. + bool IsHostSelector; + + /// Set to true if save-temps and embed-bitcode functionalities are active. + bool SaveTemps; + bool EmbedBitcode; + + /// Get dependence action or null if that does not exist. If \a CanBeCollapsed + /// is false, that action must be legal to collapse or null will be returned. + const JobAction *getDependenceAction(const ActionList &Inputs, + ActionList &SavedOffloadAction, + bool CanBeCollapsed = true) { +// An option can be collapsed only if it has a single input. +if (Inputs.size() != 1) + return nullptr; + +Action *CurAction = *Inputs.begin(); +if (!CurAction->isCollapsingWithDependingActionLegal() && CanBeCollapsed) + return nullptr; + +// If the input action is an offload action. Look through it and save any +// offload action that can be dropped in the event of a collapse. +if (auto *OA = dyn_cast(CurAction)) { + // If the depending action is a device action, we will attempt to collapse + // only with other device actions. Otherwise, we would do the same but + // with host actions only. + if (!IsHostSelector) { +if (OA->hasSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)) { + CurAction = + OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true); + if (!CurAction->isCollapsingWithDependingActionLegal() && + CanBeCollapsed) +return nullptr; + SavedOffloadAction.push_back(OA); + return dyn_cast(CurAction); +} + } else if (OA->hasHostDependence()) { +CurAction = OA->getHostDependence(); +if (!CurAction->isCollapsingWithDependingActionLegal() && +CanBeCollapsed) + return nullptr; +SavedOffloadAction.push_back(OA); +return dyn_cast(CurAction); } + return nullptr; +} + +return dyn_cast(CurAction); } - return nullptr; -} -// Returns a Tool for a given JobAction. In case the action and its -// predecessors can be combined, updates Inputs with the inputs of the -// first combined action. If one of the collapsed actions is a -// CudaHostAction, updates CollapsedCHA with the pointer to it so the -// caller can deal with extra handling such action requires. -static const Tool *selectToolForJob(Compilation &C, bool SaveTemps, -bool EmbedBitcode, const ToolChain *TC, -const JobAction *JA, -const ActionList *&Inputs, -ActionList &CollapsedOffloadAction) { - const Tool *ToolForJob = nullptr; - CollapsedOffloadAction.clear(); - - // See if we should look for a compiler with an integrated assembler. We match - // bottom up, so what we are actually looking for is an assembler job with a - // compiler in
Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry
john.brawn added a comment. Commit r274365 should make extract_symbols.py work with Python 3. Repository: rL LLVM http://reviews.llvm.org/D21385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder
sfantao updated this revision to Diff 62506. sfantao added a comment. - Use double instead of triple slash in one comment. http://reviews.llvm.org/D18172 Files: include/clang/Driver/Compilation.h lib/Driver/Driver.cpp Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1387,131 +1387,521 @@ } } -// For each unique --cuda-gpu-arch= argument creates a TY_CUDA_DEVICE -// input action and then wraps each in CudaDeviceAction paired with -// appropriate GPU arch name. In case of partial (i.e preprocessing -// only) or device-only compilation, each device action is added to /p -// Actions and /p Current is released. Otherwise the function creates -// and returns a new CudaHostAction which wraps /p Current and device -// side actions. -static Action *buildCudaActions(Compilation &C, DerivedArgList &Args, -const Arg *InputArg, Action *HostAction, -ActionList &Actions) { - Arg *PartialCompilationArg = Args.getLastArg( - options::OPT_cuda_host_only, options::OPT_cuda_device_only, - options::OPT_cuda_compile_host_device); - bool CompileHostOnly = - PartialCompilationArg && - PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only); - bool CompileDeviceOnly = - PartialCompilationArg && - PartialCompilationArg->getOption().matches(options::OPT_cuda_device_only); - - if (CompileHostOnly) { +namespace { +/// Provides a convenient interface for different programming models to generate +/// the required device actions. +class OffloadingActionBuilder final { + /// Flag used to trace errors in the builder. + bool IsValid = false; + + /// The compilation that is using this builder. + Compilation &C; + + /// The derived arguments associated with this builder. + DerivedArgList &Args; + + /// Map between an input argument and the offload kinds used to process it. + std::map InputArgToOffloadKindMap; + + /// Builder interface. It doesn't build anything or keep any state. + class DeviceActionBuilder { + public: +typedef llvm::SmallVector PhasesTy; + +enum ActionBuilderReturnCode { + // The builder acted successfully on the current action. + ABRT_Success, + // The builder didn't have to act on the current action. + ABRT_Inactive, + // The builder was successful and requested the host action to not be + // generated. + ABRT_Ignore_Host, +}; + + protected: +/// Compilation associated with this builder. +Compilation &C; + +/// Tool chains associated with this builder. The same programming +/// model may have associated one or more tool chains. +SmallVector ToolChains; + +/// The derived arguments associated with this builder. +DerivedArgList &Args; + +/// The inputs associated with this builder. +const Driver::InputList &Inputs; + +/// The associated offload kind. +Action::OffloadKind AssociatedOffloadKind = Action::OFK_None; + + public: +DeviceActionBuilder(Compilation &C, DerivedArgList &Args, +const Driver::InputList &Inputs, +Action::OffloadKind AssociatedOffloadKind) +: C(C), Args(Args), Inputs(Inputs), + AssociatedOffloadKind(AssociatedOffloadKind) {} +virtual ~DeviceActionBuilder() {} + +/// Fill up the array \a DA with all the device dependences that should be +/// added to the provided host action \a HostAction. By default it is +/// inactive. +virtual ActionBuilderReturnCode +getDeviceDepences(OffloadAction::DeviceDependences &DA, phases::ID CurPhase, + phases::ID FinalPhase, PhasesTy &Phases) { + return ABRT_Inactive; +} + +/// Update the state to include the provided host action \a HostAction as a +/// dependency of the current device action. By default it is inactive. +virtual ActionBuilderReturnCode addDeviceDepences(Action *HostAction) { + return ABRT_Inactive; +} + +/// Append top level actions generated by the builder. Return true if errors +/// were found. +virtual void appendTopLevelActions(ActionList &AL) {} + +/// Append linker actions generated by the builder. Return true if errors +/// were found. +virtual void appendLinkDependences(OffloadAction::DeviceDependences &DA) {} + +/// Initialize the builder. Return true if any initialization errors are +/// found. +virtual bool initialize() { return false; } + +/// Return true if this builder is valid. We have a valid builder if we have +/// associated device tool chains. +bool isValid() { return !ToolChains.empty(); } + +/// Return the associated offload kind. +Action::OffloadKind getAssociatedOffloadKind() { + return AssociatedOffloadKind; +} + }; + + /// \brief CUDA action builder. It injects device code in the host backend + ///
r274359 - Revert r274348 and r274349 until the Windows failures are fixed.
Author: vvassilev Date: Fri Jul 1 11:07:57 2016 New Revision: 274359 URL: http://llvm.org/viewvc/llvm-project?rev=274359&view=rev Log: Revert r274348 and r274349 until the Windows failures are fixed. Removed: cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/unittests/AST/CMakeLists.txt Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=274359&r1=274358&r2=274359&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jul 1 11:07:57 2016 @@ -72,8 +72,8 @@ namespace clang { return false; \ } while (0) -/// \brief A class that does preordor or postorder -/// depth-first traversal on the entire Clang AST and visits each node. +/// \brief A class that does preorder depth-first traversal on the +/// entire Clang AST and visits each node. /// /// This class performs three distinct tasks: /// 1. traverse the AST (i.e. go to each node); @@ -133,10 +133,6 @@ namespace clang { /// to return true, in which case all known implicit and explicit /// instantiations will be visited at the same time as the pattern /// from which they were produced. -/// -/// By default, this visitor preorder traverses the AST. If postorder traversal -/// is needed, the \c shouldTraversePostOrder method needs to be overriden -/// to return \c true. template class RecursiveASTVisitor { public: /// A queue used for performing data recursion over statements. @@ -162,9 +158,6 @@ public: /// code, e.g., implicit constructors and destructors. bool shouldVisitImplicitCode() const { return false; } - /// \brief Return whether this visitor should traverse post-order. - bool shouldTraversePostOrder() const { return false; } - /// \brief Recursively visit a statement or expression, by /// dispatching to Traverse*() based on the argument's dynamic type. /// @@ -356,7 +349,7 @@ public: bool TraverseUnary##NAME(UnaryOperator *S, \ DataRecursionQueue *Queue = nullptr) { \ TRY_TO(WalkUpFromUnary##NAME(S)); \ -TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \ +TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \ return true; \ } \ bool WalkUpFromUnary##NAME(UnaryOperator *S) { \ @@ -374,10 +367,9 @@ public: // (they're all opcodes in BinaryOperator) but do have visitors. #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \ bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { \ -if (!getDerived().shouldTraversePostOrder()) \ - TRY_TO(WalkUpFromBin##NAME(S)); \ -TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \ -TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \ +TRY_TO(WalkUpFromBin##NAME(S)); \ +TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \ +TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \ return true; \ } \ bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \ @@ -507,7 +499,6 @@ private: bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node); bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue); - bool PostVisitStmt(Stmt *S); }; template @@ -565,24 +556,6 @@ bool RecursiveASTVisitor::dataT #undef DISPATCH_STMT - -template -bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) { - switch (S->getStmtClass()) { - case Stmt::NoStmtClass: -break; -#define ABSTRACT_STMT(STMT) -#define STMT(CLASS, PARENT) \ - case Stmt::CLASS##Class: \ -TRY_TO(WalkUpFrom##CLASS(static_cast(S))); break; -#include "clang/AST/StmtNodes.inc" - } - - return true; -} - -#undef DISPATCH_STMT - template bool RecursiveASTVisitor::TraverseStmt(Stmt *S, DataRecursionQueue *Queue) { @@ -604,9 +577,6 @@ bool RecursiveASTVisitor::Trave if (Visited) { LocalQueue.po