From 7def74cc86443b395801d73ee5f6f49fe58533d7 Mon Sep 17 00:00:00 2001 From: Chandan Jain Date: Tue, 4 Nov 2025 14:46:59 -0800 Subject: [PATCH] Use -O2 compilation for Autocorrect only (#15583) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/15583 Apply -02 compiler flag to make FLLM autocorrect faster Sheet measuring different scopes of applying -02 and the resulting latency https://docs.google.com/spreadsheets/d/1ZnxoRwCIiMz3hXyhgb6sm_2UThBUyq-mpp8RzksfJMQ/edit?usp=sharing ****Latency**** Reviewed By: BlakeLucchesi, lucylq Differential Revision: D85152814 --- shim_et/xplat/executorch/build/runtime_wrapper.bzl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shim_et/xplat/executorch/build/runtime_wrapper.bzl b/shim_et/xplat/executorch/build/runtime_wrapper.bzl index d03a3f71b3b..16a204aafc5 100644 --- a/shim_et/xplat/executorch/build/runtime_wrapper.bzl +++ b/shim_et/xplat/executorch/build/runtime_wrapper.bzl @@ -117,6 +117,12 @@ def _patch_build_mode_flags(kwargs): "ovr_config//os:macos": ["-fvisibility=default"], }) + # Add -O2 compiler flag when the compiler_flag_O2 config is set + kwargs["compiler_flags"] = kwargs["compiler_flags"] + select({ + "DEFAULT": [], + # @oss-disable: "fbsource//xplat/assistant/oacr/native/scripts:compiler_flag_O2": ["-O2"], + }) + return kwargs def _patch_test_compiler_flags(kwargs):