Skip to content

Instantly share code, notes, and snippets.

@antonijn
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonijn/9565889 to your computer and use it in GitHub Desktop.
Save antonijn/9565889 to your computer and use it in GitHub Desktop.
Subtle differences
private static void foo() {
int x = 10;
void(int) f = void (int a) a = x;
}
private static void bar() {
final int x = 10;
void(int) f = void (int a) a = x;
}
define internal void @0({ i32* }* %this, i32 %a) {
%1 = alloca i32
store i32 %a, i32* %1
%2 = getelementptr inbounds { i32* }* %this, i32 0, i32 0
%3 = load i32** %2
%4 = load i32* %3
store i32 %4, i32* %1
ret void
}
define internal void @class.my.pack.MyClass.foo.0(i8* %this) {
%1 = alloca { i8*, void (i8*,i32)* }
%2 = getelementptr inbounds i32* null, i32 1
%3 = ptrtoint i32* %2 to i64
%4 = call i8* @aqua_alloc(i64 %3)
%5 = bitcast i8* %4 to i32*
store i32 10, i32* %5
%6 = getelementptr inbounds { i32* }* null, i32 1
%7 = ptrtoint { i32* }* %6 to i64
%8 = call i8* @aqua_alloc(i64 %7)
%9 = bitcast i8* %8 to { i32* }*
%10 = getelementptr inbounds { i32* }* %9, i32 0, i32 0
store i32* %5, i32** %10
%11 = bitcast void ({ i32* }*,i32)* @0 to void (i8*,i32)*
%12 = insertvalue { i8*, void (i8*,i32)* } undef, i8* %8, 0
%13 = insertvalue { i8*, void (i8*,i32)* } %12, void (i8*,i32)* %11, 1
store { i8*, void (i8*,i32)* } %13, { i8*, void (i8*,i32)* }* %1
ret void
}
define internal void @1({ i32 }* %this, i32 %a) {
%1 = alloca i32
store i32 %a, i32* %1
%2 = getelementptr inbounds { i32 }* %this, i32 0, i32 0
%3 = load i32* %2
store i32 %3, i32* %1
ret void
}
define internal void @class.my.pack.MyClass.bar.0(i8* %this) {
%1 = alloca i32
%2 = alloca { i8*, void (i8*,i32)* }
store i32 10, i32* %1
%3 = getelementptr inbounds { i32 }* null, i32 1
%4 = ptrtoint { i32 }* %3 to i64
%5 = call i8* @aqua_alloc(i64 %4)
%6 = bitcast i8* %5 to { i32 }*
%7 = getelementptr inbounds { i32 }* %6, i32 0, i32 0
%8 = load i32* %1
store i32 %8, i32* %7
%9 = bitcast void ({ i32 }*,i32)* @1 to void (i8*,i32)*
%10 = insertvalue { i8*, void (i8*,i32)* } undef, i8* %5, 0
%11 = insertvalue { i8*, void (i8*,i32)* } %10, void (i8*,i32)* %9, 1
store { i8*, void (i8*,i32)* } %11, { i8*, void (i8*,i32)* }* %2
ret void
}
define private void @anon.0(i8* %this, i32 %a) {
%1 = alloca i32
%2 = bitcast i8* %this to { i32 }*
store i32 %a, i32* %1
%3 = getelementptr inbounds { i32 }* %2, i32 0, i32 0
%4 = load i32* %3
store i32 %4, i32* %1
ret void
}
define internal void @class.my.pack.MyClass.foo.0(i8* %this) {
%1 = alloca { i8*, void (i8*,i32)* }
%2 = call i8* @aqua_alloc(i64 4)
%3 = bitcast i8* %2 to { i32 }*
%4 = getelementptr inbounds { i32 }* %3, i32 0, i32 0
store i32 10, i32* %4
%5 = bitcast { i32 }* %3 to i8*
%6 = insertvalue { i8*, void (i8*,i32)* } undef, i8* %5, 0
%7 = insertvalue { i8*, void (i8*,i32)* } %6, void (i8*,i32)* @anon.0, 1
store { i8*, void (i8*,i32)* } %7, { i8*, void (i8*,i32)* }* %1
ret void
}
define private void @anon.1(i8* %this, i32 %a) {
%1 = alloca i32
%2 = alloca i8*
store i8* %this, i8** %2
%3 = bitcast i8** %2 to { i32 }*
store i32 %a, i32* %1
%4 = getelementptr inbounds { i32 }* %3, i32 0, i32 0
%5 = load i32* %4
store i32 %5, i32* %1
ret void
}
define internal void @class.my.pack.MyClass.bar.0(i8* %this) {
%1 = alloca i8*
%2 = alloca { i8*, void (i8*,i32)* }
%3 = alloca i32
store i32 10, i32* %3
%4 = bitcast i8** %1 to { i32 }*
%5 = load i32* %3
%6 = getelementptr inbounds { i32 }* %4, i32 0, i32 0
store i32 %5, i32* %6
%7 = bitcast { i32 }* %4 to i8**
%8 = load i8** %7
%9 = insertvalue { i8*, void (i8*,i32)* } undef, i8* %8, 0
%10 = insertvalue { i8*, void (i8*,i32)* } %9, void (i8*,i32)* @anon.1, 1
store { i8*, void (i8*,i32)* } %10, { i8*, void (i8*,i32)* }* %2
ret void
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment