- GCC, a non-modular C compiler (https://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01837.html)
… If GCC were to change from a free compiler into a platform for nonfree compilers, it would no longer serve the goal of freedom very well. Therefore, we had to take care to prevent that.
- started out as ”A compilation framework for Lifelong program analysis and transformation”
- In 2005, Apple hired Lattner to begin work on implementing Clang, due to GCC changing to GPLv3.
- LLVM tried to integrate back into GCC: LLVM/GCC Integration proposal
- LLVM was not technologically superior to GCC.
- Was architected to be easy to build, test, and extend.
int foo(int p) {
int z;
int x = p + 1;
if (x < 10) {
z = 20;
} else {
z = 30;
}
return z + 10;
}
define dso_local i32 @foo(i32 %p) #0 {
entry:
%add = add nsw i32 %p, 1
%cmp = icmp slt i32 %add, 10
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
br label %if.end
if.else: ; preds = %entry
br label %if.end
if.end: ; preds = %if.else, %if.then
%z.0 = phi i32 [ 20, %if.then ], [ 30, %if.else ]
%add1 = add nsw i32 %z.0, 10
ret i32 %add1
}
define dso_local i32 @foo(i32 %p) #0 {
entry:
%p.addr = alloca i32, align 4
%z = alloca i32, align 4
%x = alloca i32, align 4
store i32 %p, i32* %p.addr, align 4
%0 = load i32, i32* %p.addr, align 4
%add = add nsw i32 %0, 1
store i32 %add, i32* %x, align 4
%1 = load i32, i32* %x, align 4
%cmp = icmp slt i32 %1, 10
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
store i32 20, i32* %z, align 4
br label %if.end
if.else: ; preds = %entry
store i32 30, i32* %z, align 4
br label %if.end
if.end: ; preds = %if.else, %if.then
%2 = load i32, i32* %z, align 4
%add1 = add nsw i32 %2, 10
ret i32 %add1
}
http://web.cecs.pdx.edu/~mperkows/temp/register-allocation.pdf