Skip to content

Commit dc1bc55

Browse files
committed
New calling convention preserve_none
Report error when swift attribute is used with preserve_none at the same time.
1 parent 5479cf7 commit dc1bc55

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

llvm/lib/Target/X86/X86ISelLoweringCall.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,16 @@ SDValue X86TargetLowering::LowerFormalArguments(
19351935
MRI.disableCalleeSavedRegister(Pair.first);
19361936
}
19371937

1938+
if (CallingConv::PreserveNone == CallConv)
1939+
for (unsigned I = 0, E = Ins.size(); I != E; ++I) {
1940+
if (Ins[I].Flags.isSwiftSelf() || Ins[I].Flags.isSwiftAsync() ||
1941+
Ins[I].Flags.isSwiftError()) {
1942+
errorUnsupported(DAG, dl,
1943+
"Swift attributes can't be used with preserve_none");
1944+
break;
1945+
}
1946+
}
1947+
19381948
return Chain;
19391949
}
19401950

@@ -2586,6 +2596,16 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
25862596
InGlue = Chain.getValue(1);
25872597
}
25882598

2599+
if (CallingConv::PreserveNone == CallConv)
2600+
for (unsigned I = 0, E = Outs.size(); I != E; ++I) {
2601+
if (Outs[I].Flags.isSwiftSelf() || Outs[I].Flags.isSwiftAsync() ||
2602+
Outs[I].Flags.isSwiftError()) {
2603+
errorUnsupported(DAG, dl,
2604+
"Swift attributes can't be used with preserve_none");
2605+
break;
2606+
}
2607+
}
2608+
25892609
// Handle result values, copying them out of physregs into vregs that we
25902610
// return.
25912611
return LowerCallResult(Chain, InGlue, CallConv, isVarArg, Ins, dl, DAG,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: not llc -mtriple=x86_64 %s -o - 2>&1 | FileCheck %s
2+
3+
; Swift attributes should not be used with preserve_none.
4+
5+
declare preserve_nonecc void @foo(ptr swiftself)
6+
7+
; CHECK: error: <unknown>:0:0: in function bar void (ptr): Swift attributes can't be used with preserve_none
8+
define preserve_nonecc void @bar(ptr swifterror) {
9+
ret void
10+
}
11+
12+
; CHECK: error: <unknown>:0:0: in function qux void (ptr): Swift attributes can't be used with preserve_none
13+
define void @qux(ptr %addr) {
14+
call preserve_nonecc void @foo(ptr swiftself %addr)
15+
ret void
16+
}

0 commit comments

Comments
 (0)