[llvm] ed02f52 - Fix unstable SmallPtrSet iteration issues due to collectUsedGlobalVariables
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 23 16:09:15 PST 2021
Author: Fangrui Song
Date: 2021-02-23T16:09:05-08:00
New Revision: ed02f52d288fb4d8f9049868afa6af84a980cbc3
URL: https://github.com/llvm/llvm-project/commit/ed02f52d288fb4d8f9049868afa6af84a980cbc3
DIFF: https://github.com/llvm/llvm-project/commit/ed02f52d288fb4d8f9049868afa6af84a980cbc3.diff
LOG: 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
Added:
Modified:
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index c555b67351957..dd47e220d9e7f 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -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) {
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index de23456a53477..804d1065a5e11 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -336,7 +336,7 @@ struct ICallBranchFunnel final
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(
More information about the llvm-commits
mailing list