[llvm] 2c736f6 - [InstCombine] Skip GEP of bitcast transform with opaque pointers
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 27 01:53:27 PST 2022
Author: Nikita Popov
Date: 2022-01-27T10:51:45+01:00
New Revision: 2c736f666b7a563c6f696957fdfa09edd971ac72
URL: https://github.com/llvm/llvm-project/commit/2c736f666b7a563c6f696957fdfa09edd971ac72
DIFF: https://github.com/llvm/llvm-project/commit/2c736f666b7a563c6f696957fdfa09edd971ac72.diff
LOG: [InstCombine] Skip GEP of bitcast transform with opaque pointers
This transform is fundamentally incompatible with opaque pointers.
Usually we would not hit it anyway because the bitcast is folded
away earlier, but due to worklist order it might survive until
here, so make sure we bail out explicitly.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 5c1192537b96..bdc72b736b85 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2082,10 +2082,15 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP,
// Note that we may have also stripped an address space cast in between.
Instruction *InstCombinerImpl::visitGEPOfBitcast(BitCastInst *BCI,
GetElementPtrInst &GEP) {
+ // With opaque pointers, there is no pointer element type we can use to
+ // adjust the GEP type.
+ PointerType *SrcType = cast<PointerType>(BCI->getSrcTy());
+ if (SrcType->isOpaque())
+ return nullptr;
+
Type *GEPEltType = GEP.getSourceElementType();
+ Type *SrcEltType = SrcType->getNonOpaquePointerElementType();
Value *SrcOp = BCI->getOperand(0);
- PointerType *SrcType = cast<PointerType>(BCI->getSrcTy());
- Type *SrcEltType = SrcType->getPointerElementType();
// GEP directly using the source operand if this GEP is accessing an element
// of a bitcasted pointer to vector or array of the same dimensions:
More information about the llvm-commits
mailing list