Created
April 14, 2014 23:10
-
-
Save o11c/10689126 to your computer and use it in GitHub Desktop.
llvm global constructors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
struct Foo | |
{ | |
Foo() | |
{ | |
puts("Hello, "); | |
} | |
}; | |
Foo foo; | |
int main() | |
{ | |
puts("World!"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'ctor.cpp' | |
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" | |
target triple = "x86_64-pc-linux-gnu" | |
%struct.Foo = type { i8 } | |
@foo = global %struct.Foo zeroinitializer, align 1 | |
@.str = private unnamed_addr constant [7 x i8] c"World!\00", align 1 | |
@.str1 = private unnamed_addr constant [8 x i8] c"Hello, \00", align 1 | |
; | |
; THIS IS THE IMPORTANT THING | |
; | |
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] | |
define internal void @__cxx_global_var_init() section ".text.startup" { | |
call void @_ZN3FooC2Ev(%struct.Foo* @foo) | |
ret void | |
} | |
; Function Attrs: uwtable | |
define linkonce_odr void @_ZN3FooC2Ev(%struct.Foo* %this) unnamed_addr #0 align 2 { | |
%1 = alloca %struct.Foo*, align 8 | |
store %struct.Foo* %this, %struct.Foo** %1, align 8 | |
%2 = load %struct.Foo** %1 | |
%3 = call i32 @puts(i8* getelementptr inbounds ([8 x i8]* @.str1, i32 0, i32 0)) | |
ret void | |
} | |
; Function Attrs: uwtable | |
define i32 @main() #0 { | |
%1 = call i32 @puts(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0)) | |
ret i32 0 | |
} | |
declare i32 @puts(i8*) #1 | |
define internal void @_GLOBAL__I_a() section ".text.startup" { | |
call void @__cxx_global_var_init() | |
ret void | |
} | |
attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | |
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | |
!llvm.ident = !{!0} | |
!0 = metadata !{metadata !"Debian clang version 3.4-2 (tags/RELEASE_34/final) (based on LLVM 3.4)"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment