Этот коммит содержится в:
Ayke van Laethem 2021-10-31 01:30:17 +02:00 коммит произвёл Ron Evans
родитель afd49e7cdd
коммит 90076f9401
18 изменённых файлов: 102 добавлений и 171 удалений

Просмотреть файл

@ -373,12 +373,12 @@ commands:
- /go/pkg/mod - /go/pkg/mod
jobs: jobs:
test-llvm10-go115: test-llvm11-go115:
docker: docker:
- image: circleci/golang:1.15-buster - image: circleci/golang:1.15-buster
steps: steps:
- test-linux: - test-linux:
llvm: "10" llvm: "11"
test-llvm11-go116: test-llvm11-go116:
docker: docker:
- image: circleci/golang:1.16-buster - image: circleci/golang:1.16-buster
@ -406,7 +406,7 @@ jobs:
workflows: workflows:
test-all: test-all:
jobs: jobs:
- test-llvm10-go115 - test-llvm11-go115
- test-llvm11-go116 - test-llvm11-go116
- build-linux - build-linux
- build-macos - build-macos

Просмотреть файл

@ -10,9 +10,9 @@ LLD_SRC ?= $(LLVM_PROJECTDIR)/lld
# Try to autodetect LLVM build tools. # Try to autodetect LLVM build tools.
detect = $(shell command -v $(1) 2> /dev/null && echo $(1)) detect = $(shell command -v $(1) 2> /dev/null && echo $(1))
CLANG ?= $(word 1,$(abspath $(call detect,llvm-build/bin/clang))$(call detect,clang-11)$(call detect,clang-10)$(call detect,clang)) CLANG ?= $(word 1,$(abspath $(call detect,llvm-build/bin/clang))$(call detect,clang-11)$(call detect,clang))
LLVM_AR ?= $(word 1,$(abspath $(call detect,llvm-build/bin/llvm-ar))$(call detect,llvm-ar-11)$(call detect,llvm-ar-10)$(call detect,llvm-ar)) LLVM_AR ?= $(word 1,$(abspath $(call detect,llvm-build/bin/llvm-ar))$(call detect,llvm-ar-11)$(call detect,llvm-ar))
LLVM_NM ?= $(word 1,$(abspath $(call detect,llvm-build/bin/llvm-nm))$(call detect,llvm-nm-11)$(call detect,llvm-nm-10)$(call detect,llvm-nm)) LLVM_NM ?= $(word 1,$(abspath $(call detect,llvm-build/bin/llvm-nm))$(call detect,llvm-nm-11)$(call detect,llvm-nm))
# Go binary and GOROOT to select # Go binary and GOROOT to select
GO ?= go GO ?= go

Просмотреть файл

@ -84,18 +84,7 @@ func loadProgramSize(path string) (*programSize, error) {
if section.Type != elf.SHT_PROGBITS && section.Type != elf.SHT_NOBITS { if section.Type != elf.SHT_PROGBITS && section.Type != elf.SHT_NOBITS {
continue continue
} }
if section.Name == ".stack" { if section.Type == elf.SHT_NOBITS {
// HACK: this works around a bug in ld.lld from LLVM 10. The linker
// marks sections with no input symbols (such as is the case for the
// .stack section) as SHT_PROGBITS instead of SHT_NOBITS. While it
// doesn't affect the generated binaries (.hex and .bin), it does
// affect the reported size.
// https://bugs.llvm.org/show_bug.cgi?id=45336
// https://reviews.llvm.org/D76981
// It has been merged in master, but it has not (yet) been
// backported to the LLVM 10 release branch.
sumBSS += section.Size
} else if section.Type == elf.SHT_NOBITS {
sumBSS += section.Size sumBSS += section.Size
} else if section.Flags&elf.SHF_EXECINSTR != 0 { } else if section.Flags&elf.SHF_EXECINSTR != 0 {
sumCode += section.Size sumCode += section.Size

Просмотреть файл

@ -16,7 +16,7 @@ import (
) )
/* /*
#include <clang-c/Index.h> // if this fails, install libclang-10-dev #include <clang-c/Index.h> // if this fails, install libclang-11-dev
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>

Просмотреть файл

@ -1,5 +1,4 @@
// +build !byollvm // +build !byollvm
// +build !llvm10
package cgo package cgo

Просмотреть файл

@ -1,14 +0,0 @@
// +build !byollvm
// +build llvm10
package cgo
/*
#cgo linux CFLAGS: -I/usr/lib/llvm-10/include
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@10/include
#cgo freebsd CFLAGS: -I/usr/local/llvm10/include
#cgo linux LDFLAGS: -L/usr/lib/llvm-10/lib -lclang
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@10/lib -lclang -lffi
#cgo freebsd LDFLAGS: -L/usr/local/llvm10/lib -lclang
*/
import "C"

Просмотреть файл

@ -3,7 +3,7 @@
// are slightly different from the ones defined in libclang.go, but they // are slightly different from the ones defined in libclang.go, but they
// should be ABI compatible. // should be ABI compatible.
#include <clang-c/Index.h> // if this fails, install libclang-10-dev #include <clang-c/Index.h> // if this fails, install libclang-11-dev
CXCursor tinygo_clang_getTranslationUnitCursor(CXTranslationUnit tu) { CXCursor tinygo_clang_getTranslationUnitCursor(CXTranslationUnit tu) {
return clang_getTranslationUnitCursor(tu); return clang_getTranslationUnitCursor(tu);

Просмотреть файл

@ -3,7 +3,6 @@ package interp
import ( import (
"io/ioutil" "io/ioutil"
"os" "os"
"regexp"
"strings" "strings"
"testing" "testing"
@ -88,8 +87,6 @@ func runTest(t *testing.T, pathPrefix string) {
} }
} }
var alignRegexp = regexp.MustCompile(", align [0-9]+$")
// fuzzyEqualIR returns true if the two LLVM IR strings passed in are roughly // fuzzyEqualIR returns true if the two LLVM IR strings passed in are roughly
// equal. That means, only relevant lines are compared (excluding comments // equal. That means, only relevant lines are compared (excluding comments
// etc.). // etc.).
@ -101,15 +98,6 @@ func fuzzyEqualIR(s1, s2 string) bool {
} }
for i, line1 := range lines1 { for i, line1 := range lines1 {
line2 := lines2[i] line2 := lines2[i]
match1 := alignRegexp.MatchString(line1)
match2 := alignRegexp.MatchString(line2)
if match1 != match2 {
// Only one of the lines has the align keyword. Remove it.
// This is a change to make the test work in both LLVM 10 and LLVM
// 11 (LLVM 11 appears to automatically add alignment everywhere).
line1 = alignRegexp.ReplaceAllString(line1, "")
line2 = alignRegexp.ReplaceAllString(line2, "")
}
if line1 != line2 { if line1 != line2 {
return false return false
} }

14
interp/testdata/basic.out.ll предоставленный
Просмотреть файл

@ -18,14 +18,14 @@ entry:
call void @runtime.printint64(i64 5) call void @runtime.printint64(i64 5)
call void @runtime.printnl() call void @runtime.printnl()
%value1 = call i64 @someValue() %value1 = call i64 @someValue()
store i64 %value1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @main.nonConst1, i32 0, i32 0) store i64 %value1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @main.nonConst1, i32 0, i32 0), align 8
%value2 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @main.nonConst1, i32 0, i32 0) %value2 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @main.nonConst1, i32 0, i32 0), align 8
store i64 %value2, i64* @main.nonConst2 store i64 %value2, i64* @main.nonConst2, align 8
call void @modifyExternal(i32* getelementptr inbounds ([8 x { i16, i32 }], [8 x { i16, i32 }]* @main.someArray, i32 0, i32 3, i32 1)) call void @modifyExternal(i32* getelementptr inbounds ([8 x { i16, i32 }], [8 x { i16, i32 }]* @main.someArray, i32 0, i32 3, i32 1))
call void @modifyExternal(i32* bitcast ([1 x i16*]* @main.exportedValue to i32*)) call void @modifyExternal(i32* bitcast ([1 x i16*]* @main.exportedValue to i32*))
store i16 5, i16* @main.exposedValue1 store i16 5, i16* @main.exposedValue1, align 2
call void @modifyExternal(i32* bitcast (void ()* @willModifyGlobal to i32*)) call void @modifyExternal(i32* bitcast (void ()* @willModifyGlobal to i32*))
store i16 7, i16* @main.exposedValue2 store i16 7, i16* @main.exposedValue2, align 2
call void @modifyExternal(i32* bitcast (void ()* @hasInlineAsm to i32*)) call void @modifyExternal(i32* bitcast (void ()* @hasInlineAsm to i32*))
call void @runtime.printint64(i64 6) call void @runtime.printint64(i64 6)
call void @runtime.printint64(i64 -1) call void @runtime.printint64(i64 -1)
@ -39,7 +39,7 @@ entry:
%agg2.insertvalue2 = insertvalue { i64, i16 } %agg2.agg1, i64 5, 0 %agg2.insertvalue2 = insertvalue { i64, i16 } %agg2.agg1, i64 5, 0
%agg2.insertvalue1 = insertvalue { float, { i64, i16 } } %agg2.agg0, { i64, i16 } %agg2.insertvalue2, 1 %agg2.insertvalue1 = insertvalue { float, { i64, i16 } } %agg2.agg0, { i64, i16 } %agg2.insertvalue2, 1
%agg2.insertvalue0 = insertvalue { i8, i32, { float, { i64, i16 } } } %agg, { float, { i64, i16 } } %agg2.insertvalue1, 2 %agg2.insertvalue0 = insertvalue { i8, i32, { float, { i64, i16 } } } %agg, { float, { i64, i16 } } %agg2.insertvalue1, 2
store { i8, i32, { float, { i64, i16 } } } %agg2.insertvalue0, { i8, i32, { float, { i64, i16 } } }* @main.insertedValue store { i8, i32, { float, { i64, i16 } } } %agg2.insertvalue0, { i8, i32, { float, { i64, i16 } } }* @main.insertedValue, align 8
ret void ret void
} }
@ -56,7 +56,7 @@ declare void @modifyExternal(i32*) local_unnamed_addr
define void @willModifyGlobal() { define void @willModifyGlobal() {
entry: entry:
store i16 8, i16* @main.exposedValue2 store i16 8, i16* @main.exposedValue2, align 2
ret void ret void
} }

4
interp/testdata/slice-copy.out.ll предоставленный
Просмотреть файл

@ -1,7 +1,7 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux" target triple = "x86_64--linux"
@"main$alloc.1" = internal unnamed_addr constant [6 x i8] c"\05\00{\00\00\04" @"main$alloc.1" = internal unnamed_addr constant [6 x i8] c"\05\00{\00\00\04", align 8
declare void @runtime.printuint8(i8) local_unnamed_addr declare void @runtime.printuint8(i8) local_unnamed_addr
@ -17,7 +17,7 @@ entry:
call void @runtime.printuint8(i8 3) call void @runtime.printuint8(i8 3)
call void @runtime.printuint8(i8 3) call void @runtime.printuint8(i8 3)
call void @runtime.printint16(i16 5) call void @runtime.printint16(i16 5)
%int16SliceDst.val = load i16, i16* bitcast ([6 x i8]* @"main$alloc.1" to i16*) %int16SliceDst.val = load i16, i16* bitcast ([6 x i8]* @"main$alloc.1" to i16*), align 2
call void @runtime.printint16(i16 %int16SliceDst.val) call void @runtime.printint16(i16 %int16SliceDst.val)
ret void ret void
} }

Просмотреть файл

@ -48,16 +48,6 @@ func printint16(n int16) {
} }
func printuint32(n uint32) { func printuint32(n uint32) {
if TargetBits == 8 {
// AVR-specific workaround on LLVM 10. Should be removed when we switch
// to LLVM 11.
prevdigits := n / 10
if prevdigits != 0 {
printuint32(prevdigits)
}
putchar(byte((n % 10) + '0'))
return
}
printuint64(uint64(n)) printuint64(uint64(n))
} }

22
transform/testdata/allocs.out.ll предоставленный
Просмотреть файл

@ -6,21 +6,21 @@ target triple = "armv7m-none-eabi"
declare nonnull i8* @runtime.alloc(i32) declare nonnull i8* @runtime.alloc(i32)
define void @testInt() { define void @testInt() {
%stackalloc.alloca = alloca [1 x i32] %stackalloc.alloca = alloca [1 x i32], align 4
store [1 x i32] zeroinitializer, [1 x i32]* %stackalloc.alloca store [1 x i32] zeroinitializer, [1 x i32]* %stackalloc.alloca, align 4
%stackalloc = bitcast [1 x i32]* %stackalloc.alloca to i32* %stackalloc = bitcast [1 x i32]* %stackalloc.alloca to i32*
store i32 5, i32* %stackalloc store i32 5, i32* %stackalloc, align 4
ret void ret void
} }
define i16 @testArray() { define i16 @testArray() {
%stackalloc.alloca = alloca [2 x i32] %stackalloc.alloca = alloca [2 x i32], align 4
store [2 x i32] zeroinitializer, [2 x i32]* %stackalloc.alloca store [2 x i32] zeroinitializer, [2 x i32]* %stackalloc.alloca, align 4
%stackalloc = bitcast [2 x i32]* %stackalloc.alloca to i16* %stackalloc = bitcast [2 x i32]* %stackalloc.alloca to i16*
%1 = getelementptr i16, i16* %stackalloc, i32 1 %1 = getelementptr i16, i16* %stackalloc, i32 1
store i16 5, i16* %1 store i16 5, i16* %1, align 2
%2 = getelementptr i16, i16* %stackalloc, i32 2 %2 = getelementptr i16, i16* %stackalloc, i32 2
%3 = load i16, i16* %2 %3 = load i16, i16* %2, align 2
ret i16 %3 ret i16 %3
} }
@ -39,8 +39,8 @@ define void @testEscapingCall2() {
} }
define void @testNonEscapingCall() { define void @testNonEscapingCall() {
%stackalloc.alloca = alloca [1 x i32] %stackalloc.alloca = alloca [1 x i32], align 4
store [1 x i32] zeroinitializer, [1 x i32]* %stackalloc.alloca store [1 x i32] zeroinitializer, [1 x i32]* %stackalloc.alloca, align 4
%stackalloc = bitcast [1 x i32]* %stackalloc.alloca to i32* %stackalloc = bitcast [1 x i32]* %stackalloc.alloca to i32*
%1 = call i32* @noescapeIntPtr(i32* %stackalloc) %1 = call i32* @noescapeIntPtr(i32* %stackalloc)
ret void ret void
@ -54,11 +54,11 @@ define i32* @testEscapingReturn() {
define void @testNonEscapingLoop() { define void @testNonEscapingLoop() {
entry: entry:
%stackalloc.alloca = alloca [1 x i32] %stackalloc.alloca = alloca [1 x i32], align 4
br label %loop br label %loop
loop: ; preds = %loop, %entry loop: ; preds = %loop, %entry
store [1 x i32] zeroinitializer, [1 x i32]* %stackalloc.alloca store [1 x i32] zeroinitializer, [1 x i32]* %stackalloc.alloca, align 4
%stackalloc = bitcast [1 x i32]* %stackalloc.alloca to i32* %stackalloc = bitcast [1 x i32]* %stackalloc.alloca to i32*
%0 = call i32* @noescapeIntPtr(i32* %stackalloc) %0 = call i32* @noescapeIntPtr(i32* %stackalloc)
%1 = icmp eq i32* null, %0 %1 = icmp eq i32* null, %0

16
transform/testdata/gc-globals.out.ll предоставленный
Просмотреть файл

@ -14,18 +14,18 @@ target triple = "wasm32-unknown-unknown-wasm"
@runtime.trackedGlobalsBitmap.1 = internal global [1 x i8] c"\09" @runtime.trackedGlobalsBitmap.1 = internal global [1 x i8] c"\09"
define void @main() { define void @main() {
%1 = load i32, i32* @globalInt %1 = load i32, i32* @globalInt, align 4
%2 = load %runtime._string, %runtime._string* getelementptr inbounds ({ %runtime._string, %runtime._interface }, { %runtime._string, %runtime._interface }* @tinygo.trackedGlobals, i32 0, i32 0) %2 = load %runtime._string, %runtime._string* getelementptr inbounds ({ %runtime._string, %runtime._interface }, { %runtime._string, %runtime._interface }* @tinygo.trackedGlobals, i32 0, i32 0), align 4
%3 = load %runtime._interface, %runtime._interface* getelementptr inbounds ({ %runtime._string, %runtime._interface }, { %runtime._string, %runtime._interface }* @tinygo.trackedGlobals, i32 0, i32 1) %3 = load %runtime._interface, %runtime._interface* getelementptr inbounds ({ %runtime._string, %runtime._interface }, { %runtime._string, %runtime._interface }* @tinygo.trackedGlobals, i32 0, i32 1), align 4
%4 = load %runtime._string, %runtime._string* @constString %4 = load %runtime._string, %runtime._string* @constString, align 4
%5 = load %runtime._interface, %runtime._interface* @constInterface %5 = load %runtime._interface, %runtime._interface* @constInterface, align 4
ret void ret void
} }
define void @runtime.markGlobals() { define void @runtime.markGlobals() {
%1 = load i32, i32* @runtime.trackedGlobalsStart %1 = load i32, i32* @runtime.trackedGlobalsStart, align 4
%2 = load i32, i32* @runtime.trackedGlobalsLength %2 = load i32, i32* @runtime.trackedGlobalsLength, align 4
%3 = getelementptr inbounds [0 x i8], [0 x i8]* bitcast ([1 x i8]* @runtime.trackedGlobalsBitmap.1 to [0 x i8]*), i32 0, i32 0 %3 = getelementptr inbounds [0 x i8], [0 x i8]* bitcast ([1 x i8]* @runtime.trackedGlobalsBitmap.1 to [0 x i8]*), i32 0, i32 0
%4 = load i8, i8* %3 %4 = load i8, i8* %3, align 1
ret void ret void
} }

100
transform/testdata/gc-stackslots.out.ll предоставленный
Просмотреть файл

@ -15,44 +15,44 @@ define i8* @getPointer() {
} }
define i8* @needsStackSlots() { define i8* @needsStackSlots() {
%gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* } %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8
store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4
%1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0 %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0
store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2 store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
%3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject* %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject*
store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%ptr = call i8* @runtime.alloc(i32 4) %ptr = call i8* @runtime.alloc(i32 4)
%4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2 %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2
store i8* %ptr, i8** %4 store i8* %ptr, i8** %4, align 4
store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
call void @someArbitraryFunction() call void @someArbitraryFunction()
%val = load i8, i8* @someGlobal %val = load i8, i8* @someGlobal, align 1
ret i8* %ptr ret i8* %ptr
} }
define i8* @needsStackSlots2() { define i8* @needsStackSlots2() {
%gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, align 8
store { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } { %runtime.stackChainObject* null, i32 5, i8* null, i8* null, i8* null, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject store { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } { %runtime.stackChainObject* null, i32 5, i8* null, i8* null, i8* null, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, align 4
%1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%2 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 0 %2 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 0
store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2 store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
%3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject* %3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject*
store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%ptr1 = call i8* @getPointer() %ptr1 = call i8* @getPointer()
%4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 4 %4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 4
store i8* %ptr1, i8** %4 store i8* %ptr1, i8** %4, align 4
%5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 3 %5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 3
store i8* %ptr1, i8** %5 store i8* %ptr1, i8** %5, align 4
%6 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 2 %6 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 2
store i8* %ptr1, i8** %6 store i8* %ptr1, i8** %6, align 4
%ptr2 = getelementptr i8, i8* @someGlobal, i32 0 %ptr2 = getelementptr i8, i8* @someGlobal, i32 0
%7 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 5 %7 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 5
store i8* %ptr2, i8** %7 store i8* %ptr2, i8** %7, align 4
%unused = call i8* @runtime.alloc(i32 4) %unused = call i8* @runtime.alloc(i32 4)
%8 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 6 %8 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 6
store i8* %unused, i8** %8 store i8* %unused, i8** %8, align 4
store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
ret i8* %ptr1 ret i8* %ptr1
} }
@ -62,79 +62,79 @@ define i8* @noAllocatingFunction() {
} }
define i8* @fibNext(i8* %x, i8* %y) { define i8* @fibNext(i8* %x, i8* %y) {
%gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* } %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8
store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4
%1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0 %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0
store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2 store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
%3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject* %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject*
store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%x.val = load i8, i8* %x %x.val = load i8, i8* %x, align 1
%y.val = load i8, i8* %y %y.val = load i8, i8* %y, align 1
%out.val = add i8 %x.val, %y.val %out.val = add i8 %x.val, %y.val
%out.alloc = call i8* @runtime.alloc(i32 1) %out.alloc = call i8* @runtime.alloc(i32 1)
%4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2 %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2
store i8* %out.alloc, i8** %4 store i8* %out.alloc, i8** %4, align 4
store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
store i8 %out.val, i8* %out.alloc store i8 %out.val, i8* %out.alloc, align 1
ret i8* %out.alloc ret i8* %out.alloc
} }
define i8* @allocLoop() { define i8* @allocLoop() {
entry: entry:
%gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, align 8
store { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } { %runtime.stackChainObject* null, i32 5, i8* null, i8* null, i8* null, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject store { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } { %runtime.stackChainObject* null, i32 5, i8* null, i8* null, i8* null, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, align 4
%0 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart %0 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%1 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 0 %1 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 0
store %runtime.stackChainObject* %0, %runtime.stackChainObject** %1 store %runtime.stackChainObject* %0, %runtime.stackChainObject** %1, align 4
%2 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject* %2 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject*
store %runtime.stackChainObject* %2, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %2, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%entry.x = call i8* @runtime.alloc(i32 1) %entry.x = call i8* @runtime.alloc(i32 1)
%3 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 2 %3 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 2
store i8* %entry.x, i8** %3 store i8* %entry.x, i8** %3, align 4
%entry.y = call i8* @runtime.alloc(i32 1) %entry.y = call i8* @runtime.alloc(i32 1)
%4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 3 %4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 3
store i8* %entry.y, i8** %4 store i8* %entry.y, i8** %4, align 4
store i8 1, i8* %entry.y store i8 1, i8* %entry.y, align 1
br label %loop br label %loop
loop: ; preds = %loop, %entry loop: ; preds = %loop, %entry
%prev.y = phi i8* [ %entry.y, %entry ], [ %prev.x, %loop ] %prev.y = phi i8* [ %entry.y, %entry ], [ %prev.x, %loop ]
%prev.x = phi i8* [ %entry.x, %entry ], [ %next.x, %loop ] %prev.x = phi i8* [ %entry.x, %entry ], [ %next.x, %loop ]
%5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 5 %5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 5
store i8* %prev.y, i8** %5 store i8* %prev.y, i8** %5, align 4
%6 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 4 %6 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 4
store i8* %prev.x, i8** %6 store i8* %prev.x, i8** %6, align 4
%next.x = call i8* @fibNext(i8* %prev.x, i8* %prev.y) %next.x = call i8* @fibNext(i8* %prev.x, i8* %prev.y)
%7 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 6 %7 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 6
store i8* %next.x, i8** %7 store i8* %next.x, i8** %7, align 4
%next.x.val = load i8, i8* %next.x %next.x.val = load i8, i8* %next.x, align 1
%loop.done = icmp ult i8 40, %next.x.val %loop.done = icmp ult i8 40, %next.x.val
br i1 %loop.done, label %end, label %loop br i1 %loop.done, label %end, label %loop
end: ; preds = %loop end: ; preds = %loop
store %runtime.stackChainObject* %0, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %0, %runtime.stackChainObject** @runtime.stackChainStart, align 4
ret i8* %next.x ret i8* %next.x
} }
declare [32 x i8]* @arrayAlloc() declare [32 x i8]* @arrayAlloc()
define void @testGEPBitcast() { define void @testGEPBitcast() {
%gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8* } %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8* }, align 8
store { %runtime.stackChainObject*, i32, i8*, i8* } { %runtime.stackChainObject* null, i32 2, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject store { %runtime.stackChainObject*, i32, i8*, i8* } { %runtime.stackChainObject* null, i32 2, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, align 4
%1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%2 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 0 %2 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 0
store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2 store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
%3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject* %3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject*
store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
%arr = call [32 x i8]* @arrayAlloc() %arr = call [32 x i8]* @arrayAlloc()
%arr.bitcast = getelementptr [32 x i8], [32 x i8]* %arr, i32 0, i32 0 %arr.bitcast = getelementptr [32 x i8], [32 x i8]* %arr, i32 0, i32 0
%4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 2 %4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 2
store i8* %arr.bitcast, i8** %4 store i8* %arr.bitcast, i8** %4, align 4
%other = call i8* @runtime.alloc(i32 1) %other = call i8* @runtime.alloc(i32 1)
%5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 3 %5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 3
store i8* %other, i8** %5 store i8* %other, i8** %5, align 4
store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
ret void ret void
} }

8
transform/testdata/maps.out.ll предоставленный
Просмотреть файл

@ -17,14 +17,14 @@ define void @testUnused() {
define i32 @testReadonly() { define i32 @testReadonly() {
%map = call %runtime.hashmap* @runtime.hashmapMake(i8 4, i8 4, i32 0) %map = call %runtime.hashmap* @runtime.hashmapMake(i8 4, i8 4, i32 0)
%hashmap.value = alloca i32 %hashmap.value = alloca i32, align 4
store i32 42, i32* %hashmap.value store i32 42, i32* %hashmap.value, align 4
%hashmap.value.bitcast = bitcast i32* %hashmap.value to i8* %hashmap.value.bitcast = bitcast i32* %hashmap.value to i8*
call void @runtime.hashmapStringSet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value.bitcast) call void @runtime.hashmapStringSet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value.bitcast)
%hashmap.value2 = alloca i32 %hashmap.value2 = alloca i32, align 4
%hashmap.value2.bitcast = bitcast i32* %hashmap.value2 to i8* %hashmap.value2.bitcast = bitcast i32* %hashmap.value2 to i8*
%commaOk = call i1 @runtime.hashmapStringGet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value2.bitcast) %commaOk = call i1 @runtime.hashmapStringGet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value2.bitcast)
%loadedValue = load i32, i32* %hashmap.value2 %loadedValue = load i32, i32* %hashmap.value2, align 4
ret i32 %loadedValue ret i32 %loadedValue
} }

2
transform/testdata/stacksize.out.ll предоставленный
Просмотреть файл

@ -11,7 +11,7 @@ declare void @"internal/task.start"(i32, i8*, i32)
define void @Reset_Handler() { define void @Reset_Handler() {
entry: entry:
%stacksize1 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @"internal/task.stackSizes", i32 0, i32 0) %stacksize1 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @"internal/task.stackSizes", i32 0, i32 0), align 4
call void @"internal/task.start"(i32 ptrtoint (void (i8*)* @"runtime.run$1$gowrapper" to i32), i8* undef, i32 %stacksize1) call void @"internal/task.start"(i32 ptrtoint (void (i8*)* @"runtime.run$1$gowrapper" to i32), i8* undef, i32 %stacksize1)
ret void ret void
} }

18
transform/testdata/wasm-abi.out.ll предоставленный
Просмотреть файл

@ -4,24 +4,24 @@ target triple = "wasm32-unknown-unknown-wasm"
declare i64 @"externalCall$i64wrap"(i8*, i32, i64) declare i64 @"externalCall$i64wrap"(i8*, i32, i64)
define internal i64 @testCall(i8* %ptr, i32 %len, i64 %foo) { define internal i64 @testCall(i8* %ptr, i32 %len, i64 %foo) {
%i64asptr = alloca i64 %i64asptr = alloca i64, align 8
%i64asptr1 = alloca i64 %i64asptr1 = alloca i64, align 8
store i64 %foo, i64* %i64asptr1 store i64 %foo, i64* %i64asptr1, align 8
call void @externalCall(i64* %i64asptr, i8* %ptr, i32 %len, i64* %i64asptr1) call void @externalCall(i64* %i64asptr, i8* %ptr, i32 %len, i64* %i64asptr1)
%retval = load i64, i64* %i64asptr %retval = load i64, i64* %i64asptr, align 8
ret i64 %retval ret i64 %retval
} }
define internal i64 @testCallNonEntry(i8* %ptr, i32 %len) { define internal i64 @testCallNonEntry(i8* %ptr, i32 %len) {
entry: entry:
%i64asptr = alloca i64 %i64asptr = alloca i64, align 8
%i64asptr1 = alloca i64 %i64asptr1 = alloca i64, align 8
br label %bb1 br label %bb1
bb1: ; preds = %entry bb1: ; preds = %entry
store i64 3, i64* %i64asptr1 store i64 3, i64* %i64asptr1, align 8
call void @externalCall(i64* %i64asptr, i8* %ptr, i32 %len, i64* %i64asptr1) call void @externalCall(i64* %i64asptr, i8* %ptr, i32 %len, i64* %i64asptr1)
%retval = load i64, i64* %i64asptr %retval = load i64, i64* %i64asptr, align 8
ret i64 %retval ret i64 %retval
} }
@ -39,7 +39,7 @@ declare void @externalCall(i64*, i8*, i32, i64*)
define void @exportedFunction(i64* %0) { define void @exportedFunction(i64* %0) {
entry: entry:
%i64 = load i64, i64* %0 %i64 = load i64, i64* %0, align 8
call void @"exportedFunction$i64wrap"(i64 %i64) call void @"exportedFunction$i64wrap"(i64 %i64)
ret void ret void
} }

Просмотреть файл

@ -9,7 +9,6 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
@ -67,8 +66,6 @@ func testTransform(t *testing.T, pathPrefix string, transform func(mod llvm.Modu
} }
} }
var alignRegexp = regexp.MustCompile(", align [0-9]+$")
// fuzzyEqualIR returns true if the two LLVM IR strings passed in are roughly // fuzzyEqualIR returns true if the two LLVM IR strings passed in are roughly
// equal. That means, only relevant lines are compared (excluding comments // equal. That means, only relevant lines are compared (excluding comments
// etc.). // etc.).
@ -80,15 +77,6 @@ func fuzzyEqualIR(s1, s2 string) bool {
} }
for i, line1 := range lines1 { for i, line1 := range lines1 {
line2 := lines2[i] line2 := lines2[i]
match1 := alignRegexp.MatchString(line1)
match2 := alignRegexp.MatchString(line2)
if match1 != match2 {
// Only one of the lines has the align keyword. Remove it.
// This is a change to make the test work in both LLVM 10 and LLVM
// 11 (LLVM 11 appears to automatically add alignment everywhere).
line1 = alignRegexp.ReplaceAllString(line1, "")
line2 = alignRegexp.ReplaceAllString(line2, "")
}
if line1 != line2 { if line1 != line2 {
return false return false
} }
@ -117,19 +105,10 @@ func filterIrrelevantIRLines(lines []string) []string {
if strings.HasPrefix(line, "source_filename = ") { if strings.HasPrefix(line, "source_filename = ") {
continue continue
} }
if llvmVersion < 10 && strings.HasPrefix(line, "attributes ") { if llvmVersion < 11 && strings.HasPrefix(line, "attributes ") {
// Ignore attribute groups. These may change between LLVM versions. // Ignore attribute groups. These may change between LLVM versions.
// Right now test outputs are for LLVM 10.
continue continue
} }
if llvmVersion < 10 && strings.HasPrefix(line, "define ") {
// Remove parameter values such as %0 in function definitions. These
// were added in LLVM 10 so to get the tests to pass on older
// versions, ignore them there (there are other tests that verify
// correct behavior).
re := regexp.MustCompile(` %[0-9]+(\)|,)`)
line = re.ReplaceAllString(line, "$1")
}
out = append(out, line) out = append(out, line)
} }
return out return out