Skip to content

Instantly share code, notes, and snippets.

@bholt
Created September 4, 2012 00:12
Show Gist options
  • Select an option

  • Save bholt/3615160 to your computer and use it in GitHub Desktop.

Select an option

Save bholt/3615160 to your computer and use it in GitHub Desktop.
; ModuleID = 'hello.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-apple-macosx10.8.0"
@.str = private unnamed_addr constant [7 x i8] c"global\00", section "llvm.metadata"
@.str1 = private unnamed_addr constant [10 x i8] c"hello.cpp\00", section "llvm.metadata"
define i32 @main(i32 %argc, i8** %argv) nounwind uwtable ssp {
entry:
%retval = alloca i32, align 4
%argc.addr = alloca i32, align 4
%argv.addr = alloca i8**, align 8
%foo = alloca i32, align 4
%bar = alloca i32*, align 8
%baz = alloca i32, align 4
store i32 0, i32* %retval
store i32 %argc, i32* %argc.addr, align 4
store i8** %argv, i8*** %argv.addr, align 8
%foo1 = bitcast i32* %foo to i8*
call void @llvm.var.annotation(i8* %foo1, i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 11)
%bar2 = bitcast i32** %bar to i8*
call void @llvm.var.annotation(i8* %bar2, i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 12)
%0 = load i32** %bar, align 8
store i32 1, i32* %0, align 4
%1 = load i32** %bar, align 8
%2 = load i32* %1, align 4
store i32 %2, i32* %baz, align 4
%3 = load i32** %bar, align 8
%4 = load i32* %3, align 4
store i32 %4, i32* %foo, align 4
ret i32 0
}
declare void @llvm.var.annotation(i8*, i8*, i8*, i32) nounwind
#include <stdio.h>
struct Point {
int x;
int y;
};
#define global __attribute((annotate("global")))
int main(int argc, char * argv[]) {
int foo __attribute__((annotate("global")));
int global * bar;
*bar = 1;
int baz = *bar;
foo = *bar;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment