[PATCH] D15798: Fix for Bug 24852 (crash with -debug -instcombine)

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 09:00:20 PST 2016


joker.eph added inline comments.

================
Comment at: unittests/IR/AsmWriterTest.cpp:49
@@ +48,3 @@
+  BI->insertAfter(Alloca1); // reparent so that it will be cleaned up
+}
+
----------------
It seems a bit overkill to me to have to create a function and multiple basic blocks, I'd expect this to be close to minimal:

```
// PR24852: Ensure that an instruction can be printed even when it
// has no parent.
LLVMContext Ctx;
auto Ty = Type::getInt32Ty(Ctx)
auto Undef = UndefValue::get(Ty);
std::unique_ptr<BinaryOperator> Add(BinaryOperator::CreateAdd(Undef, Undef));
Add.setDebugLoc(DebugLoc());
std::string S;
raw_string_ostream OS(S);
Add->print(OS)
ASSERT_EQ(OS.str(), "<insert correct string here>");
}
```




http://reviews.llvm.org/D15798





More information about the llvm-commits mailing list