summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2018-07-05 13:44:50 +0000
committerMichael Kruse <llvm@meinersbur.de>2018-07-05 13:44:50 +0000
commit9f305371d980d5635a1d08d1517ded119a35bb57 (patch)
treeea07e0caf1facf15b971242e8582cda36cb29f7a /polly/lib/CodeGen
parent8ac85d9a11c8cfb0f5c827b47394883ef8b34896 (diff)
downloadbcm5719-llvm-9f305371d980d5635a1d08d1517ded119a35bb57.tar.gz
bcm5719-llvm-9f305371d980d5635a1d08d1517ded119a35bb57.zip
[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. llvm-svn: 336350
Diffstat (limited to 'polly/lib/CodeGen')
-rw-r--r--polly/lib/CodeGen/IRBuilder.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/polly/lib/CodeGen/IRBuilder.cpp b/polly/lib/CodeGen/IRBuilder.cpp
index 3efa7c88389..4c94b9bae87 100644
--- a/polly/lib/CodeGen/IRBuilder.cpp
+++ b/polly/lib/CodeGen/IRBuilder.cpp
@@ -160,11 +160,13 @@ static llvm::Value *getMemAccInstPointerOperand(Instruction *Inst) {
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);
OpenPOWER on IntegriCloud