From db4cafa6c40a4ea99643642dd5f2532bc0745eea Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 6 Apr 2017 19:39:24 +0000 Subject: [PATCH] Bitcode: Do not create FNENTRYs for aliases of functions. There doesn't seem to be any point in doing this. Differential Revision: https://reviews.llvm.org/D31691 llvm-svn: 299694 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 16 +++++----------- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 7 ------- llvm/test/Bitcode/thinlto-function-summary.ll | 2 +- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 23649e811ede..80a2c918916b 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1796,22 +1796,16 @@ Error BitcodeReader::parseValueSymbolTable(uint64_t Offset) { return Err; Value *V = ValOrErr.get(); - auto *GO = dyn_cast(V); - if (!GO) { - // If this is an alias, need to get the actual Function object - // it aliases, in order to set up the DeferredFunctionInfo entry below. - auto *GA = dyn_cast(V); - if (GA) - GO = GA->getBaseObject(); - assert(GO); - } + auto *F = dyn_cast(V); + // Ignore function offsets emitted for aliases of functions in older + // versions of LLVM. + if (!F) + break; // Note that we subtract 1 here because the offset is relative to one word // before the start of the identification or module block, which was // historically always the start of the regular bitcode header. uint64_t FuncWordOffset = Record[1] - 1; - Function *F = dyn_cast(GO); - assert(F); uint64_t FuncBitOffset = FuncWordOffset * 32; DeferredFunctionInfo[F] = FuncBitOffset + FuncBitcodeOffsetDelta; // Set the LastFunctionBlockBit to point to the last function block. diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index be1c5521018a..7b494d4b9dd4 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -2924,13 +2924,6 @@ void ModuleBitcodeWriter::writeValueSymbolTable( NameVals.push_back(VE.getValueID(Name.getValue())); Function *F = dyn_cast(Name.getValue()); - if (!F) { - // If value is an alias, need to get the aliased base object to - // see if it is a function. - auto *GA = dyn_cast(Name.getValue()); - if (GA && GA->getBaseObject()) - F = dyn_cast(GA->getBaseObject()); - } // VST_CODE_ENTRY: [valueid, namechar x N] // VST_CODE_FNENTRY: [valueid, funcoffset, namechar x N] diff --git a/llvm/test/Bitcode/thinlto-function-summary.ll b/llvm/test/Bitcode/thinlto-function-summary.ll index 594aaab566d1..ff61b7713f0f 100644 --- a/llvm/test/Bitcode/thinlto-function-summary.ll +++ b/llvm/test/Bitcode/thinlto-function-summary.ll @@ -17,7 +17,7 @@ ; BC-NEXT: record string = 'variadic' ; BC-NEXT: record string = 'foo' ; BC-NEXT: record string = 'bar' -; BC-NEXT: record string = 'f' +; BC-NEXT: record string = 'f' ; BC-NEXT: record string = 'anon.