From a3c67e006de0e32ecad1bc406ab74ca767e4caee Mon Sep 17 00:00:00 2001 From: Mainak Mandal Date: Wed, 26 Aug 2015 10:42:59 -0700 Subject: [PATCH] make doNotOptimizeAway work with clang Summary: Projects depending on benchmark library fail to build with clang with the following error ``` ./folly/Benchark.h:263:16: error: inline asm not supported yet: don't know how to handle tied indirect register inputs ``` I am not an expert here, just tried to take an approach similar to the MSVC compiler clause Reviewed By: @andralex, @yfeldblum Differential Revision: D2368670 --- folly/Benchmark.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/folly/Benchmark.h b/folly/Benchmark.h index 3478d10f..c25ca280 100644 --- a/folly/Benchmark.h +++ b/folly/Benchmark.h @@ -257,11 +257,19 @@ void doNotOptimizeAway(T&& datum) { #pragma optimize("", on) +#elif defined(__clang__) + +template +__attribute__((__optnone__)) void doNotOptimizeAway(T&& datum) { +} + #else + template void doNotOptimizeAway(T&& datum) { asm volatile("" : "+r" (datum)); } + #endif } // namespace folly -- 2.34.1