Skip to content

Commit d799adc

Browse files
author
Jonathan Rocher
committed
Tweaks to the comments in the clang/llvm demo.
1 parent c9e119b commit d799adc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

llvm_clang_demo.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
/* This test file is used to demo how to compile C down to the LLVM Intermediate
22
Representation (LLVM-IR). To do so compile it with
3-
clang llvm_clang_demo.c -c -emit-llvm -S -o llvm_clang_demo.ll
3+
$ clang llvm_clang_demo.c -c -emit-llvm -S -o llvm_clang_demo.ll
4+
-c for just compiling
5+
-S to generate a human readable file instead of binary bytecode
6+
7+
Look at the resulting ll file and look at it again once it has been simplified
8+
with the LLVM optimizer :
9+
$ opt-3.0 -S -O3 llvm_clang_demo.ll
10+
generates a simplified llvm byte code:
11+
12+
; ModuleID = 'llvm_clang_demo.ll'
13+
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
14+
target triple = "x86_64-pc-linux-gnu"
15+
16+
define i32 @foo(i32 %a, i32 %b) nounwind uwtable readnone {
17+
%1 = add nsw i32 %b, %a
18+
ret i32 %1
19+
}
20+
421
*/
522

623
int foo(int a, int b)

0 commit comments

Comments
 (0)