[clang] [llvm] [ThinLTO] Support dead RTTI data elimination under -fno-split-lto-unit (PR #126336)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 7 19:28:48 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 4294fe173e9696a4c090857fa0766cd44c1964dc 83b532a3382a07e472558b8813d43a6f51801423 --extensions h,cpp -- clang/test/CodeGenCXX/typeid-type-test.cpp llvm/include/llvm/Support/LibCXXABI.h llvm/include/llvm/Transforms/IPO/DeadRTTIElimination.h llvm/lib/Support/LibCXXABI.cpp llvm/lib/Transforms/IPO/DeadRTTIElimination.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp llvm/include/llvm/Analysis/TypeMetadataUtils.h llvm/include/llvm/AsmParser/LLParser.h llvm/include/llvm/AsmParser/LLToken.h llvm/include/llvm/Bitcode/LLVMBitCodes.h llvm/include/llvm/IR/ModuleSummaryIndex.h llvm/include/llvm/LTO/LTO.h llvm/lib/Analysis/ModuleSummaryAnalysis.cpp llvm/lib/Analysis/TypeMetadataUtils.cpp llvm/lib/AsmParser/LLLexer.cpp llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/LTO/LTO.cpp llvm/lib/LTO/LTOBackend.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h
index 085e6eaddc..73b8974b35 100644
--- a/llvm/include/llvm/LTO/LTO.h
+++ b/llvm/include/llvm/LTO/LTO.h
@@ -529,7 +529,7 @@ private:
Error checkPartiallySplit();
- std::string & getTargetTriple() { return TargetTriple; }
+ std::string &getTargetTriple() { return TargetTriple; }
void setTargetTriple(std::string TT) { TargetTriple = std::move(TT); }
diff --git a/llvm/include/llvm/Support/LibCXXABI.h b/llvm/include/llvm/Support/LibCXXABI.h
index 37f4b43f95..855aca5527 100644
--- a/llvm/include/llvm/Support/LibCXXABI.h
+++ b/llvm/include/llvm/Support/LibCXXABI.h
@@ -8,9 +8,9 @@ namespace llvm {
class CXXABI {
- virtual const char * getVTablePrefix() = 0;
- virtual const char * getTypeNamePrefix() = 0;
- virtual const char * getTypeInfoPrefix() = 0;
+ virtual const char *getVTablePrefix() = 0;
+ virtual const char *getTypeNamePrefix() = 0;
+ virtual const char *getTypeInfoPrefix() = 0;
public:
static std::unique_ptr<CXXABI> Create(Triple &TT);
@@ -32,9 +32,9 @@ public:
class Itanium final : public CXXABI {
- const char * getVTablePrefix() override { return "_ZTV"; }
- const char * getTypeNamePrefix() override { return "_ZTS"; }
- const char * getTypeInfoPrefix() override { return "_ZTI"; }
+ const char *getVTablePrefix() override { return "_ZTV"; }
+ const char *getTypeNamePrefix() override { return "_ZTS"; }
+ const char *getTypeInfoPrefix() override { return "_ZTI"; }
public:
virtual ~Itanium() {}
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index ec0aa81d05..a1778bf6e2 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -925,7 +925,8 @@ static bool hasNonVTableUsers(const User *U, CXXABI *ABI) {
}
// The virtual table type is either a struct of arrays. For example:
- // @vtable = constant { [3 x ptr] } { [3 x ptr] [ ptr null, ptr @rtti, ptr @vf] }
+ // @vtable = constant { [3 x ptr] } { [3 x ptr] [ ptr null, ptr @rtti, ptr
+ // @vf] }
//
// In this case, the user of @rtti is an anonymous ConstantArray.
// Therefore, if the user of the type information is anonymous,
@@ -959,8 +960,7 @@ static void analyzeRTTIVars(ModuleSummaryIndex &Index, const Module &M) {
continue;
if (hasNonVTableUsers(&GV, ABI.get())) {
- std::string TypeName =
- ABI->getTypeNameFromTypeInfo(GV.getName());
+ std::string TypeName = ABI->getTypeNameFromTypeInfo(GV.getName());
const GlobalVariable *TypeNameGV = M.getNamedGlobal(TypeName);
if (TypeNameGV)
Index.addTypeIdAccessed(TypeNameGV->getName());
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 49a0c31af5..a4c07acf96 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -53,9 +53,9 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO.h"
+#include "llvm/Transforms/IPO/DeadRTTIElimination.h"
#include "llvm/Transforms/IPO/MemProfContextDisambiguation.h"
#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
-#include "llvm/Transforms/IPO/DeadRTTIElimination.h"
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
#include "llvm/Transforms/Utils/SplitModule.h"
@@ -1931,7 +1931,6 @@ Error LTO::runThinLTO(
computeDeadSymbolsWithConstProp(ThinLTO.CombinedIndex, GUIDPreservedSymbols,
IsPrevailing, Conf.OptLevel > 0);
-
if (Conf.CombinedIndexHook &&
!Conf.CombinedIndexHook(ThinLTO.CombinedIndex, GUIDPreservedSymbols))
return Error::success();
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index d0566f0d00..c094d1f166 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -581,8 +581,8 @@ static void dropDeadSymbols(Module &Mod, const GVSummaryMapTy &DefinedGlobals,
// themselves when possible.
for (GlobalValue *GV : DeadGVs) {
GV->removeDeadConstantUsers();
- if (ABI && (ABI->isTypeInfo(GV->getName()) ||
- ABI->isTypeName(GV->getName()))) {
+ if (ABI &&
+ (ABI->isTypeInfo(GV->getName()) || ABI->isTypeName(GV->getName()))) {
GV->replaceAllUsesWith(
ConstantPointerNull::get(PointerType::get(Mod.getContext(), 0)));
GV->eraseFromParent();
diff --git a/llvm/lib/Transforms/IPO/DeadRTTIElimination.cpp b/llvm/lib/Transforms/IPO/DeadRTTIElimination.cpp
index bef2f52cd4..4566973f2e 100644
--- a/llvm/lib/Transforms/IPO/DeadRTTIElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadRTTIElimination.cpp
@@ -29,8 +29,7 @@ void DeadRTTIElimIndex::run() {
for (auto &VI : ExportSummary) {
StringRef GVSName = VI.second.U.Name;
- if (!ABI->isVTable(GVSName) ||
- TypeIdSlotMayLiveVTables.contains(GVSName) ||
+ if (!ABI->isVTable(GVSName) || TypeIdSlotMayLiveVTables.contains(GVSName) ||
VI.second.SummaryList.empty())
continue;
``````````
</details>
https://github.com/llvm/llvm-project/pull/126336
More information about the cfe-commits
mailing list