[llvm] [ORC] Add AutoImportGenerator for COFF dllimport auto-import (PR #203914)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 07:19:39 PDT 2026


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 origin/main HEAD --extensions h,cpp -- llvm/unittests/ExecutionEngine/Orc/AutoImportGeneratorTest.cpp llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp llvm/tools/llvm-jitlink/llvm-jitlink.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index f77f2a35d..b217521b6 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -627,7 +627,8 @@ Error AutoImportGenerator::tryToGenerate(LookupState &LS, LookupKind K,
     std::string Tmp = Base.str();
     if (void *P = Dylib.getAddressOfSymbol(Tmp.c_str()))
       Resolved[BaseName] = {ExecutorAddr::fromPtr(P),
-                            JITSymbolFlags::Exported | JITSymbolFlags::Callable};
+                            JITSymbolFlags::Exported |
+                                JITSymbolFlags::Callable};
   }
 
   if (Resolved.empty())
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 2b280cae2..65203cc15 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1990,9 +1990,9 @@ static Error addAutoImportGenerators(Session &S) {
   // so it is incompatible with out-of-process execution.
   if (OutOfProcessExecutor.getNumOccurrences() ||
       OutOfProcessExecutorConnect.getNumOccurrences())
-    return make_error<StringError>(
-        "-" + AutoImportDylibs.ArgStr + " requires in-process execution",
-        inconvertibleErrorCode());
+    return make_error<StringError>("-" + AutoImportDylibs.ArgStr +
+                                       " requires in-process execution",
+                                   inconvertibleErrorCode());
 
   for (const auto &LibPath : AutoImportDylibs) {
     auto G = orc::AutoImportGenerator::Load(S.ES, *S.ObjLayer, LibPath.c_str());
diff --git a/llvm/unittests/ExecutionEngine/Orc/AutoImportGeneratorTest.cpp b/llvm/unittests/ExecutionEngine/Orc/AutoImportGeneratorTest.cpp
index 8f56217b9..e6b2d19bc 100644
--- a/llvm/unittests/ExecutionEngine/Orc/AutoImportGeneratorTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/AutoImportGeneratorTest.cpp
@@ -25,10 +25,11 @@
 //
 // The tests execute the generator's thunk in-process, so an x86_64 host is
 // required (the thunk is native code we call); they import a no-argument,
-// integer-returning function the host exports -- kernel32!GetCurrentProcessId on
-// Windows, libc getpid on POSIX. Such functions are ABI-safe to call regardless
-// of the stub graph's calling convention: no argument registers to mismatch,
-// and the result comes back in EAX under both the Win64 and SysV ABIs.
+// integer-returning function the host exports -- kernel32!GetCurrentProcessId
+// on Windows, libc getpid on POSIX. Such functions are ABI-safe to call
+// regardless of the stub graph's calling convention: no argument registers to
+// mismatch, and the result comes back in EAX under both the Win64 and SysV
+// ABIs.
 #if defined(__x86_64__) || defined(_M_X64)
 
 #if defined(_WIN32)
@@ -99,7 +100,8 @@ TEST_F(AutoImportGeneratorTest, SynthesizesImpSlotAndThunk) {
   void *RealSym1 = realAddr(AIG_SYM1);
   ASSERT_NE(RealSym1, nullptr);
 
-  auto AIGOrErr = AutoImportGenerator::Load(ES, ObjLinkingLayer, AIG_IMPORT_LIB);
+  auto AIGOrErr =
+      AutoImportGenerator::Load(ES, ObjLinkingLayer, AIG_IMPORT_LIB);
   ASSERT_THAT_EXPECTED(AIGOrErr, Succeeded());
   JD.addGenerator(std::move(*AIGOrErr));
 
@@ -128,7 +130,8 @@ TEST_F(AutoImportGeneratorTest, UnexportedSymbolFailsToLink) {
   // report so it does not pollute the test log.
   ES.setErrorReporter(consumeError);
 
-  auto AIGOrErr = AutoImportGenerator::Load(ES, ObjLinkingLayer, AIG_IMPORT_LIB);
+  auto AIGOrErr =
+      AutoImportGenerator::Load(ES, ObjLinkingLayer, AIG_IMPORT_LIB);
   ASSERT_THAT_EXPECTED(AIGOrErr, Succeeded());
   JD.addGenerator(std::move(*AIGOrErr));
 
@@ -141,7 +144,8 @@ TEST_F(AutoImportGeneratorTest, UnexportedSymbolFailsToLink) {
 // ResourceTracker that the client can reclaim in one step; a subsequent import
 // transparently starts a fresh tracker.
 TEST_F(AutoImportGeneratorTest, StubsResourceTrackerLifecycle) {
-  auto AIGOrErr = AutoImportGenerator::Load(ES, ObjLinkingLayer, AIG_IMPORT_LIB);
+  auto AIGOrErr =
+      AutoImportGenerator::Load(ES, ObjLinkingLayer, AIG_IMPORT_LIB);
   ASSERT_THAT_EXPECTED(AIGOrErr, Succeeded());
   AutoImportGenerator &AIG = **AIGOrErr;
   JD.addGenerator(std::move(*AIGOrErr));

``````````

</details>


https://github.com/llvm/llvm-project/pull/203914


More information about the llvm-commits mailing list