llvm-6502/test/CodeGen/WinEH/cppeh-prepared-cleanups.ll
David Blaikie 32b845d223 [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))

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-16 23:24:18 +00:00

242 lines
9.8 KiB
LLVM
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

; RUN: llc < %s | FileCheck %s
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
%eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }
%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }
%eh.ThrowInfo = type { i32, i32, i32, i32 }
%struct.S = type { i8 }
$"\01??_DS@@QEAA@XZ" = comdat any
$"\01??_R0H@8" = comdat any
$"_CT??_R0H@84" = comdat any
$_CTA1H = comdat any
$_TI1H = comdat any
@"\01??_7type_info@@6B@" = external constant i8*
@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
@__ImageBase = external constant i8
@"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat
@_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableType* @"_CT??_R0H@84" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
@_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableTypeArray.1* @_CTA1H to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, section ".xdata", comdat
; CHECK-LABEL: "?test1@@YAXXZ":
; CHECK: .seh_handlerdata
; CHECK-NEXT: .long ("$cppxdata$?test1@@YAXXZ")@IMGREL
; CHECK-NEXT:"$cppxdata$?test1@@YAXXZ":
; CHECK-NEXT: .long 429065506
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long ("$stateUnwindMap$?test1@@YAXXZ")@IMGREL
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long ("$ip2state$?test1@@YAXXZ")@IMGREL
; CHECK-NEXT: .long 32
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 1
; CHECK-NEXT:"$stateUnwindMap$?test1@@YAXXZ":
; CHECK-NEXT: .long -1
; CHECK-NEXT: .long "?test1@@YAXXZ.cleanup"@IMGREL
; CHECK-NEXT:"$ip2state$?test1@@YAXXZ":
; CHECK-NEXT: .long .Ltmp0@IMGREL
; CHECK-NEXT: .long 0
define void @"\01?test1@@YAXXZ"() #0 {
entry:
%unwindhelp = alloca i64
%tmp = alloca i32, align 4
%exn.slot = alloca i8*
%ehselector.slot = alloca i32
store i32 0, i32* %tmp
%0 = bitcast i32* %tmp to i8*
call void (...) @llvm.frameescape()
store volatile i64 -2, i64* %unwindhelp
%1 = bitcast i64* %unwindhelp to i8*
call void @llvm.eh.unwindhelp(i8* %1)
invoke void @_CxxThrowException(i8* %0, %eh.ThrowInfo* @_TI1H) #8
to label %unreachable unwind label %lpad1
lpad1: ; preds = %entry
%2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
%recover = call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @"\01?test1@@YAXXZ.cleanup")
indirectbr i8* %recover, []
unreachable: ; preds = %entry
unreachable
}
declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
declare i32 @__CxxFrameHandler3(...)
; Function Attrs: nounwind
define linkonce_odr void @"\01??_DS@@QEAA@XZ"(%struct.S* %this) unnamed_addr #1 comdat align 2 {
entry:
%this.addr = alloca %struct.S*, align 8
store %struct.S* %this, %struct.S** %this.addr, align 8
%this1 = load %struct.S*, %struct.S** %this.addr
call void @"\01??1S@@QEAA@XZ"(%struct.S* %this1) #4
ret void
}
; CHECK-LABEL: "?test2@@YAX_N@Z":
; CHECK: .seh_handlerdata
; CHECK-NEXT: .long ("$cppxdata$?test2@@YAX_N@Z")@IMGREL
; CHECK-NEXT:"$cppxdata$?test2@@YAX_N@Z":
; CHECK-NEXT: .long 429065506
; CHECK-NEXT: .long 2
; CHECK-NEXT: .long ("$stateUnwindMap$?test2@@YAX_N@Z")@IMGREL
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 4
; CHECK-NEXT: .long ("$ip2state$?test2@@YAX_N@Z")@IMGREL
; CHECK-NEXT: .long 40
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 1
; CHECK-NEXT:"$stateUnwindMap$?test2@@YAX_N@Z":
; CHECK-NEXT: .long -1
; CHECK-NEXT: .long "?test2@@YAX_N@Z.cleanup"@IMGREL
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long "?test2@@YAX_N@Z.cleanup1"@IMGREL
; CHECK-NEXT:"$ip2state$?test2@@YAX_N@Z":
; CHECK-NEXT: .long .Lfunc_begin1@IMGREL
; CHECK-NEXT: .long -1
; CHECK-NEXT: .long .Ltmp7@IMGREL
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long .Ltmp9@IMGREL
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long .Ltmp12@IMGREL
; CHECK-NEXT: .long 0
define void @"\01?test2@@YAX_N@Z"(i1 zeroext %b) #2 {
%b.addr = alloca i8, align 1
%s = alloca %struct.S, align 1
%exn.slot = alloca i8*
%ehselector.slot = alloca i32
%s1 = alloca %struct.S, align 1
%frombool = zext i1 %b to i8
store i8 %frombool, i8* %b.addr, align 1
call void (...) @llvm.frameescape(%struct.S* %s, %struct.S* %s1)
call void @"\01?may_throw@@YAXXZ"()
invoke void @"\01?may_throw@@YAXXZ"()
to label %invoke.cont unwind label %lpad1
invoke.cont: ; preds = %entry
%1 = load i8, i8* %b.addr, align 1
%tobool = trunc i8 %1 to i1
br i1 %tobool, label %if.then, label %if.else
if.then: ; preds = %invoke.cont
invoke void @"\01?may_throw@@YAXXZ"()
to label %invoke.cont3 unwind label %lpad3
invoke.cont3: ; preds = %if.then
call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s1) #4
br label %if.end
lpad1: ; preds = %entry, %if.end
%2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
%recover = call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @"\01?test2@@YAX_N@Z.cleanup")
indirectbr i8* %recover, []
lpad3: ; preds = %if.then
%3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
%recover4 = call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @"\01?test2@@YAX_N@Z.cleanup1", i32 0, void (i8*, i8*)* @"\01?test2@@YAX_N@Z.cleanup")
indirectbr i8* %recover4, []
if.else: ; preds = %invoke.cont
call void @"\01?dont_throw@@YAXXZ"() #4
br label %if.end
if.end: ; preds = %if.else, %invoke.cont3
invoke void @"\01?may_throw@@YAXXZ"()
to label %invoke.cont4 unwind label %lpad1
invoke.cont4: ; preds = %if.end
call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s) #4
ret void
}
declare void @"\01?may_throw@@YAXXZ"() #3
; Function Attrs: nounwind
declare void @"\01?dont_throw@@YAXXZ"() #1
; Function Attrs: nounwind
declare void @"\01??1S@@QEAA@XZ"(%struct.S*) #1
; Function Attrs: nounwind
declare i8* @llvm.eh.actions(...) #4
define internal void @"\01?test1@@YAXXZ.cleanup"(i8*, i8*) #5 {
entry:
%s = alloca %struct.S, align 1
call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s) #4
ret void
}
; Function Attrs: nounwind
declare void @llvm.frameescape(...) #4
; Function Attrs: nounwind readnone
declare i8* @llvm.framerecover(i8*, i8*, i32) #6
; Function Attrs: nounwind
declare void @llvm.eh.unwindhelp(i8*) #4
define internal void @"\01?test2@@YAX_N@Z.cleanup"(i8*, i8*) #7 {
entry:
%s.i8 = call i8* @llvm.framerecover(i8* bitcast (void (i1)* @"\01?test2@@YAX_N@Z" to i8*), i8* %1, i32 0)
%s = bitcast i8* %s.i8 to %struct.S*
call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s) #4
invoke void @llvm.donothing()
to label %entry.split unwind label %stub
entry.split: ; preds = %entry
ret void
stub: ; preds = %entry
%2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
unreachable
}
define internal void @"\01?test2@@YAX_N@Z.cleanup1"(i8*, i8*) #7 {
entry:
%s1.i8 = call i8* @llvm.framerecover(i8* bitcast (void (i1)* @"\01?test2@@YAX_N@Z" to i8*), i8* %1, i32 1)
%s1 = bitcast i8* %s1.i8 to %struct.S*
call void @"\01??_DS@@QEAA@XZ"(%struct.S* %s1) #4
invoke void @llvm.donothing()
to label %entry.split unwind label %stub
entry.split: ; preds = %entry
ret void
stub: ; preds = %entry
%2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
unreachable
}
declare void @llvm.donothing()
attributes #0 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" "wineh-parent"="?test1@@YAXXZ" }
attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" "wineh-parent"="?test2@@YAX_N@Z" }
attributes #3 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { nounwind }
attributes #5 = { "wineh-parent"="?test1@@YAXXZ" }
attributes #6 = { nounwind readnone }
attributes #7 = { "wineh-parent"="?test2@@YAX_N@Z" }
attributes #8 = { noreturn }