| 1 | <h2>Full Example</h2> |
| 2 | <pre><code> |
| 3 | ; Declare the string constant as a global constant. |
| 4 | @.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00" |
| 5 | |
| 6 | ; External declaration of the puts function |
| 7 | declare i32 @puts(i8* nocapture) nounwind |
| 8 | |
| 9 | ; Definition of main function |
| 10 | define i32 @main() { ; i32()* |
| 11 | entry: |
| 12 | ; Convert [13 x i8]* to i8*... |
| 13 | %cast210 = getelementptr [13 x i8], [13 x i8]* @.str, i64 0, i64 0 |
| 14 | |
| 15 | ; Call puts function to write out the string to stdout. |
| 16 | call i32 @puts(i8* %cast210) |
| 17 | ret i32 0 |
| 18 | } |
| 19 | |
| 20 | ; Named metadata |
| 21 | !0 = !{i32 42, null, !"string"} |
| 22 | !foo = !{!0} |
| 23 | </code></pre> |