Skip to content

[MLIR] Avoid #include OMPIRBuilder.h #151302

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

Merged
merged 4 commits into from
Jul 30, 2025

Conversation

Meinersbur
Copy link
Member

#include "llvm/Frontend/OpenMP/OMPIRBuilder.h" can be replaced with forward-declarations of OpenMPIRBuilder and CanonicalLoopInfo. This also avoids a dependency to omp_gen of the LLVMFrontendOpenMP component which is included indirectly in OMPIRBuilder.h.

Since its inclusion in #147069, additional indirect dependencies on headers included by OMPIRBuilder.h were introduced as well. These are now included directly.

Reported-by: fabrizio-indirli

See #147069 (comment)

@llvmbot
Copy link
Member

llvmbot commented Jul 30, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-llvm

Author: Michael Kruse (Meinersbur)

Changes

#include "llvm/Frontend/OpenMP/OMPIRBuilder.h" can be replaced with forward-declarations of OpenMPIRBuilder and CanonicalLoopInfo. This also avoids a dependency to omp_gen of the LLVMFrontendOpenMP component which is included indirectly in OMPIRBuilder.h.

Since its inclusion in #147069, additional indirect dependencies on headers included by OMPIRBuilder.h were introduced as well. These are now included directly.

Reported-by: fabrizio-indirli

See #147069 (comment)


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

2 Files Affected:

  • (modified) mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h (+2-1)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp (+1)
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index f3f73f49f199a..f0bd5245a7d41 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -25,11 +25,12 @@
 #include "mlir/Target/LLVMIR/TypeToLLVM.h"
 
 #include "llvm/ADT/SetVector.h"
-#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/FPEnv.h"
+#include "llvm/IR/Module.h"
 
 namespace llvm {
 class BasicBlock;
+class CanonicalLoopInfo;
 class Function;
 class IRBuilderBase;
 class OpenMPIRBuilder;
diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index cffe310c468c4..52cd0cec0c800 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -30,6 +30,7 @@
 #include "mlir/IR/Types.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include "llvm/IR/IRBuilder.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"

@Meinersbur Meinersbur merged commit ffcee26 into llvm:main Jul 30, 2025
9 checks passed
Meinersbur added a commit that referenced this pull request Jul 30, 2025
The sanizer bots are reporting a missing declaration:

```
In file included from /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp:17:
In file included from /home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h:26:
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h:318:34: error: no type named 'CallBase' in namespace 'llvm'
  318 |                            llvm::CallBase *call,
      |                            ~~~~~~^
1 error generated.
```

https://lab.llvm.org/buildbot/#/builders/94/builds/9340
https://lab.llvm.org/buildbot/#/builders/24/builds/11029
https://lab.llvm.org/buildbot/#/builders/169/builds/13454
https://lab.llvm.org/buildbot/#/builders/25/builds/10250

PR #151302 removed some indirect header #includes which had to be
includes explicitly. I do not know why this particular error only occurs
with the sanitizer buildbots.

Fix by adding a forward declaration.
@RoboTux
Copy link
Contributor

RoboTux commented Jul 31, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants