summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2017-01-20 23:25:17 +0000
committerTim Northover <tnorthover@apple.com>2017-01-20 23:25:17 +0000
commit7f3ad2e07b3bae3f1801ae5872714e8bd86f3589 (patch)
tree72fa7bd6c00f1b80d140e8f06752879ee65e66f9 /llvm/lib/CodeGen
parent67addbcacf17afd4ec38f612506f678449f9aae1 (diff)
downloadbcm5719-llvm-7f3ad2e07b3bae3f1801ae5872714e8bd86f3589.tar.gz
bcm5719-llvm-7f3ad2e07b3bae3f1801ae5872714e8bd86f3589.zip
GlobalISel: prevent heap use-after-free when looking up VReg.
Translating the constant can create more VRegs, which can invalidate the reference into the DenseMap. So we have to look up the value again after all that's happened. llvm-svn: 292675
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 1cfe5345c65..ba6db371139 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -81,7 +81,9 @@ unsigned IRTranslator::getOrCreateVReg(const Value &Val) {
}
}
}
- return ValReg;
+
+ // Look Val up again in case the reference has been invalidated since.
+ return ValToVReg[&Val];
}
int IRTranslator::getOrCreateFrameIndex(const AllocaInst &AI) {
OpenPOWER on IntegriCloud