mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 08:23:41 +00:00
transform: update stringtobytes test to opaque pointers
This commit is contained in:
committed by
Damian Gryski
parent
e0f3333cc3
commit
4acb1a5845
Vendored
+13
-13
@@ -3,30 +3,30 @@ target triple = "x86_64--linux"
|
|||||||
|
|
||||||
@str = constant [6 x i8] c"foobar"
|
@str = constant [6 x i8] c"foobar"
|
||||||
|
|
||||||
declare { i8*, i64, i64 } @runtime.stringToBytes(i8*, i64)
|
declare { ptr, i64, i64 } @runtime.stringToBytes(ptr, i64)
|
||||||
|
|
||||||
declare void @printSlice(i8* nocapture readonly, i64, i64)
|
declare void @printSlice(ptr nocapture readonly, i64, i64)
|
||||||
|
|
||||||
declare void @writeToSlice(i8* nocapture, i64, i64)
|
declare void @writeToSlice(ptr nocapture, i64, i64)
|
||||||
|
|
||||||
; Test that runtime.stringToBytes can be fully optimized away.
|
; Test that runtime.stringToBytes can be fully optimized away.
|
||||||
define void @testReadOnly() {
|
define void @testReadOnly() {
|
||||||
entry:
|
entry:
|
||||||
%0 = call fastcc { i8*, i64, i64 } @runtime.stringToBytes(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i32 0, i32 0), i64 6)
|
%0 = call fastcc { ptr, i64, i64 } @runtime.stringToBytes(ptr @str, i64 6)
|
||||||
%1 = extractvalue { i8*, i64, i64 } %0, 0
|
%1 = extractvalue { ptr, i64, i64 } %0, 0
|
||||||
%2 = extractvalue { i8*, i64, i64 } %0, 1
|
%2 = extractvalue { ptr, i64, i64 } %0, 1
|
||||||
%3 = extractvalue { i8*, i64, i64 } %0, 2
|
%3 = extractvalue { ptr, i64, i64 } %0, 2
|
||||||
call fastcc void @printSlice(i8* %1, i64 %2, i64 %3)
|
call fastcc void @printSlice(ptr %1, i64 %2, i64 %3)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
; Test that even though the slice is written to, some values can be propagated.
|
; Test that even though the slice is written to, some values can be propagated.
|
||||||
define void @testReadWrite() {
|
define void @testReadWrite() {
|
||||||
entry:
|
entry:
|
||||||
%0 = call fastcc { i8*, i64, i64 } @runtime.stringToBytes(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i32 0, i32 0), i64 6)
|
%0 = call fastcc { ptr, i64, i64 } @runtime.stringToBytes(ptr @str, i64 6)
|
||||||
%1 = extractvalue { i8*, i64, i64 } %0, 0
|
%1 = extractvalue { ptr, i64, i64 } %0, 0
|
||||||
%2 = extractvalue { i8*, i64, i64 } %0, 1
|
%2 = extractvalue { ptr, i64, i64 } %0, 1
|
||||||
%3 = extractvalue { i8*, i64, i64 } %0, 2
|
%3 = extractvalue { ptr, i64, i64 } %0, 2
|
||||||
call fastcc void @writeToSlice(i8* %1, i64 %2, i64 %3)
|
call fastcc void @writeToSlice(ptr %1, i64 %2, i64 %3)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -3,22 +3,22 @@ target triple = "x86_64--linux"
|
|||||||
|
|
||||||
@str = constant [6 x i8] c"foobar"
|
@str = constant [6 x i8] c"foobar"
|
||||||
|
|
||||||
declare { i8*, i64, i64 } @runtime.stringToBytes(i8*, i64)
|
declare { ptr, i64, i64 } @runtime.stringToBytes(ptr, i64)
|
||||||
|
|
||||||
declare void @printSlice(i8* nocapture readonly, i64, i64)
|
declare void @printSlice(ptr nocapture readonly, i64, i64)
|
||||||
|
|
||||||
declare void @writeToSlice(i8* nocapture, i64, i64)
|
declare void @writeToSlice(ptr nocapture, i64, i64)
|
||||||
|
|
||||||
define void @testReadOnly() {
|
define void @testReadOnly() {
|
||||||
entry:
|
entry:
|
||||||
call fastcc void @printSlice(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i32 0, i32 0), i64 6, i64 6)
|
call fastcc void @printSlice(ptr @str, i64 6, i64 6)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
define void @testReadWrite() {
|
define void @testReadWrite() {
|
||||||
entry:
|
entry:
|
||||||
%0 = call fastcc { i8*, i64, i64 } @runtime.stringToBytes(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i32 0, i32 0), i64 6)
|
%0 = call fastcc { ptr, i64, i64 } @runtime.stringToBytes(ptr @str, i64 6)
|
||||||
%1 = extractvalue { i8*, i64, i64 } %0, 0
|
%1 = extractvalue { ptr, i64, i64 } %0, 0
|
||||||
call fastcc void @writeToSlice(i8* %1, i64 6, i64 6)
|
call fastcc void @writeToSlice(ptr %1, i64 6, i64 6)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user