Avoid -O3 optimizations on TensorShape's copy for linux armv7a in release mode
Resolve COMPMID-4286
Signed-off-by: Giorgio Arena <giorgio.arena@arm.com>
Change-Id: I2f658f1b366c6bccada9b81de1f310602c41a161
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5176
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
diff --git a/SConstruct b/SConstruct
index ad9a3ac..48b01c9 100644
--- a/SConstruct
+++ b/SConstruct
@@ -336,6 +336,8 @@
env.Append(CPPDEFINES = ['BARE_METAL'])
if env['os'] == 'linux' and env['arch'] == 'armv7a':
env.Append(CXXFLAGS = [ '-Wno-psabi' ])
+ if not env['debug']:
+ env.Append(CPPDEFINES = ['LINUX_V7_RELEASE'])
if env['specs_file'] != "":
env.Append(LINKFLAGS = ['-specs='+env['specs_file']])
diff --git a/arm_compute/core/TensorShape.h b/arm_compute/core/TensorShape.h
index 7c5ea8d..9f6cf77 100644
--- a/arm_compute/core/TensorShape.h
+++ b/arm_compute/core/TensorShape.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2020 Arm Limited.
+ * Copyright (c) 2016-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -57,7 +57,18 @@
apply_dimension_correction();
}
/** Allow instances of this class to be copy constructed */
+ // Avoid -O3 aggressive optimization for the copy constructor when building in release mode for armv7a
+#if defined(LINUX_V7_RELEASE)
+#pragma GCC push_options
+#pragma GCC optimize("O2")
+ TensorShape(const TensorShape &other)
+ : Dimensions(static_cast<const Dimensions &>(other))
+ {
+ }
+#pragma GCC pop_options
+#else // defined(LINUX_V7_RELEASE)
TensorShape(const TensorShape &) = default;
+#endif // defined(LINUX_V7_RELEASE)
/** Allow instances of this class to be copied */
TensorShape &operator=(const TensorShape &) = default;
/** Allow instances of this class to be move constructed */