Last active
December 11, 2015 23:19
-
-
Save dtzWill/4676116 to your computer and use it in GitHub Desktop.
TD DSGraphs for test.c at various optimization levels (for http://llvm.org/bugs/show_bug.cgi?id=15110).
This file contains 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 = 'test.c' | |
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-unknown-linux-gnu" | |
%struct.foo = type { i32, float } | |
define %struct.foo* @bar(%struct.foo* %f) nounwind uwtable { | |
%1 = alloca %struct.foo*, align 8 | |
%f2 = alloca %struct.foo*, align 8 | |
store %struct.foo* %f, %struct.foo** %1, align 8 | |
%2 = call i8* @malloc(i64 8) | |
%3 = bitcast i8* %2 to %struct.foo* | |
store %struct.foo* %3, %struct.foo** %f2, align 8 | |
%4 = load %struct.foo** %1, align 8 | |
%5 = getelementptr inbounds %struct.foo* %4, i32 0, i32 0 | |
%6 = load i32* %5, align 4 | |
%7 = load %struct.foo** %f2, align 8 | |
%8 = getelementptr inbounds %struct.foo* %7, i32 0, i32 0 | |
store i32 %6, i32* %8, align 4 | |
%9 = load %struct.foo** %1, align 8 | |
%10 = getelementptr inbounds %struct.foo* %9, i32 0, i32 1 | |
%11 = load float* %10, align 4 | |
%12 = load %struct.foo** %f2, align 8 | |
%13 = getelementptr inbounds %struct.foo* %12, i32 0, i32 1 | |
store float %11, float* %13, align 4 | |
%14 = load %struct.foo** %f2, align 8 | |
ret %struct.foo* %14 | |
} | |
declare i8* @malloc(i64) | |
define i32 @main() nounwind uwtable { | |
%1 = alloca i32, align 4 | |
%f = alloca %struct.foo*, align 8 | |
%f2 = alloca %struct.foo*, align 8 | |
store i32 0, i32* %1 | |
%2 = call i8* @malloc(i64 8) | |
%3 = bitcast i8* %2 to %struct.foo* | |
store %struct.foo* %3, %struct.foo** %f, align 8 | |
%4 = load %struct.foo** %f, align 8 | |
%5 = getelementptr inbounds %struct.foo* %4, i32 0, i32 0 | |
store i32 1, i32* %5, align 4 | |
%6 = load %struct.foo** %f, align 8 | |
%7 = getelementptr inbounds %struct.foo* %6, i32 0, i32 1 | |
store float 5.000000e-01, float* %7, align 4 | |
%8 = load %struct.foo** %f, align 8 | |
%9 = call %struct.foo* @bar(%struct.foo* %8) | |
store %struct.foo* %9, %struct.foo** %f2, align 8 | |
%10 = load %struct.foo** %f, align 8 | |
%11 = call i32 (...)* @free(%struct.foo* %10) | |
%12 = load %struct.foo** %f2, align 8 | |
%13 = call i32 (...)* @free(%struct.foo* %12) | |
ret i32 0 | |
} | |
declare i32 @free(...) |
This file contains 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 = 'test.c' | |
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-unknown-linux-gnu" | |
%struct.foo = type { i32, float } | |
define noalias %struct.foo* @bar(%struct.foo* nocapture %f) nounwind uwtable { | |
%1 = tail call i8* @malloc(i64 8) nounwind | |
%2 = bitcast i8* %1 to %struct.foo* | |
%3 = getelementptr inbounds %struct.foo* %f, i64 0, i32 0 | |
%4 = load i32* %3, align 4, !tbaa !0 | |
%5 = bitcast i8* %1 to i32* | |
store i32 %4, i32* %5, align 4, !tbaa !0 | |
%6 = getelementptr inbounds %struct.foo* %f, i64 0, i32 1 | |
%7 = load float* %6, align 4, !tbaa !3 | |
%8 = getelementptr inbounds i8* %1, i64 4 | |
%9 = bitcast i8* %8 to float* | |
store float %7, float* %9, align 4, !tbaa !3 | |
ret %struct.foo* %2 | |
} | |
declare noalias i8* @malloc(i64) nounwind | |
define i32 @main() nounwind uwtable { | |
%1 = tail call i8* @malloc(i64 8) nounwind | |
%2 = bitcast i8* %1 to %struct.foo* | |
%3 = bitcast i8* %1 to i32* | |
store i32 1, i32* %3, align 4, !tbaa !0 | |
%4 = getelementptr inbounds i8* %1, i64 4 | |
%5 = bitcast i8* %4 to float* | |
store float 5.000000e-01, float* %5, align 4, !tbaa !3 | |
%6 = tail call %struct.foo* @bar(%struct.foo* %2) | |
%7 = tail call i32 (...)* @free(i8* %1) nounwind | |
%8 = tail call i32 (...)* @free(%struct.foo* %6) nounwind | |
ret i32 0 | |
} | |
declare i32 @free(...) | |
!0 = metadata !{metadata !"int", metadata !1} | |
!1 = metadata !{metadata !"omnipotent char", metadata !2} | |
!2 = metadata !{metadata !"Simple C/C++ TBAA"} | |
!3 = metadata !{metadata !"float", metadata !1} |
This file contains 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 = 'test.c' | |
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-unknown-linux-gnu" | |
%struct.foo = type { i32, float } | |
define noalias %struct.foo* @bar(%struct.foo* nocapture %f) nounwind uwtable { | |
%1 = tail call i8* @malloc(i64 8) nounwind | |
%2 = bitcast i8* %1 to %struct.foo* | |
%3 = getelementptr inbounds %struct.foo* %f, i64 0, i32 0 | |
%4 = load i32* %3, align 4, !tbaa !0 | |
%5 = bitcast i8* %1 to i32* | |
store i32 %4, i32* %5, align 4, !tbaa !0 | |
%6 = getelementptr inbounds %struct.foo* %f, i64 0, i32 1 | |
%7 = load float* %6, align 4, !tbaa !3 | |
%8 = getelementptr inbounds i8* %1, i64 4 | |
%9 = bitcast i8* %8 to float* | |
store float %7, float* %9, align 4, !tbaa !3 | |
ret %struct.foo* %2 | |
} | |
declare noalias i8* @malloc(i64) nounwind | |
define i32 @main() nounwind uwtable { | |
%1 = tail call i8* @malloc(i64 8) nounwind | |
%2 = bitcast i8* %1 to i32* | |
store i32 1, i32* %2, align 4, !tbaa !0 | |
%3 = getelementptr inbounds i8* %1, i64 4 | |
%4 = bitcast i8* %3 to float* | |
store float 5.000000e-01, float* %4, align 4, !tbaa !3 | |
%5 = tail call i8* @malloc(i64 8) nounwind | |
%6 = bitcast i8* %5 to i32* | |
store i32 1, i32* %6, align 4, !tbaa !0 | |
%7 = getelementptr inbounds i8* %5, i64 4 | |
%8 = bitcast i8* %7 to float* | |
store float 5.000000e-01, float* %8, align 4, !tbaa !3 | |
%9 = tail call i32 (...)* @free(i8* %1) nounwind | |
%10 = tail call i32 (...)* @free(i8* %5) nounwind | |
ret i32 0 | |
} | |
declare i32 @free(...) | |
!0 = metadata !{metadata !"int", metadata !1} | |
!1 = metadata !{metadata !"omnipotent char", metadata !2} | |
!2 = metadata !{metadata !"Simple C/C++ TBAA"} | |
!3 = metadata !{metadata !"float", metadata !1} |
This file contains 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
struct foo { | |
int x; | |
float y; | |
}; | |
struct foo* bar(struct foo *f) { | |
struct foo *f2 = (struct foo*) malloc(sizeof(struct foo)); | |
f2->x = f->x; | |
f2->y = f->y; | |
return f2; | |
} | |
int main() { | |
struct foo *f = (struct foo*) malloc(sizeof(struct foo)); | |
f->x = 1; | |
f->y = .5; | |
struct foo *f2 = bar(f); | |
free(f); | |
free(f2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment