llvm.org GIT mirror llvm / 8620890
rdar://11542750 - llvm.trap should be marked no return. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157551 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
6 changed file(s) with 43 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
83858385
83868386
Syntax:
83878387

                  
                
8388 declare void @llvm.trap()
8388 declare void @llvm.trap() noreturn nounwind
83898389
83908390
83918391
Overview:
84108410
84118411
Syntax:
84128412

                  
                
8413 declare void @llvm.debugtrap()
8413 declare void @llvm.debugtrap() nounwind
84148414
84158415
84168416
Overview:
5353 class NoCapture : IntrinsicProperty {
5454 int ArgNo = argNo;
5555 }
56
57 def IntrNoReturn : IntrinsicProperty;
5658
5759 //===----------------------------------------------------------------------===//
5860 // Types used by intrinsics.
399401 //
400402 def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
401403 GCCBuiltin<"__builtin_flt_rounds">;
402 def int_trap : Intrinsic<[]>,
404 def int_trap : Intrinsic<[], [], [IntrNoReturn]>,
403405 GCCBuiltin<"__builtin_trap">;
404406 def int_debugtrap : Intrinsic<[]>,
405407 GCCBuiltin<"__builtin_debugtrap">;
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
3 ; RUN: FileCheck %s < %t1.ll
34
45 declare i1 @llvm.isunordered.f32(float, float)
56
5758 }
5859
5960 ; FIXME: test ALL the intrinsics in this file.
61
62 ; rdar://11542750
63 ; CHECK: declare void @llvm.trap() noreturn nounwind
64 declare void @llvm.trap()
65
66 define void @trap() {
67 call void @llvm.trap()
68 ret void
69 }
7171
7272 /// canThrow - True if the intrinsic can throw.
7373 bool canThrow;
74
74
75 /// isNoReturn - True if the intrinsic is no-return.
76 bool isNoReturn;
77
7578 enum ArgAttribute {
7679 NoCapture
7780 };
386386 isOverloaded = false;
387387 isCommutative = false;
388388 canThrow = false;
389 isNoReturn = false;
389390
390391 if (DefName.size() <= 4 ||
391392 std::string(DefName.begin(), DefName.begin() + 4) != "int_")
510511 isCommutative = true;
511512 else if (Property->getName() == "Throws")
512513 canThrow = true;
514 else if (Property->getName() == "IntrNoReturn")
515 isNoReturn = true;
513516 else if (Property->isSubClassOf("NoCapture")) {
514517 unsigned ArgNo = Property->getValueAsInt("ArgNo");
515518 ArgumentAttributes.push_back(std::make_pair(ArgNo, NoCapture));
450450 if (L->canThrow != R->canThrow)
451451 return R->canThrow;
452452
453 if (L->isNoReturn != R->isNoReturn)
454 return R->isNoReturn;
455
453456 // Try to order by readonly/readnone attribute.
454457 ModRefKind LK = getModRefKind(*L);
455458 ModRefKind RK = getModRefKind(*R);
548551
549552 ModRefKind modRef = getModRefKind(intrinsic);
550553
551 if (!intrinsic.canThrow || modRef) {
554 if (!intrinsic.canThrow || modRef || intrinsic.isNoReturn) {
552555 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(~0, ";
556 bool Emitted = false;
553557 if (!intrinsic.canThrow) {
554558 OS << "Attribute::NoUnwind";
555 if (modRef) OS << '|';
559 Emitted = true;
556560 }
561
562 if (intrinsic.isNoReturn) {
563 if (Emitted) OS << '|';
564 OS << "Attribute::NoReturn";
565 Emitted = true;
566 }
567
557568 switch (modRef) {
558569 case MRK_none: break;
559 case MRK_readonly: OS << "Attribute::ReadOnly"; break;
560 case MRK_readnone: OS << "Attribute::ReadNone"; break;
570 case MRK_readonly:
571 if (Emitted) OS << '|';
572 OS << "Attribute::ReadOnly";
573 break;
574 case MRK_readnone:
575 if (Emitted) OS << '|';
576 OS << "Attribute::ReadNone";
577 break;
561578 }
562579 OS << ");\n";
563580 }