[llvm] 8d734fd - Added better datalayout incompatible error message (#191862)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 14:47:37 PDT 2026


Author: Stefan Mada
Date: 2026-04-14T14:47:31-07:00
New Revision: 8d734fdae5f55add3dcc67f6ad4ce8d6d8f7af69

URL: https://github.com/llvm/llvm-project/commit/8d734fdae5f55add3dcc67f6ad4ce8d6d8f7af69
DIFF: https://github.com/llvm/llvm-project/commit/8d734fdae5f55add3dcc67f6ad4ce8d6d8f7af69.diff

LOG: Added better datalayout incompatible error message (#191862)

The existing datalayout incompatible error assert does not help with
debugging, as it does not print the datalayouts in question.

This change makes this failure give more useful information.

Added: 
    

Modified: 
    llvm/lib/CodeGen/MachineFunction.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index a2dd9c425370c..f74ebf2d2c52b 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -63,6 +63,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/DOTGraphTraits.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/GraphWriter.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
@@ -234,9 +235,14 @@ void MachineFunction::init() {
     WasmEHInfo = new (Allocator) WasmEHFuncInfo();
   }
 
-  assert(Target.isCompatibleDataLayout(getDataLayout()) &&
-         "Can't create a MachineFunction using a Module with a "
-         "Target-incompatible DataLayout attached\n");
+  if (!Target.isCompatibleDataLayout(getDataLayout())) {
+    report_fatal_error(
+        formatv("Can't create a MachineFunction using a Module with a "
+                "Target-incompatible DataLayout attached\n  Target "
+                "DataLayout: {0}\n  Module DataLayout: {1}\n",
+                Target.createDataLayout().getStringRepresentation(),
+                getDataLayout().getStringRepresentation()));
+  }
 
   PSVManager = std::make_unique<PseudoSourceValueManager>(getTarget());
 }


        


More information about the llvm-commits mailing list