[llvm-branch-commits] [flang] a6a1c8b - Revert "[Flang][OpenMP] Disable declarate target tests on Windows (#77306)"
Author: Mehdi Amini Date: 2024-01-08T15:48:39+01:00 New Revision: a6a1c8bb8ce58f58d538ca1ff61e3f3130a771ef URL: https://github.com/llvm/llvm-project/commit/a6a1c8bb8ce58f58d538ca1ff61e3f3130a771ef DIFF: https://github.com/llvm/llvm-project/commit/a6a1c8bb8ce58f58d538ca1ff61e3f3130a771ef.diff LOG: Revert "[Flang][OpenMP] Disable declarate target tests on Windows (#77306)" This reverts commit 4a456489e051ff037655597a0b54654aa1f5a2a5. Added: Modified: flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap-enter.f90 flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap.f90 flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap-enter.f90 flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap.f90 Removed: diff --git a/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap-enter.f90 b/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap-enter.f90 index ff0f70444c60ed..8e88d1b0f52a95 100644 --- a/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap-enter.f90 +++ b/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap-enter.f90 @@ -3,8 +3,6 @@ !RUN: bbc -emit-fir -fopenmp %s -o - | FileCheck %s !RUN: bbc -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE -!XFAIL: system-windows - ! CHECK-LABEL: func.func @_QPimplicitly_captured_twice ! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget{{.*}}} function implicitly_captured_twice() result(k) diff --git a/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap.f90 b/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap.f90 index 0b3f2db8ca1f7d..a90b04246e6dc1 100644 --- a/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap.f90 +++ b/flang/test/Lower/OpenMP/FIR/declare-target-implicit-func-and-subr-cap.f90 @@ -3,8 +3,6 @@ !RUN: bbc -emit-fir -fopenmp %s -o - | FileCheck %s !RUN: bbc -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE -!XFAIL: system-windows - ! CHECK-LABEL: func.func @_QPimplicitly_captured ! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget{{.*}}} function implicitly_captured(toggle) result(k) diff --git a/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap-enter.f90 b/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap-enter.f90 index 4e0fa1fdc74c24..ed718a485e3ddc 100644 --- a/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap-enter.f90 +++ b/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap-enter.f90 @@ -3,8 +3,6 @@ !RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s !RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE -!XFAIL: system-windows - ! CHECK-LABEL: func.func @_QPimplicitly_captured_twice ! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget{{.*}}} function implicitly_captured_twice() result(k) diff --git a/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap.f90 b/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap.f90 index f7fd836e50e939..df81c43a2fe69b 100644 --- a/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap.f90 +++ b/flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap.f90 @@ -3,8 +3,6 @@ !RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s !RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE -!XFAIL: system-windows - ! CHECK-LABEL: func.func @_QPimplicitly_captured ! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget{{.*}}} function implicitly_captured(toggle) result(k) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [clang] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
@@ -0,0 +1,18 @@ +; RUN: llc < %s -relocation-model=pic -mtriple=sparc | FileCheck --check-prefix=CALL %s +; RUN: llc < %s -relocation-model=pic -mtriple=sparcv9 -mcpu=ultrasparc | FileCheck --check-prefix=CALL %s +; RUN: llc < %s -relocation-model=pic -mtriple=sparcv9 | FileCheck --check-prefix=RDPC %s + +;; SPARC32 and SPARC64 for classic UltraSPARCs implement GETPCX +;; with a fake `call`. +;; All other SPARC64 targets implement it with `rd %pc, %o7`. + +@value = external global i32 + +; CALL: call +; CALL-NOT: rd %pc +; RDPC: rd %pc +; RDPC-not: call +define i32 @test() { + %1 = load i32, i32* @value + ret i32 %1 +} s-barannikov wrote: The test should show the full expansion (autogenerate the checks?). https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
@@ -234,8 +244,15 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI, // add , %o7, s-barannikov wrote: Please update the comment to include the rdpc case. https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [clang] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
@@ -118,9 +126,11 @@ def : Proc<"ma2480", [FeatureLeon, LeonCASA]>; def : Proc<"ma2485", [FeatureLeon, LeonCASA]>; def : Proc<"ma2x8x", [FeatureLeon, LeonCASA]>; def : Proc<"v9", [FeatureV9]>; -def : Proc<"ultrasparc", [FeatureV9, FeatureV8Deprecated, FeatureVIS]>; +def : Proc<"ultrasparc", [FeatureV9, FeatureV8Deprecated, FeatureVIS], + [TuneSlowRDPC]>; s-barannikov wrote: Why is it in TuneFeatures? Sparc doesn't seem to support -mtune. https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
@@ -234,8 +244,15 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI, // add , %o7, OutStreamer->emitLabel(StartLabel); - MCOperand Callee = createPCXCallOP(EndLabel, OutContext); - EmitCall(*OutStreamer, Callee, STI); + if (!STI.getTargetTriple().isSPARC64() || + STI.hasFeature(Sparc::TuneSlowRDPC)) { +MCOperand Callee = createPCXCallOP(EndLabel, OutContext); +EmitCall(*OutStreamer, Callee, STI); + } else { +// TODO make it possible to store PC in other registers +// so that leaf function optimization becomes possible. s-barannikov wrote: Would that be hard to do the expansion at instruction selection level? https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [openmp] ee1c408 - Revert "[OpenMP][libomptarget] Enable automatic unified shared memory executi… (#75999)"
Author: carlobertolli Date: 2024-01-08T14:37:25-06:00 New Revision: ee1c408206ac48c612f9f4b8cc526d9167097090 URL: https://github.com/llvm/llvm-project/commit/ee1c408206ac48c612f9f4b8cc526d9167097090 DIFF: https://github.com/llvm/llvm-project/commit/ee1c408206ac48c612f9f4b8cc526d9167097090.diff LOG: Revert "[OpenMP][libomptarget] Enable automatic unified shared memory executi… (#75999)" This reverts commit 22a73e7c4616e0405db85598c049a7ca70cca7cc. Added: Modified: openmp/libomptarget/include/Shared/PluginAPI.h openmp/libomptarget/include/Shared/PluginAPI.inc openmp/libomptarget/include/Shared/Requirements.h openmp/libomptarget/include/device.h openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp openmp/libomptarget/plugins-nextgen/amdgpu/utils/UtilitiesRTL.h openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp openmp/libomptarget/src/OpenMP/Mapping.cpp openmp/libomptarget/src/PluginManager.cpp openmp/libomptarget/src/device.cpp Removed: openmp/libomptarget/test/mapping/auto_zero_copy.cpp diff --git a/openmp/libomptarget/include/Shared/PluginAPI.h b/openmp/libomptarget/include/Shared/PluginAPI.h index aece53d7ee1caa..c6aacf4ce2124b 100644 --- a/openmp/libomptarget/include/Shared/PluginAPI.h +++ b/openmp/libomptarget/include/Shared/PluginAPI.h @@ -219,9 +219,6 @@ int32_t __tgt_rtl_initialize_record_replay(int32_t DeviceId, int64_t MemorySize, void *VAddr, bool isRecord, bool SaveOutput, uint64_t &ReqPtrArgOffset); - -// Returns true if the device \p DeviceId suggests to use auto zero-copy. -int32_t __tgt_rtl_use_auto_zero_copy(int32_t DeviceId); } #endif // OMPTARGET_SHARED_PLUGIN_API_H diff --git a/openmp/libomptarget/include/Shared/PluginAPI.inc b/openmp/libomptarget/include/Shared/PluginAPI.inc index b842c6eef1d4fc..25ebe7d437f9d1 100644 --- a/openmp/libomptarget/include/Shared/PluginAPI.inc +++ b/openmp/libomptarget/include/Shared/PluginAPI.inc @@ -47,4 +47,3 @@ PLUGIN_API_HANDLE(data_notify_mapped, false); PLUGIN_API_HANDLE(data_notify_unmapped, false); PLUGIN_API_HANDLE(set_device_offset, false); PLUGIN_API_HANDLE(initialize_record_replay, false); -PLUGIN_API_HANDLE(use_auto_zero_copy, false); diff --git a/openmp/libomptarget/include/Shared/Requirements.h b/openmp/libomptarget/include/Shared/Requirements.h index b16a1650f0c403..19d6b8ffca495f 100644 --- a/openmp/libomptarget/include/Shared/Requirements.h +++ b/openmp/libomptarget/include/Shared/Requirements.h @@ -33,12 +33,7 @@ enum OpenMPOffloadingRequiresDirFlags : int64_t { /// unified_shared_memory clause. OMP_REQ_UNIFIED_SHARED_MEMORY = 0x008, /// dynamic_allocators clause. - OMP_REQ_DYNAMIC_ALLOCATORS = 0x010, - /// Auto zero-copy extension: - /// when running on an APU, the GPU plugin may decide to - /// run in zero-copy even though the user did not program - /// their application with unified_shared_memory requirement. - OMPX_REQ_AUTO_ZERO_COPY = 0x020 + OMP_REQ_DYNAMIC_ALLOCATORS = 0x010 }; class RequirementCollection { @@ -70,14 +65,6 @@ class RequirementCollection { return; } -// Auto zero-copy is only valid when no other requirement has been set -// and it is computed at device initialization time, after the requirement -// flag has already been set to OMP_REQ_NONE. -if (SetFlags == OMP_REQ_NONE && NewFlags == OMPX_REQ_AUTO_ZERO_COPY) { - SetFlags = NewFlags; - return; -} - // If multiple compilation units are present enforce // consistency across all of them for require clauses: // - reverse_offload diff --git a/openmp/libomptarget/include/device.h b/openmp/libomptarget/include/device.h index 8b4396ac468d78..d28d3c508faf56 100644 --- a/openmp/libomptarget/include/device.h +++ b/openmp/libomptarget/include/device.h @@ -164,9 +164,6 @@ struct DeviceTy { /// Print all offload entries to stderr. void dumpOffloadEntries(); - /// Ask the device whether the runtime should use auto zero-copy. - bool useAutoZeroCopy(); - private: /// Deinitialize the device (and plugin). void deinit(); diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp index b5f0baee23dc2c..b67642e9e1bcb3 100644 --- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp +++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp @@ -1848,9 +1848,8 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy { OMPX_StreamBusyWait("LIBOMPTARGET_AMDGPU_STREAM_BUSYWAIT", 200), OMPX_UseMultipleSdmaEngines( "LIBOMPTARGET_AMDGPU_USE_MULTIPLE_SDMA_ENGINES", false), -HSAXnackEnv("HSA_XNAC
[llvm-branch-commits] [clang] [llvm] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
@@ -118,9 +126,11 @@ def : Proc<"ma2480", [FeatureLeon, LeonCASA]>; def : Proc<"ma2485", [FeatureLeon, LeonCASA]>; def : Proc<"ma2x8x", [FeatureLeon, LeonCASA]>; def : Proc<"v9", [FeatureV9]>; -def : Proc<"ultrasparc", [FeatureV9, FeatureV8Deprecated, FeatureVIS]>; +def : Proc<"ultrasparc", [FeatureV9, FeatureV8Deprecated, FeatureVIS], + [TuneSlowRDPC]>; koachan wrote: -mtune enablement is at PR #77195. clang already accepts, recognises, and passes the flag on to the backend, it's just the backend haven't made any use of the provided info yet. https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [clang] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
@@ -118,9 +126,11 @@ def : Proc<"ma2480", [FeatureLeon, LeonCASA]>; def : Proc<"ma2485", [FeatureLeon, LeonCASA]>; def : Proc<"ma2x8x", [FeatureLeon, LeonCASA]>; def : Proc<"v9", [FeatureV9]>; -def : Proc<"ultrasparc", [FeatureV9, FeatureV8Deprecated, FeatureVIS]>; +def : Proc<"ultrasparc", [FeatureV9, FeatureV8Deprecated, FeatureVIS], + [TuneSlowRDPC]>; s-barannikov wrote: I see. IIUC -mtune is translate into -tune-cpu llc option. If so, the test should use this option. https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [test][hwasan] Test function name in summaries (PR #77391)
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/77391 None ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [test][hwasan] Test function name in summaries (PR #77391)
llvmbot wrote: @llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/77391.diff 7 Files Affected: - (modified) compiler-rt/test/hwasan/TestCases/Linux/aligned_alloc-alignment.cpp (+1-1) - (modified) compiler-rt/test/hwasan/TestCases/Linux/pvalloc-overflow.cpp (+1-1) - (modified) compiler-rt/test/hwasan/TestCases/Posix/posix_memalign-alignment.cpp (+1-1) - (modified) compiler-rt/test/hwasan/TestCases/allocator_returns_null.cpp (+8-8) - (modified) compiler-rt/test/hwasan/TestCases/halt-on-error.cpp (+3-3) - (modified) compiler-rt/test/hwasan/TestCases/report-unmapped.cpp (+1-1) - (modified) compiler-rt/test/hwasan/TestCases/use-after-free.c (+1-1) ``diff diff --git a/compiler-rt/test/hwasan/TestCases/Linux/aligned_alloc-alignment.cpp b/compiler-rt/test/hwasan/TestCases/Linux/aligned_alloc-alignment.cpp index 429760ba0e1951..ad5b7616e8a7fb 100644 --- a/compiler-rt/test/hwasan/TestCases/Linux/aligned_alloc-alignment.cpp +++ b/compiler-rt/test/hwasan/TestCases/Linux/aligned_alloc-alignment.cpp @@ -14,7 +14,7 @@ int main() { // CHECK: ERROR: HWAddressSanitizer: invalid alignment requested in aligned_alloc: 17 // CHECK: {{#0 0x.* in .*}}{{aligned_alloc|memalign}} // CHECK: {{#1 0x.* in main .*aligned_alloc-alignment.cpp:}}[[@LINE-3]] - // CHECK: SUMMARY: HWAddressSanitizer: invalid-aligned-alloc-alignment + // CHECK: SUMMARY: HWAddressSanitizer: invalid-aligned-alloc-alignment {{.*}} in aligned_alloc printf("pointer after failed aligned_alloc: %zd\n", (size_t)p); // CHECK-NULL: pointer after failed aligned_alloc: 0 diff --git a/compiler-rt/test/hwasan/TestCases/Linux/pvalloc-overflow.cpp b/compiler-rt/test/hwasan/TestCases/Linux/pvalloc-overflow.cpp index b0b1ed3b798cba..bd9f34a0dac921 100644 --- a/compiler-rt/test/hwasan/TestCases/Linux/pvalloc-overflow.cpp +++ b/compiler-rt/test/hwasan/TestCases/Linux/pvalloc-overflow.cpp @@ -39,6 +39,6 @@ int main(int argc, char *argv[]) { // CHECK: {{ERROR: HWAddressSanitizer: pvalloc parameters overflow: size .* rounded up to system page size .* cannot be represented in type size_t}} // CHECK: {{#0 0x.* in .*pvalloc}} // CHECK: {{#1 0x.* in main .*pvalloc-overflow.cpp:}} -// CHECK: SUMMARY: HWAddressSanitizer: pvalloc-overflow +// CHECK: SUMMARY: HWAddressSanitizer: pvalloc-overflow {{.*}} in pvalloc // CHECK-NULL: errno: 12 diff --git a/compiler-rt/test/hwasan/TestCases/Posix/posix_memalign-alignment.cpp b/compiler-rt/test/hwasan/TestCases/Posix/posix_memalign-alignment.cpp index eb9355f6da7219..029e086f99ada2 100644 --- a/compiler-rt/test/hwasan/TestCases/Posix/posix_memalign-alignment.cpp +++ b/compiler-rt/test/hwasan/TestCases/Posix/posix_memalign-alignment.cpp @@ -11,7 +11,7 @@ int main() { // CHECK: ERROR: HWAddressSanitizer: invalid alignment requested in posix_memalign: 17 // CHECK: {{#0 0x.* in .*posix_memalign}} // CHECK: {{#1 0x.* in main .*posix_memalign-alignment.cpp:}}[[@LINE-3]] - // CHECK: SUMMARY: HWAddressSanitizer: invalid-posix-memalign-alignment + // CHECK: SUMMARY: HWAddressSanitizer: invalid-posix-memalign-alignment {{.*}} in posix_memalign printf("pointer after failed posix_memalign: %zd\n", (size_t)p); // CHECK-NULL: pointer after failed posix_memalign: 42 diff --git a/compiler-rt/test/hwasan/TestCases/allocator_returns_null.cpp b/compiler-rt/test/hwasan/TestCases/allocator_returns_null.cpp index aa98076bf91ee9..18ee9406d146fb 100644 --- a/compiler-rt/test/hwasan/TestCases/allocator_returns_null.cpp +++ b/compiler-rt/test/hwasan/TestCases/allocator_returns_null.cpp @@ -87,21 +87,21 @@ int main(int argc, char **argv) { } // CHECK-mCRASH: malloc: -// CHECK-mCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big +// CHECK-mCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big {{.*}} in malloc // CHECK-cCRASH: calloc: -// CHECK-cCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big +// CHECK-cCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big {{.*}} in calloc // CHECK-coCRASH: calloc-overflow: -// CHECK-coCRASH: SUMMARY: HWAddressSanitizer: calloc-overflow +// CHECK-coCRASH: SUMMARY: HWAddressSanitizer: calloc-overflow {{.*}} in calloc // CHECK-rCRASH: realloc: -// CHECK-rCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big +// CHECK-rCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big {{.*}} in realloc // CHECK-mrCRASH: realloc-after-malloc: -// CHECK-mrCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big +// CHECK-mrCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big {{.*}} in realloc // CHECK-nCRASH: new: -// CHECK-nCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big +// CHECK-nCRASH: SUMMARY: HWAddressSanitizer: allocation-size-too-big {{.*}} in operator new // CHECK-nCRASH-OOM: new: -// CHECK-nCRASH-OOM: SUMMARY: HWAddressSanitizer: out-of-memory +// CHECK-nCRASH-OOM: SUMMARY: HWAddressSanitizer: o
[llvm-branch-commits] [compiler-rt] [test][hwasan] Test function name in summaries (PR #77391)
https://github.com/kstoimenov approved this pull request. https://github.com/llvm/llvm-project/pull/77391 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] dd88bd2 - Revert "[ASan][libc++] String annotations optimizations fix with lambda (#76200)"
Author: Tacet Date: 2024-01-09T00:34:25+01:00 New Revision: dd88bd27b380e4b5ffd7260a29ec57d6093a70dd URL: https://github.com/llvm/llvm-project/commit/dd88bd27b380e4b5ffd7260a29ec57d6093a70dd DIFF: https://github.com/llvm/llvm-project/commit/dd88bd27b380e4b5ffd7260a29ec57d6093a70dd.diff LOG: Revert "[ASan][libc++] String annotations optimizations fix with lambda (#76200)" This reverts commit c68a9d25e99a096f6862fc4b57dd380a21245d31. Added: Modified: libcxx/include/string Removed: diff --git a/libcxx/include/string b/libcxx/include/string index e2be53eaee2417..c676182fba8bac 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -922,7 +922,7 @@ public: // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first. // __str's memory needs to be unpoisoned only in the case where it's a short string. - : __r_([](basic_string &__s){ if(!__s.__is_long()) __s.__annotate_delete(); return std::move(__s.__r_); }(__str)) { + : __r_(((__str.__is_long() ? 0 : (__str.__annotate_delete(), 0)), std::move(__str.__r_))) { __str.__r_.first() = __rep(); __str.__annotate_new(0); if (!__is_long()) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)
https://github.com/ChuanqiXu9 created https://github.com/llvm/llvm-project/pull/77417 This is the successor of https://github.com/llvm/llvm-project/pull/76774. I meant to use spr but I failed. So I created the stacked review here manually. Hope this won't be too bad. The core idea of the patch is: when we see the new specialization for template decl in other modules, we don't add the specialization to the update list (so it'll be loaded at once if needed). But we add these specializations and the corresponding hashed values to a hash table and we wrote the hash table to disk instead. So when we read that template decl in other modules, we will associate the hash table with that template decl. In fact, the whole process is exactly the same with how we update the name lookup table. >From 538f9098a49cec659793ba0c679a8e70b6af867c Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 4 Jan 2024 16:19:05 +0800 Subject: [PATCH] Load Specialization Updates Lazily --- .../include/clang/Serialization/ASTBitCodes.h | 2 + clang/include/clang/Serialization/ASTReader.h | 11 +++-- clang/include/clang/Serialization/ASTWriter.h | 7 clang/lib/Serialization/ASTCommon.h | 2 +- clang/lib/Serialization/ASTReader.cpp | 24 +-- clang/lib/Serialization/ASTReaderDecl.cpp | 37 +--- clang/lib/Serialization/ASTWriter.cpp | 42 +++ clang/lib/Serialization/ASTWriterDecl.cpp | 7 +++- clang/test/Modules/cxx-templates.cpp | 9 ++-- .../Serialization/LoadSpecLazily.cpp | 34 +++ 10 files changed, 140 insertions(+), 35 deletions(-) diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 23a279de96ab15..212ae7db30faa0 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -695,6 +695,8 @@ enum ASTRecordTypes { /// Record code for an unterminated \#pragma clang assume_nonnull begin /// recorded in a preamble. PP_ASSUME_NONNULL_LOC = 67, + + UPDATE_SPECIALIZATION = 68, }; /// Record types used within a source manager block. diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 293d6495d164ef..ecd4932c16a401 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -610,18 +610,22 @@ class ASTReader // Updates for visible decls can occur for other contexts than just the // TU, and when we read those update records, the actual context may not // be available yet, so have this pending map using the ID as a key. It - // will be realized when the context is actually loaded. - struct PendingVisibleUpdate { + // will be realized when the data is actually loaded. + struct UpdateData { ModuleFile *Mod; const unsigned char *Data; }; - using DeclContextVisibleUpdates = SmallVector; + using DeclContextVisibleUpdates = SmallVector; /// Updates to the visible declarations of declaration contexts that /// haven't been loaded yet. llvm::DenseMap PendingVisibleUpdates; + using SpecializationsUpdate = SmallVector; + llvm::DenseMap + PendingSpecializationsUpdates; + /// The set of C++ or Objective-C classes that have forward /// declarations that have not yet been linked to their definitions. llvm::SmallPtrSet PendingDefinitions; @@ -650,6 +654,7 @@ class ASTReader bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor, uint64_t Offset, Decl *D); + void AddSpecializations(const Decl *D, const unsigned char *Data, ModuleFile &M); /// A vector containing identifiers that have already been /// loaded. diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 09806b87590766..9f689b18652589 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -385,6 +385,9 @@ class ASTWriter : public ASTDeserializationListener, /// record containing modifications to them. DeclUpdateMap DeclUpdates; + using SpecializationUpdateMap = llvm::MapVector>; + SpecializationUpdateMap SpecializationsUpdates; + using FirstLatestDeclMap = llvm::DenseMap; /// Map of first declarations from a chained PCH that point to the @@ -527,6 +530,9 @@ class ASTWriter : public ASTDeserializationListener, bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC); bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC); + void GenerateSpecializationsLookupTable(const NamedDecl *D, +llvm::SmallVectorImpl &Specs, +llvm::SmallVectorImpl &LookupTable); uint64_t WriteSpecializationsLookupTable( const NamedDecl *D, llvm::SmallVectorImpl &Specializations); @@ -5
[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: Chuanqi Xu (ChuanqiXu9) Changes This is the successor of https://github.com/llvm/llvm-project/pull/76774. I meant to use spr but I failed. So I created the stacked review here manually. Hope this won't be too bad. The core idea of the patch is: when we see the new specialization for template decl in other modules, we don't add the specialization to the update list (so it'll be loaded at once if needed). But we add these specializations and the corresponding hashed values to a hash table and we wrote the hash table to disk instead. So when we read that template decl in other modules, we will associate the hash table with that template decl. In fact, the whole process is exactly the same with how we update the name lookup table. --- Full diff: https://github.com/llvm/llvm-project/pull/77417.diff 10 Files Affected: - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+2) - (modified) clang/include/clang/Serialization/ASTReader.h (+8-3) - (modified) clang/include/clang/Serialization/ASTWriter.h (+7) - (modified) clang/lib/Serialization/ASTCommon.h (+1-1) - (modified) clang/lib/Serialization/ASTReader.cpp (+20-4) - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+23-14) - (modified) clang/lib/Serialization/ASTWriter.cpp (+35-7) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+5-2) - (modified) clang/test/Modules/cxx-templates.cpp (+5-4) - (modified) clang/unittests/Serialization/LoadSpecLazily.cpp (+34) ``diff diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 23a279de96ab15..212ae7db30faa0 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -695,6 +695,8 @@ enum ASTRecordTypes { /// Record code for an unterminated \#pragma clang assume_nonnull begin /// recorded in a preamble. PP_ASSUME_NONNULL_LOC = 67, + + UPDATE_SPECIALIZATION = 68, }; /// Record types used within a source manager block. diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 293d6495d164ef..ecd4932c16a401 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -610,18 +610,22 @@ class ASTReader // Updates for visible decls can occur for other contexts than just the // TU, and when we read those update records, the actual context may not // be available yet, so have this pending map using the ID as a key. It - // will be realized when the context is actually loaded. - struct PendingVisibleUpdate { + // will be realized when the data is actually loaded. + struct UpdateData { ModuleFile *Mod; const unsigned char *Data; }; - using DeclContextVisibleUpdates = SmallVector; + using DeclContextVisibleUpdates = SmallVector; /// Updates to the visible declarations of declaration contexts that /// haven't been loaded yet. llvm::DenseMap PendingVisibleUpdates; + using SpecializationsUpdate = SmallVector; + llvm::DenseMap + PendingSpecializationsUpdates; + /// The set of C++ or Objective-C classes that have forward /// declarations that have not yet been linked to their definitions. llvm::SmallPtrSet PendingDefinitions; @@ -650,6 +654,7 @@ class ASTReader bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor, uint64_t Offset, Decl *D); + void AddSpecializations(const Decl *D, const unsigned char *Data, ModuleFile &M); /// A vector containing identifiers that have already been /// loaded. diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 09806b87590766..9f689b18652589 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -385,6 +385,9 @@ class ASTWriter : public ASTDeserializationListener, /// record containing modifications to them. DeclUpdateMap DeclUpdates; + using SpecializationUpdateMap = llvm::MapVector>; + SpecializationUpdateMap SpecializationsUpdates; + using FirstLatestDeclMap = llvm::DenseMap; /// Map of first declarations from a chained PCH that point to the @@ -527,6 +530,9 @@ class ASTWriter : public ASTDeserializationListener, bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC); bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC); + void GenerateSpecializationsLookupTable(const NamedDecl *D, +llvm::SmallVectorImpl &Specs, +llvm::SmallVectorImpl &LookupTable); uint64_t WriteSpecializationsLookupTable( const NamedDecl *D, llvm::SmallVectorImpl &Specializations); @@ -542,6 +548,7 @@ class ASTWriter : public ASTDeserializationListener, void WriteReferencedSelectorsPo
[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 50fd47f2bfda527807f8cc5e46425050246868aa 538f9098a49cec659793ba0c679a8e70b6af867c -- clang/include/clang/Serialization/ASTBitCodes.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ASTWriter.h clang/lib/Serialization/ASTCommon.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/Modules/cxx-templates.cpp clang/unittests/Serialization/LoadSpecLazily.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index ecd4932c16..10726b440d 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -654,7 +654,8 @@ private: bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor, uint64_t Offset, Decl *D); - void AddSpecializations(const Decl *D, const unsigned char *Data, ModuleFile &M); + void AddSpecializations(const Decl *D, const unsigned char *Data, + ModuleFile &M); /// A vector containing identifiers that have already been /// loaded. diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 9f689b1865..0d39f8ace8 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -385,7 +385,8 @@ private: /// record containing modifications to them. DeclUpdateMap DeclUpdates; - using SpecializationUpdateMap = llvm::MapVector>; + using SpecializationUpdateMap = + llvm::MapVector>; SpecializationUpdateMap SpecializationsUpdates; using FirstLatestDeclMap = llvm::DenseMap; @@ -530,9 +531,9 @@ private: bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC); bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC); - void GenerateSpecializationsLookupTable(const NamedDecl *D, -llvm::SmallVectorImpl &Specs, -llvm::SmallVectorImpl &LookupTable); + void GenerateSpecializationsLookupTable( + const NamedDecl *D, llvm::SmallVectorImpl &Specs, + llvm::SmallVectorImpl &LookupTable); uint64_t WriteSpecializationsLookupTable( const NamedDecl *D, llvm::SmallVectorImpl &Specializations); diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 54ce94a1a5..5583fce2e4 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1344,10 +1344,11 @@ bool ASTReader::ReadVisibleDeclContextStorage(ModuleFile &M, return false; } -void ASTReader::AddSpecializations(const Decl *D, const unsigned char *Data, ModuleFile &M) { +void ASTReader::AddSpecializations(const Decl *D, const unsigned char *Data, + ModuleFile &M) { D = D->getCanonicalDecl(); - SpecializationsLookups[D].Table.add(&M, Data, - reader::SpecializationsLookupTrait(*this, M)); + SpecializationsLookups[D].Table.add( + &M, Data, reader::SpecializationsLookupTrait(*this, M)); } bool ASTReader::ReadSpecializations(ModuleFile &M, BitstreamCursor &Cursor, @@ -3487,8 +3488,9 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F, case UPDATE_SPECIALIZATION: { unsigned Idx = 0; serialization::DeclID ID = ReadDeclID(F, Record, Idx); - auto *Data = (const unsigned char*)Blob.data(); - PendingSpecializationsUpdates[ID].push_back(PendingVisibleUpdate{&F, Data}); + auto *Data = (const unsigned char *)Blob.data(); + PendingSpecializationsUpdates[ID].push_back( + PendingVisibleUpdate{&F, Data}); // If we've already loaded the decl, perform the updates when we finish // loading this block. if (Decl *D = GetExistingDecl(ID)) diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 68c1536b19..cbc21be234 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -321,8 +321,9 @@ namespace clang { void ReadFunctionDefinition(FunctionDecl *FD); void Visit(Decl *D); -void UpdateDecl(Decl *D, -SmallVectorImpl &UpdatedPartialSpecializations); +void UpdateDecl( +Decl *D, +SmallVectorImpl &UpdatedPartialSpecializations); static void setNextObjCCategory(ObjCCategoryDecl *Cat, ObjCCategoryDecl *Next) { @@ -4234,8 +4235,7 @@ void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord
[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)
https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/77417 >From 23184b26934c5a3ba833fb3d7a12adcafb6fad8e Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 4 Jan 2024 16:19:05 +0800 Subject: [PATCH] Load Specialization Updates Lazily --- .../include/clang/Serialization/ASTBitCodes.h | 2 + clang/include/clang/Serialization/ASTReader.h | 12 -- clang/include/clang/Serialization/ASTWriter.h | 8 clang/lib/Serialization/ASTCommon.h | 2 +- clang/lib/Serialization/ASTReader.cpp | 26 +-- clang/lib/Serialization/ASTReaderDecl.cpp | 41 -- clang/lib/Serialization/ASTWriter.cpp | 43 --- clang/lib/Serialization/ASTWriterDecl.cpp | 9 +++- clang/test/Modules/cxx-templates.cpp | 9 ++-- .../Serialization/LoadSpecLazily.cpp | 34 +++ 10 files changed, 152 insertions(+), 34 deletions(-) diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 23a279de96ab15..212ae7db30faa0 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -695,6 +695,8 @@ enum ASTRecordTypes { /// Record code for an unterminated \#pragma clang assume_nonnull begin /// recorded in a preamble. PP_ASSUME_NONNULL_LOC = 67, + + UPDATE_SPECIALIZATION = 68, }; /// Record types used within a source manager block. diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 293d6495d164ef..10726b440de515 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -610,18 +610,22 @@ class ASTReader // Updates for visible decls can occur for other contexts than just the // TU, and when we read those update records, the actual context may not // be available yet, so have this pending map using the ID as a key. It - // will be realized when the context is actually loaded. - struct PendingVisibleUpdate { + // will be realized when the data is actually loaded. + struct UpdateData { ModuleFile *Mod; const unsigned char *Data; }; - using DeclContextVisibleUpdates = SmallVector; + using DeclContextVisibleUpdates = SmallVector; /// Updates to the visible declarations of declaration contexts that /// haven't been loaded yet. llvm::DenseMap PendingVisibleUpdates; + using SpecializationsUpdate = SmallVector; + llvm::DenseMap + PendingSpecializationsUpdates; + /// The set of C++ or Objective-C classes that have forward /// declarations that have not yet been linked to their definitions. llvm::SmallPtrSet PendingDefinitions; @@ -650,6 +654,8 @@ class ASTReader bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor, uint64_t Offset, Decl *D); + void AddSpecializations(const Decl *D, const unsigned char *Data, + ModuleFile &M); /// A vector containing identifiers that have already been /// loaded. diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 09806b87590766..0d39f8ace87843 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -385,6 +385,10 @@ class ASTWriter : public ASTDeserializationListener, /// record containing modifications to them. DeclUpdateMap DeclUpdates; + using SpecializationUpdateMap = + llvm::MapVector>; + SpecializationUpdateMap SpecializationsUpdates; + using FirstLatestDeclMap = llvm::DenseMap; /// Map of first declarations from a chained PCH that point to the @@ -527,6 +531,9 @@ class ASTWriter : public ASTDeserializationListener, bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC); bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC); + void GenerateSpecializationsLookupTable( + const NamedDecl *D, llvm::SmallVectorImpl &Specs, + llvm::SmallVectorImpl &LookupTable); uint64_t WriteSpecializationsLookupTable( const NamedDecl *D, llvm::SmallVectorImpl &Specializations); @@ -542,6 +549,7 @@ class ASTWriter : public ASTDeserializationListener, void WriteReferencedSelectorsPool(Sema &SemaRef); void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver, bool IsModule); + void WriteSpecializationsUpdates(); void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord); void WriteDeclContextVisibleUpdate(const DeclContext *DC); void WriteFPPragmaOptions(const FPOptionsOverride &Opts); diff --git a/clang/lib/Serialization/ASTCommon.h b/clang/lib/Serialization/ASTCommon.h index 296642e3674a49..9d190c05062444 100644 --- a/clang/lib/Serialization/ASTCommon.h +++ b/clang/lib/Serialization/ASTCommon.h @@ -23,7 +23,7 @@ namespace serialization {
[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)
vgvassilev wrote: Let me try something. https://github.com/llvm/llvm-project/pull/77417 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)
vgvassilev wrote: @ChuanqiXu9, I managed to push the commit here back to https://github.com/llvm/llvm-project/pull/76774 and we can continue the discussion there. Would that be sufficient? https://github.com/llvm/llvm-project/pull/77417 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits