File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 11/* This test file is used to demo how to compile C down to the LLVM Intermediate
22Representation (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
623int foo (int a , int b )
You can’t perform that action at this time.
0 commit comments