Put __attribute__ ((noinline)) for the function (this semantics is supported by both gcc and clang).
char __attribute__ ((noinline)) ges(long long a, long long b) {
return (a >= b);
}
In the following example, if you don't put __attribute__ ((noinline)) for the function, the compiler would be very clever, it would generate the result for you during compile time, so you never got chance to run your llvm BE code.
$ cat functional.cpp
#include <iostream>
#include <cassert>
using namespace std;
long long __attribute__ ((noinline)) ges(long long a, long long b) {
return (a >= b);
}
int main(void) {
cout << "ges(1, 2) = " << ges(1, 2) << endl;
assert(ges(1,2) == 0);
cout << "ges(2, 2) = " << ges(2, 2) << endl;
assert(ges(2,2) == 1);
cout << "ges(3, 2) = " << ges(3, 2) << endl;
assert(ges(3,2) == 1);
}
No comments:
Post a Comment