Commit a3c67e00 authored by Mainak Mandal's avatar Mainak Mandal Committed by Sara Golemon

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
parent 148045d0
......@@ -257,11 +257,19 @@ void doNotOptimizeAway(T&& datum) {
#pragma optimize("", on)
#elif defined(__clang__)
template <class T>
__attribute__((__optnone__)) void doNotOptimizeAway(T&& datum) {
}
#else
template <class T>
void doNotOptimizeAway(T&& datum) {
asm volatile("" : "+r" (datum));
}
#endif
} // namespace folly
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment