[llvm] d2495b6 - [RGT] Exercise both paths through a test

Paul Robinson via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 11 10:47:33 PST 2022


Author: Paul Robinson
Date: 2022-02-11T10:47:00-08:00
New Revision: d2495b69f29d26561181402ca51ee16ab6c96ec2

URL: https://github.com/llvm/llvm-project/commit/d2495b69f29d26561181402ca51ee16ab6c96ec2
DIFF: https://github.com/llvm/llvm-project/commit/d2495b69f29d26561181402ca51ee16ab6c96ec2.diff

LOG: [RGT] Exercise both paths through a test

BitcastToGEP had an opaque/typed pointer decision point, make sure it
exercises both sides.

Found by the Rotten Green Tests project.

Added: 
    

Modified: 
    llvm/unittests/IR/ConstantsTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp
index faf8502b19df3..98975dcf18c89 100644
--- a/llvm/unittests/IR/ConstantsTest.cpp
+++ b/llvm/unittests/IR/ConstantsTest.cpp
@@ -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) {


        


More information about the llvm-commits mailing list