[llvm] 5035ea5 - Orc: Compute the JIT DataLayout from the triple and ABI (#226316)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 23:07:42 PDT 2026


Author: Matt Arsenault
Date: 2026-09-25T08:07:35+02:00
New Revision: 5035ea5e1b16ba89eba76994ef50bdf0ff439840

URL: https://github.com/llvm/llvm-project/commit/5035ea5e1b16ba89eba76994ef50bdf0ff439840
DIFF: https://github.com/llvm/llvm-project/commit/5035ea5e1b16ba89eba76994ef50bdf0ff439840.diff

LOG: Orc: Compute the JIT DataLayout from the triple and ABI (#226316)

getDefaultDataLayoutForTarget was constructing a throwaway TargetMachine
purely to read back its cached DataLayout. Directly compute it from
the triple and ABI name instead.

Co-Authored-By: Claude Opus 5 <noreply at anthropic.com>

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
index 08a17dbee8131..9ba9cc36fd4e4 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_EXECUTIONENGINE_ORC_JITTARGETMACHINEBUILDER_H
 #define LLVM_EXECUTIONENGINE_ORC_JITTARGETMACHINEBUILDER_H
 
+#include "llvm/IR/DataLayout.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
@@ -62,14 +63,11 @@ class JITTargetMachineBuilder {
 
   /// Get the default DataLayout for the target.
   ///
-  /// Note: This is reasonably expensive, as it creates a temporary
-  /// TargetMachine instance under the hood. It is only suitable for use during
+  /// Note: This is reasonably expensive. It is only suitable for use during
   /// JIT setup.
-  Expected<DataLayout> getDefaultDataLayoutForTarget() {
-    auto TM = createTargetMachine();
-    if (!TM)
-      return TM.takeError();
-    return (*TM)->createDataLayout();
+  Expected<DataLayout> getDefaultDataLayoutForTarget() const {
+    return DataLayout::parse(
+        TT.computeDataLayout(Options.MCOptions.getABIName()));
   }
 
   /// Set the CPU string.


        


More information about the llvm-commits mailing list