2020-03-02 07:36:55 +01:00
|
|
|
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic | FileCheck --check-prefixes=LARGE,LARGE-BSS %s
|
|
|
|
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -mattr=+secure-plt -relocation-model=pic | FileCheck --check-prefixes=LARGE,LARGE-SECUREPLT %s
|
2019-02-27 22:53:14 +01:00
|
|
|
; RUN: llc < %s -mtriple=powerpc-unknown-netbsd -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
|
|
|
|
; RUN: llc < %s -mtriple=powerpc-unknown-netbsd -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
|
|
|
|
; RUN: llc < %s -mtriple=powerpc-unknown-openbsd -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
|
|
|
|
; RUN: llc < %s -mtriple=powerpc-unknown-openbsd -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
|
2019-06-28 21:48:31 +02:00
|
|
|
; RUN: llc < %s -mtriple=powerpc-linux-musl -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
|
|
|
|
; RUN: llc < %s -mtriple=powerpc-linux-musl -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
|
2020-03-02 07:36:55 +01:00
|
|
|
$bar1 = comdat any
|
|
|
|
|
2014-11-12 16:16:30 +01:00
|
|
|
@bar = common global i32 0, align 4
|
2020-03-02 07:36:55 +01:00
|
|
|
@bar1 = global i32 0, align 4, comdat($bar1)
|
|
|
|
@bar2 = global i32 0, align 4, comdat($bar1)
|
2014-11-12 16:16:30 +01:00
|
|
|
|
2015-01-10 02:57:21 +01:00
|
|
|
declare i32 @call_foo(i32, ...)
|
|
|
|
|
2014-11-12 16:16:30 +01:00
|
|
|
define i32 @foo() {
|
|
|
|
entry:
|
2015-02-27 22:17:42 +01:00
|
|
|
%0 = load i32, i32* @bar, align 4
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 01:24:18 +02:00
|
|
|
%call = call i32 (i32, ...) @call_foo(i32 %0, i32 0, i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64)
|
2014-11-12 16:16:30 +01:00
|
|
|
ret i32 %0
|
|
|
|
}
|
|
|
|
|
2020-03-02 07:36:55 +01:00
|
|
|
define i32 @load() {
|
|
|
|
entry:
|
|
|
|
%0 = load i32, i32* @bar1
|
|
|
|
%1 = load i32, i32* @bar2
|
|
|
|
%2 = add i32 %0, %1
|
|
|
|
ret i32 %2
|
|
|
|
}
|
|
|
|
|
2014-11-12 16:16:30 +01:00
|
|
|
!llvm.module.flags = !{!0}
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-15 20:07:53 +01:00
|
|
|
!0 = !{i32 1, !"PIC Level", i32 2}
|
2014-11-12 16:16:30 +01:00
|
|
|
; LARGE-BSS: [[POFF:\.L[0-9]+\$poff]]:
|
|
|
|
; LARGE-BSS-NEXT: .long .LTOC-[[PB:\.L[0-9]+\$pb]]
|
|
|
|
; LARGE-BSS-NEXT: foo:
|
2016-09-06 14:30:00 +02:00
|
|
|
; LARGE-BSS: stwu 1, -32(1)
|
|
|
|
; LARGE-BSS: stw 30, 24(1)
|
2014-11-12 16:16:30 +01:00
|
|
|
; LARGE-BSS: bl [[PB]]
|
|
|
|
; LARGE-BSS-NEXT: [[PB]]:
|
|
|
|
; LARGE-BSS: mflr 30
|
|
|
|
; LARGE-BSS: lwz [[REG:[0-9]+]], [[POFF]]-[[PB]](30)
|
|
|
|
; LARGE-BSS-NEXT: add 30, [[REG]], 30
|
2015-01-10 02:57:21 +01:00
|
|
|
; LARGE-BSS-DAG: lwz [[VREG:[0-9]+]], [[VREF:\.LC[0-9]+]]-.LTOC(30)
|
2015-01-08 16:47:19 +01:00
|
|
|
; LARGE-BSS-DAG: lwz {{[0-9]+}}, 0([[VREG]])
|
2015-01-10 02:57:21 +01:00
|
|
|
; LARGE-BSS-DAG: stw {{[0-9]+}}, 8(1)
|
2016-09-22 19:22:43 +02:00
|
|
|
; LARGE-BSS: lwz 30, 24(1)
|
2018-03-27 13:23:53 +02:00
|
|
|
; LARGE-SECUREPLT: addis 30, 30, .LTOC-.L0$pb@ha
|
|
|
|
; LARGE-SECUREPLT: addi 30, 30, .LTOC-.L0$pb@l
|
|
|
|
; LARGE-SECUREPLT: bl call_foo@PLT+32768
|
2020-03-02 07:36:55 +01:00
|
|
|
|
|
|
|
; LARGE: .section .bss.bar1,"aGw",@nobits,bar1,comdat
|
|
|
|
; LARGE: bar1:
|
|
|
|
; LARGE: .section .bss.bar2,"aGw",@nobits,bar1,comdat
|
|
|
|
; LARGE: bar2:
|
|
|
|
; LARGE: .section .got2,"aw",@progbits
|
|
|
|
; LARGE-NEXT: .p2align 2
|
|
|
|
; LARGE-NEXT: .LC0:
|
|
|
|
; LARGE-NEXT: .long bar
|
|
|
|
; LARGE-NEXT: .LC1:
|
|
|
|
; LARGE-NEXT: .long bar1
|
|
|
|
; LARGE-NEXT: .LC2:
|
|
|
|
; LARGE-NEXT: .long bar2
|