[polly] r336350 - [CodeGen] Fix potential null pointer dereference. NFC.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 5 06:44:50 PDT 2018
Author: meinersbur
Date: Thu Jul 5 06:44:50 2018
New Revision: 336350
URL: http://llvm.org/viewvc/llvm-project?rev=336350&view=rev
Log:
[CodeGen] Fix potential null pointer dereference. NFC.
ScalarEvolution::getSCEV dereferences its argument, s.t. passing nullptr
leads to undefined behaviour.
Check for nullptr before calling it instead of checking its argument
afterwards.
Modified:
polly/trunk/lib/CodeGen/IRBuilder.cpp
Modified: polly/trunk/lib/CodeGen/IRBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IRBuilder.cpp?rev=336350&r1=336349&r2=336350&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IRBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IRBuilder.cpp Thu Jul 5 06:44:50 2018
@@ -160,11 +160,13 @@ static llvm::Value *getMemAccInstPointer
void ScopAnnotator::annotateSecondLevel(llvm::Instruction *Inst,
llvm::Value *BasePtr) {
- auto *PtrSCEV = SE->getSCEV(getMemAccInstPointerOperand(Inst));
+ Value *Ptr = getMemAccInstPointerOperand(Inst);
+ if (!Ptr)
+ return;
+
+ auto *PtrSCEV = SE->getSCEV(Ptr);
auto *BasePtrSCEV = SE->getPointerBase(PtrSCEV);
- if (!PtrSCEV)
- return;
auto SecondLevelAliasScope = SecondLevelAliasScopeMap.lookup(PtrSCEV);
auto SecondLevelOtherAliasScopeList =
SecondLevelOtherAliasScopeListMap.lookup(PtrSCEV);
More information about the llvm-commits
mailing list