@@ -10,7 +10,7 @@ use rustc_middle::bug;
1010use rustc_middle:: ty:: Ty ;
1111use rustc_middle:: ty:: layout:: LayoutOf ;
1212#[ cfg( feature = "master" ) ]
13- use rustc_session:: config;
13+ use rustc_session:: { Session , config} ;
1414use rustc_target:: callconv:: { ArgAttributes , CastTarget , FnAbi , PassMode } ;
1515#[ cfg( feature = "master" ) ]
1616use rustc_target:: spec:: Arch ;
@@ -230,32 +230,43 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
230230
231231 #[ cfg( feature = "master" ) ]
232232 fn gcc_cconv ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> Option < FnAttribute < ' gcc > > {
233- conv_to_fn_attribute ( self . conv , & cx . tcx . sess . target . arch )
233+ conv_to_fn_attribute ( cx . sess ( ) , self . conv )
234234 }
235235}
236236
237237#[ cfg( feature = "master" ) ]
238- pub fn conv_to_fn_attribute < ' gcc > ( conv : CanonAbi , arch : & Arch ) -> Option < FnAttribute < ' gcc > > {
238+ pub fn conv_to_fn_attribute < ' gcc > ( sess : & Session , conv : CanonAbi ) -> Option < FnAttribute < ' gcc > > {
239239 let attribute = match conv {
240240 CanonAbi :: C | CanonAbi :: Rust => return None ,
241- // gcc/gccjit does not have anything for this.
242- CanonAbi :: RustPreserveNone => return None ,
241+ CanonAbi :: RustPreserveNone => {
242+ // This calling convention is LLVM-specific and unspecified.
243+ sess. dcx ( )
244+ . fatal ( "gcc/gccjit backend does not support RustPreserveNone calling convention" )
245+ }
246+ CanonAbi :: RustTail => {
247+ // This calling convention is LLVM-specific and unspecified.
248+ sess. dcx ( ) . fatal ( "gcc/gccjit backend does not support RustTail calling convention" )
249+ }
243250 CanonAbi :: RustCold => FnAttribute :: Cold ,
244251 // Functions with this calling convention can only be called from assembly, but it is
245252 // possible to declare an `extern "custom"` block, so the backend still needs a calling
246253 // convention for declaring foreign functions.
247254 CanonAbi :: Custom => return None ,
248- // gcc/gccjit does not have anything for Swift's calling convention.
249- CanonAbi :: Swift => panic ! ( "gcc/gccjit backend does not support Swift calling convention" ) ,
255+ CanonAbi :: Swift => {
256+ // gcc/gccjit does not have anything for Swift's calling convention.
257+ sess. dcx ( ) . fatal ( "gcc/gccjit backend does not support Swift calling convention" )
258+ }
250259 CanonAbi :: Arm ( arm_call) => match arm_call {
251260 ArmCall :: CCmseNonSecureCall => FnAttribute :: ArmCmseNonsecureCall ,
252261 ArmCall :: CCmseNonSecureEntry => FnAttribute :: ArmCmseNonsecureEntry ,
253262 ArmCall :: Aapcs => FnAttribute :: ArmPcs ( "aapcs" ) ,
254263 } ,
255- CanonAbi :: GpuKernel => match arch {
264+ CanonAbi :: GpuKernel => match & sess . target . arch {
256265 & Arch :: AmdGpu => FnAttribute :: GcnAmdGpuHsaKernel ,
257266 & Arch :: Nvptx64 => FnAttribute :: NvptxKernel ,
258- arch => panic ! ( "Arch {arch} does not support GpuKernel calling convention" ) ,
267+ arch => sess
268+ . dcx ( )
269+ . fatal ( format ! ( "Arch {arch} does not support GpuKernel calling convention" ) ) ,
259270 } ,
260271 // FIXME(antoyo): check if those AVR attributes are mapped correctly.
261272 CanonAbi :: Interrupt ( interrupt_kind) => match interrupt_kind {
0 commit comments