-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
48 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
if [ -n $1 ]; then | ||
file=$(basename $1 .c) | ||
clang -S -c -Xclang -disable-O0-optnone -fno-discard-value-names -emit-llvm $1 -o $file.ll | ||
opt -S -p=mem2reg $file.ll -o $file.ll | ||
else | ||
echo "please give the .c file" | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,39 @@ | ||
; ModuleID = 'swap.ll' | ||
source_filename = "swap.c" | ||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-apple-macosx10.15.0" | ||
; ModuleID = 'example.ll' | ||
source_filename = "example.c" | ||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function Attrs: noinline nounwind optnone ssp uwtable | ||
define void @swap(i8** %p, i8** %q) #0 { | ||
; Function Attrs: noinline nounwind uwtable | ||
define dso_local void @swap(ptr noundef %p, ptr noundef %q) #0 { | ||
entry: | ||
%p.addr = alloca i8**, align 8 | ||
%q.addr = alloca i8**, align 8 | ||
%t = alloca i8*, align 8 | ||
store i8** %p, i8*** %p.addr, align 8 | ||
store i8** %q, i8*** %q.addr, align 8 | ||
%0 = load i8**, i8*** %p.addr, align 8 | ||
%1 = load i8*, i8** %0, align 8 | ||
store i8* %1, i8** %t, align 8 | ||
%2 = load i8**, i8*** %q.addr, align 8 | ||
%3 = load i8*, i8** %2, align 8 | ||
%4 = load i8**, i8*** %p.addr, align 8 | ||
store i8* %3, i8** %4, align 8 | ||
%5 = load i8*, i8** %t, align 8 | ||
%6 = load i8**, i8*** %q.addr, align 8 | ||
store i8* %5, i8** %6, align 8 | ||
%0 = load ptr, ptr %p, align 8 | ||
%1 = load ptr, ptr %q, align 8 | ||
store ptr %1, ptr %p, align 8 | ||
store ptr %0, ptr %q, align 8 | ||
ret void | ||
} | ||
|
||
; Function Attrs: noinline nounwind optnone ssp uwtable | ||
define i32 @main() #0 { | ||
; Function Attrs: noinline nounwind uwtable | ||
define dso_local i32 @main() #0 { | ||
entry: | ||
%a1 = alloca i8, align 1 | ||
%b1 = alloca i8, align 1 | ||
%a = alloca i8*, align 8 | ||
%b = alloca i8*, align 8 | ||
store i8* %a1, i8** %a, align 8 | ||
store i8* %b1, i8** %b, align 8 | ||
call void @swap(i8** %a, i8** %b) | ||
%a = alloca ptr, align 8 | ||
%b = alloca ptr, align 8 | ||
store ptr %a1, ptr %a, align 8 | ||
store ptr %b1, ptr %b, align 8 | ||
call void @swap(ptr noundef %a, ptr noundef %b) | ||
ret i32 0 | ||
} | ||
|
||
attributes #0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } | ||
attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } | ||
|
||
!llvm.module.flags = !{!0, !1} | ||
!llvm.ident = !{!2} | ||
!llvm.module.flags = !{!0, !1, !2, !3, !4} | ||
!llvm.ident = !{!5} | ||
|
||
!0 = !{i32 1, !"wchar_size", i32 4} | ||
!1 = !{i32 7, !"PIC Level", i32 2} | ||
!2 = !{!"clang version 10.0.0 "} | ||
!1 = !{i32 8, !"PIC Level", i32 2} | ||
!2 = !{i32 7, !"PIE Level", i32 2} | ||
!3 = !{i32 7, !"uwtable", i32 2} | ||
!4 = !{i32 7, !"frame-pointer", i32 2} | ||
!5 = !{!"clang version 16.0.0"} |
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