From 6f437117af2fa9f380b0d866cd203aad6c30c9b1 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 22 Jul 2020 12:27:50 -0400 Subject: [PATCH 01/23] AMDGPU: Don't assert on f16 inv2pi immediates pre-gfx8 v_cvt_f32_f16 can still accept this value as a literal constant. This showed up in GlobalISel since it doesn't have constant folding for G_FPEXT. --- .../Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp | 4 ++-- llvm/test/MC/AMDGPU/inline-imm-inv2pi.s | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 llvm/test/MC/AMDGPU/inline-imm-inv2pi.s diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp index 257638b8d87ded..e44c0194e811b6 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp @@ -424,8 +424,8 @@ void AMDGPUInstPrinter::printImmediate16(uint32_t Imm, O<< "4.0"; else if (Imm == 0xC400) O<< "-4.0"; - else if (Imm == 0x3118) { - assert(STI.getFeatureBits()[AMDGPU::FeatureInv2PiInlineImm]); + else if (Imm == 0x3118 && + STI.getFeatureBits()[AMDGPU::FeatureInv2PiInlineImm]) { O << "0.15915494"; } else { uint64_t Imm16 = static_cast(Imm); diff --git a/llvm/test/MC/AMDGPU/inline-imm-inv2pi.s b/llvm/test/MC/AMDGPU/inline-imm-inv2pi.s new file mode 100644 index 00000000000000..e5ecfa293ba4d7 --- /dev/null +++ b/llvm/test/MC/AMDGPU/inline-imm-inv2pi.s @@ -0,0 +1,10 @@ +// RUN: llvm-mc -arch=amdgcn -mcpu=tahiti -show-encoding %s | FileCheck -check-prefix=SI %s +// RUN: llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s | FileCheck -check-prefix=VI %s + +// The value inv2pi should not assert on any targets, but is +// printed differently depending on whether it's a legal inline +// immediate or not. + +// SI: v_cvt_f32_f16_e32 v0, 0x3118 ; encoding: [0xff,0x16,0x00,0x7e,0x18,0x31,0x00,0x00] +// VI: v_cvt_f32_f16_e32 v0, 0.15915494 ; encoding: [0xf8,0x16,0x00,0x7e] +v_cvt_f32_f16_e32 v0, 0x3118 From 6dbd4775bf7ab92befb6d359d3bdf82fee285462 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 22 Jul 2020 11:01:16 -0700 Subject: [PATCH 02/23] Fix Windows build --- lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp index 072fe6aaf0f9f3..63bb6b7c404364 100644 --- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -363,7 +363,7 @@ TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) { CompilerType compiler_type = udt_type->GetForwardCompilerType(); EXPECT_TRUE(TypeSystemClang::IsClassType(compiler_type.GetOpaqueQualType())); EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_Class"), - udt_type->GetByteSize()); + udt_type->GetByteSize(nullptr)); } TEST_F(SymbolFilePDBTests, TestNestedClassTypes) { @@ -417,7 +417,7 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) { EXPECT_TRUE(TypeSystemClang::IsClassType(compiler_type.GetOpaqueQualType())); EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NestedClass"), - udt_type->GetByteSize()); + udt_type->GetByteSize(nullptr)); } TEST_F(SymbolFilePDBTests, TestClassInNamespace) { @@ -461,7 +461,7 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) { EXPECT_TRUE(TypeSystemClang::IsClassType(compiler_type.GetOpaqueQualType())); EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NSClass"), - udt_type->GetByteSize()); + udt_type->GetByteSize(nullptr)); } TEST_F(SymbolFilePDBTests, TestEnumTypes) { @@ -491,7 +491,7 @@ TEST_F(SymbolFilePDBTests, TestEnumTypes) { std::string sizeof_var = "sizeof_"; sizeof_var.append(Enum); EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var), - enum_type->GetByteSize()); + enum_type->GetByteSize(nullptr)); } } @@ -539,7 +539,7 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) { std::string sizeof_var = "sizeof_"; sizeof_var.append(Typedef); EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var), - typedef_type->GetByteSize()); + typedef_type->GetByteSize(nullptr)); } } From 708752b2f6c55eec85accf4d67b9e9da5a08ddf1 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Wed, 22 Jul 2020 14:04:58 -0400 Subject: [PATCH 03/23] [OpenMP] Implement TR8 `present` map type modifier in runtime (2/2) This implements OpenMP runtime support for the OpenMP TR8 `present` map type modifier. The previous patch in this series implements Clang front end support. See that patch summary for behaviors that are not yet supported. Reviewed By: grokos, jdoerfert Differential Revision: https://reviews.llvm.org/D83062 --- openmp/libomptarget/include/omptarget.h | 18 +++--- openmp/libomptarget/src/device.cpp | 57 ++++++++++------- openmp/libomptarget/src/device.h | 5 +- openmp/libomptarget/src/omptarget.cpp | 62 ++++++++++++++----- openmp/libomptarget/src/private.h | 12 +++- .../test/mapping/present/target.c | 42 +++++++++++++ .../test/mapping/present/target_data.c | 42 +++++++++++++ .../test/mapping/present/target_enter_data.c | 41 ++++++++++++ .../test/mapping/present/target_exit_data.c | 40 ++++++++++++ .../mapping/present/unified_shared_memory.c | 41 ++++++++++++ .../present/zero_length_array_section.c | 45 ++++++++++++++ .../present/zero_length_array_section_exit.c | 43 +++++++++++++ 12 files changed, 398 insertions(+), 50 deletions(-) create mode 100644 openmp/libomptarget/test/mapping/present/target.c create mode 100644 openmp/libomptarget/test/mapping/present/target_data.c create mode 100644 openmp/libomptarget/test/mapping/present/target_enter_data.c create mode 100644 openmp/libomptarget/test/mapping/present/target_exit_data.c create mode 100644 openmp/libomptarget/test/mapping/present/unified_shared_memory.c create mode 100644 openmp/libomptarget/test/mapping/present/zero_length_array_section.c create mode 100644 openmp/libomptarget/test/mapping/present/zero_length_array_section_exit.c diff --git a/openmp/libomptarget/include/omptarget.h b/openmp/libomptarget/include/omptarget.h index 95d7158969f344..0751816cd9d9eb 100644 --- a/openmp/libomptarget/include/omptarget.h +++ b/openmp/libomptarget/include/omptarget.h @@ -49,6 +49,8 @@ enum tgt_map_type { OMP_TGT_MAPTYPE_IMPLICIT = 0x200, // copy data to device OMP_TGT_MAPTYPE_CLOSE = 0x400, + // runtime error if not already allocated + OMP_TGT_MAPTYPE_PRESENT = 0x1000, // member of struct, member given by [16 MSBs] - 1 OMP_TGT_MAPTYPE_MEMBER_OF = 0xffff000000000000 }; @@ -259,14 +261,6 @@ void __kmpc_push_target_tripcount(int64_t device_id, uint64_t loop_tripcount); } #endif -#ifdef OMPTARGET_DEBUG -#include -#define DEBUGP(prefix, ...) \ - { \ - fprintf(stderr, "%s --> ", prefix); \ - fprintf(stderr, __VA_ARGS__); \ - } - #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif @@ -293,6 +287,14 @@ void __kmpc_push_target_tripcount(int64_t device_id, uint64_t loop_tripcount); * // 16 digits for 64bit * (uintptr_t) ptr); */ + +#ifdef OMPTARGET_DEBUG +#include +#define DEBUGP(prefix, ...) \ + { \ + fprintf(stderr, "%s --> ", prefix); \ + fprintf(stderr, __VA_ARGS__); \ + } #else #define DEBUGP(prefix, ...) \ {} diff --git a/openmp/libomptarget/src/device.cpp b/openmp/libomptarget/src/device.cpp index 575354305dda0e..867083fde48927 100644 --- a/openmp/libomptarget/src/device.cpp +++ b/openmp/libomptarget/src/device.cpp @@ -160,8 +160,10 @@ LookupResult DeviceTy::lookupMapping(void *HstPtrBegin, int64_t Size) { // If NULL is returned, then either data allocation failed or the user tried // to do an illegal mapping. void *DeviceTy::getOrAllocTgtPtr(void *HstPtrBegin, void *HstPtrBase, - int64_t Size, bool &IsNew, bool &IsHostPtr, bool IsImplicit, - bool UpdateRefCount, bool HasCloseModifier) { + int64_t Size, bool &IsNew, bool &IsHostPtr, + bool IsImplicit, bool UpdateRefCount, + bool HasCloseModifier, + bool HasPresentModifier) { void *rc = NULL; IsHostPtr = false; IsNew = false; @@ -190,31 +192,40 @@ void *DeviceTy::getOrAllocTgtPtr(void *HstPtrBegin, void *HstPtrBase, } else if ((lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter) && !IsImplicit) { // Explicit extension of mapped data - not allowed. DP("Explicit extension of mapping is not allowed.\n"); - } else if (Size) { - // If unified shared memory is active, implicitly mapped variables that are not - // privatized use host address. Any explicitly mapped variables also use - // host address where correctness is not impeded. In all other cases - // maps are respected. - // In addition to the mapping rules above, the close map - // modifier forces the mapping of the variable to the device. - if (RTLs->RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY && - !HasCloseModifier) { + } else if (RTLs->RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY && + !HasCloseModifier) { + // If unified shared memory is active, implicitly mapped variables that are + // not privatized use host address. Any explicitly mapped variables also use + // host address where correctness is not impeded. In all other cases maps + // are respected. + // In addition to the mapping rules above, the close map modifier forces the + // mapping of the variable to the device. + if (Size) { DP("Return HstPtrBegin " DPxMOD " Size=%ld RefCount=%s\n", - DPxPTR((uintptr_t)HstPtrBegin), Size, (UpdateRefCount ? " updated" : "")); + DPxPTR((uintptr_t)HstPtrBegin), Size, + (UpdateRefCount ? " updated" : "")); IsHostPtr = true; rc = HstPtrBegin; - } else { - // If it is not contained and Size > 0 we should create a new entry for it. - IsNew = true; - uintptr_t tp = (uintptr_t)RTL->data_alloc(RTLDeviceID, Size, HstPtrBegin); - DP("Creating new map entry: HstBase=" DPxMOD ", HstBegin=" DPxMOD ", " - "HstEnd=" DPxMOD ", TgtBegin=" DPxMOD "\n", DPxPTR(HstPtrBase), - DPxPTR(HstPtrBegin), DPxPTR((uintptr_t)HstPtrBegin + Size), DPxPTR(tp)); - HostDataToTargetMap.emplace( - HostDataToTargetTy((uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin, - (uintptr_t)HstPtrBegin + Size, tp)); - rc = (void *)tp; } + } else if (HasPresentModifier) { + DP("Mapping required by 'present' map type modifier does not exist for " + "HstPtrBegin=" DPxMOD ", Size=%ld\n", + DPxPTR(HstPtrBegin), Size); + MESSAGE("device mapping required by 'present' map type modifier does not " + "exist for host address " DPxMOD " (%ld bytes)", + DPxPTR(HstPtrBegin), Size); + } else if (Size) { + // If it is not contained and Size > 0, we should create a new entry for it. + IsNew = true; + uintptr_t tp = (uintptr_t)RTL->data_alloc(RTLDeviceID, Size, HstPtrBegin); + DP("Creating new map entry: HstBase=" DPxMOD ", HstBegin=" DPxMOD ", " + "HstEnd=" DPxMOD ", TgtBegin=" DPxMOD "\n", + DPxPTR(HstPtrBase), DPxPTR(HstPtrBegin), + DPxPTR((uintptr_t)HstPtrBegin + Size), DPxPTR(tp)); + HostDataToTargetMap.emplace( + HostDataToTargetTy((uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin, + (uintptr_t)HstPtrBegin + Size, tp)); + rc = (void *)tp; } DataMapMtx.unlock(); diff --git a/openmp/libomptarget/src/device.h b/openmp/libomptarget/src/device.h index 309785acb47215..ebec76c3cf62ab 100644 --- a/openmp/libomptarget/src/device.h +++ b/openmp/libomptarget/src/device.h @@ -177,8 +177,9 @@ struct DeviceTy { uint64_t getMapEntryRefCnt(void *HstPtrBegin); LookupResult lookupMapping(void *HstPtrBegin, int64_t Size); void *getOrAllocTgtPtr(void *HstPtrBegin, void *HstPtrBase, int64_t Size, - bool &IsNew, bool &IsHostPtr, bool IsImplicit, bool UpdateRefCount = true, - bool HasCloseModifier = false); + bool &IsNew, bool &IsHostPtr, bool IsImplicit, + bool UpdateRefCount, bool HasCloseModifier, + bool HasPresentModifier); void *getTgtPtrBegin(void *HstPtrBegin, int64_t Size); void *getTgtPtrBegin(void *HstPtrBegin, int64_t Size, bool &IsLast, bool UpdateRefCount, bool &IsHostPtr); diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp index 6b4549be6ae118..47971b9c0a00a3 100644 --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -308,6 +308,7 @@ int target_data_begin(DeviceTy &Device, int32_t arg_num, void **args_base, // Force the creation of a device side copy of the data when: // a close map modifier was associated with a map that contained a to. bool HasCloseModifier = arg_types[i] & OMP_TGT_MAPTYPE_CLOSE; + bool HasPresentModifier = arg_types[i] & OMP_TGT_MAPTYPE_PRESENT; // UpdateRef is based on MEMBER_OF instead of TARGET_PARAM because if we // have reached this point via __tgt_target_data_begin and not __tgt_target // then no argument is marked as TARGET_PARAM ("omp target data map" is not @@ -316,13 +317,26 @@ int target_data_begin(DeviceTy &Device, int32_t arg_num, void **args_base, bool UpdateRef = !(arg_types[i] & OMP_TGT_MAPTYPE_MEMBER_OF); if (arg_types[i] & OMP_TGT_MAPTYPE_PTR_AND_OBJ) { DP("Has a pointer entry: \n"); - // base is address of pointer. - Pointer_TgtPtrBegin = Device.getOrAllocTgtPtr(HstPtrBase, HstPtrBase, - sizeof(void *), Pointer_IsNew, IsHostPtr, IsImplicit, UpdateRef, - HasCloseModifier); + // Base is address of pointer. + // + // Usually, the pointer is already allocated by this time. For example: + // + // #pragma omp target map(s.p[0:N]) + // + // The map entry for s comes first, and the PTR_AND_OBJ entry comes + // afterward, so the pointer is already allocated by the time the + // PTR_AND_OBJ entry is handled below, and Pointer_TgtPtrBegin is thus + // non-null. However, "declare target link" can produce a PTR_AND_OBJ + // entry for a global that might not already be allocated by the time the + // PTR_AND_OBJ entry is handled below, and so the allocation might fail + // when HasPresentModifier. + Pointer_TgtPtrBegin = Device.getOrAllocTgtPtr( + HstPtrBase, HstPtrBase, sizeof(void *), Pointer_IsNew, IsHostPtr, + IsImplicit, UpdateRef, HasCloseModifier, HasPresentModifier); if (!Pointer_TgtPtrBegin) { - DP("Call to getOrAllocTgtPtr returned null pointer (device failure or " - "illegal mapping).\n"); + DP("Call to getOrAllocTgtPtr returned null pointer (%s).\n", + HasPresentModifier ? "'present' map type modifier" + : "device failure or illegal mapping"); return OFFLOAD_FAIL; } DP("There are %zu bytes allocated at target address " DPxMOD " - is%s new" @@ -334,13 +348,15 @@ int target_data_begin(DeviceTy &Device, int32_t arg_num, void **args_base, UpdateRef = true; // subsequently update ref count of pointee } - void *TgtPtrBegin = Device.getOrAllocTgtPtr(HstPtrBegin, HstPtrBase, - data_size, IsNew, IsHostPtr, IsImplicit, UpdateRef, HasCloseModifier); - if (!TgtPtrBegin && data_size) { - // If data_size==0, then the argument could be a zero-length pointer to - // NULL, so getOrAlloc() returning NULL is not an error. - DP("Call to getOrAllocTgtPtr returned null pointer (device failure or " - "illegal mapping).\n"); + void *TgtPtrBegin = Device.getOrAllocTgtPtr( + HstPtrBegin, HstPtrBase, data_size, IsNew, IsHostPtr, IsImplicit, + UpdateRef, HasCloseModifier, HasPresentModifier); + // If data_size==0, then the argument could be a zero-length pointer to + // NULL, so getOrAlloc() returning NULL is not an error. + if (!TgtPtrBegin && (data_size || HasPresentModifier)) { + DP("Call to getOrAllocTgtPtr returned null pointer (%s).\n", + HasPresentModifier ? "'present' map type modifier" + : "device failure or illegal mapping"); return OFFLOAD_FAIL; } DP("There are %" PRId64 " bytes allocated at target address " DPxMOD @@ -459,13 +475,27 @@ int target_data_end(DeviceTy &Device, int32_t arg_num, void **args_base, (arg_types[i] & OMP_TGT_MAPTYPE_PTR_AND_OBJ); bool ForceDelete = arg_types[i] & OMP_TGT_MAPTYPE_DELETE; bool HasCloseModifier = arg_types[i] & OMP_TGT_MAPTYPE_CLOSE; + bool HasPresentModifier = arg_types[i] & OMP_TGT_MAPTYPE_PRESENT; // If PTR_AND_OBJ, HstPtrBegin is address of pointee void *TgtPtrBegin = Device.getTgtPtrBegin(HstPtrBegin, data_size, IsLast, UpdateRef, IsHostPtr); - DP("There are %" PRId64 " bytes allocated at target address " DPxMOD - " - is%s last\n", data_size, DPxPTR(TgtPtrBegin), - (IsLast ? "" : " not")); + if (!TgtPtrBegin && (data_size || HasPresentModifier)) { + DP("Mapping does not exist (%s)\n", + (HasPresentModifier ? "'present' map type modifier" : "ignored")); + if (HasPresentModifier) { + // FIXME: This should not be an error on exit from "omp target data", + // but it should be an error upon entering an "omp target exit data". + MESSAGE("device mapping required by 'present' map type modifier does " + "not exist for host address " DPxMOD " (%ld bytes)", + DPxPTR(HstPtrBegin), data_size); + return OFFLOAD_FAIL; + } + } else { + DP("There are %" PRId64 " bytes allocated at target address " DPxMOD + " - is%s last\n", + data_size, DPxPTR(TgtPtrBegin), (IsLast ? "" : " not")); + } bool DelEntry = IsLast || ForceDelete; diff --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h index cb20d8cdc79070..7772175cdca2e1 100644 --- a/openmp/libomptarget/src/private.h +++ b/openmp/libomptarget/src/private.h @@ -80,9 +80,19 @@ typedef int (*TargetDataFuncPtrTy)(DeviceTy &, int32_t, void **, void **, int64_t *, int64_t *, void **, __tgt_async_info *); //////////////////////////////////////////////////////////////////////////////// -// implementation for fatal messages +// implementation for messages //////////////////////////////////////////////////////////////////////////////// +#define MESSAGE0(_str) \ + do { \ + fprintf(stderr, "Libomptarget message: %s\n", _str); \ + } while (0) + +#define MESSAGE(_str, ...) \ + do { \ + fprintf(stderr, "Libomptarget message: " _str "\n", __VA_ARGS__); \ + } while (0) + #define FATAL_MESSAGE0(_num, _str) \ do { \ fprintf(stderr, "Libomptarget fatal error %d: %s\n", _num, _str); \ diff --git a/openmp/libomptarget/test/mapping/present/target.c b/openmp/libomptarget/test/mapping/present/target.c new file mode 100644 index 00000000000000..1d61dc06baa429 --- /dev/null +++ b/openmp/libomptarget/test/mapping/present/target.c @@ -0,0 +1,42 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +#include + +int main() { + int i; + + // CHECK: addr=0x[[#%x,HOST_ADDR:]], size=[[#%u,SIZE:]] + fprintf(stderr, "addr=%p, size=%ld\n", &i, sizeof i); + + // CHECK-NOT: Libomptarget +#pragma omp target data map(alloc: i) +#pragma omp target map(present, alloc: i) + ; + + // CHECK: i is present + fprintf(stderr, "i is present\n"); + + // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] ([[#SIZE]] bytes) + // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory +#pragma omp target map(present, alloc: i) + ; + + // CHECK-NOT: i is present + fprintf(stderr, "i is present\n"); + + return 0; +} diff --git a/openmp/libomptarget/test/mapping/present/target_data.c b/openmp/libomptarget/test/mapping/present/target_data.c new file mode 100644 index 00000000000000..fd3107d87fefc0 --- /dev/null +++ b/openmp/libomptarget/test/mapping/present/target_data.c @@ -0,0 +1,42 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +#include + +int main() { + int i; + + // CHECK: addr=0x[[#%x,HOST_ADDR:]], size=[[#%u,SIZE:]] + fprintf(stderr, "addr=%p, size=%ld\n", &i, sizeof i); + + // CHECK-NOT: Libomptarget +#pragma omp target data map(alloc: i) +#pragma omp target data map(present, alloc: i) + ; + + // CHECK: i is present + fprintf(stderr, "i is present\n"); + + // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] ([[#SIZE]] bytes) + // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory +#pragma omp target data map(present, alloc: i) + ; + + // CHECK-NOT: i is present + fprintf(stderr, "i is present\n"); + + return 0; +} diff --git a/openmp/libomptarget/test/mapping/present/target_enter_data.c b/openmp/libomptarget/test/mapping/present/target_enter_data.c new file mode 100644 index 00000000000000..d96e7a4140da97 --- /dev/null +++ b/openmp/libomptarget/test/mapping/present/target_enter_data.c @@ -0,0 +1,41 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +#include + +int main() { + int i; + + // CHECK: addr=0x[[#%x,HOST_ADDR:]], size=[[#%u,SIZE:]] + fprintf(stderr, "addr=%p, size=%ld\n", &i, sizeof i); + + // CHECK-NOT: Libomptarget +#pragma omp target enter data map(alloc: i) +#pragma omp target enter data map(present, alloc: i) +#pragma omp target exit data map(delete: i) + + // CHECK: i is present + fprintf(stderr, "i is present\n"); + + // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] ([[#SIZE]] bytes) + // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory +#pragma omp target enter data map(present, alloc: i) + + // CHECK-NOT: i is present + fprintf(stderr, "i is present\n"); + + return 0; +} diff --git a/openmp/libomptarget/test/mapping/present/target_exit_data.c b/openmp/libomptarget/test/mapping/present/target_exit_data.c new file mode 100644 index 00000000000000..86b7ad89ce3ada --- /dev/null +++ b/openmp/libomptarget/test/mapping/present/target_exit_data.c @@ -0,0 +1,40 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +#include + +int main() { + int i; + + // CHECK: addr=0x[[#%x,HOST_ADDR:]], size=[[#%u,SIZE:]] + fprintf(stderr, "addr=%p, size=%ld\n", &i, sizeof i); + + // CHECK-NOT: Libomptarget +#pragma omp target enter data map(alloc: i) +#pragma omp target exit data map(present, release: i) + + // CHECK: i is present + fprintf(stderr, "i is present\n"); + + // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] ([[#SIZE]] bytes) + // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory +#pragma omp target exit data map(present, release: i) + + // CHECK-NOT: i is present + fprintf(stderr, "i is present\n"); + + return 0; +} diff --git a/openmp/libomptarget/test/mapping/present/unified_shared_memory.c b/openmp/libomptarget/test/mapping/present/unified_shared_memory.c new file mode 100644 index 00000000000000..22d87460179cac --- /dev/null +++ b/openmp/libomptarget/test/mapping/present/unified_shared_memory.c @@ -0,0 +1,41 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +#include + +// The runtime considers unified shared memory to be always present. +#pragma omp requires unified_shared_memory + +int main() { + int i; + + // CHECK-NOT: Libomptarget +#pragma omp target data map(alloc: i) +#pragma omp target map(present, alloc: i) + ; + + // CHECK: i is present + fprintf(stderr, "i is present\n"); + + // CHECK-NOT: Libomptarget +#pragma omp target map(present, alloc: i) + ; + + // CHECK: is present + fprintf(stderr, "i is present\n"); + + return 0; +} diff --git a/openmp/libomptarget/test/mapping/present/zero_length_array_section.c b/openmp/libomptarget/test/mapping/present/zero_length_array_section.c new file mode 100644 index 00000000000000..5488888e14018a --- /dev/null +++ b/openmp/libomptarget/test/mapping/present/zero_length_array_section.c @@ -0,0 +1,45 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +#include + +int main() { + int arr[5]; + + // CHECK: addr=0x[[#%x,HOST_ADDR:]] + fprintf(stderr, "addr=%p\n", arr); + + // CHECK-NOT: Libomptarget +#pragma omp target data map(alloc: arr[0:5]) +#pragma omp target map(present, alloc: arr[0:0]) + ; + + // CHECK: arr is present + fprintf(stderr, "arr is present\n"); + + // arr[0:0] doesn't create an actual mapping in the first directive. + // + // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] (0 bytes) + // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory +#pragma omp target data map(alloc: arr[0:0]) +#pragma omp target map(present, alloc: arr[0:0]) + ; + + // CHECK-NOT: arr is present + fprintf(stderr, "arr is present\n"); + + return 0; +} diff --git a/openmp/libomptarget/test/mapping/present/zero_length_array_section_exit.c b/openmp/libomptarget/test/mapping/present/zero_length_array_section_exit.c new file mode 100644 index 00000000000000..bedc6a2729c56c --- /dev/null +++ b/openmp/libomptarget/test/mapping/present/zero_length_array_section_exit.c @@ -0,0 +1,43 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 +// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +#include + +int main() { + int arr[5]; + + // CHECK: addr=0x[[#%x,HOST_ADDR:]] + fprintf(stderr, "addr=%p\n", arr); + + // CHECK-NOT: Libomptarget +#pragma omp target enter data map(alloc: arr[0:5]) +#pragma omp target exit data map(present, release: arr[0:0]) + + // CHECK: arr is present + fprintf(stderr, "arr is present\n"); + + // arr[0:0] doesn't create an actual mapping in the first directive. + // + // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] (0 bytes) + // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory +#pragma omp target enter data map(alloc: arr[0:0]) +#pragma omp target exit data map(present, release: arr[0:0]) + + // CHECK-NOT: arr is present + fprintf(stderr, "arr is present\n"); + + return 0; +} From d074749423a7ae33365aecc09548e2a83dbaed98 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 22 Jul 2020 14:10:17 -0400 Subject: [PATCH 04/23] [gn build] (manually) port 746b5fad5b --- llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn index ca24b4b4037838..97007eecd1eb92 100644 --- a/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn +++ b/llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn @@ -37,6 +37,7 @@ write_cmake_config("lit_common_configured") { "LLVM_LIBCXX_USED=0", "GOLD_EXECUTABLE=ld", + "GNU_LD_EXECUTABLE=ld", "COMPILER_RT_RESOLVED_TEST_COMPILER=" + rebase_path("$root_build_dir/bin/clang"), "COMPILER_RT_TEST_COMPILER_ID=Clang", From 0c92bfa4b8fd47a5525ce967fd3ba6f7557ea408 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 8 Jul 2020 20:36:48 -0400 Subject: [PATCH 05/23] GlobalISel: Don't use virtual for distinguishing arg handlers There's no reason to involve the hassle of a virtual method targets have to override for a simple boolean. Not sure exactly what's going on with Mips, but it seems to define its own totally separate handler classes. --- .../llvm/CodeGen/GlobalISel/CallLowering.h | 24 +++++-- .../AArch64/GISel/AArch64CallLowering.cpp | 12 ++-- llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp | 59 +++++++--------- llvm/lib/Target/ARM/ARMCallLowering.cpp | 34 +++++---- llvm/lib/Target/Mips/MipsCallLowering.cpp | 69 ++++++++++--------- llvm/lib/Target/X86/X86CallLowering.cpp | 33 ++++----- 6 files changed, 116 insertions(+), 115 deletions(-) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h index 442c824e22c0c3..6eb5c853bb3622 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h @@ -111,15 +111,18 @@ class CallLowering { /// argument should go, exactly what happens can vary slightly. This /// class abstracts the differences. struct ValueHandler { - ValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, - CCAssignFn *AssignFn) - : MIRBuilder(MIRBuilder), MRI(MRI), AssignFn(AssignFn) {} + ValueHandler(bool IsIncoming, MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI, CCAssignFn *AssignFn) + : MIRBuilder(MIRBuilder), MRI(MRI), AssignFn(AssignFn), + IsIncomingArgumentHandler(IsIncoming) {} virtual ~ValueHandler() = default; /// Returns true if the handler is dealing with incoming arguments, /// i.e. those that move values from some physical location to vregs. - virtual bool isIncomingArgumentHandler() const = 0; + bool isIncomingArgumentHandler() const { + return IsIncomingArgumentHandler; + } /// Materialize a VReg containing the address of the specified /// stack-based object. This is either based on a FrameIndex or @@ -178,9 +181,22 @@ class CallLowering { CCAssignFn *AssignFn; private: + bool IsIncomingArgumentHandler; virtual void anchor(); }; + struct IncomingValueHandler : public ValueHandler { + IncomingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, + CCAssignFn *AssignFn) + : ValueHandler(true, MIRBuilder, MRI, AssignFn) {} + }; + + struct OutgoingValueHandler : public ValueHandler { + OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, + CCAssignFn *AssignFn) + : ValueHandler(false, MIRBuilder, MRI, AssignFn) {} + }; + protected: /// Getter for generic TargetLowering class. const TargetLowering *getTLI() const { diff --git a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp index 8b2b87a4c2e4ce..62bc38e307bff8 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp @@ -52,10 +52,10 @@ AArch64CallLowering::AArch64CallLowering(const AArch64TargetLowering &TLI) : CallLowering(&TLI) {} namespace { -struct IncomingArgHandler : public CallLowering::ValueHandler { +struct IncomingArgHandler : public CallLowering::IncomingValueHandler { IncomingArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, CCAssignFn *AssignFn) - : ValueHandler(MIRBuilder, MRI, AssignFn), StackUsed(0) {} + : IncomingValueHandler(MIRBuilder, MRI, AssignFn), StackUsed(0) {} Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { @@ -98,8 +98,6 @@ struct IncomingArgHandler : public CallLowering::ValueHandler { /// (it's an implicit-def of the BL). virtual void markPhysRegUsed(unsigned PhysReg) = 0; - bool isIncomingArgumentHandler() const override { return true; } - uint64_t StackUsed; }; @@ -126,17 +124,15 @@ struct CallReturnHandler : public IncomingArgHandler { MachineInstrBuilder MIB; }; -struct OutgoingArgHandler : public CallLowering::ValueHandler { +struct OutgoingArgHandler : public CallLowering::OutgoingValueHandler { OutgoingArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstrBuilder MIB, CCAssignFn *AssignFn, CCAssignFn *AssignFnVarArg, bool IsTailCall = false, int FPDiff = 0) - : ValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB), + : OutgoingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB), AssignFnVarArg(AssignFnVarArg), IsTailCall(IsTailCall), FPDiff(FPDiff), StackSize(0), SPReg(0) {} - bool isIncomingArgumentHandler() const override { return false; } - Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { MachineFunction &MF = MIRBuilder.getMF(); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp index 269ce77cac4d9e..791b10f4917177 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp @@ -35,9 +35,9 @@ using namespace llvm; namespace { struct AMDGPUValueHandler : public CallLowering::ValueHandler { - AMDGPUValueHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI, - CCAssignFn *AssignFn) - : ValueHandler(B, MRI, AssignFn) {} + AMDGPUValueHandler(bool IsIncoming, MachineIRBuilder &B, + MachineRegisterInfo &MRI, CCAssignFn *AssignFn) + : ValueHandler(IsIncoming, B, MRI, AssignFn) {} /// Wrapper around extendRegister to ensure we extend to a full 32-bit /// register. @@ -52,15 +52,13 @@ struct AMDGPUValueHandler : public CallLowering::ValueHandler { } }; -struct OutgoingValueHandler : public AMDGPUValueHandler { - OutgoingValueHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI, - MachineInstrBuilder MIB, CCAssignFn *AssignFn) - : AMDGPUValueHandler(B, MRI, AssignFn), MIB(MIB) {} +struct AMDGPUOutgoingValueHandler : public AMDGPUValueHandler { + AMDGPUOutgoingValueHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI, + MachineInstrBuilder MIB, CCAssignFn *AssignFn) + : AMDGPUValueHandler(false, B, MRI, AssignFn), MIB(MIB) {} MachineInstrBuilder MIB; - bool isIncomingArgumentHandler() const override { return false; } - Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { llvm_unreachable("not implemented"); @@ -100,12 +98,12 @@ struct OutgoingValueHandler : public AMDGPUValueHandler { } }; -struct IncomingArgHandler : public AMDGPUValueHandler { +struct AMDGPUIncomingArgHandler : public AMDGPUValueHandler { uint64_t StackUsed = 0; - IncomingArgHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI, - CCAssignFn *AssignFn) - : AMDGPUValueHandler(B, MRI, AssignFn) {} + AMDGPUIncomingArgHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI, + CCAssignFn *AssignFn) + : AMDGPUValueHandler(true, B, MRI, AssignFn) {} Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { @@ -163,25 +161,22 @@ struct IncomingArgHandler : public AMDGPUValueHandler { /// parameters (it's a basic-block live-in), and a call instruction /// (it's an implicit-def of the BL). virtual void markPhysRegUsed(unsigned PhysReg) = 0; - - // FIXME: What is the point of this being a callback? - bool isIncomingArgumentHandler() const override { return true; } }; -struct FormalArgHandler : public IncomingArgHandler { +struct FormalArgHandler : public AMDGPUIncomingArgHandler { FormalArgHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI, CCAssignFn *AssignFn) - : IncomingArgHandler(B, MRI, AssignFn) {} + : AMDGPUIncomingArgHandler(B, MRI, AssignFn) {} void markPhysRegUsed(unsigned PhysReg) override { MIRBuilder.getMBB().addLiveIn(PhysReg); } }; -struct CallReturnHandler : public IncomingArgHandler { +struct CallReturnHandler : public AMDGPUIncomingArgHandler { CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstrBuilder MIB, CCAssignFn *AssignFn) - : IncomingArgHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} + : AMDGPUIncomingArgHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} void markPhysRegUsed(unsigned PhysReg) override { MIB.addDef(PhysReg, RegState::Implicit); @@ -190,7 +185,7 @@ struct CallReturnHandler : public IncomingArgHandler { MachineInstrBuilder MIB; }; -struct OutgoingArgHandler : public AMDGPUValueHandler { +struct AMDGPUOutgoingArgHandler : public AMDGPUValueHandler { MachineInstrBuilder MIB; CCAssignFn *AssignFnVarArg; @@ -203,15 +198,13 @@ struct OutgoingArgHandler : public AMDGPUValueHandler { bool IsTailCall; - OutgoingArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, - MachineInstrBuilder MIB, CCAssignFn *AssignFn, - CCAssignFn *AssignFnVarArg, bool IsTailCall = false, - int FPDiff = 0) - : AMDGPUValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB), - AssignFnVarArg(AssignFnVarArg), - FPDiff(FPDiff), IsTailCall(IsTailCall) {} - - bool isIncomingArgumentHandler() const override { return false; } + AMDGPUOutgoingArgHandler(MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI, MachineInstrBuilder MIB, + CCAssignFn *AssignFn, CCAssignFn *AssignFnVarArg, + bool IsTailCall = false, int FPDiff = 0) + : AMDGPUValueHandler(false, MIRBuilder, MRI, AssignFn), MIB(MIB), + AssignFnVarArg(AssignFnVarArg), FPDiff(FPDiff), IsTailCall(IsTailCall) { + } Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { @@ -443,7 +436,7 @@ bool AMDGPUCallLowering::lowerReturnVal(MachineIRBuilder &B, }); CCAssignFn *AssignFn = TLI.CCAssignFnForReturn(CC, F.isVarArg()); - OutgoingValueHandler RetHandler(B, *MRI, Ret, AssignFn); + AMDGPUOutgoingValueHandler RetHandler(B, *MRI, Ret, AssignFn); return handleAssignments(B, SplitRetInfos, RetHandler); } @@ -1217,8 +1210,8 @@ bool AMDGPUCallLowering::lowerCall(MachineIRBuilder &MIRBuilder, // Do the actual argument marshalling. SmallVector PhysRegs; - OutgoingArgHandler Handler(MIRBuilder, MRI, MIB, AssignFnFixed, - AssignFnVarArg, false); + AMDGPUOutgoingArgHandler Handler(MIRBuilder, MRI, MIB, AssignFnFixed, + AssignFnVarArg, false); if (!handleAssignments(CCInfo, ArgLocs, MIRBuilder, OutArgs, Handler)) return false; diff --git a/llvm/lib/Target/ARM/ARMCallLowering.cpp b/llvm/lib/Target/ARM/ARMCallLowering.cpp index 4f1410eecff4f7..0b2427e4142006 100644 --- a/llvm/lib/Target/ARM/ARMCallLowering.cpp +++ b/llvm/lib/Target/ARM/ARMCallLowering.cpp @@ -85,12 +85,11 @@ namespace { /// Helper class for values going out through an ABI boundary (used for handling /// function return values and call parameters). -struct OutgoingValueHandler : public CallLowering::ValueHandler { - OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, - MachineInstrBuilder &MIB, CCAssignFn *AssignFn) - : ValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} - - bool isIncomingArgumentHandler() const override { return false; } +struct ARMOutgoingValueHandler : public CallLowering::OutgoingValueHandler { + ARMOutgoingValueHandler(MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI, MachineInstrBuilder &MIB, + CCAssignFn *AssignFn) + : OutgoingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { @@ -258,7 +257,8 @@ bool ARMCallLowering::lowerReturnVal(MachineIRBuilder &MIRBuilder, CCAssignFn *AssignFn = TLI.CCAssignFnForReturn(F.getCallingConv(), F.isVarArg()); - OutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), Ret, AssignFn); + ARMOutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), Ret, + AssignFn); return handleAssignments(MIRBuilder, SplitRetInfos, RetHandler); } @@ -282,12 +282,10 @@ namespace { /// Helper class for values coming in through an ABI boundary (used for handling /// formal arguments and call return values). -struct IncomingValueHandler : public CallLowering::ValueHandler { - IncomingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, - CCAssignFn AssignFn) - : ValueHandler(MIRBuilder, MRI, AssignFn) {} - - bool isIncomingArgumentHandler() const override { return true; } +struct ARMIncomingValueHandler : public CallLowering::IncomingValueHandler { + ARMIncomingValueHandler(MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI, CCAssignFn AssignFn) + : IncomingValueHandler(MIRBuilder, MRI, AssignFn) {} Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { @@ -399,10 +397,10 @@ struct IncomingValueHandler : public CallLowering::ValueHandler { virtual void markPhysRegUsed(unsigned PhysReg) = 0; }; -struct FormalArgHandler : public IncomingValueHandler { +struct FormalArgHandler : public ARMIncomingValueHandler { FormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, CCAssignFn AssignFn) - : IncomingValueHandler(MIRBuilder, MRI, AssignFn) {} + : ARMIncomingValueHandler(MIRBuilder, MRI, AssignFn) {} void markPhysRegUsed(unsigned PhysReg) override { MIRBuilder.getMRI()->addLiveIn(PhysReg); @@ -469,10 +467,10 @@ bool ARMCallLowering::lowerFormalArguments( namespace { -struct CallReturnHandler : public IncomingValueHandler { +struct CallReturnHandler : public ARMIncomingValueHandler { CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstrBuilder MIB, CCAssignFn *AssignFn) - : IncomingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} + : ARMIncomingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} void markPhysRegUsed(unsigned PhysReg) override { MIB.addDef(PhysReg, RegState::Implicit); @@ -554,7 +552,7 @@ bool ARMCallLowering::lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo & } auto ArgAssignFn = TLI.CCAssignFnForCall(Info.CallConv, IsVarArg); - OutgoingValueHandler ArgHandler(MIRBuilder, MRI, MIB, ArgAssignFn); + ARMOutgoingValueHandler ArgHandler(MIRBuilder, MRI, MIB, ArgAssignFn); if (!handleAssignments(MIRBuilder, ArgInfos, ArgHandler)) return false; diff --git a/llvm/lib/Target/Mips/MipsCallLowering.cpp b/llvm/lib/Target/Mips/MipsCallLowering.cpp index cffd99affac109..5b5dc56cd33952 100644 --- a/llvm/lib/Target/Mips/MipsCallLowering.cpp +++ b/llvm/lib/Target/Mips/MipsCallLowering.cpp @@ -87,9 +87,10 @@ bool MipsCallLowering::MipsHandler::handle( } namespace { -class IncomingValueHandler : public MipsCallLowering::MipsHandler { +class MipsIncomingValueHandler : public MipsCallLowering::MipsHandler { public: - IncomingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI) + MipsIncomingValueHandler(MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI) : MipsHandler(MIRBuilder, MRI) {} private: @@ -117,11 +118,11 @@ class IncomingValueHandler : public MipsCallLowering::MipsHandler { } }; -class CallReturnHandler : public IncomingValueHandler { +class CallReturnHandler : public MipsIncomingValueHandler { public: CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) - : IncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {} + : MipsIncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {} private: void markPhysRegUsed(unsigned PhysReg) override { @@ -133,9 +134,9 @@ class CallReturnHandler : public IncomingValueHandler { } // end anonymous namespace -void IncomingValueHandler::assignValueToReg(Register ValVReg, - const CCValAssign &VA, - const EVT &VT) { +void MipsIncomingValueHandler::assignValueToReg(Register ValVReg, + const CCValAssign &VA, + const EVT &VT) { Register PhysReg = VA.getLocReg(); if (VT == MVT::f64 && PhysReg >= Mips::A0 && PhysReg <= Mips::A3) { const MipsSubtarget &STI = @@ -167,8 +168,8 @@ void IncomingValueHandler::assignValueToReg(Register ValVReg, } } -Register IncomingValueHandler::getStackAddress(const CCValAssign &VA, - MachineMemOperand *&MMO) { +Register MipsIncomingValueHandler::getStackAddress(const CCValAssign &VA, + MachineMemOperand *&MMO) { MachineFunction &MF = MIRBuilder.getMF(); unsigned Size = alignTo(VA.getValVT().getSizeInBits(), 8) / 8; unsigned Offset = VA.getLocMemOffset(); @@ -186,8 +187,8 @@ Register IncomingValueHandler::getStackAddress(const CCValAssign &VA, return MIRBuilder.buildFrameIndex(LLT::pointer(0, 32), FI).getReg(0); } -void IncomingValueHandler::assignValueToAddress(Register ValVReg, - const CCValAssign &VA) { +void MipsIncomingValueHandler::assignValueToAddress(Register ValVReg, + const CCValAssign &VA) { if (VA.getLocInfo() == CCValAssign::SExt || VA.getLocInfo() == CCValAssign::ZExt || VA.getLocInfo() == CCValAssign::AExt) { @@ -197,10 +198,10 @@ void IncomingValueHandler::assignValueToAddress(Register ValVReg, buildLoad(ValVReg, VA); } -bool IncomingValueHandler::handleSplit(SmallVectorImpl &VRegs, - ArrayRef ArgLocs, - unsigned ArgLocsStartIndex, - Register ArgsReg, const EVT &VT) { +bool MipsIncomingValueHandler::handleSplit(SmallVectorImpl &VRegs, + ArrayRef ArgLocs, + unsigned ArgLocsStartIndex, + Register ArgsReg, const EVT &VT) { if (!assignVRegs(VRegs, ArgLocs, ArgLocsStartIndex, VT)) return false; setLeastSignificantFirst(VRegs); @@ -209,10 +210,10 @@ bool IncomingValueHandler::handleSplit(SmallVectorImpl &VRegs, } namespace { -class OutgoingValueHandler : public MipsCallLowering::MipsHandler { +class MipsOutgoingValueHandler : public MipsCallLowering::MipsHandler { public: - OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, - MachineInstrBuilder &MIB) + MipsOutgoingValueHandler(MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) : MipsHandler(MIRBuilder, MRI), MIB(MIB) {} private: @@ -234,9 +235,9 @@ class OutgoingValueHandler : public MipsCallLowering::MipsHandler { }; } // end anonymous namespace -void OutgoingValueHandler::assignValueToReg(Register ValVReg, - const CCValAssign &VA, - const EVT &VT) { +void MipsOutgoingValueHandler::assignValueToReg(Register ValVReg, + const CCValAssign &VA, + const EVT &VT) { Register PhysReg = VA.getLocReg(); if (VT == MVT::f64 && PhysReg >= Mips::A0 && PhysReg <= Mips::A3) { const MipsSubtarget &STI = @@ -254,8 +255,8 @@ void OutgoingValueHandler::assignValueToReg(Register ValVReg, } } -Register OutgoingValueHandler::getStackAddress(const CCValAssign &VA, - MachineMemOperand *&MMO) { +Register MipsOutgoingValueHandler::getStackAddress(const CCValAssign &VA, + MachineMemOperand *&MMO) { MachineFunction &MF = MIRBuilder.getMF(); const TargetFrameLowering *TFL = MF.getSubtarget().getFrameLowering(); @@ -278,16 +279,16 @@ Register OutgoingValueHandler::getStackAddress(const CCValAssign &VA, return AddrReg.getReg(0); } -void OutgoingValueHandler::assignValueToAddress(Register ValVReg, - const CCValAssign &VA) { +void MipsOutgoingValueHandler::assignValueToAddress(Register ValVReg, + const CCValAssign &VA) { MachineMemOperand *MMO; Register Addr = getStackAddress(VA, MMO); Register ExtReg = extendRegister(ValVReg, VA); MIRBuilder.buildStore(ExtReg, Addr, *MMO); } -Register OutgoingValueHandler::extendRegister(Register ValReg, - const CCValAssign &VA) { +Register MipsOutgoingValueHandler::extendRegister(Register ValReg, + const CCValAssign &VA) { LLT LocTy{VA.getLocVT()}; switch (VA.getLocInfo()) { case CCValAssign::SExt: { @@ -308,10 +309,10 @@ Register OutgoingValueHandler::extendRegister(Register ValReg, llvm_unreachable("unable to extend register"); } -bool OutgoingValueHandler::handleSplit(SmallVectorImpl &VRegs, - ArrayRef ArgLocs, - unsigned ArgLocsStartIndex, - Register ArgsReg, const EVT &VT) { +bool MipsOutgoingValueHandler::handleSplit(SmallVectorImpl &VRegs, + ArrayRef ArgLocs, + unsigned ArgLocsStartIndex, + Register ArgsReg, const EVT &VT) { MIRBuilder.buildUnmerge(VRegs, ArgsReg); setLeastSignificantFirst(VRegs); if (!assignVRegs(VRegs, ArgLocs, ArgLocsStartIndex, VT)) @@ -403,7 +404,7 @@ bool MipsCallLowering::lowerReturn(MachineIRBuilder &MIRBuilder, CCInfo.AnalyzeReturn(Outs, TLI.CCAssignFnForReturn()); setLocInfo(ArgLocs, Outs); - OutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), Ret); + MipsOutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), Ret); if (!RetHandler.handle(ArgLocs, RetInfos)) { return false; } @@ -455,7 +456,7 @@ bool MipsCallLowering::lowerFormalArguments( CCInfo.AnalyzeFormalArguments(Ins, TLI.CCAssignFnForCall()); setLocInfo(ArgLocs, Ins); - IncomingValueHandler Handler(MIRBuilder, MF.getRegInfo()); + MipsIncomingValueHandler Handler(MIRBuilder, MF.getRegInfo()); if (!Handler.handle(ArgLocs, ArgInfos)) return false; @@ -579,7 +580,7 @@ bool MipsCallLowering::lowerCall(MachineIRBuilder &MIRBuilder, CCInfo.AnalyzeCallOperands(Outs, TLI.CCAssignFnForCall(), FuncOrigArgs, Call); setLocInfo(ArgLocs, Outs); - OutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), MIB); + MipsOutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), MIB); if (!RetHandler.handle(ArgLocs, ArgInfos)) { return false; } diff --git a/llvm/lib/Target/X86/X86CallLowering.cpp b/llvm/lib/Target/X86/X86CallLowering.cpp index 319dc947060480..0286482ac9af8e 100644 --- a/llvm/lib/Target/X86/X86CallLowering.cpp +++ b/llvm/lib/Target/X86/X86CallLowering.cpp @@ -95,15 +95,14 @@ bool X86CallLowering::splitToValueTypes(const ArgInfo &OrigArg, namespace { -struct OutgoingValueHandler : public CallLowering::ValueHandler { - OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, - MachineInstrBuilder &MIB, CCAssignFn *AssignFn) - : ValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB), +struct X86OutgoingValueHandler : public CallLowering::IncomingValueHandler { + X86OutgoingValueHandler(MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI, MachineInstrBuilder &MIB, + CCAssignFn *AssignFn) + : IncomingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB), DL(MIRBuilder.getMF().getDataLayout()), STI(MIRBuilder.getMF().getSubtarget()) {} - bool isIncomingArgumentHandler() const override { return false; } - Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { LLT p0 = LLT::pointer(0, DL.getPointerSizeInBits(0)); @@ -215,7 +214,7 @@ bool X86CallLowering::lowerReturn( return false; } - OutgoingValueHandler Handler(MIRBuilder, MRI, MIB, RetCC_X86); + X86OutgoingValueHandler Handler(MIRBuilder, MRI, MIB, RetCC_X86); if (!handleAssignments(MIRBuilder, SplitArgs, Handler)) return false; } @@ -226,14 +225,12 @@ bool X86CallLowering::lowerReturn( namespace { -struct IncomingValueHandler : public CallLowering::ValueHandler { - IncomingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, - CCAssignFn *AssignFn) - : ValueHandler(MIRBuilder, MRI, AssignFn), +struct X86IncomingValueHandler : public CallLowering::IncomingValueHandler { + X86IncomingValueHandler(MachineIRBuilder &MIRBuilder, + MachineRegisterInfo &MRI, CCAssignFn *AssignFn) + : IncomingValueHandler(MIRBuilder, MRI, AssignFn), DL(MIRBuilder.getMF().getDataLayout()) {} - bool isIncomingArgumentHandler() const override { return true; } - Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { auto &MFI = MIRBuilder.getMF().getFrameInfo(); @@ -298,10 +295,10 @@ struct IncomingValueHandler : public CallLowering::ValueHandler { const DataLayout &DL; }; -struct FormalArgHandler : public IncomingValueHandler { +struct FormalArgHandler : public X86IncomingValueHandler { FormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, CCAssignFn *AssignFn) - : IncomingValueHandler(MIRBuilder, MRI, AssignFn) {} + : X86IncomingValueHandler(MIRBuilder, MRI, AssignFn) {} void markPhysRegUsed(unsigned PhysReg) override { MIRBuilder.getMRI()->addLiveIn(PhysReg); @@ -309,10 +306,10 @@ struct FormalArgHandler : public IncomingValueHandler { } }; -struct CallReturnHandler : public IncomingValueHandler { +struct CallReturnHandler : public X86IncomingValueHandler { CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, CCAssignFn *AssignFn, MachineInstrBuilder &MIB) - : IncomingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} + : X86IncomingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} void markPhysRegUsed(unsigned PhysReg) override { MIB.addDef(PhysReg, RegState::Implicit); @@ -421,7 +418,7 @@ bool X86CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, return false; } // Do the actual argument marshalling. - OutgoingValueHandler Handler(MIRBuilder, MRI, MIB, CC_X86); + X86OutgoingValueHandler Handler(MIRBuilder, MRI, MIB, CC_X86); if (!handleAssignments(MIRBuilder, SplitArgs, Handler)) return false; From d26526fd096c927d41949b77160ec750f4068f2a Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 10 Jul 2020 13:57:11 -0400 Subject: [PATCH 06/23] AArch64: Use Register --- llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp index 62bc38e307bff8..5bfed7e472b061 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp @@ -96,7 +96,7 @@ struct IncomingArgHandler : public CallLowering::IncomingValueHandler { /// How the physical register gets marked varies between formal /// parameters (it's a basic-block live-in), and a call instruction /// (it's an implicit-def of the BL). - virtual void markPhysRegUsed(unsigned PhysReg) = 0; + virtual void markPhysRegUsed(MCRegister PhysReg) = 0; uint64_t StackUsed; }; @@ -106,7 +106,7 @@ struct FormalArgHandler : public IncomingArgHandler { CCAssignFn *AssignFn) : IncomingArgHandler(MIRBuilder, MRI, AssignFn) {} - void markPhysRegUsed(unsigned PhysReg) override { + void markPhysRegUsed(MCRegister PhysReg) override { MIRBuilder.getMRI()->addLiveIn(PhysReg); MIRBuilder.getMBB().addLiveIn(PhysReg); } @@ -117,7 +117,7 @@ struct CallReturnHandler : public IncomingArgHandler { MachineInstrBuilder MIB, CCAssignFn *AssignFn) : IncomingArgHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {} - void markPhysRegUsed(unsigned PhysReg) override { + void markPhysRegUsed(MCRegister PhysReg) override { MIB.addDef(PhysReg, RegState::Implicit); } @@ -414,7 +414,7 @@ static void handleMustTailForwardedRegisters(MachineIRBuilder &MIRBuilder, // Conservatively forward X8, since it might be used for an aggregate // return. if (!CCInfo.isAllocated(AArch64::X8)) { - unsigned X8VReg = MF.addLiveIn(AArch64::X8, &AArch64::GPR64RegClass); + Register X8VReg = MF.addLiveIn(AArch64::X8, &AArch64::GPR64RegClass); Forwards.push_back(ForwardedRegister(X8VReg, AArch64::X8, MVT::i64)); } From 652e30476c52d2b47295bcf37a89a8824a1b6b9d Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Wed, 22 Jul 2020 11:16:08 -0700 Subject: [PATCH 07/23] [llvm][NFC] Remove definition from build system of LLVM_HAVE_TF_AOT We can just use the definition from config.h. This means we need to move a few lines around in CMakeLists.txt - the TF_AOT detection needs to be before the spot we process the config.h.cmake files. Differential Revision: https://reviews.llvm.org/D84349 --- llvm/CMakeLists.txt | 51 ++++++++++------------ llvm/include/llvm/Analysis/InlineAdvisor.h | 1 + 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 303b39221d9e69..a3353a40238ac7 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -845,6 +845,29 @@ if (tensorflow_c_api) include_directories(${TENSORFLOW_C_LIB_PATH}/include) endif() +# They are not referenced. See set_output_directory(). +set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin ) +set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) + +# For up-to-date instructions for installing the Tensorflow dependency, refer to +# the bot setup script: https://github.com/google/ml-compiler-opt/blob/master/buildbot/buildbot_init.sh +# Specifically, assuming python3 is installed: +# python3 -m pip install --upgrade pip && python3 -m pip install --user tf_nightly==2.3.0.dev20200528 +# Then set TENSORFLOW_AOT_PATH to the package install - usually it's ~/.local/lib/python3.7/site-packages/tensorflow +# +set(TENSORFLOW_AOT_PATH "" CACHE PATH "Path to TensorFlow pip install dir") + +if (NOT TENSORFLOW_AOT_PATH STREQUAL "") + set(LLVM_HAVE_TF_AOT "ON" CACHE BOOL "Tensorflow AOT available") + set(TENSORFLOW_AOT_COMPILER + "${TENSORFLOW_AOT_PATH}/../../../../bin/saved_model_cli" + CACHE PATH "Path to the Tensorflow AOT compiler") + include_directories(${TENSORFLOW_AOT_PATH}/include) + add_subdirectory(${TENSORFLOW_AOT_PATH}/xla_aot_runtime_src + ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime) +endif() + # Configure the three LLVM configuration header files. configure_file( ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake @@ -875,12 +898,6 @@ add_custom_target(srpm COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' ${LLVM_SRPM_BINARY_SPECFILE}) set_target_properties(srpm PROPERTIES FOLDER "Misc") - -# They are not referenced. See set_output_directory(). -set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin ) -set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) -set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) - if(APPLE AND DARWIN_LTO_LIBRARY) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") @@ -975,28 +992,6 @@ if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2") endif() -# For up-to-date instructions for installing the Tensorflow dependency, refer to -# the bot setup script: https://github.com/google/ml-compiler-opt/blob/master/buildbot/buildbot_init.sh -# Specifically, assuming python3 is installed: -# python3 -m pip install --upgrade pip && python3 -m pip install --user tf_nightly==2.3.0.dev20200528 -# Then set TENSORFLOW_AOT_PATH to the package install - usually it's ~/.local/lib/python3.7/site-packages/tensorflow -# -set(TENSORFLOW_AOT_PATH "" CACHE PATH "Path to TensorFlow pip install dir") - -if (NOT TENSORFLOW_AOT_PATH STREQUAL "") - set(LLVM_HAVE_TF_AOT "ON" CACHE BOOL "Tensorflow AOT available") - set(TENSORFLOW_AOT_COMPILER - "${TENSORFLOW_AOT_PATH}/../../../../bin/saved_model_cli" - CACHE PATH "Path to the Tensorflow AOT compiler") - # Unlike the LLVM_HAVE_TF_API case, we don't need to expose this through - # llvm-config.h, because it's an internal implementation detail. A user of the llvm library that wants to also - # use the TF AOT compiler may do so through their custom build step. - add_definitions("-DLLVM_HAVE_TF_AOT") - include_directories(${TENSORFLOW_AOT_PATH}/include) - add_subdirectory(${TENSORFLOW_AOT_PATH}/xla_aot_runtime_src - ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime) -endif() - # Put this before tblgen. Else we have a circular dependence. add_subdirectory(lib/Demangle) add_subdirectory(lib/Support) diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h b/llvm/include/llvm/Analysis/InlineAdvisor.h index e262e9a89261d8..8eb48cc75b5898 100644 --- a/llvm/include/llvm/Analysis/InlineAdvisor.h +++ b/llvm/include/llvm/Analysis/InlineAdvisor.h @@ -14,6 +14,7 @@ #include #include "llvm/Analysis/InlineCost.h" +#include "llvm/Config/config.h" #include "llvm/IR/PassManager.h" namespace llvm { From 3eec65782575a1284391e447142fd004dd5de4a9 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 22 Jul 2020 20:12:18 +0200 Subject: [PATCH 08/23] Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups. After lots of follow-up fixes, there are still problems, such as -Wno-suggest-override getting passed to the Windows Resource Compiler because it was added with add_definitions in the CMake file. Rather than piling on another fix, let's revert so this can be re-landed when there's a proper fix. This reverts commit 21c0b4c1e8d6a171899b31d072a47dac27258fc5. This reverts commit 81d68ad27b29b1e6bc93807c6e42b14e9a77eade. This reverts commit a361aa5249856e333a373df90947dabf34cd6aab. This reverts commit fa42b7cf2949802ff0b8a63a2e111a2a68711067. This reverts commit 955f87f947fda3072a69b0b00ca83c1f6a0566f6. This reverts commit 8b16e45f66e24e4c10e2cea1b70d2b85a7ce64d5. This reverts commit 308a127a38d1111f3940420b98ff45fc1c17715f. This reverts commit 274b6b0c7a8b584662595762eaeff57d61c6807f. This reverts commit 1c7037a2a5576d0bb083db10ad947a8308e61f65. --- clang-tools-extra/clangd/unittests/CMakeLists.txt | 4 ---- clang-tools-extra/unittests/CMakeLists.txt | 4 ---- clang/unittests/CMakeLists.txt | 4 ---- compiler-rt/cmake/Modules/AddCompilerRT.cmake | 1 - compiler-rt/cmake/config-ix.cmake | 1 - flang/unittests/CMakeLists.txt | 4 ---- libcxx/CMakeLists.txt | 4 +--- libcxxabi/CMakeLists.txt | 2 -- lld/unittests/CMakeLists.txt | 4 ---- lldb/unittests/CMakeLists.txt | 4 ---- llvm/cmake/modules/HandleLLVMOptions.cmake | 15 --------------- llvm/lib/Testing/Support/CMakeLists.txt | 4 ---- llvm/unittests/CMakeLists.txt | 4 ---- llvm/utils/benchmark/CMakeLists.txt | 4 ---- llvm/utils/unittest/CMakeLists.txt | 3 --- mlir/unittests/CMakeLists.txt | 4 ---- parallel-libs/acxxel/CMakeLists.txt | 3 --- polly/unittests/CMakeLists.txt | 4 ---- 18 files changed, 1 insertion(+), 72 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt b/clang-tools-extra/clangd/unittests/CMakeLists.txt index 8a4a0fb37fc6bc..c25e2b7f810373 100644 --- a/clang-tools-extra/clangd/unittests/CMakeLists.txt +++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt @@ -22,10 +22,6 @@ if(CLANG_BUILT_STANDALONE) endif() endif() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - if (CLANGD_ENABLE_REMOTE) include_directories(${CMAKE_CURRENT_BINARY_DIR}/../index/remote) add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1) diff --git a/clang-tools-extra/unittests/CMakeLists.txt b/clang-tools-extra/unittests/CMakeLists.txt index 751827cd2a0f97..086a68e638307e 100644 --- a/clang-tools-extra/unittests/CMakeLists.txt +++ b/clang-tools-extra/unittests/CMakeLists.txt @@ -5,10 +5,6 @@ function(add_extra_unittest test_dirname) add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN}) endfunction() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - add_subdirectory(clang-apply-replacements) add_subdirectory(clang-change-namespace) add_subdirectory(clang-doc) diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt index 64168f44f84398..4c222e24599f0d 100644 --- a/clang/unittests/CMakeLists.txt +++ b/clang/unittests/CMakeLists.txt @@ -10,10 +10,6 @@ if(CLANG_BUILT_STANDALONE) endif() endif() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - # add_clang_unittest(test_dirname file1.cpp file2.cpp) # # Will compile the list of files together and link against the clang diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index efb66081827053..dab55707338a4f 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -403,7 +403,6 @@ set(COMPILER_RT_GMOCK_CFLAGS append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS) append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS) -append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override COMPILER_RT_UNITTEST_CFLAGS) if(MSVC) # gtest use a lot of stuff marked as deprecated on Windows. diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 0a27910ed4943d..f535123351d666 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -106,7 +106,6 @@ check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" COMPILER_RT_HAS_WNON_VIRT check_cxx_compiler_flag("-Werror -Wvariadic-macros" COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG) check_cxx_compiler_flag("-Werror -Wunused-parameter" COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG) check_cxx_compiler_flag("-Werror -Wcovered-switch-default" COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG) -check_cxx_compiler_flag("-Werror -Wsuggest-override" COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG) check_cxx_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC) check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG) diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt index 0d52bc054a8c84..d53d155f2f2b51 100644 --- a/flang/unittests/CMakeLists.txt +++ b/flang/unittests/CMakeLists.txt @@ -5,10 +5,6 @@ function(add_flang_unittest test_dirname) add_unittest(FlangUnitTests ${test_dirname} ${ARGN}) endfunction() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - add_subdirectory(Optimizer) add_subdirectory(Decimal) add_subdirectory(Evaluate) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 3ba09fd87f6aaf..caf655d6799aaf 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -578,7 +578,6 @@ function(cxx_add_warning_flags target) target_add_compile_flags_if_supported(${target} PRIVATE -Wno-user-defined-literals -Wno-covered-switch-default - -Wno-suggest-override -Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs ) if (LIBCXX_TARGETING_CLANG_CL) @@ -603,8 +602,7 @@ function(cxx_add_warning_flags target) target_add_compile_flags_if_supported(${target} PRIVATE -Wno-literal-suffix -Wno-c++14-compat - -Wno-noexcept-type - -Wno-suggest-override) + -Wno-noexcept-type) endif() if (LIBCXX_ENABLE_WERROR) target_add_compile_flags_if_supported(${target} PRIVATE -Werror) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index c28c438002d4d3..e4e20d950b8900 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -283,8 +283,6 @@ add_compile_flags_if_supported(-Wunused-variable) add_compile_flags_if_supported(-Wwrite-strings) add_compile_flags_if_supported(-Wundef) -add_compile_flags_if_supported(-Wno-suggest-override) - if (LIBCXXABI_ENABLE_WERROR) add_compile_flags_if_supported(-Werror) add_compile_flags_if_supported(-WX) diff --git a/lld/unittests/CMakeLists.txt b/lld/unittests/CMakeLists.txt index 3330f7c28aeb52..84d35d43f4e877 100644 --- a/lld/unittests/CMakeLists.txt +++ b/lld/unittests/CMakeLists.txt @@ -12,9 +12,5 @@ function(add_lld_unittest test_dirname) target_link_libraries(${test_dirname} ${LLVM_COMMON_LIBS}) endfunction() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - add_subdirectory(DriverTests) add_subdirectory(MachOTests) diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt index 3a31559463d12a..6422b726ca69d9 100644 --- a/lldb/unittests/CMakeLists.txt +++ b/lldb/unittests/CMakeLists.txt @@ -5,10 +5,6 @@ add_dependencies(lldb-test-deps LLDBUnitTests) include_directories(${LLDB_SOURCE_ROOT}) include_directories(${LLDB_PROJECT_ROOT}/unittests) -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - set(LLDB_GTEST_COMMON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/gtest_common.h) if (MSVC) list(APPEND LLVM_COMPILE_FLAGS /FI ${LLDB_GTEST_COMMON_INCLUDE}) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 62dd0ef79cf481..2e249593e12f1f 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -672,21 +672,6 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL)) # Enable -Wdelete-non-virtual-dtor if available. add_flag_if_supported("-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG) - # Enable -Wsuggest-override if it's available, and only if it doesn't - # suggest adding 'override' to functions that are already marked 'final' - # (which means it is disabled for GCC < 9.2). - check_cxx_compiler_flag("-Wsuggest-override" CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=suggest-override") - CHECK_CXX_SOURCE_COMPILES("class base {public: virtual void anchor();}; - class derived : base {public: void anchor() final;}; - int main() { return 0; }" - CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL) - set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) - append_if(CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL "-Wsuggest-override" CMAKE_CXX_FLAGS) - endif() - # Check if -Wcomment is OK with an // comment ending with '\' if the next # line is also a // comment. set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) diff --git a/llvm/lib/Testing/Support/CMakeLists.txt b/llvm/lib/Testing/Support/CMakeLists.txt index 4d2f46e9b79db8..fe460aeefc91f8 100644 --- a/llvm/lib/Testing/Support/CMakeLists.txt +++ b/llvm/lib/Testing/Support/CMakeLists.txt @@ -15,10 +15,6 @@ add_llvm_library(LLVMTestingSupport Support ) -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include) target_link_libraries(LLVMTestingSupport PRIVATE gtest) diff --git a/llvm/unittests/CMakeLists.txt b/llvm/unittests/CMakeLists.txt index c1e02313d0441a..d7dbaeaa32fe87 100644 --- a/llvm/unittests/CMakeLists.txt +++ b/llvm/unittests/CMakeLists.txt @@ -14,10 +14,6 @@ function(add_llvm_target_unittest test_dir_name) add_llvm_unittest(${test_dir_name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) endfunction() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - add_subdirectory(ADT) add_subdirectory(Analysis) add_subdirectory(AsmParser) diff --git a/llvm/utils/benchmark/CMakeLists.txt b/llvm/utils/benchmark/CMakeLists.txt index ce1d38e6862a99..38bc8c6bc9560c 100644 --- a/llvm/utils/benchmark/CMakeLists.txt +++ b/llvm/utils/benchmark/CMakeLists.txt @@ -156,10 +156,6 @@ else() add_cxx_compiler_flag(-fno-exceptions) endif() - if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_cxx_compiler_flag(-Wno-suggest-override) - endif() - if (HAVE_CXX_FLAG_FSTRICT_ALIASING) if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") #ICC17u2: Many false positives for Wstrict-aliasing add_cxx_compiler_flag(-Wstrict-aliasing) diff --git a/llvm/utils/unittest/CMakeLists.txt b/llvm/utils/unittest/CMakeLists.txt index 36761a60d9f722..5aad048f2c35d8 100644 --- a/llvm/utils/unittest/CMakeLists.txt +++ b/llvm/utils/unittest/CMakeLists.txt @@ -43,9 +43,6 @@ endif() if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG) add_definitions("-Wno-covered-switch-default") endif() -if(CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() set(LLVM_REQUIRES_RTTI 1) add_definitions( -DGTEST_HAS_RTTI=0 ) diff --git a/mlir/unittests/CMakeLists.txt b/mlir/unittests/CMakeLists.txt index 69b58420dfdbf1..851092c5b56a44 100644 --- a/mlir/unittests/CMakeLists.txt +++ b/mlir/unittests/CMakeLists.txt @@ -5,10 +5,6 @@ function(add_mlir_unittest test_dirname) add_unittest(MLIRUnitTests ${test_dirname} ${ARGN}) endfunction() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - add_subdirectory(Analysis) add_subdirectory(Dialect) add_subdirectory(IR) diff --git a/parallel-libs/acxxel/CMakeLists.txt b/parallel-libs/acxxel/CMakeLists.txt index f2ebe4833972fd..547dd62d2fbf57 100644 --- a/parallel-libs/acxxel/CMakeLists.txt +++ b/parallel-libs/acxxel/CMakeLists.txt @@ -36,9 +36,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Add warning flags. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() add_library( acxxel diff --git a/polly/unittests/CMakeLists.txt b/polly/unittests/CMakeLists.txt index 1a0584976cbb09..fac70383de948c 100644 --- a/polly/unittests/CMakeLists.txt +++ b/polly/unittests/CMakeLists.txt @@ -19,10 +19,6 @@ function(add_polly_unittest test_name) target_link_libraries(${test_name} PRIVATE Polly) endfunction() -if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) - add_definitions("-Wno-suggest-override") -endif() - add_subdirectory(Isl) add_subdirectory(Flatten) add_subdirectory(DeLICM) From afa1afd4108d973e059e5f5ad68cf01efe7985da Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 22 Apr 2020 11:15:05 -0400 Subject: [PATCH 09/23] [CMake] Bump CMake minimum version to 3.13.4 This upgrade should be friction-less because we've already been ensuring that CMake >= 3.13.4 is used. This is part of the effort discussed on llvm-dev here: http://lists.llvm.org/pipermail/llvm-dev/2020-April/140578.html Differential Revision: https://reviews.llvm.org/D78648 --- clang/CMakeLists.txt | 2 +- .../tests/functional/exec/CMakeLists.txt | 2 +- compiler-rt/CMakeLists.txt | 2 +- .../cmake/Modules/CustomLibcxx/CMakeLists.txt | 2 +- compiler-rt/lib/builtins/CMakeLists.txt | 2 +- flang/CMakeLists.txt | 2 +- libclc/CMakeLists.txt | 2 +- libcxx/CMakeLists.txt | 2 +- libcxx/utils/ci/runtimes/CMakeLists.txt | 2 +- libcxxabi/CMakeLists.txt | 2 +- libunwind/CMakeLists.txt | 2 +- lld/CMakeLists.txt | 2 +- lldb/CMakeLists.txt | 5 +---- lldb/tools/debugserver/CMakeLists.txt | 2 +- llvm/CMakeLists.txt | 8 +------- llvm/docs/CMake.rst | 4 ++-- llvm/docs/CMakePrimer.rst | 18 +++++++++--------- llvm/docs/GettingStarted.rst | 2 +- llvm/runtimes/CMakeLists.txt | 4 ++-- llvm/utils/benchmark/CMakeLists.txt | 2 +- mlir/examples/standalone/CMakeLists.txt | 2 +- openmp/CMakeLists.txt | 2 +- openmp/cmake/DetectTestCompiler/CMakeLists.txt | 2 +- .../runtime/cmake/LibompCheckLinkerFlag.cmake | 2 +- parallel-libs/CMakeLists.txt | 2 +- parallel-libs/acxxel/CMakeLists.txt | 2 +- polly/CMakeLists.txt | 2 +- pstl/CMakeLists.txt | 2 +- 28 files changed, 38 insertions(+), 47 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 948452661a32fa..1a6a20a271f36d 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt index 42ee1d11db828a..007ad4530d6dc2 100644 --- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt +++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt @@ -1,6 +1,6 @@ project(exec C) -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) include(CheckCCompilerFlag) check_c_compiler_flag("-std=c99" C99_SUPPORTED) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index fa62814b635d3c..cfbd07a40e15f7 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -3,7 +3,7 @@ # An important constraint of the build is that it only produces libraries # based on the ability of the host toolchain to target various platforms. -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) diff --git a/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt b/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt index e61c222587e651..26d17ce6f14a71 100644 --- a/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt +++ b/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) project(custom-libcxx C CXX) # Build static libcxxabi. diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 058bfc815a1a64..99aed905d75969 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -3,7 +3,7 @@ # architecture-specific code in various subdirectories. if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - cmake_minimum_required(VERSION 3.4.3) + cmake_minimum_required(VERSION 3.13.4) project(CompilerRTBuiltins C ASM) set(COMPILER_RT_STANDALONE_BUILD TRUE) diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index 13e675f1096e5e..9dd6281d410bff 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9.0) +cmake_minimum_required(VERSION 3.13.4) # RPATH settings on macOS do not affect INSTALL_NAME. if (POLICY CMP0068) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 9472f191fbde96..c12dc10fa45d42 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.9.2 ) +cmake_minimum_required(VERSION 3.13.4) project( libclc VERSION 0.2.0 LANGUAGES CXX ) include( GNUInstallDirs ) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index caf655d6799aaf..a5adccf62a9630 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -8,7 +8,7 @@ endif() #=============================================================================== # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default diff --git a/libcxx/utils/ci/runtimes/CMakeLists.txt b/libcxx/utils/ci/runtimes/CMakeLists.txt index 43ebf9e4a196c9..f46ef63b809c71 100644 --- a/libcxx/utils/ci/runtimes/CMakeLists.txt +++ b/libcxx/utils/ci/runtimes/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0068) cmake_policy(SET CMP0068 NEW) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index e4e20d950b8900..534ef7e8c8474d 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -8,7 +8,7 @@ endif() # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index b50550dc376ee3..c5b536532f3c20 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -2,7 +2,7 @@ # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) if (POLICY CMP0042) cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt index 5090c935e75ad1..e9bd1bd29c5cfe 100644 --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -1,7 +1,7 @@ # Check if lld is built as a standalone project. if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(lld) - cmake_minimum_required(VERSION 3.4.3) + cmake_minimum_required(VERSION 3.13.4) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(LLD_BUILT_STANDALONE TRUE) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index b1c0597cf3b3f1..14cfba1f64ff52 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -1,7 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3) -if(CMAKE_SYSTEM_NAME STREQUAL Windows) - cmake_minimum_required(VERSION 3.13) -endif() +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) diff --git a/lldb/tools/debugserver/CMakeLists.txt b/lldb/tools/debugserver/CMakeLists.txt index fc23cf3c7e206c..eba5c41491329c 100644 --- a/lldb/tools/debugserver/CMakeLists.txt +++ b/lldb/tools/debugserver/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) project(Debugserver LANGUAGES C CXX ASM-ATT) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index a3353a40238ac7..ddf8071563279b 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1,12 +1,6 @@ # See docs/CMake.html for instructions about how to build LLVM with CMake. -cmake_minimum_required(VERSION 3.4.3) - -if ("${CMAKE_VERSION}" VERSION_LESS "3.13.4") - message(FATAL_ERROR - "Your CMake version is ${CMAKE_VERSION}. The minimum version of CMake " - "required to build LLVM is now 3.13.4.") -endif() +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0068) cmake_policy(SET CMP0068 NEW) diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst index 1f908d3e95b121..f96e34f21e8032 100644 --- a/llvm/docs/CMake.rst +++ b/llvm/docs/CMake.rst @@ -34,7 +34,7 @@ Quick start We use here the command-line, non-interactive CMake interface. #. `Download `_ and install - CMake. Version 3.4.3 is the minimum required. + CMake. Version 3.13.4 is the minimum required. #. Open a shell. Your development tools must be reachable from this shell through the PATH environment variable. @@ -717,7 +717,7 @@ and uses them to build a simple application ``simple-tool``. .. code-block:: cmake - cmake_minimum_required(VERSION 3.4.3) + cmake_minimum_required(VERSION 3.13.4) project(SimpleProject) find_package(LLVM REQUIRED CONFIG) diff --git a/llvm/docs/CMakePrimer.rst b/llvm/docs/CMakePrimer.rst index abfd08017fbfad..bc63ac1c027347 100644 --- a/llvm/docs/CMakePrimer.rst +++ b/llvm/docs/CMakePrimer.rst @@ -54,7 +54,7 @@ program. The example uses only CMake language-defined functions. .. code-block:: cmake - cmake_minimum_required(VERSION 3.2) + cmake_minimum_required(VERSION 3.15) project(HelloWorld) add_executable(HelloWorld HelloWorld.cpp) @@ -64,13 +64,13 @@ block to define "APPLE" when targeting Apple platforms: .. code-block:: cmake - cmake_minimum_required(VERSION 3.2) + cmake_minimum_required(VERSION 3.15) project(HelloWorld) add_executable(HelloWorld HelloWorld.cpp) if(APPLE) target_compile_definitions(HelloWorld PUBLIC APPLE) endif() - + Variables, Types, and Scope =========================== @@ -93,7 +93,7 @@ example: set(var_name var1) set(${var_name} foo) # same as "set(var1 foo)" set(${${var_name}}_var bar) # same as "set(foo_var bar)" - + Dereferencing an unset variable results in an empty expansion. It is a common pattern in CMake to conditionally set variables knowing that it will be used in code paths that the variable isn't set. There are examples of this throughout @@ -107,7 +107,7 @@ An example of variable empty expansion is: set(extra_sources Apple.cpp) endif() add_executable(HelloWorld HelloWorld.cpp ${extra_sources}) - + In this example the ``extra_sources`` variable is only defined if you're targeting an Apple platform. For all other targets the ``extra_sources`` will be evaluated as empty before add_executable is given its arguments. @@ -124,7 +124,7 @@ defining lists: # Creates a list with members a, b, c, and d set(my_list a b c d) set(my_list "a;b;c;d") - + # Creates a string "a b c d" set(my_string "a b c d") @@ -141,7 +141,7 @@ make a list of variable names that refer to other lists. For example: set(a 1 2 3) set(b 4 5 6) set(c 7 8 9) - + With this layout you can iterate through the list of lists printing each value with the following code: @@ -152,7 +152,7 @@ with the following code: message(${value}) endforeach() endforeach() - + You'll notice that the inner foreach loop's list is doubly dereferenced. This is because the first dereference turns ``list_name`` into the name of the sub-list (a, b, or c in the example), then the second dereference is to get the value of @@ -385,7 +385,7 @@ result in some unexpected behavior if using unreferenced variables. For example: message("${var}") endforeach() endmacro() - + set(my_list a b c d) set(my_list_of_numbers 1 2 3 4) print_list(my_list_of_numbers) diff --git a/llvm/docs/GettingStarted.rst b/llvm/docs/GettingStarted.rst index 478571bd4c2383..c30ebecc89e039 100644 --- a/llvm/docs/GettingStarted.rst +++ b/llvm/docs/GettingStarted.rst @@ -167,7 +167,7 @@ uses the package and provides other details. =========================================================== ============ ========================================== Package Version Notes =========================================================== ============ ========================================== -`CMake `__ >=3.4.3 Makefile/workspace generator +`CMake `__ >=3.13.4 Makefile/workspace generator `GCC `_ >=5.1.0 C/C++ compiler\ :sup:`1` `python `_ >=2.7 Automated test suite\ :sup:`2` `zlib `_ >=1.2.3.4 Compression library\ :sup:`3` diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index 0f29e24a26eb4e..dc74a46c70b556 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -7,7 +7,7 @@ # Setting CMake minimum required version should be at the very top of the file # if this is the entry point. if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - cmake_minimum_required(VERSION 3.4.3) + cmake_minimum_required(VERSION 3.13.4) project(Runtimes C CXX ASM) endif() @@ -56,7 +56,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name}) endfunction() - cmake_minimum_required(VERSION 3.4.3) + cmake_minimum_required(VERSION 3.13.4) project(Runtimes C CXX ASM) find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) diff --git a/llvm/utils/benchmark/CMakeLists.txt b/llvm/utils/benchmark/CMakeLists.txt index 38bc8c6bc9560c..542c70ca494839 100644 --- a/llvm/utils/benchmark/CMakeLists.txt +++ b/llvm/utils/benchmark/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.12) +cmake_minimum_required(VERSION 3.13.4) # Tell cmake 3.0+ that it's safe to clear the PROJECT_VERSION variable in the # call to project() below. diff --git a/mlir/examples/standalone/CMakeLists.txt b/mlir/examples/standalone/CMakeLists.txt index 9f30f70f949fd3..45dc80804aa9a0 100644 --- a/mlir/examples/standalone/CMakeLists.txt +++ b/mlir/examples/standalone/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.13.4) if(POLICY CMP0068) cmake_policy(SET CMP0068 NEW) diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt index 6f0d9e7280026d..f18688f08c4577 100644 --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13.4) # Add cmake directory to search for custom cmake functions. set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) diff --git a/openmp/cmake/DetectTestCompiler/CMakeLists.txt b/openmp/cmake/DetectTestCompiler/CMakeLists.txt index c230fc8d4cf1a4..7fa32a90972baa 100644 --- a/openmp/cmake/DetectTestCompiler/CMakeLists.txt +++ b/openmp/cmake/DetectTestCompiler/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.13.4) project(DetectTestCompiler C CXX) include(CheckCCompilerFlag) diff --git a/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake b/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake index 2b6cda676a62c4..e601e53f112378 100644 --- a/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake +++ b/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake @@ -17,7 +17,7 @@ function(libomp_check_linker_flag flag boolean) set(library_source "int foo(int a) { return a*a; }") set(cmake_source - "cmake_minimum_required(VERSION 2.8) + "cmake_minimum_required(VERSION 3.13.4) project(foo C) set(CMAKE_SHARED_LINKER_FLAGS \"${flag}\") add_library(foo SHARED src_to_link.c)") diff --git a/parallel-libs/CMakeLists.txt b/parallel-libs/CMakeLists.txt index c1fcf45cd71239..35ca8bc1bce103 100644 --- a/parallel-libs/CMakeLists.txt +++ b/parallel-libs/CMakeLists.txt @@ -1 +1 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.13.4) diff --git a/parallel-libs/acxxel/CMakeLists.txt b/parallel-libs/acxxel/CMakeLists.txt index 547dd62d2fbf57..7e71446107a58d 100644 --- a/parallel-libs/acxxel/CMakeLists.txt +++ b/parallel-libs/acxxel/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.13.4) option(ACXXEL_ENABLE_UNIT_TESTS "enable acxxel unit tests" ON) option(ACXXEL_ENABLE_MULTI_DEVICE_UNIT_TESTS "enable acxxel multi-device unit tests" OFF) diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt index 9939097f743ee3..2e94512b2cffb2 100644 --- a/polly/CMakeLists.txt +++ b/polly/CMakeLists.txt @@ -1,7 +1,7 @@ # Check if this is a in tree build. if (NOT DEFINED LLVM_MAIN_SRC_DIR) project(Polly) - cmake_minimum_required(VERSION 3.4.3) + cmake_minimum_required(VERSION 3.13.4) # Where is LLVM installed? find_package(LLVM CONFIG REQUIRED) diff --git a/pstl/CMakeLists.txt b/pstl/CMakeLists.txt index 8e6e1354707b0b..8bea8843589bbf 100644 --- a/pstl/CMakeLists.txt +++ b/pstl/CMakeLists.txt @@ -5,7 +5,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===----------------------------------------------------------------------===## -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.13.4) set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h") file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$") From cd0a36bbda1f4765b7ec06a2c21400dacab49f57 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 22 Jul 2020 18:02:43 +0100 Subject: [PATCH 10/23] CodeViewDebug.cpp - remove duplicate includes that already exist in CodeViewDebug.h. NFC. --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 3f053c7a38c77d..5d52e7fb809201 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -13,15 +13,10 @@ #include "CodeViewDebug.h" #include "DwarfExpression.h" #include "llvm/ADT/APSInt.h" -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/MapVector.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/ADT/Triple.h" @@ -40,7 +35,6 @@ #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/Config/llvm-config.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" #include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h" #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" @@ -48,14 +42,12 @@ #include "llvm/DebugInfo/CodeView/Line.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeTableCollection.h" #include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DebugInfoMetadata.h" -#include "llvm/IR/DebugLoc.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalVariable.h" @@ -71,7 +63,6 @@ #include "llvm/Support/BinaryStreamWriter.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" @@ -85,12 +76,8 @@ #include #include #include -#include #include #include -#include -#include -#include using namespace llvm; using namespace llvm::codeview; From 1c060aa988452508fcfc65357f4a6467f3f88cc1 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 22 Jul 2020 19:00:28 +0100 Subject: [PATCH 11/23] DwarfCompileUnit.cpp - remove duplicate includes that already exist in DwarfCompileUnit.h. NFC. Also remove DIE.h include from DwarfCompileUnit.h and replace with forward declarations. --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 12 ------------ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 4 +++- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index d5ce8e5b2be3b5..ece6665e99f6c4 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -12,18 +12,12 @@ #include "DwarfCompileUnit.h" #include "AddressPool.h" -#include "DwarfDebug.h" #include "DwarfExpression.h" -#include "DwarfUnit.h" #include "llvm/ADT/None.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/DIE.h" -#include "llvm/CodeGen/LexicalScopes.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineOperand.h" @@ -32,22 +26,16 @@ #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DebugInfo.h" -#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbolWasm.h" #include "llvm/MC/MachineLocation.h" -#include "llvm/Support/Casting.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -#include -#include -#include #include -#include #include #include diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index 4ccd8c96dd0df4..85aee2307e0677 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -22,7 +22,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/DbgEntityHistoryCalculator.h" -#include "llvm/CodeGen/DIE.h" #include "llvm/CodeGen/LexicalScopes.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/Support/Casting.h" @@ -34,6 +33,9 @@ namespace llvm { class AsmPrinter; +class DIE; +class DIELoc; +class DIEValueList; class DwarfFile; class GlobalVariable; class MCExpr; From 08b4a50e39d8b8db17b8eddacba795e99304e418 Mon Sep 17 00:00:00 2001 From: Amy Kwan Date: Wed, 22 Jul 2020 12:16:08 -0500 Subject: [PATCH 12/23] [PowerPC][Power10] Fix the Test LSB by Byte (xvtlsbb) Builtins Implementation The implementation of the xvtlsbb builtins/intrinsics were not correct as the intrinsics previously used i1 as an argument type. This patch changes the i1 argument type used in these intrinsics to be i32 instead, as having the second as an i1 can lead to issues in the backend. Differential Revision: https://reviews.llvm.org/D84291 --- clang/include/clang/Basic/BuiltinsPPC.def | 2 +- clang/test/CodeGen/builtins-ppc-p10vector.c | 4 ++-- llvm/include/llvm/IR/IntrinsicsPowerPC.td | 2 +- llvm/lib/Target/PowerPC/PPCInstrPrefix.td | 2 +- llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll | 9 ++++++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def index 5d445c253a8559..b74cb8df78bac6 100644 --- a/clang/include/clang/Basic/BuiltinsPPC.def +++ b/clang/include/clang/Basic/BuiltinsPPC.def @@ -467,7 +467,7 @@ BUILTIN(__builtin_vsx_xxsldwi, "v.", "t") BUILTIN(__builtin_vsx_xxeval, "V2ULLiV2ULLiV2ULLiV2ULLiIi", "") -BUILTIN(__builtin_vsx_xvtlsbb, "iV16Ucb", "") +BUILTIN(__builtin_vsx_xvtlsbb, "iV16UcUi", "") // P10 Vector Permute Extended built-in. BUILTIN(__builtin_vsx_xxpermx, "V16UcV16UcV16UcV16UcIi", "") diff --git a/clang/test/CodeGen/builtins-ppc-p10vector.c b/clang/test/CodeGen/builtins-ppc-p10vector.c index 4e804fbafb301d..0d084c6eed853e 100644 --- a/clang/test/CodeGen/builtins-ppc-p10vector.c +++ b/clang/test/CodeGen/builtins-ppc-p10vector.c @@ -583,13 +583,13 @@ vector float test_vec_vec_splati_ins_f(void) { } int test_vec_test_lsbb_all_ones(void) { - // CHECK: @llvm.ppc.vsx.xvtlsbb(<16 x i8> %{{.+}}, i1 true + // CHECK: @llvm.ppc.vsx.xvtlsbb(<16 x i8> %{{.+}}, i32 1 // CHECK-NEXT: ret i32 return vec_test_lsbb_all_ones(vuca); } int test_vec_test_lsbb_all_zeros(void) { - // CHECK: @llvm.ppc.vsx.xvtlsbb(<16 x i8> %{{.+}}, i1 false + // CHECK: @llvm.ppc.vsx.xvtlsbb(<16 x i8> %{{.+}}, i32 0 // CHECK-NEXT: ret i32 return vec_test_lsbb_all_zeros(vuca); } diff --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td b/llvm/include/llvm/IR/IntrinsicsPowerPC.td index 2abb6b4e55fe73..d2d418bc2d6452 100644 --- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td +++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td @@ -1069,7 +1069,7 @@ def int_ppc_vsx_xxinsertw : [IntrNoMem]>; def int_ppc_vsx_xvtlsbb : PowerPC_VSX_Intrinsic<"xvtlsbb", [llvm_i32_ty], - [llvm_v16i8_ty, llvm_i1_ty], [IntrNoMem]>; + [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_ppc_vsx_xxeval : PowerPC_VSX_Intrinsic<"xxeval", [llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, diff --git a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td index 6bf8475a79470b..4c9f9e8bb083cc 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td +++ b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td @@ -1085,7 +1085,7 @@ let Predicates = [IsISA3_1] in { (v4i32 (COPY_TO_REGCLASS (XXGENPCVWM $VRB, imm:$IMM), VRRC))>; def : Pat<(v2i64 (int_ppc_vsx_xxgenpcvdm v2i64:$VRB, imm:$IMM)), (v2i64 (COPY_TO_REGCLASS (XXGENPCVDM $VRB, imm:$IMM), VRRC))>; - def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, -1)), + def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, 1)), (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_lt)>; def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, 0)), (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_eq)>; diff --git a/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll b/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll index d4e71d18c6ebba..2ac1b2b7514bcd 100644 --- a/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll +++ b/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll @@ -2,11 +2,14 @@ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \ ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \ ; RUN: FileCheck %s +; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O0 \ +; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \ +; RUN: FileCheck %s ; These test cases aims to test the builtins for the Power10 VSX vector ; instructions introduced in ISA 3.1. -declare i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8>, i1) +declare i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8>, i32) define signext i32 @test_vec_test_lsbb_all_ones(<16 x i8> %vuca) { ; CHECK-LABEL: test_vec_test_lsbb_all_ones: @@ -17,7 +20,7 @@ define signext i32 @test_vec_test_lsbb_all_ones(<16 x i8> %vuca) { ; CHECK-NEXT: extsw r3, r3 ; CHECK-NEXT: blr entry: - %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 1) + %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 1) ret i32 %0 } @@ -30,6 +33,6 @@ define signext i32 @test_vec_test_lsbb_all_zeros(<16 x i8> %vuca) { ; CHECK-NEXT: extsw r3, r3 ; CHECK-NEXT: blr entry: - %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 0) + %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 0) ret i32 %0 } From eae6bb3807977a2998ac9114a1d6ecb6bdafc3cd Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 22 Jul 2020 20:18:13 +0200 Subject: [PATCH 13/23] [SCCP] Add multi-edge switch + phi test case (NFC) --- llvm/test/Transforms/SCCP/switch.ll | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/llvm/test/Transforms/SCCP/switch.ll b/llvm/test/Transforms/SCCP/switch.ll index fc329c2628eb66..1d9c12b5c6751f 100644 --- a/llvm/test/Transforms/SCCP/switch.ll +++ b/llvm/test/Transforms/SCCP/switch.ll @@ -18,6 +18,38 @@ d: ret void } +define i32 @test_duplicate_successors_phi(i1 %c, i32 %x) { +; CHECK-LABEL: @test_duplicate_successors_phi( +; CHECK-NEXT: entry: +; CHECK-NEXT: br i1 [[C:%.*]], label [[SWITCH:%.*]], label [[END:%.*]] +; CHECK: switch: +; CHECK-NEXT: switch i32 -1, label [[SWITCH_DEFAULT:%.*]] [ +; CHECK-NEXT: i32 0, label [[END]] +; CHECK-NEXT: i32 1, label [[END]] +; CHECK-NEXT: ] +; CHECK: switch.default: +; CHECK-NEXT: ret i32 -1 +; CHECK: end: +; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 1, [[SWITCH]] ], [ 1, [[SWITCH]] ] +; CHECK-NEXT: ret i32 [[PHI]] +; +entry: + br i1 %c, label %switch, label %end + +switch: + switch i32 -1, label %switch.default [ + i32 0, label %end + i32 1, label %end + ] + +switch.default: + ret i32 -1 + +end: + %phi = phi i32 [ %x, %entry ], [ 1, %switch ], [ 1, %switch ] + ret i32 %phi +} + define i32 @test_local_range(i32 %x) { ; CHECK-LABEL: @test_local_range( ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[X:%.*]], 3 From d2ec91845c6711a2ea57ce2b0012f960f0e119f0 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 22 Jul 2020 11:32:18 -0700 Subject: [PATCH 14/23] [lldb] Use std::make_unique (NFC) --- .../Plugins/OperatingSystem/Python/OperatingSystemPython.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 417aa2e21436f7..4350010f029653 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -133,8 +133,8 @@ DynamicRegisterInfo *OperatingSystemPython::GetDynamicRegisterInfo() { if (!dictionary) return nullptr; - m_register_info_up.reset(new DynamicRegisterInfo( - *dictionary, m_process->GetTarget().GetArchitecture())); + m_register_info_up = std::make_unique( + *dictionary, m_process->GetTarget().GetArchitecture()); assert(m_register_info_up->GetNumRegisters() > 0); assert(m_register_info_up->GetNumRegisterSets() > 0); } From f3e667bf86f482ad7c27327ce8ca040dee296d0e Mon Sep 17 00:00:00 2001 From: LLVM GN Syncbot Date: Wed, 22 Jul 2020 18:37:02 +0000 Subject: [PATCH 15/23] [gn build] Port 418121c30a8 --- llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn | 2 +- llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn index c2f79568b6de27..a1ed1d25d381a1 100644 --- a/llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn @@ -47,6 +47,7 @@ static_library("Analysis") { "DomTreeUpdater.cpp", "DominanceFrontier.cpp", "EHPersonalities.cpp", + "FunctionPropertiesAnalysis.cpp", "GlobalsModRef.cpp", "GuardUtils.cpp", "HeatUtils.cpp", @@ -55,7 +56,6 @@ static_library("Analysis") { "IndirectCallPromotionAnalysis.cpp", "InlineAdvisor.cpp", "InlineCost.cpp", - "InlineFeaturesAnalysis.cpp", "InlineSizeEstimatorAnalysis.cpp", "InstCount.cpp", "InstructionPrecedenceTracking.cpp", diff --git a/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn index b0dcd497d844e6..c4bed481e051b7 100644 --- a/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn @@ -22,9 +22,9 @@ unittest("AnalysisTests") { "DDGTest.cpp", "DivergenceAnalysisTest.cpp", "DomTreeUpdaterTest.cpp", + "FunctionPropertiesAnalysisTest.cpp", "GlobalsModRefTest.cpp", "IVDescriptorsTest.cpp", - "InlineFeaturesAnalysisTest.cpp", "LazyCallGraphTest.cpp", "LoadsTest.cpp", "LoopInfoTest.cpp", From e58660750e76fa36c62d6b515da291d0ffa53e2b Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 22 Apr 2020 11:15:05 -0400 Subject: [PATCH 16/23] [libc++] Build the dylib with C++17 to allow aligned new/delete This allows simplifying the implementation of barriers. This is a re-commit of 1ac403bd145d, which had to be reverted in 64a9c944fc45 because the minimum CMake version wasn't high enough. Now that we've upgraded, we can do this. Differential Revision: https://reviews.llvm.org/D75243 --- libcxx/CMakeLists.txt | 6 +++--- libcxx/src/barrier.cpp | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index a5adccf62a9630..bf2ae67ecd5c92 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -519,10 +519,10 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic) # Required flags ============================================================== function(cxx_add_basic_build_flags target) - # Require C++14 for all targets. C++14 is needed to ensure constant - # initialization for certain globals (ex global memory resources). + # Require C++17 for all targets. C++17 is needed to use aligned allocation + # in the dylib. set_target_properties(${target} PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/libcxx/src/barrier.cpp b/libcxx/src/barrier.cpp index c5e33cbba3bd0b..9ee476993b8133 100644 --- a/libcxx/src/barrier.cpp +++ b/libcxx/src/barrier.cpp @@ -26,21 +26,15 @@ class __barrier_algorithm_base { } __tickets[64]; }; - ptrdiff_t& __expected; - unique_ptr __state_allocation; - __state_t* __state; + ptrdiff_t& __expected; + unique_ptr<__state_t[]> __state; _LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected(__expected) { size_t const __count = (__expected + 1) >> 1; - size_t const __size = sizeof(__state_t) * __count; - size_t __allocation_size = __size + alignof(__state_t); - __state_allocation = unique_ptr(new char[__allocation_size]); - void* __allocation = __state_allocation.get(); - void* const __state_ = align(alignof(__state_t), __size, __allocation, __allocation_size); - __state = new (__state_) __barrier_algorithm_base::__state_t[__count]; + __state = unique_ptr<__state_t[]>(new __state_t[__count]); } _LIBCPP_HIDDEN bool __arrive(__barrier_phase_t __old_phase) From 16779f8084541b626578a4bda2f51ee741dcd7bf Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 22 Apr 2020 10:23:38 -0400 Subject: [PATCH 17/23] [libc++] Add static_assert to make sure rate limiter doesn't use locks We want to be sure that atomic is always lock-free, or the code will be much slower than expected (and could even conceivably fail if the lock implementation somehow calls back into libc++abi). --- libcxxabi/src/private_typeinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp index 55a90b3ae1d4d3..3e8bdae32e4185 100644 --- a/libcxxabi/src/private_typeinfo.cpp +++ b/libcxxabi/src/private_typeinfo.cpp @@ -641,6 +641,7 @@ __dynamic_cast(const void *static_ptr, const __class_type_info *static_type, { // We get here only if there is some kind of visibility problem // in client code. + static_assert(std::atomic::is_always_lock_free, ""); static std::atomic error_count(0); size_t error_count_snapshot = error_count.fetch_add(1, std::memory_order_relaxed); if ((error_count_snapshot & (error_count_snapshot-1)) == 0) @@ -667,6 +668,7 @@ __dynamic_cast(const void *static_ptr, const __class_type_info *static_type, if (info.path_dst_ptr_to_static_ptr == unknown && info.path_dynamic_ptr_to_static_ptr == unknown) { + static_assert(std::atomic::is_always_lock_free, ""); static std::atomic error_count(0); size_t error_count_snapshot = error_count.fetch_add(1, std::memory_order_relaxed); if ((error_count_snapshot & (error_count_snapshot-1)) == 0) From bcbc6117b5d944bca8519dd34131cda1e83789fe Mon Sep 17 00:00:00 2001 From: Andrew Litteken Date: Wed, 22 Jul 2020 10:15:36 -0700 Subject: [PATCH 18/23] [CGP] Add Pass Dependencies Add pass dependecies: - TargetTransformInfoWrapperPass - TargetPassConfig - LoopInfoWrapperPass - TargetLibraryInfoWrapperPass To fix inconsistencies when passes are added to the pipeline. Reviewers: efriedma, kmclaughlin, paquette Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D84346 --- llvm/lib/CodeGen/CodeGenPrepare.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 465ba08dbfcdb5..42cffafbb1ce9b 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -439,7 +439,11 @@ char CodeGenPrepare::ID = 0; INITIALIZE_PASS_BEGIN(CodeGenPrepare, DEBUG_TYPE, "Optimize for code generation", false, false) +INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass) +INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) +INITIALIZE_PASS_DEPENDENCY(TargetPassConfig) +INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) INITIALIZE_PASS_END(CodeGenPrepare, DEBUG_TYPE, "Optimize for code generation", false, false) From f72106e2a35b12ef4bb265e755a6ee33a576c768 Mon Sep 17 00:00:00 2001 From: Pete Steinfeld Date: Wed, 22 Jul 2020 11:33:35 -0700 Subject: [PATCH 19/23] [flang] Fix an assert when RESHAPE() is called on empty strings Summary: When a constant array of empty strings goes through contant folding, the result is something that contains no bytes. If this array is passed to the intrinsic function `RESHAPE()`, we were not handling things correctly. I fixed this by checking for an empty destination when calling the function `CopyFrom()` on an array of strings. I also added a test with a couple of different examples that trigger the problem. Reviewers: klausler, tskeith, DavidTruby Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D84352 --- flang/lib/Evaluate/constant.cpp | 31 ++++++++++++++++++------------ flang/test/Semantics/modfile25.f90 | 3 +++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/flang/lib/Evaluate/constant.cpp b/flang/lib/Evaluate/constant.cpp index ecdcc0ab8e3e6c..e7497630f59696 100644 --- a/flang/lib/Evaluate/constant.cpp +++ b/flang/lib/Evaluate/constant.cpp @@ -244,19 +244,26 @@ std::size_t Constant>::CopyFrom( std::size_t count, ConstantSubscripts &resultSubscripts, const std::vector *dimOrder) { CHECK(length_ == source.length_); - std::size_t copied{0}; - std::size_t elementBytes{length_ * sizeof(decltype(values_[0]))}; - ConstantSubscripts sourceSubscripts{source.lbounds()}; - while (copied < count) { - auto *dest{&values_.at(SubscriptsToOffset(resultSubscripts) * length_)}; - const auto *src{&source.values_.at( - source.SubscriptsToOffset(sourceSubscripts) * length_)}; - std::memcpy(dest, src, elementBytes); - copied++; - source.IncrementSubscripts(sourceSubscripts); - IncrementSubscripts(resultSubscripts, dimOrder); + if (length_ == 0) { + // It's possible that the array of strings consists of all empty strings. + // If so, constant folding will result in a string that's completely empty + // and the length_ will be zero, and there's nothing to do. + return count; + } else { + std::size_t copied{0}; + std::size_t elementBytes{length_ * sizeof(decltype(values_[0]))}; + ConstantSubscripts sourceSubscripts{source.lbounds()}; + while (copied < count) { + auto *dest{&values_.at(SubscriptsToOffset(resultSubscripts) * length_)}; + const auto *src{&source.values_.at( + source.SubscriptsToOffset(sourceSubscripts) * length_)}; + std::memcpy(dest, src, elementBytes); + copied++; + source.IncrementSubscripts(sourceSubscripts); + IncrementSubscripts(resultSubscripts, dimOrder); + } + return copied; } - return copied; } // Constant specialization diff --git a/flang/test/Semantics/modfile25.f90 b/flang/test/Semantics/modfile25.f90 index 850298d54e4ddf..76dc61a54b6cef 100644 --- a/flang/test/Semantics/modfile25.f90 +++ b/flang/test/Semantics/modfile25.f90 @@ -22,6 +22,9 @@ subroutine subr(x,n1,n2) real, intent(in) :: x(:,:) integer, intent(in) :: n1(3), n2(:) real, allocatable :: a(:,:,:) + ! the following fail if we don't handle empty strings + Character(0) :: ch1(1,2,3) = Reshape([('',n=1,1*2*3)],[1,2,3]) + Character(0) :: ch2(3) = reshape(['','',''], [3]) a = reshape(x,n1) a = reshape(x,n2(10:30:9)) ! fails if we can't figure out triplet shape end subroutine From e9748a7255df1f45175a391d90803e84f62b3c12 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 22 Jul 2020 15:24:16 -0400 Subject: [PATCH 20/23] [libc++] Workaround broken support for C++17 in GCC 5 --- libcxx/include/variant | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcxx/include/variant b/libcxx/include/variant index 03557239a69e68..5ea2cbdae7446d 100644 --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -227,7 +227,10 @@ public: _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 14 +// TODO: GCC 5 lies about its support for C++17 (it says it supports it but it +// really doesn't). That breaks variant, which uses some C++17 features. +// Remove this once we drop support for GCC 5. +#if _LIBCPP_STD_VER > 14 && !(_GNUC_VER_NEW < 6000) _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY From a1b9fb220f6d71be3dde450c1695c92a7579af57 Mon Sep 17 00:00:00 2001 From: Thomas Raoux Date: Wed, 22 Jul 2020 12:16:29 -0700 Subject: [PATCH 21/23] [mlir][linalg] Add vectorization transform for CopyOp CopyOp get vectorized to vector.transfer_read followed by vector.transfer_write Differential Revision: https://reviews.llvm.org/D83739 --- .../Linalg/Transforms/Vectorization.cpp | 51 ++++++++++++++++--- .../Dialect/Linalg/transform-patterns.mlir | 17 +++++++ .../lib/Transforms/TestLinalgTransforms.cpp | 1 + 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp index 8e5da6ae539dcc..23d89c21e6e0ab 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -96,7 +96,7 @@ LogicalResult mlir::linalg::vectorizeLinalgOpPrecondition(Operation *op) { if (!outputTensorType.cast().hasStaticShape()) return failure(); - if (isa(op)) + if (isa(op)) return success(); return isContraction(op); @@ -119,12 +119,6 @@ void mlir::linalg::vectorizeLinalgOp(OpBuilder &builder, Operation *op) { return; } - assert(succeeded(isContraction(op)) && "Expected contraction"); - - // Vectorize other ops as vector contraction. - // TODO: interface. - LLVM_DEBUG(dbgs() << dbgPref - << "Rewrite linalg op as vector.contract: " << *op); // In the case of 0-D memrefs, return null and special case to scalar load or // store later. auto extractVectorTypeFromScalarView = [](Value v) { @@ -133,6 +127,49 @@ void mlir::linalg::vectorizeLinalgOp(OpBuilder &builder, Operation *op) { ? VectorType() : VectorType::get(mt.getShape(), mt.getElementType()); }; + + if (auto copyOp = dyn_cast(op)) { + // Vectorize copy as a vector.transfer_read+vector.transfer_write. + LLVM_DEBUG(dbgs() << dbgPref + << "Rewrite linalg.copy as vector.transfer_read + " + "vector.transfer_write: " + << *op); + Value zero = std_constant_index(0); + Value viewInput = copyOp.input(); + Value viewOutput = copyOp.output(); + Value vector; + if (VectorType inputType = extractVectorTypeFromScalarView(viewInput)) { + SmallVector indicesInput(inputType.getRank(), zero); + if (copyOp.inputPermutation()) + vector = vector_transfer_read( + extractVectorTypeFromScalarView(viewInput), viewInput, indicesInput, + copyOp.inputPermutation().getValue()); + else + vector = + vector_transfer_read(extractVectorTypeFromScalarView(viewInput), + viewInput, indicesInput); + } else { + vector = std_load(viewInput).value; + } + if (VectorType outputType = extractVectorTypeFromScalarView(viewOutput)) { + SmallVector indicesOutput(outputType.getRank(), zero); + if (copyOp.outputPermutation()) + vector_transfer_write(vector, viewOutput, indicesOutput, + copyOp.outputPermutation().getValue()); + else + vector_transfer_write(vector, viewOutput, indicesOutput); + } else { + std_store(vector, viewOutput); + } + return; + } + + assert(succeeded(isContraction(op)) && "Expected contraction"); + + // Vectorize other ops as vector contraction. + // TODO: interface. + LLVM_DEBUG(dbgs() << dbgPref + << "Rewrite linalg op as vector.contract: " << *op); auto linalgOp = cast(op); Value viewA = linalgOp.getInput(0); Value viewB = linalgOp.getInput(1); diff --git a/mlir/test/Dialect/Linalg/transform-patterns.mlir b/mlir/test/Dialect/Linalg/transform-patterns.mlir index 819b3b76413757..3f7d16497253d8 100644 --- a/mlir/test/Dialect/Linalg/transform-patterns.mlir +++ b/mlir/test/Dialect/Linalg/transform-patterns.mlir @@ -152,6 +152,23 @@ func @test_vectorize_fill(%A : memref<8x16xf32>, %arg0 : f32) { // CHECK-LABEL: func @test_vectorize_fill // CHECK: vector.broadcast {{.*}} : f32 to vector<8x16xf32> +func @test_vectorize_copy(%A : memref<8x16xf32>, %B : memref<8x16xf32>) { + linalg.copy(%A, %B) { __internal_linalg_transform__ = "VECTORIZE"} : memref<8x16xf32>, memref<8x16xf32> + return +} +// CHECK-LABEL: func @test_vectorize_copy +// CHECK: %[[V:.*]] = vector.transfer_read {{.*}} : memref<8x16xf32>, vector<8x16xf32> +// CHECK: vector.transfer_write %[[V]], {{.*}} : vector<8x16xf32>, memref<8x16xf32> + +func @test_vectorize_copy_scalar(%A : memref, %B : memref) { + linalg.copy(%A, %B) { __internal_linalg_transform__ = "VECTORIZE"} : memref, memref + return +} +// CHECK-LABEL: func @test_vectorize_copy_scalar +// CHECK: %[[V:.*]] = load {{.*}} : memref +// CHECK: store %[[V]], {{.*}} : memref + + #matmul_accesses = [ affine_map<(m, n, k) -> (m, k)>, affine_map<(m, n, k) -> (k, n)>, diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp index 4fb378c5ab8a5a..e356eb72fa4295 100644 --- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp @@ -144,6 +144,7 @@ static void applyPatterns(FuncOp funcOp) { //===--------------------------------------------------------------------===// patterns.insert, LinalgVectorizationPattern, + LinalgVectorizationPattern, LinalgVectorizationPattern>( ctx, LinalgMarker(Identifier::get("VECTORIZE", ctx))); From 411eb87c7962ec817ab6bf7aa3c737a3159d2d4e Mon Sep 17 00:00:00 2001 From: David Green Date: Wed, 22 Jul 2020 20:43:02 +0100 Subject: [PATCH 22/23] [ARM] Fix missing MVE_VMUL_qr predicate This was missed out of 1030e82598da, but hopefully fixes the issues reported with NEON accidentally generating MVE instructions. --- llvm/lib/Target/ARM/ARMInstrMVE.td | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMInstrMVE.td b/llvm/lib/Target/ARM/ARMInstrMVE.td index c3f8e4897bbbac..c00fb15d606822 100644 --- a/llvm/lib/Target/ARM/ARMInstrMVE.td +++ b/llvm/lib/Target/ARM/ARMInstrMVE.td @@ -5312,8 +5312,10 @@ class MVE_VMUL_qr_int size> multiclass MVE_VMUL_qr_int_m { def "" : MVE_VMUL_qr_int<"vmul", VTI.Suffix, VTI.Size>; - defm : MVE_TwoOpPatternDup(NAME), ARMimmOneV>; + let Predicates = [HasMVEInt] in { + defm : MVE_TwoOpPatternDup(NAME), ARMimmOneV>; + } } defm MVE_VMUL_qr_i8 : MVE_VMUL_qr_int_m; From b198de67e0bab462217db50814b1434796fa7caf Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 12 Jul 2020 15:36:56 -0700 Subject: [PATCH 23/23] Merge some of the PCH object support with modular codegen I was trying to pick this up a bit when reviewing D48426 (& perhaps D69778) - in any case, looks like D48426 added a module level flag that might not be needed. The D48426 implementation worked by setting a module level flag, then code generating contents from the PCH a special case in ASTContext::DeclMustBeEmitted would be used to delay emitting the definition of these functions if they came from a Module with this flag. This strategy is similar to the one initially implemented for modular codegen that was removed in D29901 in favor of the modular decls list and a bit on each decl to specify whether it's homed to a module. One major difference between PCH object support and modular code generation, other than the specific list of decls that are homed, is the compilation model: MSVC PCH modules are built into the object file for some other source file (when compiling that source file /Yc is specified to say "this compilation is where the PCH is homed"), whereas modular code generation invokes a separate compilation for the PCH alone. So the current modular code generation test of to decide if a decl should be emitted "is the module where this decl is serialized the current main file" has to be extended (as Lubos did in D69778) to also test the command line flag -building-pch-with-obj. Otherwise the whole thing is basically streamlined down to the modular code generation path. This even offers one extra material improvement compared to the existing divergent implementation: Homed functions are not emitted into object files that use the pch. Instead at -O0 they are not emitted into the IR at all, and at -O1 they are emitted using available_externally (existing functionality implemented for modular code generation). The pch-codegen test has been updated to reflect this new behavior. [If possible: I'd love it if we could not have the extra MSVC-style way of accessing dllexport-pch-homing, and just do it the modular codegen way, but I understand that it might be a limitation of existing build systems. @hans / @thakis: Do either of you know if it'd be practical to move to something more similar to .pcm handling, where the pch itself is passed to the compilation, rather than homed as a side effect of compiling some other source file?] Reviewers: llunak, hans Differential Revision: https://reviews.llvm.org/D83652 --- clang/include/clang/AST/ExternalASTSource.h | 4 --- .../clang/Sema/MultiplexExternalSemaSource.h | 2 -- clang/include/clang/Serialization/ASTReader.h | 2 -- .../include/clang/Serialization/ModuleFile.h | 3 -- clang/lib/AST/ASTContext.cpp | 31 ------------------- .../lib/Sema/MultiplexExternalSemaSource.cpp | 7 ----- clang/lib/Serialization/ASTReader.cpp | 9 +----- clang/lib/Serialization/ASTReaderDecl.cpp | 21 ++++++------- clang/lib/Serialization/ASTWriter.cpp | 2 -- clang/lib/Serialization/ASTWriterDecl.cpp | 11 +++++-- clang/test/CodeGen/pch-dllexport.cpp | 16 +++++++--- 11 files changed, 30 insertions(+), 78 deletions(-) diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h index def877b9181693..caae0770931b38 100644 --- a/clang/include/clang/AST/ExternalASTSource.h +++ b/clang/include/clang/AST/ExternalASTSource.h @@ -161,10 +161,6 @@ class ExternalASTSource : public RefCountedBase { /// Retrieve the module that corresponds to the given module ID. virtual Module *getModule(unsigned ID) { return nullptr; } - /// Determine whether D comes from a PCH which was built with a corresponding - /// object file. - virtual bool DeclIsFromPCHWithObjectFile(const Decl *D) { return false; } - /// Return a descriptor for the corresponding module, if one exists. virtual llvm::Optional getSourceDescriptor(unsigned ID); diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/clang/include/clang/Sema/MultiplexExternalSemaSource.h index e94dd5d4687113..b54a6283d64086 100644 --- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h @@ -153,8 +153,6 @@ class MultiplexExternalSemaSource : public ExternalSemaSource { /// Retrieve the module that corresponds to the given module ID. Module *getModule(unsigned ID) override; - bool DeclIsFromPCHWithObjectFile(const Decl *D) override; - /// Perform layout on the given record. /// /// This routine allows the external AST source to provide an specific diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 1d5571cd28549b..e883eb2f1749fd 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -2085,8 +2085,6 @@ class ASTReader /// Note: overrides method in ExternalASTSource Module *getModule(unsigned ID) override; - bool DeclIsFromPCHWithObjectFile(const Decl *D) override; - /// Retrieve the module file with a given local ID within the specified /// ModuleFile. ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID); diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h index cec29da69372f1..598e6121070246 100644 --- a/clang/include/clang/Serialization/ModuleFile.h +++ b/clang/include/clang/Serialization/ModuleFile.h @@ -155,9 +155,6 @@ class ModuleFile { /// Whether timestamps are included in this module file. bool HasTimestamps = false; - /// Whether the PCH has a corresponding object file. - bool PCHHasObjectFile = false; - /// Whether the top-level module has been read from the AST file. bool DidReadTopLevelSubmodule = false; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4fde647cefde14..fc7631712c3cfd 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10473,37 +10473,6 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { else return false; - if (D->isFromASTFile() && !LangOpts.BuildingPCHWithObjectFile) { - assert(getExternalSource() && "It's from an AST file; must have a source."); - // On Windows, PCH files are built together with an object file. If this - // declaration comes from such a PCH and DeclMustBeEmitted would return - // true, it would have returned true and the decl would have been emitted - // into that object file, so it doesn't need to be emitted here. - // Note that decls are still emitted if they're referenced, as usual; - // DeclMustBeEmitted is used to decide whether a decl must be emitted even - // if it's not referenced. - // - // Explicit template instantiation definitions are tricky. If there was an - // explicit template instantiation decl in the PCH before, it will look like - // the definition comes from there, even if that was just the declaration. - // (Explicit instantiation defs of variable templates always get emitted.) - bool IsExpInstDef = - isa(D) && - cast(D)->getTemplateSpecializationKind() == - TSK_ExplicitInstantiationDefinition; - - // Implicit member function definitions, such as operator= might not be - // marked as template specializations, since they're not coming from a - // template but synthesized directly on the class. - IsExpInstDef |= - isa(D) && - cast(D)->getParent()->getTemplateSpecializationKind() == - TSK_ExplicitInstantiationDefinition; - - if (getExternalSource()->DeclIsFromPCHWithObjectFile(D) && !IsExpInstDef) - return false; - } - // If this is a member of a class template, we do not need to emit it. if (D->getDeclContext()->isDependentContext()) return false; diff --git a/clang/lib/Sema/MultiplexExternalSemaSource.cpp b/clang/lib/Sema/MultiplexExternalSemaSource.cpp index 80333e63127e42..252008cda15d20 100644 --- a/clang/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/clang/lib/Sema/MultiplexExternalSemaSource.cpp @@ -172,13 +172,6 @@ Module *MultiplexExternalSemaSource::getModule(unsigned ID) { return nullptr; } -bool MultiplexExternalSemaSource::DeclIsFromPCHWithObjectFile(const Decl *D) { - for (auto *S : Sources) - if (S->DeclIsFromPCHWithObjectFile(D)) - return true; - return false; -} - bool MultiplexExternalSemaSource::layoutRecordType(const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 4a1a995204e599..6b96b4ff59b8e4 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2747,7 +2747,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, return VersionMismatch; } - bool hasErrors = Record[7]; + bool hasErrors = Record[6]; if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) { Diag(diag::err_pch_with_compiler_errors); return HadErrors; @@ -2765,8 +2765,6 @@ ASTReader::ReadControlBlock(ModuleFile &F, F.HasTimestamps = Record[5]; - F.PCHHasObjectFile = Record[6]; - const std::string &CurBranch = getClangFullRepositoryVersion(); StringRef ASTBranch = Blob; if (StringRef(CurBranch) != ASTBranch && !DisableValidation) { @@ -8590,11 +8588,6 @@ Module *ASTReader::getModule(unsigned ID) { return getSubmodule(ID); } -bool ASTReader::DeclIsFromPCHWithObjectFile(const Decl *D) { - ModuleFile *MF = getOwningModuleFile(D); - return MF && MF->PCHHasObjectFile; -} - ModuleFile *ASTReader::getLocalModuleFile(ModuleFile &F, unsigned ID) { if (ID & 1) { // It's a module, look it up by submodule ID. diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index eef4ab16ec15e0..0b87161ddeea34 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -504,10 +504,9 @@ uint64_t ASTDeclReader::GetCurrentCursorOffset() { void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) { if (Record.readInt()) { - Reader.DefinitionSource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile; - if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile && - Reader.DeclIsFromPCHWithObjectFile(FD)) - Reader.DefinitionSource[FD] = true; + Reader.DefinitionSource[FD] = + Loc.F->Kind == ModuleKind::MK_MainFile || + Reader.getContext().getLangOpts().BuildingPCHWithObjectFile; } if (auto *CD = dyn_cast(FD)) { CD->setNumCtorInitializers(Record.readInt()); @@ -1436,10 +1435,9 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) { } if (VD->getStorageDuration() == SD_Static && Record.readInt()) { - Reader.DefinitionSource[VD] = Loc.F->Kind == ModuleKind::MK_MainFile; - if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile && - Reader.DeclIsFromPCHWithObjectFile(VD)) - Reader.DefinitionSource[VD] = true; + Reader.DefinitionSource[VD] = + Loc.F->Kind == ModuleKind::MK_MainFile || + Reader.getContext().getLangOpts().BuildingPCHWithObjectFile; } enum VarKind { @@ -1700,10 +1698,9 @@ void ASTDeclReader::ReadCXXDefinitionData( Data.HasODRHash = true; if (Record.readInt()) { - Reader.DefinitionSource[D] = Loc.F->Kind == ModuleKind::MK_MainFile; - if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile && - Reader.DeclIsFromPCHWithObjectFile(D)) - Reader.DefinitionSource[D] = true; + Reader.DefinitionSource[D] = + Loc.F->Kind == ModuleKind::MK_MainFile || + Reader.getContext().getLangOpts().BuildingPCHWithObjectFile; } Data.NumBases = Record.readInt(); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index a8803aeb1b8aba..9ea90b2a0212a9 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1119,7 +1119,6 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min. MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Timestamps - MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // PCHHasObjectFile MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Errors MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev)); @@ -1134,7 +1133,6 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, CLANG_VERSION_MINOR, !isysroot.empty(), IncludeTimestamps, - Context.getLangOpts().BuildingPCHWithObjectFile, ASTHasCompilerErrors}; Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record, getClangFullRepositoryVersion()); diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index eecdf89c791ad8..ec05ab772d933b 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -1031,8 +1031,10 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) { // that module interface unit, not by its users. (Inline variables are // still emitted in module users.) ModulesCodegen = - (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit && - Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal); + (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit || + (D->hasAttr() && + Writer.Context->getLangOpts().BuildingPCHWithObjectFile)) && + Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal; } Record.push_back(ModulesCodegen); if (ModulesCodegen) @@ -2469,7 +2471,10 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) { Linkage = Writer->Context->GetGVALinkageForFunction(FD); ModulesCodegen = *Linkage == GVA_StrongExternal; } - if (Writer->Context->getLangOpts().ModulesCodegen) { + if (Writer->Context->getLangOpts().ModulesCodegen || + (FD->hasAttr() && + Writer->Context->getLangOpts().BuildingPCHWithObjectFile)) { + // Under -fmodules-codegen, codegen is performed for all non-internal, // non-always_inline functions, unless they are available elsewhere. if (!FD->hasAttr()) { diff --git a/clang/test/CodeGen/pch-dllexport.cpp b/clang/test/CodeGen/pch-dllexport.cpp index 034995fdffc4f8..72f344c77be1d2 100644 --- a/clang/test/CodeGen/pch-dllexport.cpp +++ b/clang/test/CodeGen/pch-dllexport.cpp @@ -3,13 +3,20 @@ // RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCH %s // Build PCH with object file, then use it. -// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-pch -building-pch-with-obj -o %t %s -// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -building-pch-with-obj -o - %s | FileCheck -check-prefix=OBJ %s -// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCHWITHOBJ %s +// RUN: %clang_cc1 -triple i686-pc-win32 -O1 -fms-extensions -emit-pch -building-pch-with-obj -o %t %s +// RUN: %clang_cc1 -triple i686-pc-win32 -O1 -disable-llvm-optzns -fms-extensions -emit-obj -emit-llvm -include-pch %t -building-pch-with-obj -o - %s | FileCheck -check-prefix=OBJ %s +// RUN: %clang_cc1 -triple i686-pc-win32 -O1 -disable-llvm-optzns -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCHWITHOBJ -check-prefix=PCHWITHOBJ-O1 %s // Check for vars separately to avoid having to reorder the check statements. +// RUN: %clang_cc1 -triple i686-pc-win32 -O1 -disable-llvm-optzns -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCHWITHOBJVARS %s + +// Test the PCHWITHOBJ at -O0 where available_externally definitions are not +// provided: +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-pch -building-pch-with-obj -o %t %s +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCHWITHOBJ -check-prefix=PCHWITHOBJ-O0 %s // RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCHWITHOBJVARS %s + #ifndef IN_HEADER #define IN_HEADER @@ -23,7 +30,8 @@ inline void __declspec(dllexport) foo() {} inline void __declspec(dllexport) baz() {} // OBJ: define weak_odr dso_local dllexport void @"?baz@@YAXXZ" // PCH: define weak_odr dso_local dllexport void @"?baz@@YAXXZ" -// PCHWITHOBJ: define weak_odr dso_local dllexport void @"?baz@@YAXXZ" +// PCHWITHOBJ-O1: define available_externally dso_local void @"?baz@@YAXXZ" +// PCHWITHOBJ-O0-NOT: define {{.*}}"?baz@@YAXXZ" struct __declspec(dllexport) S {