llvm2alive: add support for poison
MODIFY
llvm_util/utils.cpp
llvm_util/utils.cpp
@@ -276,6 +276,13 @@ Value* get_operand(llvm::Value *v,
RETURN_CACHE(ret);
}
+ if (isa<llvm::PoisonValue>(v)) {
+ auto val = make_unique<PoisonValue>(*ty);
+ auto ret = val.get();
+ current_fn->addConstant(move(val));
+ RETURN_CACHE(ret);
+ }
+
if (isa<llvm::UndefValue>(v)) {
auto val = make_unique<UndefValue>(*ty);
auto ret = val.get();

ADD
tests/alive-tv/poison-fail.srctgt.ll
+define i32 @src() {
+ ret i32 0
+}
+
+define i32 @tgt() {
+ ret i32 poison
+}
+
+; ERROR: Target is more poisonous than source

ADD
tests/alive-tv/poison.srctgt.ll
+define i32 @src() {
+ ret i32 poison
+}
+
+define i32 @tgt() {
+ ret i32 0
+}

ADD
tests/alive-tv/undef/poison-fail.srctgt.ll
+define i32 @src() {
+ ret i32 undef
+}
+
+define i32 @tgt() {
+ ret i32 poison
+}
+
+; ERROR: Target is more poisonous than source

ADD
tests/alive-tv/undef/poison.srctgt.ll
+define i32 @src() {
+ ret i32 poison
+}
+
+define i32 @tgt() {
+ ret i32 undef
+}

llvm2alive: add support for poison (#591)