Skip to content

Instantly share code, notes, and snippets.

@vihanb

vihanb/goat.ll Secret

Created March 8, 2018 01:12
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 vihanb/7c6d46ed3b81b1b276cec39e328671eb to your computer and use it in GitHub Desktop.
Save vihanb/7c6d46ed3b81b1b276cec39e328671eb to your computer and use it in GitHub Desktop.
VSL Goat Test
; ModuleID = 'main'
source_filename = "main"
%"String.$12" = type { i32, i8* }
%"Goat.$53" = type { %"String.$12"* }
@0 = private unnamed_addr constant [4 x i8] c"foo\00"
@1 = private unnamed_addr constant %"String.$12" { i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i32 0, i32 0) }
define i32 @main(i32, i8**) {
entry:
%2 = call i8* @malloc(i64 8)
%3 = bitcast i8* %2 to %"Goat.$53"*
%4 = call %"Goat.$53"* @"Goat.init$54"(%"Goat.$53"* %3)
%5 = getelementptr inbounds %"Goat.$53", %"Goat.$53"* %4, i32 0, i32 0
%6 = load %"String.$12"*, %"String.$12"** %5
call void @"print.$32"(%"String.$12"* %6)
ret i32 0
}
; Function Attrs: inlinehint norecurse
define %"Goat.$53"* @"Goat.init$54"(%"Goat.$53"*) #0 {
entry:
%1 = getelementptr inbounds %"Goat.$53", %"Goat.$53"* %0, i32 0, i32 0
store %"String.$12"* @1, %"String.$12"** %1
ret %"Goat.$53"* %0
}
declare i8* @malloc(i64)
define void @"print.$32"(%"String.$12"*) {
entry:
%1 = getelementptr inbounds %"String.$12", %"String.$12"* %0, i32 0, i32 1
%2 = load i8*, i8** %1
%3 = call i32 @puts(i8* %2)
ret void
}
declare i32 @puts(i8*)
attributes #0 = { inlinehint norecurse }
class Goat {
let a = "foo"
}
public func main() {
let name = Goat()
print(name.a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment