1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Fix unstable SmallPtrSet iteration issues due to collectUsedGlobalVariables

While here, decrease inline element counts from 8 to 4. See D97128 for the choice.

Depends on D97128 (which added a new SmallVecImpl overload for collectUsedGlobalVariables).

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D97139
This commit is contained in:
Fangrui Song 2021-02-23 12:32:08 -08:00
parent 7d33c2a5f8
commit 6d06e5c821
2 changed files with 4 additions and 5 deletions

View File

@ -4855,7 +4855,7 @@ void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
const std::vector<uint8_t> &CmdArgs) {
// Save llvm.compiler.used and remove it.
SmallVector<Constant *, 2> UsedArray;
SmallPtrSet<GlobalValue *, 4> UsedGlobals;
SmallVector<GlobalValue *, 4> UsedGlobals;
Type *UsedElementType = Type::getInt8Ty(M.getContext())->getPointerTo(0);
GlobalVariable *Used = collectUsedGlobalVariables(M, UsedGlobals, true);
for (auto *GV : UsedGlobals) {

View File

@ -336,7 +336,7 @@ private:
struct ScopedSaveAliaseesAndUsed {
Module &M;
SmallPtrSet<GlobalValue *, 16> Used, CompilerUsed;
SmallVector<GlobalValue *, 4> Used, CompilerUsed;
std::vector<std::pair<GlobalIndirectSymbol *, Function *>> FunctionAliases;
ScopedSaveAliaseesAndUsed(Module &M) : M(M) {
@ -367,9 +367,8 @@ struct ScopedSaveAliaseesAndUsed {
}
~ScopedSaveAliaseesAndUsed() {
appendToUsed(M, std::vector<GlobalValue *>(Used.begin(), Used.end()));
appendToCompilerUsed(M, std::vector<GlobalValue *>(CompilerUsed.begin(),
CompilerUsed.end()));
appendToUsed(M, Used);
appendToCompilerUsed(M, CompilerUsed);
for (auto P : FunctionAliases)
P.first->setIndirectSymbol(