[llvm-commits] [llvm] r62918 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Torok Edwin edwintorok at gmail.com
Sat Jan 24 03:31:04 PST 2009


Author: edwin
Date: Sat Jan 24 05:30:49 2009
New Revision: 62918

URL: http://llvm.org/viewvc/llvm-project?rev=62918&view=rev
Log:
void* is represented as pointer to empty struct {}.
Thus we need to check whether the struct is empty before trying to index into
it. This fixes PR3381.

Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=62918&r1=62917&r2=62918&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sat Jan 24 05:30:49 2009
@@ -11170,6 +11170,8 @@
     
     while (1) {
       if (const StructType *STy = dyn_cast<StructType>(SrcPTy)) {
+        if (!STy->getNumElements()) /* Void is represented as {} */
+          break;
         NewGEPIndices.push_back(Zero);
         SrcPTy = STy->getElementType(0);
       } else if (const ArrayType *ATy = dyn_cast<ArrayType>(SrcPTy)) {





More information about the llvm-commits mailing list