diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2025-06-04 12:37:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-04 12:37:30 +0800 |
commit | 7e1fa09ce2a228c949ce4490c98f2c73ed8ada00 (patch) | |
tree | efa3f6575ae315a1569f72a942d4fc7f0fbffafb /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | dc513fa8dc361cb71a2c607f2bd75d812f31459b (diff) | |
download | llvm-7e1fa09ce2a228c949ce4490c98f2c73ed8ada00.zip llvm-7e1fa09ce2a228c949ce4490c98f2c73ed8ada00.tar.gz llvm-7e1fa09ce2a228c949ce4490c98f2c73ed8ada00.tar.bz2 |
[SimplifyCFG] Bail out on vector GEPs in `passingValueIsAlwaysUndefined` (#142526)
Closes https://github.com/llvm/llvm-project/issues/142522.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 245d0c4..e221022 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -8108,6 +8108,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) { /// Check if passing a value to an instruction will cause undefined behavior. static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValueMayBeModified) { + assert(V->getType() == I->getType() && "Mismatched types"); Constant *C = dyn_cast<Constant>(V); if (!C) return false; @@ -8165,6 +8166,10 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValu // Look through GEPs. A load from a GEP derived from NULL is still undefined if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User)) if (GEP->getPointerOperand() == I) { + // The type of GEP may differ from the type of base pointer. + // Bail out on vector GEPs, as they are not handled by other checks. + if (GEP->getType()->isVectorTy()) + return false; // The current base address is null, there are four cases to consider: // getelementptr (TY, null, 0) -> null // getelementptr (TY, null, not zero) -> may be modified |