brintos

brintos / llvm-project-archived public Read only

0
0
Text · 900 B · 2c69039 Raw
45 lines · c
1#include <stdio.h>2 3#if defined(__arm__) || defined(__aarch64__) || defined (__mips__) || defined(__powerpc64__)4// Clang does not accept regparm attribute on these platforms.5// Fortunately, the default calling convention passes arguments in registers6// anyway.7#define REGPARM(N)8#else9#define REGPARM(N) __attribute__((regparm(N)))10#endif11 12struct bar {13  int m1;14  int m2;15};16 17void f1(int a, struct bar *b) __attribute__((noinline)) REGPARM(2);18void f1(int a, struct bar *b)19{20  b->m2 = b->m1 + a; // set breakpoint here21}22 23void f2(struct bar *b) __attribute__((noinline)) REGPARM(1);24void f2(struct bar *b)25{26  int c = b->m2;27  printf("%d\n", c); // set breakpoint here28}29 30float f3() __attribute__((noinline));31float f3() {32  return 3.14f;33}34 35int main()36{37  struct bar myBar = { 3, 4 };38  f1(2, &myBar);39  f2(&myBar);40 41  float f = f3();42  printf("%f\n", f); // set breakpoint here43  return 0;44}45