From 38f082f0411f603f522149b7fbfc600fd1b6b51c Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Tue, 22 Aug 2023 15:58:20 +0900 Subject: [PATCH] Workaround Clang hangs indefinitely When building the function under -O1, Clang hangs indefinitely. It works fine under either -O0 or -O2. Workaround by turning off optimization for just the offending function. Test: presubmit Bug: 296850773 Bug: 294796809 Change-Id: Ia72a9e9e56183d71296cd5d8628461197cb5b2a4 --- neuralnetworks/1.2/utils/test/DeviceTest.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/neuralnetworks/1.2/utils/test/DeviceTest.cpp b/neuralnetworks/1.2/utils/test/DeviceTest.cpp index 0d8c141582..0e855c4b10 100644 --- a/neuralnetworks/1.2/utils/test/DeviceTest.cpp +++ b/neuralnetworks/1.2/utils/test/DeviceTest.cpp @@ -54,6 +54,10 @@ constexpr V1_0::PerformanceInfo kNoPerformanceInfo = { .execTime = std::numeric_limits::max(), .powerUsage = std::numeric_limits::max()}; +// FIXME: This function causes Clang to hang indefinitely when building with +// -O1. Turn off optimization as a temporary workaround. +// http://b/296850773 +#pragma clang optimize off template auto makeCallbackReturn(Args&&... args) { return [argPack = std::make_tuple(std::forward(args)...)](const auto& cb) { @@ -61,6 +65,7 @@ auto makeCallbackReturn(Args&&... args) { return Void(); }; } +#pragma clang optimize on sp createMockDevice() { const auto mockDevice = MockDevice::create();