llvm.org GIT mirror llvm / 85b4089
add a new @llvm.donothing intrinsic that, well, does nothing, and teach CodeGen to ignore calls to it git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159383 91177308-0d34-0410-b5e6-96231b3b80d8 Nuno Lopes 8 years ago
3 changed file(s) with 42 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
411411 def int_debugtrap : Intrinsic<[]>,
412412 GCCBuiltin<"__builtin_debugtrap">;
413413
414 // NOP: calls/invokes to this intrinsic are removed by codegen
415 def int_donothing : Intrinsic<[], [], [IntrNoMem]>;
416
414417 // Intrisics to support half precision floating point format
415418 let Properties = [IntrNoMem] in {
416419 def int_convert_to_fp16 : Intrinsic<[llvm_i16_ty], [llvm_float_ty]>,
18271827 MachineBasicBlock *LandingPad = FuncInfo.MBBMap[I.getSuccessor(1)];
18281828
18291829 const Value *Callee(I.getCalledValue());
1830 const Function *Fn = dyn_cast(Callee);
18301831 if (isa(Callee))
18311832 visitInlineAsm(&I);
1832 else
1833 else if (Fn && Fn->isIntrinsic()) {
1834 assert(Fn->getIntrinsicID() == Intrinsic::donothing);
1835 return; // ignore invokes to @llvm.donothing
1836 } else
18331837 LowerCallTo(&I, getValue(Callee), false, LandingPad);
18341838
18351839 // If the value of the invoke is used outside of its defining block, make it
51765180 case Intrinsic::invariant_end:
51775181 case Intrinsic::lifetime_end:
51785182 // Discard region information.
5183 return 0;
5184 case Intrinsic::donothing:
5185 // ignore
51795186 return 0;
51805187 }
51815188 }
0 ; RUN: llc < %s | FileCheck %s
1
2 declare i32 @__gxx_personality_v0(...)
3 declare void @__cxa_call_unexpected(i8*)
4 declare void @llvm.donothing() readnone
5
6 ; CHECK: f1
7 define void @f1() nounwind uwtable ssp {
8 entry:
9 ; CHECK-NOT donothing
10 invoke void @llvm.donothing()
11 to label %invoke.cont unwind label %lpad
12
13 invoke.cont:
14 ret void
15
16 lpad:
17 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
18 filter [0 x i8*] zeroinitializer
19 %1 = extractvalue { i8*, i32 } %0, 0
20 tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind
21 unreachable
22 }
23
24 ; CHECK: f2
25 define void @f2() nounwind {
26 entry:
27 ; CHECK-NOT donothing
28 call void @llvm.donothing()
29 ret void
30 }