Introduce MBEDTLS_OPTIMIZE_ALWAYS

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/common.h b/library/common.h
index cfbff02..00c2cd3 100644
--- a/library/common.h
+++ b/library/common.h
@@ -201,4 +201,11 @@
 #define MBEDTLS_COMPILER_IS_GCC
 #endif
 
+/* If -Os is specified, override with -O2 for a given function */
+#if defined(MBEDTLS_COMPILER_IS_GCC) && defined(__OPTIMIZE_SIZE__)
+#define MBEDTLS_OPTIMIZE_ALWAYS __attribute__((optimize("-O2")))
+#else
+#define MBEDTLS_OPTIMIZE_ALWAYS
+#endif
+
 #endif /* MBEDTLS_LIBRARY_COMMON_H */