Вопрос

What is the equivalent of GCC's #pragma GCC optimize("O0") or VS's #pragma optimize("", off) in Apple LLVM 5.0 compiler?

I need it to disable optimizations for just a section of code.

Это было полезно?

Решение

From a brief search it doesn't look like clang/llvm supports such a pragma at this time. If you don't want to turn off optimizations for an entire file I suggest factoring what you don't want optimized into a separate file and setting -O0 on it separately.

Другие советы

Actually there is now a way to do that by specifying an __attribute__ ((optnone)) to the function that wraps the code you don't want to be optimized.

For instance I'm using it to have a clear benchmark of an inline function

static void BM_notoptimizedfunction(benchmark::State& state) __attribute__ ((optnone)) {
    // your code here won't be optimized by clang
}

And that's it !

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top