Duncan Sands | ac65661 | 2007-09-26 07:28:20 +0000 | [diff] [blame] | 1 | // RUN: %llvmgcc -c -emit-llvm %s -o - | llvm-dis | grep llvm.global.annotations |
| 2 | // RUN: %llvmgcc -c -emit-llvm %s -o - | llvm-dis | grep llvm.var.annotation | count 3 |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3 | |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | /* Global variable with attribute */ |
| 7 | int X __attribute__((annotate("GlobalValAnnotation"))); |
| 8 | |
| 9 | /* Function with attribute */ |
| 10 | int foo(int y) __attribute__((annotate("GlobalValAnnotation"))) |
| 11 | __attribute__((noinline)); |
| 12 | |
| 13 | int foo(int y __attribute__((annotate("LocalValAnnotation")))) { |
| 14 | int x __attribute__((annotate("LocalValAnnotation"))); |
| 15 | x = 34; |
| 16 | return y + x; |
| 17 | } |
| 18 | |
| 19 | int main() { |
| 20 | static int a __attribute__((annotate("GlobalValAnnotation"))); |
| 21 | a = foo(2); |
| 22 | printf("hello world%d\n", a); |
| 23 | return 0; |
| 24 | } |