[RGT] Exercise both paths through a test
authorPaul Robinson <paul.robinson@sony.com>
Fri, 11 Feb 2022 18:41:24 +0000 (10:41 -0800)
committerPaul Robinson <paul.robinson@sony.com>
Fri, 11 Feb 2022 18:47:00 +0000 (10:47 -0800)
BitcastToGEP had an opaque/typed pointer decision point, make sure it
exercises both sides.

Found by the Rotten Green Tests project.

llvm/unittests/IR/ConstantsTest.cpp

index faf8502..98975dc 100644 (file)
@@ -469,9 +469,11 @@ TEST(ConstantsTest, BuildConstantDataVectors) {
   }
 }
 
-TEST(ConstantsTest, BitcastToGEP) {
+void bitcastToGEPHelper(bool useOpaquePointers) {
   LLVMContext Context;
   std::unique_ptr<Module> M(new Module("MyModule", Context));
+  if (useOpaquePointers)
+    Context.enableOpaquePointers();
 
   auto *i32 = Type::getInt32Ty(Context);
   auto *U = StructType::create(Context, "Unsized");
@@ -490,6 +492,11 @@ TEST(ConstantsTest, BitcastToGEP) {
   }
 }
 
+TEST(ConstantsTest, BitcastToGEP) {
+  bitcastToGEPHelper(true);
+  bitcastToGEPHelper(false);
+}
+
 bool foldFuncPtrAndConstToNull(LLVMContext &Context, Module *TheModule,
                                uint64_t AndValue,
                                MaybeAlign FunctionAlign = llvm::None) {