add support for llvm.trap
MODIFY
llvm_util/llvm2alive.cpp
llvm_util/llvm2alive.cpp
@@ -870,6 +870,14 @@ end:
return error(i);
RETURN_IDENTIFIER(make_unique<Free>(*b, false));
}
+ case llvm::Intrinsic::trap:
+ {
+ FnAttrs attrs;
+ attrs.set(FnAttrs::NoReturn);
+ attrs.set(FnAttrs::NoWrite);
+ return make_unique<FnCall>(*llvm_type2alive(i.getType()),
+ "", "#trap", move(attrs));
+ }
// do nothing intrinsics
case llvm::Intrinsic::dbg_addr:

ADD
tests/alive-tv/trap-and-plainfn-distinct-rev.srctgt.ll
+define void @src() {
+; trap and any readnone noreturn function should not be considered equivalent
+ call void @plain_fn() noreturn readnone
+ unreachable
+}
+
+define void @tgt() {
+ call void @llvm.trap()
+ unreachable
+}
+
+declare void @plain_fn()
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/trap-and-plainfn-distinct.srctgt.ll
+define void @src() {
+ call void @llvm.trap()
+ unreachable
+}
+
+define void @tgt() {
+; trap and any readnone noreturn function should not be considered equivalent
+ call void @plain_fn() noreturn readnone
+ unreachable
+}
+
+declare void @plain_fn()
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/trap-and-plainfn-distinct2-rev.srctgt.ll
+define void @src() {
+; trap and any readonly noreturn function should not be considered equivalent
+ call void @plain_fn() noreturn readonly
+ unreachable
+}
+
+define void @tgt() {
+ call void @llvm.trap()
+ unreachable
+}
+
+declare void @plain_fn()
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/trap-and-plainfn-distinct2.srctgt.ll
+define void @src() {
+ call void @llvm.trap()
+ unreachable
+}
+
+define void @tgt() {
+; trap and any readonly noreturn function should not be considered equivalent
+ call void @plain_fn() noreturn readonly
+ unreachable
+}
+
+declare void @plain_fn()
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/trap-and-plainfn-distinct3-rev.srctgt.ll
+define void @src() {
+; trap and any function should not be considered equivalent
+ call void @plain_fn()
+; NOTE: due to issue #375, using unreachable here will unexpectedly make this test pass, because plain_fn always returns.
+ ret void
+}
+
+define void @tgt() {
+ call void @llvm.trap()
+ unreachable
+}
+
+declare void @plain_fn()
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/trap-and-plainfn-distinct3.srctgt.ll
+define void @src() {
+ call void @llvm.trap()
+ unreachable
+}
+
+define void @tgt() {
+; trap and any function should not be considered equivalent
+ call void @plain_fn()
+ unreachable
+}
+
+declare void @plain_fn()
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/trap.srctgt.ll
+define void @src(i8* %dummyptr) {
+ call void @llvm.trap()
+ store i8 0, i8* %dummyptr
+ ret void
+}
+
+define void @tgt(i8* %dummyptr) {
+ call void @llvm.trap()
+ unreachable
+}
+
+declare void @llvm.trap()

ADD
tests/alive-tv/trap2.srctgt.ll
+define void @src() {
+ store i8 0, i8* null
+ ret void
+}
+
+define void @tgt() {
+ call void @llvm.trap()
+ unreachable
+}
+
+declare void @llvm.trap()

ADD
tests/alive-tv/trap3.srctgt.ll
+define void @src(i8* %ptr) {
+ store i8 0, i8* %ptr
+ call void @llvm.trap()
+ unreachable
+}
+
+define void @tgt(i8* %ptr) {
+ store i8 1, i8* %ptr
+ call void @llvm.trap()
+ unreachable
+}
+
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

ADD
tests/alive-tv/trap4.srctgt.ll
+define void @src(i8* %ptr) {
+ call void @llvm.trap()
+ unreachable
+}
+
+define void @tgt(i8* %ptr) {
+ unreachable
+}
+
+
+declare void @llvm.trap()
+
+; ERROR: Source is more defined than target

add support for llvm.trap (#624)