From a5c3afd0e68afcca5dfabaa0850d88735e9f9493 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 1 Nov 2012 13:55:17 -0700 Subject: Do not dematerialize functions with referencing blockAddress constants When reduce-memory-footprint is enabled, llc attempts to dematerialize all functions once they are codegen'ed. However functions which have global blockAddress constants referring to their BBs need to be kept around, or the references will be replaced with bogus constants and not relocated. BUG=none TEST=computed_goto_test (easily reproducible by enabling -streaming-bitcde for ordinary llc) Review URL: https://codereview.chromium.org/11364028 --- lib/Bitcode/Reader/BitcodeReader.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index ff1f35e190..96b3925ed7 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2839,6 +2839,16 @@ bool BitcodeReader::isDematerializable(const GlobalValue *GV) const { const Function *F = dyn_cast(GV); if (!F || F->isDeclaration()) return false; + // @LOCALMOD-START + // Don't dematerialize functions with BBs which have their address taken; + // it will cause any referencing blockAddress constants to also be destroyed, + // but because they are GVs, they need to stay around until PassManager + // finalization. + for (Function::const_iterator BB = F->begin(); BB != F->end(); ++BB) { + if (BB->hasAddressTaken()) + return false; + } + // @LOCALMOD-END return DeferredFunctionInfo.count(const_cast(F)); } -- cgit v1.2.3-18-g5258