From: Mainak Mandal Date: Wed, 26 Aug 2015 17:42:59 +0000 (-0700) Subject: make doNotOptimizeAway work with clang X-Git-Tag: v0.56.0~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a3c67e006de0e32ecad1bc406ab74ca767e4caee;p=folly.git 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 --- 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