File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1069,6 +1069,19 @@ obj builder(BuilderRef B) {
1069
1069
ret llvm. LLVMBuildPtrDiff ( B , LHS , RHS , _str. buf ( "" ) ) ;
1070
1070
}
1071
1071
1072
+ fn Trap ( ) -> ValueRef {
1073
+ let BasicBlockRef BB = llvm. LLVMGetInsertBlock ( B ) ;
1074
+ let ValueRef FN = llvm. LLVMGetBasicBlockParent ( BB ) ;
1075
+ let ModuleRef M = llvm. LLVMGetGlobalParent ( FN ) ;
1076
+ let ValueRef T = llvm. LLVMGetNamedFunction ( M , _str. buf ( "llvm.trap" ) ) ;
1077
+ check ( T as int != 0 ) ;
1078
+ let vec[ ValueRef ] Args = vec ( ) ;
1079
+ ret llvm. LLVMBuildCall ( B , T ,
1080
+ _vec. buf [ ValueRef ] ( Args ) ,
1081
+ _vec. len [ ValueRef ] ( Args ) ,
1082
+ _str. buf ( "" ) ) ;
1083
+ }
1084
+
1072
1085
drop {
1073
1086
llvm. LLVMDisposeBuilder ( B ) ;
1074
1087
}
Original file line number Diff line number Diff line change @@ -1369,13 +1369,20 @@ fn trans_main_fn(@trans_ctxt cx, ValueRef llcrate) {
1369
1369
1370
1370
}
1371
1371
1372
+ fn declare_intrinsics ( ModuleRef llmod) {
1373
+ let vec[ TypeRef ] T_trap_args = vec ( ) ;
1374
+ decl_cdecl_fn ( llmod, "llvm.trap" , T_trap_args , T_void ( ) ) ;
1375
+ }
1376
+
1372
1377
fn trans_crate ( session . session sess, @ast. crate crate, str output ) {
1373
1378
auto llmod =
1374
1379
llvm. LLVMModuleCreateWithNameInContext ( _str. buf ( "rust_out" ) ,
1375
1380
llvm. LLVMGetGlobalContext ( ) ) ;
1376
1381
1377
1382
llvm. LLVMSetModuleInlineAsm ( llmod, _str. buf ( x86. get_module_asm ( ) ) ) ;
1378
1383
1384
+ declare_intrinsics ( llmod) ;
1385
+
1379
1386
auto glues = @rec ( activate_glue = decl_glue ( llmod,
1380
1387
abi. activate_glue_name ( ) ) ,
1381
1388
yield_glue = decl_glue ( llmod, abi. yield_glue_name ( ) ) ,
You can’t perform that action at this time.
0 commit comments