summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2017-04-27 18:39:08 +0000
committerEli Friedman <efriedma@codeaurora.org>2017-04-27 18:39:08 +0000
commit10ab923b320b5fcdb0b610ea4c3e40e5fd816d7e (patch)
tree8640a7b245d734ba9df7e18f6759299716385d55 /llvm/lib
parentf9ea176f0547bc8987348fe80502dd38dcaa3be0 (diff)
downloadbcm5719-llvm-10ab923b320b5fcdb0b610ea4c3e40e5fd816d7e.tar.gz
bcm5719-llvm-10ab923b320b5fcdb0b610ea4c3e40e5fd816d7e.zip
[GlobalOpt] Correctly update metadata when localizing a global.
Just calling dropAllReferences leaves pointers to the ConstantExpr behind, so we would eventually crash with a null pointer dereference. Differential Revision: https://reviews.llvm.org/D32551 llvm-svn: 301575
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index ae9d4ce11e0..bb2ebb46a4b 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1792,7 +1792,9 @@ static void makeAllConstantUsesInstructions(Constant *C) {
NewU->insertBefore(UI);
UI->replaceUsesOfWith(U, NewU);
}
- U->dropAllReferences();
+ // We've replaced all the uses, so destroy the constant. (destroyConstant
+ // will update value handles and metadata.)
+ U->destroyConstant();
}
}
OpenPOWER on IntegriCloud