[clang] [llvm] Tentative fix for not removing newly internal functions (PR #106146)
Greg Roth via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 14:47:47 PDT 2024
================
@@ -18,19 +18,20 @@
using namespace llvm;
static bool finalizeLinkage(Module &M) {
- SmallPtrSet<Function *, 8> EntriesAndExports;
+ SmallPtrSet<Function *, 8> Funcs;
// Find all entry points and export functions
for (Function &EF : M.functions()) {
- if (!EF.hasFnAttribute("hlsl.shader") && !EF.hasFnAttribute("hlsl.export"))
+ if (EF.hasFnAttribute("hlsl.shader") || EF.hasFnAttribute("hlsl.export"))
continue;
- EntriesAndExports.insert(&EF);
+ Funcs.insert(&EF);
}
- for (Function &F : M.functions()) {
- if (F.getLinkage() == GlobalValue::ExternalLinkage &&
- !EntriesAndExports.contains(&F)) {
- F.setLinkage(GlobalValue::InternalLinkage);
+ for (Function *F : Funcs) {
+ if (F->getLinkage() == GlobalValue::ExternalLinkage) {
+ F->setLinkage(GlobalValue::InternalLinkage);
+ if (F->isDefTriviallyDead())
----------------
pow2clk wrote:
Not sure if this should also check that the alwaysinline attribute is set like AlwaysInliner does: https://github.com/llvm/llvm-project/blob/2a5ac9d9aff91406b0c58629df3a4e4dce87738c/llvm/lib/Transforms/IPO/AlwaysInliner.cpp#L89
We should always inline functions that are marked internal, so I don't know of a case where it wouldn't be set.
https://github.com/llvm/llvm-project/pull/106146
More information about the cfe-commits
mailing list