Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM] Fix missing includes for function declarations that will be needed for explicit symbol visibility #103900

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

fsfod
Copy link
Contributor

@fsfod fsfod commented Aug 14, 2024

In multiple source files function definitions never sees there declaration in a header because its never included causing linker errors when explicit symbol visibility macros\dllexport are added to the declarations.

Most of these were originally found by @tstellar in #67502

TargetRegistry.h is needed in MCExternalSymbolizer.cpp for createMCSymbolizer
Analysis/Passes.h is needed in LazyValueInfo.cpp and RegionInfo.cpp for createLazyValueInfoPassin and createRegionInfoPass
Transforms/Scalar.h is needed in SpeculativeExecution.cpp for createSpeculativeExecutionPass

…eded for explicit symbol visibility

In multiple source files function definitions never sees there declaration in a
header because its never included causing linker errors when explicit symbol visibility
macros are added to the declarations.

TargetRegistry.h is needed in MCExternalSymbolizer.cpp for createMCSymbolizer
Analysis/Passes.h is needed in LazyValueInfo.cpp and RegionInfo.cpp for createLazyValueInfoPassin and createRegionInfoPass
Transforms/Scalar.h is needed in SpeculativeExecution.cpp for createSpeculativeExecutionPass
@fsfod fsfod requested a review from nikic as a code owner August 14, 2024 12:51
@llvmbot
Copy link
Member

llvmbot commented Aug 14, 2024

@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-llvm-analysis

@llvm/pr-subscribers-mc

Author: Thomas Fransham (fsfod)

Changes

In multiple source files function definitions never sees there declaration in a header because its never included causing linker errors when explicit symbol visibility macros\dllexport are added to the declarations.

Most of these were originally found by @tstellar in #67502

TargetRegistry.h is needed in MCExternalSymbolizer.cpp for createMCSymbolizer
Analysis/Passes.h is needed in LazyValueInfo.cpp and RegionInfo.cpp for createLazyValueInfoPassin and createRegionInfoPass
Transforms/Scalar.h is needed in SpeculativeExecution.cpp for createSpeculativeExecutionPass


Full diff: https://github.com/llvm/llvm-project/pull/103900.diff

4 Files Affected:

  • (modified) llvm/lib/Analysis/LazyValueInfo.cpp (+1)
  • (modified) llvm/lib/Analysis/RegionInfo.cpp (+1)
  • (modified) llvm/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp (+1)
  • (modified) llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp (+1)
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 310a7eafc81500..47d3dac73083ee 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/InstructionSimplify.h"
+#include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/ValueLattice.h"
 #include "llvm/Analysis/ValueTracking.h"
diff --git a/llvm/lib/Analysis/RegionInfo.cpp b/llvm/lib/Analysis/RegionInfo.cpp
index 9be23a374eca5a..15257b4a9a926f 100644
--- a/llvm/lib/Analysis/RegionInfo.cpp
+++ b/llvm/lib/Analysis/RegionInfo.cpp
@@ -15,6 +15,7 @@
 #ifndef NDEBUG
 #include "llvm/Analysis/RegionPrinter.h"
 #endif
+#include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/RegionInfoImpl.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Function.h"
diff --git a/llvm/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp b/llvm/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
index e3f4cdd21557e2..52cf1ff1376d08 100644
--- a/llvm/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
+++ b/llvm/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
@@ -10,6 +10,7 @@
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstring>
 
diff --git a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
index ed9c1828ce06a2..6e1bb892f62018 100644
--- a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -71,6 +71,7 @@
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Transforms/Scalar.h"
 
 using namespace llvm;
 

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

(Can also solve most of these by removing no longer needed LegacyPM passes, but it's fine to land this in the meantime.)

@fsfod
Copy link
Contributor Author

fsfod commented Aug 14, 2024

I don't have commit access if you want to merge it for me.

@nikic nikic merged commit 8345289 into llvm:main Aug 14, 2024
12 checks passed
@fsfod fsfod deleted the include-fixes branch August 14, 2024 16:45
@efriedma-quic
Copy link
Collaborator

Should we consider enabling -Wmissing-prototypes so this doesn't regress in the future?

@nikic
Copy link
Contributor

nikic commented Aug 14, 2024

Should we consider enabling -Wmissing-prototypes so this doesn't regress in the future?

Assuming you mean -Wmissing-declarations, that does sound like a good idea to me... Would also catch missing static modifiers on functions.

bwendling pushed a commit to bwendling/llvm-project that referenced this pull request Aug 15, 2024
…eded for explicit symbol visibility (llvm#103900)

In multiple source files function definitions never sees there
declaration in a header because its never included causing linker errors
when explicit symbol visibility macros\dllexport are added to the
declarations.

Most of these were originally found by @tstellar in
llvm#67502

TargetRegistry.h is needed in MCExternalSymbolizer.cpp for
createMCSymbolizer
Analysis/Passes.h is needed in LazyValueInfo.cpp and RegionInfo.cpp for
createLazyValueInfoPassin and createRegionInfoPass
Transforms/Scalar.h is needed in SpeculativeExecution.cpp for
createSpeculativeExecutionPass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants