
This commit changes a target triple like "armv6m-none-eabi" to "armv6m-unknown-unknow-eabi". The reason is that while the former is correctly parsed in Clang (due to normalization), it wasn't parsed correctly in LLVM meaning that the environment wasn't set to EABI. This change normalizes all target triples and uses the EABI environment (-eabi in the triple) for Cortex-M targets. This change also drops the `--target=` flag in the target JSON files, the flag is now added implicitly in `(*compileopts.Config).CFlags()`. This removes some duplication in target JSON files. Unfortunately, this change also increases code size for Cortex-M targets. It looks like LLVM now emits calls like __aeabi_memmove instead of memmove, which pull in slightly more code (they basically just call the regular C functions) and the calls themself don't seem to be as efficient as they could be. Perhaps this is a LLVM bug that will be fixed in the future, as this is a very common occurrence.
136 строки
4,7 КиБ
LLVM
136 строки
4,7 КиБ
LLVM
; ModuleID = 'go1.17.go'
|
|
source_filename = "go1.17.go"
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
|
target triple = "wasm32-unknown-wasi"
|
|
|
|
declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*)
|
|
|
|
define hidden void @main.init(i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
ret void
|
|
}
|
|
|
|
define hidden i8* @main.Add32(i8* %p, i32 %len, i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%0 = getelementptr i8, i8* %p, i32 %len
|
|
ret i8* %0
|
|
}
|
|
|
|
define hidden i8* @main.Add64(i8* %p, i64 %len, i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%0 = trunc i64 %len to i32
|
|
%1 = getelementptr i8, i8* %p, i32 %0
|
|
ret i8* %1
|
|
}
|
|
|
|
define hidden [4 x i32]* @main.SliceToArray(i32* %s.data, i32 %s.len, i32 %s.cap, i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%0 = icmp ult i32 %s.len, 4
|
|
br i1 %0, label %slicetoarray.throw, label %slicetoarray.next
|
|
|
|
slicetoarray.throw: ; preds = %entry
|
|
call void @runtime.sliceToArrayPointerPanic(i8* undef, i8* null)
|
|
unreachable
|
|
|
|
slicetoarray.next: ; preds = %entry
|
|
%1 = bitcast i32* %s.data to [4 x i32]*
|
|
ret [4 x i32]* %1
|
|
}
|
|
|
|
declare void @runtime.sliceToArrayPointerPanic(i8*, i8*)
|
|
|
|
define hidden [4 x i32]* @main.SliceToArrayConst(i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%makeslice = call i8* @runtime.alloc(i32 24, i8* undef, i8* null)
|
|
br i1 false, label %slicetoarray.throw, label %slicetoarray.next
|
|
|
|
slicetoarray.throw: ; preds = %entry
|
|
unreachable
|
|
|
|
slicetoarray.next: ; preds = %entry
|
|
%0 = bitcast i8* %makeslice to [4 x i32]*
|
|
ret [4 x i32]* %0
|
|
}
|
|
|
|
define hidden { i32*, i32, i32 } @main.SliceInt(i32* dereferenceable_or_null(4) %ptr, i32 %len, i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%0 = icmp ugt i32 %len, 1073741823
|
|
%1 = icmp eq i32* %ptr, null
|
|
%2 = icmp ne i32 %len, 0
|
|
%3 = and i1 %1, %2
|
|
%4 = or i1 %3, %0
|
|
br i1 %4, label %unsafe.Slice.throw, label %unsafe.Slice.next
|
|
|
|
unsafe.Slice.throw: ; preds = %entry
|
|
call void @runtime.unsafeSlicePanic(i8* undef, i8* null)
|
|
unreachable
|
|
|
|
unsafe.Slice.next: ; preds = %entry
|
|
%5 = insertvalue { i32*, i32, i32 } undef, i32* %ptr, 0
|
|
%6 = insertvalue { i32*, i32, i32 } %5, i32 %len, 1
|
|
%7 = insertvalue { i32*, i32, i32 } %6, i32 %len, 2
|
|
ret { i32*, i32, i32 } %7
|
|
}
|
|
|
|
declare void @runtime.unsafeSlicePanic(i8*, i8*)
|
|
|
|
define hidden { i8*, i32, i32 } @main.SliceUint16(i8* dereferenceable_or_null(1) %ptr, i16 %len, i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%0 = icmp eq i8* %ptr, null
|
|
%1 = icmp ne i16 %len, 0
|
|
%2 = and i1 %0, %1
|
|
br i1 %2, label %unsafe.Slice.throw, label %unsafe.Slice.next
|
|
|
|
unsafe.Slice.throw: ; preds = %entry
|
|
call void @runtime.unsafeSlicePanic(i8* undef, i8* null)
|
|
unreachable
|
|
|
|
unsafe.Slice.next: ; preds = %entry
|
|
%3 = zext i16 %len to i32
|
|
%4 = insertvalue { i8*, i32, i32 } undef, i8* %ptr, 0
|
|
%5 = insertvalue { i8*, i32, i32 } %4, i32 %3, 1
|
|
%6 = insertvalue { i8*, i32, i32 } %5, i32 %3, 2
|
|
ret { i8*, i32, i32 } %6
|
|
}
|
|
|
|
define hidden { i32*, i32, i32 } @main.SliceUint64(i32* dereferenceable_or_null(4) %ptr, i64 %len, i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%0 = icmp ugt i64 %len, 1073741823
|
|
%1 = icmp eq i32* %ptr, null
|
|
%2 = icmp ne i64 %len, 0
|
|
%3 = and i1 %1, %2
|
|
%4 = or i1 %3, %0
|
|
br i1 %4, label %unsafe.Slice.throw, label %unsafe.Slice.next
|
|
|
|
unsafe.Slice.throw: ; preds = %entry
|
|
call void @runtime.unsafeSlicePanic(i8* undef, i8* null)
|
|
unreachable
|
|
|
|
unsafe.Slice.next: ; preds = %entry
|
|
%5 = trunc i64 %len to i32
|
|
%6 = insertvalue { i32*, i32, i32 } undef, i32* %ptr, 0
|
|
%7 = insertvalue { i32*, i32, i32 } %6, i32 %5, 1
|
|
%8 = insertvalue { i32*, i32, i32 } %7, i32 %5, 2
|
|
ret { i32*, i32, i32 } %8
|
|
}
|
|
|
|
define hidden { i32*, i32, i32 } @main.SliceInt64(i32* dereferenceable_or_null(4) %ptr, i64 %len, i8* %context, i8* %parentHandle) unnamed_addr {
|
|
entry:
|
|
%0 = icmp ugt i64 %len, 1073741823
|
|
%1 = icmp eq i32* %ptr, null
|
|
%2 = icmp ne i64 %len, 0
|
|
%3 = and i1 %1, %2
|
|
%4 = or i1 %3, %0
|
|
br i1 %4, label %unsafe.Slice.throw, label %unsafe.Slice.next
|
|
|
|
unsafe.Slice.throw: ; preds = %entry
|
|
call void @runtime.unsafeSlicePanic(i8* undef, i8* null)
|
|
unreachable
|
|
|
|
unsafe.Slice.next: ; preds = %entry
|
|
%5 = trunc i64 %len to i32
|
|
%6 = insertvalue { i32*, i32, i32 } undef, i32* %ptr, 0
|
|
%7 = insertvalue { i32*, i32, i32 } %6, i32 %5, 1
|
|
%8 = insertvalue { i32*, i32, i32 } %7, i32 %5, 2
|
|
ret { i32*, i32, i32 } %8
|
|
}
|