mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
198d8baafb
One of several parallel first steps to remove the target type of pointers, replacing them with a single opaque pointer type. This adds an explicit type parameter to the gep instruction so that when the first parameter becomes an opaque pointer type, the type to gep through is still available to the instructions. * This doesn't modify gep operators, only instructions (operators will be handled separately) * Textual IR changes only. Bitcode (including upgrade) and changing the in-memory representation will be in separate changes. * geps of vectors are transformed as: getelementptr <4 x float*> %x, ... ->getelementptr float, <4 x float*> %x, ... Then, once the opaque pointer type is introduced, this will ultimately look like: getelementptr float, <4 x ptr> %x with the unambiguous interpretation that it is a vector of pointers to float. * address spaces remain on the pointer, not the type: getelementptr float addrspace(1)* %x ->getelementptr float, float addrspace(1)* %x Then, eventually: getelementptr float, ptr addrspace(1) %x Importantly, the massive amount of test case churn has been automated by same crappy python code. I had to manually update a few test cases that wouldn't fit the script's model (r228970,r229196,r229197,r229198). The python script just massages stdin and writes the result to stdout, I then wrapped that in a shell script to handle replacing files, then using the usual find+xargs to migrate all the files. update.py: import fileinput import sys import re ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") def conv(match, line): if not match: return line line = match.groups()[0] if len(match.groups()[5]) == 0: line += match.groups()[2] line += match.groups()[3] line += ", " line += match.groups()[1] line += "\n" return line for line in sys.stdin: if line.find("getelementptr ") == line.find("getelementptr inbounds"): if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("): line = conv(re.match(ibrep, line), line) elif line.find("getelementptr ") != line.find("getelementptr ("): line = conv(re.match(normrep, line), line) sys.stdout.write(line) apply.sh: for name in "$@" do python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name" rm -f "$name.tmp" done The actual commands: From llvm/src: find test/ -name *.ll | xargs ./apply.sh From llvm/src/tools/clang: find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}" From llvm/src/tools/polly: find test/ -name *.ll | xargs ./apply.sh After that, check-all (with llvm, clang, clang-tools-extra, lld, compiler-rt, and polly all checked out). The extra 'rm' in the apply.sh script is due to a few files in clang's test suite using interesting unicode stuff that my python script was throwing exceptions on. None of those files needed to be migrated, so it seemed sufficient to ignore those cases. Reviewers: rafael, dexonsmith, grosser Differential Revision: http://reviews.llvm.org/D7636 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
90 lines
5.3 KiB
LLVM
90 lines
5.3 KiB
LLVM
; RUN: llc -relocation-model=pic < %s | grep ":$" | sort | uniq -d | count 0
|
|
target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32-n32"
|
|
target triple = "thumbv7-apple-darwin10"
|
|
|
|
; This function produces a duplicate LPC label unless special care is taken when duplicating a t2LDRpci_pic instruction.
|
|
|
|
%struct.PlatformMutex = type { i32, [40 x i8] }
|
|
%struct.SpinLock = type { %struct.PlatformMutex }
|
|
%"struct.WTF::TCMalloc_ThreadCache" = type { i32, %struct._opaque_pthread_t*, i8, [68 x %"struct.WTF::TCMalloc_ThreadCache_FreeList"], i32, i32, %"struct.WTF::TCMalloc_ThreadCache"*, %"struct.WTF::TCMalloc_ThreadCache"* }
|
|
%"struct.WTF::TCMalloc_ThreadCache_FreeList" = type { i8*, i16, i16 }
|
|
%struct.__darwin_pthread_handler_rec = type { void (i8*)*, i8*, %struct.__darwin_pthread_handler_rec* }
|
|
%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] }
|
|
|
|
@_ZN3WTFL8heap_keyE = internal global i32 0 ; <i32*> [#uses=1]
|
|
@_ZN3WTFL10tsd_initedE.b = internal global i1 false ; <i1*> [#uses=2]
|
|
@_ZN3WTFL13pageheap_lockE = internal global %struct.SpinLock { %struct.PlatformMutex { i32 850045863, [40 x i8] zeroinitializer } } ; <%struct.SpinLock*> [#uses=1]
|
|
@_ZN3WTFL12thread_heapsE = internal global %"struct.WTF::TCMalloc_ThreadCache"* null ; <%"struct.WTF::TCMalloc_ThreadCache"**> [#uses=1]
|
|
@llvm.used = appending global [1 x i8*] [i8* bitcast (%"struct.WTF::TCMalloc_ThreadCache"* ()* @_ZN3WTF20TCMalloc_ThreadCache22CreateCacheIfNecessaryEv to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
|
|
|
|
define %"struct.WTF::TCMalloc_ThreadCache"* @_ZN3WTF20TCMalloc_ThreadCache22CreateCacheIfNecessaryEv() nounwind {
|
|
entry:
|
|
%0 = tail call i32 @pthread_mutex_lock(%struct.PlatformMutex* getelementptr inbounds (%struct.SpinLock* @_ZN3WTFL13pageheap_lockE, i32 0, i32 0)) nounwind
|
|
%.b24 = load i1* @_ZN3WTFL10tsd_initedE.b, align 4 ; <i1> [#uses=1]
|
|
br i1 %.b24, label %bb5, label %bb6
|
|
|
|
bb5: ; preds = %entry
|
|
%1 = tail call %struct._opaque_pthread_t* @pthread_self() nounwind
|
|
br label %bb6
|
|
|
|
bb6: ; preds = %bb5, %entry
|
|
%me.0 = phi %struct._opaque_pthread_t* [ %1, %bb5 ], [ null, %entry ] ; <%struct._opaque_pthread_t*> [#uses=2]
|
|
br label %bb11
|
|
|
|
bb7: ; preds = %bb11
|
|
%2 = getelementptr inbounds %"struct.WTF::TCMalloc_ThreadCache", %"struct.WTF::TCMalloc_ThreadCache"* %h.0, i32 0, i32 1
|
|
%3 = load %struct._opaque_pthread_t** %2, align 4
|
|
%4 = tail call i32 @pthread_equal(%struct._opaque_pthread_t* %3, %struct._opaque_pthread_t* %me.0) nounwind
|
|
%5 = icmp eq i32 %4, 0
|
|
br i1 %5, label %bb10, label %bb14
|
|
|
|
bb10: ; preds = %bb7
|
|
%6 = getelementptr inbounds %"struct.WTF::TCMalloc_ThreadCache", %"struct.WTF::TCMalloc_ThreadCache"* %h.0, i32 0, i32 6
|
|
br label %bb11
|
|
|
|
bb11: ; preds = %bb10, %bb6
|
|
%h.0.in = phi %"struct.WTF::TCMalloc_ThreadCache"** [ @_ZN3WTFL12thread_heapsE, %bb6 ], [ %6, %bb10 ] ; <%"struct.WTF::TCMalloc_ThreadCache"**> [#uses=1]
|
|
%h.0 = load %"struct.WTF::TCMalloc_ThreadCache"** %h.0.in, align 4 ; <%"struct.WTF::TCMalloc_ThreadCache"*> [#uses=4]
|
|
%7 = icmp eq %"struct.WTF::TCMalloc_ThreadCache"* %h.0, null
|
|
br i1 %7, label %bb13, label %bb7
|
|
|
|
bb13: ; preds = %bb11
|
|
%8 = tail call %"struct.WTF::TCMalloc_ThreadCache"* @_ZN3WTF20TCMalloc_ThreadCache7NewHeapEP17_opaque_pthread_t(%struct._opaque_pthread_t* %me.0) nounwind
|
|
br label %bb14
|
|
|
|
bb14: ; preds = %bb13, %bb7
|
|
%heap.1 = phi %"struct.WTF::TCMalloc_ThreadCache"* [ %8, %bb13 ], [ %h.0, %bb7 ] ; <%"struct.WTF::TCMalloc_ThreadCache"*> [#uses=4]
|
|
%9 = tail call i32 @pthread_mutex_unlock(%struct.PlatformMutex* getelementptr inbounds (%struct.SpinLock* @_ZN3WTFL13pageheap_lockE, i32 0, i32 0)) nounwind
|
|
%10 = getelementptr inbounds %"struct.WTF::TCMalloc_ThreadCache", %"struct.WTF::TCMalloc_ThreadCache"* %heap.1, i32 0, i32 2
|
|
%11 = load i8* %10, align 4
|
|
%toBool15not = icmp eq i8 %11, 0 ; <i1> [#uses=1]
|
|
br i1 %toBool15not, label %bb19, label %bb22
|
|
|
|
bb19: ; preds = %bb14
|
|
%.b = load i1* @_ZN3WTFL10tsd_initedE.b, align 4 ; <i1> [#uses=1]
|
|
br i1 %.b, label %bb21, label %bb22
|
|
|
|
bb21: ; preds = %bb19
|
|
store i8 1, i8* %10, align 4
|
|
%12 = load i32* @_ZN3WTFL8heap_keyE, align 4
|
|
%13 = bitcast %"struct.WTF::TCMalloc_ThreadCache"* %heap.1 to i8*
|
|
%14 = tail call i32 @pthread_setspecific(i32 %12, i8* %13) nounwind
|
|
ret %"struct.WTF::TCMalloc_ThreadCache"* %heap.1
|
|
|
|
bb22: ; preds = %bb19, %bb14
|
|
ret %"struct.WTF::TCMalloc_ThreadCache"* %heap.1
|
|
}
|
|
|
|
declare i32 @pthread_mutex_lock(%struct.PlatformMutex*)
|
|
|
|
declare i32 @pthread_mutex_unlock(%struct.PlatformMutex*)
|
|
|
|
declare hidden %"struct.WTF::TCMalloc_ThreadCache"* @_ZN3WTF20TCMalloc_ThreadCache7NewHeapEP17_opaque_pthread_t(%struct._opaque_pthread_t*) nounwind
|
|
|
|
declare i32 @pthread_setspecific(i32, i8*)
|
|
|
|
declare %struct._opaque_pthread_t* @pthread_self()
|
|
|
|
declare i32 @pthread_equal(%struct._opaque_pthread_t*, %struct._opaque_pthread_t*)
|
|
|