[llvm] 8026eba - unittests: Compute DataLayout from the triple, not the TargetMachine (#224249)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 03:05:32 PDT 2026


Author: Matt Arsenault
Date: 2026-09-23T12:05:25+02:00
New Revision: 8026eba98cb3a41f4dc7cde86d24ff9de01ce846

URL: https://github.com/llvm/llvm-project/commit/8026eba98cb3a41f4dc7cde86d24ff9de01ce846
DIFF: https://github.com/llvm/llvm-project/commit/8026eba98cb3a41f4dc7cde86d24ff9de01ce846.diff

LOG: unittests: Compute DataLayout from the triple, not the TargetMachine (#224249)

Eventually createDataLayout should be removed, so migrate these uses.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>

Added: 
    

Modified: 
    llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp
    llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp
    llvm/unittests/CodeGen/CodeGenTestBase.h
    llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
    llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
    llvm/unittests/CodeGen/GlobalISel/IRTranslatorBF16Test.cpp
    llvm/unittests/CodeGen/MIR2VecTest.cpp
    llvm/unittests/CodeGen/MachineModuleInfoTest.cpp
    llvm/unittests/CodeGen/PassManagerTest.cpp
    llvm/unittests/CodeGen/SelectionDAGTestBase.h
    llvm/unittests/CodeGen/X86MCInstLowerTest.cpp
    llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
    llvm/unittests/MI/LiveIntervalTest.cpp
    llvm/unittests/MIR/MachineMetadata.cpp
    llvm/unittests/MIR/MachineStableHashTest.cpp
    llvm/unittests/Target/AArch64/AArch64RegisterInfoTest.cpp
    llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
    llvm/unittests/Target/AArch64/InstSizes.cpp
    llvm/unittests/Target/AMDGPU/AMDGPUMCExprTest.cpp
    llvm/unittests/Target/AMDGPU/CSETest.cpp
    llvm/unittests/Target/AMDGPU/ExecMayBeModifiedBeforeAnyUse.cpp
    llvm/unittests/Target/AMDGPU/PALMetadata.cpp
    llvm/unittests/Target/ARM/ARMSelectionDAGTest.cpp
    llvm/unittests/Target/ARM/InstSizes.cpp
    llvm/unittests/Target/LoongArch/InstSizes.cpp
    llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
    llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp
    llvm/unittests/Target/SPIRV/SPIRVGlobalRegistryTests.cpp
    llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp
    llvm/unittests/Target/X86/MachineSizeOptsTest.cpp
    llvm/unittests/Target/X86/X86SelectionDAGTest.cpp
    llvm/unittests/tools/llvm-exegesis/X86/SnippetRepetitorTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp b/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp
index 08a32390140d60..c7cbd95fbca7af 100644
--- a/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp
+++ b/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp
@@ -66,7 +66,7 @@ class AMDGPUSelectionDAGTest : public testing::Test {
     LLVMContext Context;
     std::unique_ptr<Module> M(new Module("TestModule", Context));
     M->setTargetTriple(TargetTriple);
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     legacy::PassManager PM;
     PM.add(new AddMetadataPass(PalMDString));

diff  --git a/llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp b/llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp
index d0991e62013430..36ec58f9064c43 100644
--- a/llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp
+++ b/llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp
@@ -407,7 +407,7 @@ class AsmPrinterHandlerTest : public AsmPrinterFixtureBase {
     PM.add(TestPrinter->releaseAP()); // Takes ownership of destroying AP
     LLVMContext Context;
     std::unique_ptr<Module> M(new Module("TestModule", Context));
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TM->getTargetTriple().computeDataLayout());
     PM.run(*M);
     // Now check that we can run it twice.
     AP->addAsmPrinterHandler(std::make_unique<TestHandler>(*this));

diff  --git a/llvm/unittests/CodeGen/CodeGenTestBase.h b/llvm/unittests/CodeGen/CodeGenTestBase.h
index 0a3117779fc363..b6256c6a8c3918 100644
--- a/llvm/unittests/CodeGen/CodeGenTestBase.h
+++ b/llvm/unittests/CodeGen/CodeGenTestBase.h
@@ -77,7 +77,7 @@ class CodeGenTestBase : public testing::Test {
       return false;
 
     Mod = MIR->parseIRModule();
-    Mod->setDataLayout(TM->createDataLayout());
+    Mod->setDataLayout(TM->getTargetTriple().computeDataLayout());
     if (MIR->parseMachineFunctions(*Mod, MAM)) {
       Mod.reset();
       return false;

diff  --git a/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp b/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
index c0cf4ff546d7b1..c81f8d99ae5179 100644
--- a/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
+++ b/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
@@ -55,7 +55,7 @@ std::unique_ptr<Module> parseMIR(const TargetMachine &TM, StringRef MIRCode,
   if (!Mod)
     return nullptr;
 
-  Mod->setDataLayout(TM.createDataLayout());
+  Mod->setDataLayout(TM.getTargetTriple().computeDataLayout());
 
   if (MIR->parseMachineFunctions(*Mod, MMI)) {
     M.reset();

diff  --git a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
index 5da3f8c2a67ded..c680b0044f6f8e 100644
--- a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
+++ b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
@@ -66,7 +66,7 @@ parseMIR(LLVMContext &Context, std::unique_ptr<MIRParser> &MIR,
   if (!M)
     return nullptr;
 
-  M->setDataLayout(TM.createDataLayout());
+  M->setDataLayout(TM.getTargetTriple().computeDataLayout());
 
   if (MIR->parseMachineFunctions(*M, MMI))
     return nullptr;

diff  --git a/llvm/unittests/CodeGen/GlobalISel/IRTranslatorBF16Test.cpp b/llvm/unittests/CodeGen/GlobalISel/IRTranslatorBF16Test.cpp
index 819998b750fd8c..00a440e3d7a891 100644
--- a/llvm/unittests/CodeGen/GlobalISel/IRTranslatorBF16Test.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/IRTranslatorBF16Test.cpp
@@ -89,7 +89,7 @@ TEST_F(AArch64IRTranslatorTest, IRTranslateBfloat16) {
   auto TM = createTargetMachine();
   if (!TM)
     GTEST_SKIP();
-  M->setDataLayout(TM->createDataLayout());
+  M->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   TM->setGlobalISel(true);
   TM->setGlobalISelAbort(GlobalISelAbortMode::DisableWithDiag);

diff  --git a/llvm/unittests/CodeGen/MIR2VecTest.cpp b/llvm/unittests/CodeGen/MIR2VecTest.cpp
index d42749c553eea4..723fedb18735c7 100644
--- a/llvm/unittests/CodeGen/MIR2VecTest.cpp
+++ b/llvm/unittests/CodeGen/MIR2VecTest.cpp
@@ -86,7 +86,7 @@ class MIR2VecVocabTestFixture : public ::testing::Test {
     }
 
     // Set the data layout to match the target machine
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     // Create a dummy function to get subtarget info
     FunctionType *FT = FunctionType::get(Type::getVoidTy(*Ctx), false);

diff  --git a/llvm/unittests/CodeGen/MachineModuleInfoTest.cpp b/llvm/unittests/CodeGen/MachineModuleInfoTest.cpp
index 81d36feca3ba43..4c1a1828acafbc 100644
--- a/llvm/unittests/CodeGen/MachineModuleInfoTest.cpp
+++ b/llvm/unittests/CodeGen/MachineModuleInfoTest.cpp
@@ -44,7 +44,7 @@ class MachineModuleInfoTest : public testing::Test {
     TargetOptions Options;
     TM.reset(T->createTargetMachine(TargetTriple, "", "", Options, std::nullopt,
                                     std::nullopt, CodeGenOptLevel::None));
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
   }
 
   Function *createEmptyFunction(StringRef Name) {

diff  --git a/llvm/unittests/CodeGen/PassManagerTest.cpp b/llvm/unittests/CodeGen/PassManagerTest.cpp
index f004d14b4aee4f..a9f4afdaf2534f 100644
--- a/llvm/unittests/CodeGen/PassManagerTest.cpp
+++ b/llvm/unittests/CodeGen/PassManagerTest.cpp
@@ -179,7 +179,7 @@ TEST_F(PassManagerTest, Basic) {
   if (!TM)
     GTEST_SKIP();
 
-  M->setDataLayout(TM->createDataLayout());
+  M->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   MachineModuleInfo MMI(TM.get());
 
@@ -228,7 +228,7 @@ TEST_F(PassManagerTest, DiagnosticHandler) {
   if (!TM)
     GTEST_SKIP();
 
-  M->setDataLayout(TM->createDataLayout());
+  M->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   MachineModuleInfo MMI(TM.get());
 

diff  --git a/llvm/unittests/CodeGen/SelectionDAGTestBase.h b/llvm/unittests/CodeGen/SelectionDAGTestBase.h
index de931cf0a8118d..a5628b09bcc20d 100644
--- a/llvm/unittests/CodeGen/SelectionDAGTestBase.h
+++ b/llvm/unittests/CodeGen/SelectionDAGTestBase.h
@@ -52,7 +52,7 @@ class SelectionDAGTestBase : public testing::Test {
     SMDiagnostic SMError;
     M = parseAssemblyString(Assembly, SMError, Context);
     ASSERT_TRUE(M && "Could not parse module!");
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     F = M->getFunction("f");
     ASSERT_TRUE(F && "Could not get function f!");

diff  --git a/llvm/unittests/CodeGen/X86MCInstLowerTest.cpp b/llvm/unittests/CodeGen/X86MCInstLowerTest.cpp
index cffa2b8df5282e..32d77d16c32728 100644
--- a/llvm/unittests/CodeGen/X86MCInstLowerTest.cpp
+++ b/llvm/unittests/CodeGen/X86MCInstLowerTest.cpp
@@ -118,7 +118,7 @@ class X86MCInstLowerTest : public testing::Test {
     M = parseAssemblyString(AssemblyF, SMError, Context);
     if (!M)
       report_fatal_error(SMError.getMessage());
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     // Get llvm::Function from M
     Foo = M->getFunction("foo");

diff  --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
index 61b99ddf0995d7..c2d5f4c91baed4 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
@@ -132,7 +132,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestOverrideObjectFlags) {
   {
     auto Ctx = std::make_unique<LLVMContext>();
     ModuleBuilder MB(*Ctx, TM->getTargetTriple().str(), "dummy");
-    MB.getModule()->setDataLayout(TM->createDataLayout());
+    MB.getModule()->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
     Function *FooImpl = MB.createFunctionDecl(
         FunctionType::get(Type::getVoidTy(*Ctx), {}, false), "foo");
@@ -207,7 +207,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestAutoClaimResponsibilityForSymbols) {
   {
     auto Ctx = std::make_unique<LLVMContext>();
     ModuleBuilder MB(*Ctx, TM->getTargetTriple().str(), "dummy");
-    MB.getModule()->setDataLayout(TM->createDataLayout());
+    MB.getModule()->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
     Function *FooImpl = MB.createFunctionDecl(
         FunctionType::get(Type::getVoidTy(*Ctx), {}, false), "foo");
@@ -256,7 +256,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestMemoryBufferNamePropagation) {
   {
     auto Ctx = std::make_unique<LLVMContext>();
     ModuleBuilder MB(*Ctx, TM->getTargetTriple().str(), "dummy");
-    MB.getModule()->setDataLayout(TM->createDataLayout());
+    MB.getModule()->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
     Function *FooImpl = MB.createFunctionDecl(
         FunctionType::get(Type::getVoidTy(*Ctx), {}, false), "foo");

diff  --git a/llvm/unittests/MI/LiveIntervalTest.cpp b/llvm/unittests/MI/LiveIntervalTest.cpp
index 0a1851529e4f04..28cb59b1dd4780 100644
--- a/llvm/unittests/MI/LiveIntervalTest.cpp
+++ b/llvm/unittests/MI/LiveIntervalTest.cpp
@@ -68,7 +68,7 @@ std::unique_ptr<Module> parseMIR(LLVMContext &Context,
   if (!M)
     return nullptr;
 
-  M->setDataLayout(TM.createDataLayout());
+  M->setDataLayout(TM.getTargetTriple().computeDataLayout());
 
   MachineModuleInfoWrapperPass *MMIWP = new MachineModuleInfoWrapperPass(&TM);
   if (MIR->parseMachineFunctions(*M, MMIWP->getMMI()))

diff  --git a/llvm/unittests/MIR/MachineMetadata.cpp b/llvm/unittests/MIR/MachineMetadata.cpp
index c611cf062bf6be..98c8afc0a5fa61 100644
--- a/llvm/unittests/MIR/MachineMetadata.cpp
+++ b/llvm/unittests/MIR/MachineMetadata.cpp
@@ -80,7 +80,7 @@ class MachineMetadataTest : public testing::Test {
     if (!Mod)
       return nullptr;
 
-    Mod->setDataLayout(TM.createDataLayout());
+    Mod->setDataLayout(TM.getTargetTriple().computeDataLayout());
 
     if (MIR->parseMachineFunctions(*Mod, MMI)) {
       M.reset();

diff  --git a/llvm/unittests/MIR/MachineStableHashTest.cpp b/llvm/unittests/MIR/MachineStableHashTest.cpp
index bedecb17df51f7..49010053a15cc7 100644
--- a/llvm/unittests/MIR/MachineStableHashTest.cpp
+++ b/llvm/unittests/MIR/MachineStableHashTest.cpp
@@ -61,7 +61,7 @@ class MachineStableHashTest : public testing::Test {
     if (!Mod)
       return nullptr;
 
-    Mod->setDataLayout(TM.createDataLayout());
+    Mod->setDataLayout(TM.getTargetTriple().computeDataLayout());
 
     if (MIR->parseMachineFunctions(*Mod, MMI)) {
       M.reset();

diff  --git a/llvm/unittests/Target/AArch64/AArch64RegisterInfoTest.cpp b/llvm/unittests/Target/AArch64/AArch64RegisterInfoTest.cpp
index 0906219ce0a4f2..0f2cc69be42e5f 100644
--- a/llvm/unittests/Target/AArch64/AArch64RegisterInfoTest.cpp
+++ b/llvm/unittests/Target/AArch64/AArch64RegisterInfoTest.cpp
@@ -165,7 +165,7 @@ TEST(AArch64ReservedRegs, ArtificialHIRegistersAreReserved) {
   // Create an empty machine function
   LLVMContext Context;
   Module M("", Context);
-  M.setDataLayout(TM->createDataLayout());
+  M.setDataLayout(TM->getTargetTriple().computeDataLayout());
   Function *F = Function::Create(
       FunctionType::get(Type::getVoidTy(Context), /*isVarArg=*/false),
       GlobalValue::ExternalLinkage, "f", &M);

diff  --git a/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp b/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
index 270ff3cc2cb96d..ab5cf3ef145ee7 100644
--- a/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
+++ b/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
@@ -49,7 +49,7 @@ class AArch64SelectionDAGTest : public testing::Test {
     M = parseAssemblyString(Assembly, SMError, Context);
     if (!M)
       report_fatal_error(SMError.getMessage());
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     F = M->getFunction("f");
     if (!F)

diff  --git a/llvm/unittests/Target/AArch64/InstSizes.cpp b/llvm/unittests/Target/AArch64/InstSizes.cpp
index 898e3dae167b32..59dfc4d0340299 100644
--- a/llvm/unittests/Target/AArch64/InstSizes.cpp
+++ b/llvm/unittests/Target/AArch64/InstSizes.cpp
@@ -78,7 +78,7 @@ void runChecks(
   ASSERT_TRUE(M);
 
   M->setTargetTriple(TM->getTargetTriple());
-  M->setDataLayout(TM->createDataLayout());
+  M->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   MachineModuleInfo MMI(TM);
   bool Res = MParser->parseMachineFunctions(*M, MMI);

diff  --git a/llvm/unittests/Target/AMDGPU/AMDGPUMCExprTest.cpp b/llvm/unittests/Target/AMDGPU/AMDGPUMCExprTest.cpp
index 6a890647cb83fe..2f1c3eedac3e85 100644
--- a/llvm/unittests/Target/AMDGPU/AMDGPUMCExprTest.cpp
+++ b/llvm/unittests/Target/AMDGPU/AMDGPUMCExprTest.cpp
@@ -35,7 +35,7 @@ class AMDGPUMCExprTest : public AMDGPUTestBase {
 
     LLVMCtx = std::make_unique<LLVMContext>();
     M = std::make_unique<Module>("Module", *LLVMCtx);
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TM->getTargetTriple().computeDataLayout());
     auto *FType = FunctionType::get(Type::getVoidTy(*LLVMCtx), false);
     auto *F = Function::Create(FType, GlobalValue::ExternalLinkage, "Test", *M);
     MMI = std::make_unique<MachineModuleInfo>(TM.get());

diff  --git a/llvm/unittests/Target/AMDGPU/CSETest.cpp b/llvm/unittests/Target/AMDGPU/CSETest.cpp
index 1bb2450642f6eb..186bb3760d3d8d 100644
--- a/llvm/unittests/Target/AMDGPU/CSETest.cpp
+++ b/llvm/unittests/Target/AMDGPU/CSETest.cpp
@@ -25,7 +25,7 @@ TEST_F(AMDGPUTestBase, TestCSEForRegisterClassOrBankAndLLT) {
 
   LLVMContext Ctx;
   Module Mod("Module", Ctx);
-  Mod.setDataLayout(TM->createDataLayout());
+  Mod.setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   auto *Type = FunctionType::get(Type::getVoidTy(Ctx), false);
   auto *F = Function::Create(Type, GlobalValue::ExternalLinkage, "Test", &Mod);

diff  --git a/llvm/unittests/Target/AMDGPU/ExecMayBeModifiedBeforeAnyUse.cpp b/llvm/unittests/Target/AMDGPU/ExecMayBeModifiedBeforeAnyUse.cpp
index b9efe4a1d3a8f3..39b2d0b43fe016 100644
--- a/llvm/unittests/Target/AMDGPU/ExecMayBeModifiedBeforeAnyUse.cpp
+++ b/llvm/unittests/Target/AMDGPU/ExecMayBeModifiedBeforeAnyUse.cpp
@@ -23,7 +23,7 @@ TEST_F(AMDGPUTestBase, ExecMayBeModifiedBeforeAnyUse) {
 
   LLVMContext Ctx;
   Module Mod("Module", Ctx);
-  Mod.setDataLayout(TM->createDataLayout());
+  Mod.setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   auto *Type = FunctionType::get(Type::getVoidTy(Ctx), false);
   auto *F = Function::Create(Type, GlobalValue::ExternalLinkage, "Test", &Mod);

diff  --git a/llvm/unittests/Target/AMDGPU/PALMetadata.cpp b/llvm/unittests/Target/AMDGPU/PALMetadata.cpp
index e67144a72cdbcf..d593b61ab8d75d 100644
--- a/llvm/unittests/Target/AMDGPU/PALMetadata.cpp
+++ b/llvm/unittests/Target/AMDGPU/PALMetadata.cpp
@@ -38,7 +38,7 @@ class PALMetadata : public AMDGPUTestBase {
 
     Ctx = std::make_unique<LLVMContext>();
     M = std::make_unique<Module>("Module", *Ctx);
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TM->getTargetTriple().computeDataLayout());
     auto *FType = FunctionType::get(Type::getVoidTy(*Ctx), false);
     auto *F = Function::Create(FType, GlobalValue::ExternalLinkage, "Test", *M);
     MMI = std::make_unique<MachineModuleInfo>(TM.get());

diff  --git a/llvm/unittests/Target/ARM/ARMSelectionDAGTest.cpp b/llvm/unittests/Target/ARM/ARMSelectionDAGTest.cpp
index 8f1c42999c4024..f36e3e07e07e48 100644
--- a/llvm/unittests/Target/ARM/ARMSelectionDAGTest.cpp
+++ b/llvm/unittests/Target/ARM/ARMSelectionDAGTest.cpp
@@ -49,7 +49,7 @@ class ARMSelectionDAGTest : public testing::Test {
     M = parseAssemblyString(Assembly, SMError, Context);
     if (!M)
       report_fatal_error(SMError.getMessage());
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     F = M->getFunction("f");
     if (!F)

diff  --git a/llvm/unittests/Target/ARM/InstSizes.cpp b/llvm/unittests/Target/ARM/InstSizes.cpp
index deaa223eb1c27c..538098eedecf16 100644
--- a/llvm/unittests/Target/ARM/InstSizes.cpp
+++ b/llvm/unittests/Target/ARM/InstSizes.cpp
@@ -53,7 +53,7 @@ void runChecks(
   ASSERT_TRUE(M);
 
   M->setTargetTriple(TM->getTargetTriple());
-  M->setDataLayout(TM->createDataLayout());
+  M->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   MachineModuleInfo MMI(TM);
   bool Res = MParser->parseMachineFunctions(*M, MMI);

diff  --git a/llvm/unittests/Target/LoongArch/InstSizes.cpp b/llvm/unittests/Target/LoongArch/InstSizes.cpp
index 0ff82974620abe..f18eb9774a5157 100644
--- a/llvm/unittests/Target/LoongArch/InstSizes.cpp
+++ b/llvm/unittests/Target/LoongArch/InstSizes.cpp
@@ -71,7 +71,7 @@ void runChecks(
   ASSERT_TRUE(M);
 
   M->setTargetTriple(TM->getTargetTriple());
-  M->setDataLayout(TM->createDataLayout());
+  M->setDataLayout(TM->getTargetTriple().computeDataLayout());
 
   MachineModuleInfo MMI(TM);
   bool Res = MParser->parseMachineFunctions(*M, MMI);

diff  --git a/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp b/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
index cb18413c7ddc29..3c9be35812fdaf 100644
--- a/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
+++ b/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
@@ -53,7 +53,7 @@ class RISCVInstrInfoTest : public testing::TestWithParam<const char *> {
 
     Ctx = std::make_unique<LLVMContext>();
     M = std::make_unique<Module>("Module", *Ctx);
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TT.computeDataLayout());
     auto *FType = FunctionType::get(Type::getVoidTy(*Ctx), false);
     auto *F = Function::Create(FType, GlobalValue::ExternalLinkage, "Test", *M);
     MMI = std::make_unique<MachineModuleInfo>(TM.get());

diff  --git a/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp b/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp
index 8e069ce1405075..4be6f470aebf2d 100644
--- a/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp
+++ b/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp
@@ -49,7 +49,7 @@ class RISCVSelectionDAGTest : public testing::Test {
     M = parseAssemblyString(Assembly, SMError, Context);
     if (!M)
       report_fatal_error(SMError.getMessage());
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     F = M->getFunction("f");
     if (!F)

diff  --git a/llvm/unittests/Target/SPIRV/SPIRVGlobalRegistryTests.cpp b/llvm/unittests/Target/SPIRV/SPIRVGlobalRegistryTests.cpp
index 618edab01f91bc..25942f541454b4 100644
--- a/llvm/unittests/Target/SPIRV/SPIRVGlobalRegistryTests.cpp
+++ b/llvm/unittests/Target/SPIRV/SPIRVGlobalRegistryTests.cpp
@@ -44,7 +44,7 @@ class SPIRVGlobalRegistryTest : public testing::Test {
                                     std::nullopt));
     Ctx = std::make_unique<LLVMContext>();
     Mod = std::make_unique<Module>("M", *Ctx);
-    Mod->setDataLayout(TM->createDataLayout());
+    Mod->setDataLayout(TT.computeDataLayout());
     auto *F = Function::Create(FunctionType::get(Type::getVoidTy(*Ctx), false),
                                GlobalValue::ExternalLinkage, "f", *Mod);
     MMI = std::make_unique<MachineModuleInfo>(TM.get());
@@ -91,7 +91,7 @@ TEST_F(SPIRVGlobalRegistryTest, PrepareFunctionsClearsStalePointers) {
 
   LLVMContext Ctx2;
   Module Mod2("M2", Ctx2);
-  Mod2.setDataLayout(TM->createDataLayout());
+  Mod2.setDataLayout(TM->getTargetTriple().computeDataLayout());
   Function::Create(FunctionType::get(Type::getVoidTy(Ctx2), false),
                    GlobalValue::ExternalLinkage, "g", Mod2);
 

diff  --git a/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp b/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp
index 84c49eb2c8d098..dfa4630eb23f1e 100644
--- a/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp
+++ b/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp
@@ -54,7 +54,7 @@ std::unique_ptr<Module> parseMIR(LLVMContext &Context,
   if (!M)
     return nullptr;
 
-  M->setDataLayout(TM.createDataLayout());
+  M->setDataLayout(TM.getTargetTriple().computeDataLayout());
 
   if (MIR->parseMachineFunctions(*M, MMI))
     return nullptr;

diff  --git a/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp b/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp
index aafc5c088d81d8..372c123c105524 100644
--- a/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp
+++ b/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp
@@ -77,7 +77,7 @@ class MachineSizeOptsTest : public testing::Test {
     if (!M)
       report_fatal_error("parseIRModule failed");
     M->setTargetTriple(TM->getTargetTriple());
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TM->getTargetTriple().computeDataLayout());
     MMI = std::make_unique<MachineModuleInfo>(TM.get());
     if (Parser->parseMachineFunctions(*M, *MMI))
       report_fatal_error("parseMachineFunctions failed");

diff  --git a/llvm/unittests/Target/X86/X86SelectionDAGTest.cpp b/llvm/unittests/Target/X86/X86SelectionDAGTest.cpp
index 07164dd5041044..40887f668a074a 100644
--- a/llvm/unittests/Target/X86/X86SelectionDAGTest.cpp
+++ b/llvm/unittests/Target/X86/X86SelectionDAGTest.cpp
@@ -48,7 +48,7 @@ class X86SelectionDAGTest : public testing::Test {
     M = parseAssemblyString(Assembly, SMError, Context);
     if (!M)
       report_fatal_error(SMError.getMessage());
-    M->setDataLayout(TM->createDataLayout());
+    M->setDataLayout(TargetTriple.computeDataLayout());
 
     F = M->getFunction("f");
     if (!F)

diff  --git a/llvm/unittests/tools/llvm-exegesis/X86/SnippetRepetitorTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/SnippetRepetitorTest.cpp
index 7a40901de92915..3a7aceb77370d5 100644
--- a/llvm/unittests/tools/llvm-exegesis/X86/SnippetRepetitorTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/X86/SnippetRepetitorTest.cpp
@@ -30,7 +30,7 @@ class X86SnippetRepetitorTest : public X86TestBase {
     TM = State.createTargetMachine();
     Context = std::make_unique<LLVMContext>();
     Mod = std::make_unique<Module>("X86SnippetRepetitorTest", *Context);
-    Mod->setDataLayout(TM->createDataLayout());
+    Mod->setDataLayout(TM->getTargetTriple().computeDataLayout());
     MMI = std::make_unique<MachineModuleInfo>(TM.get());
     MF = &createVoidVoidPtrMachineFunction("TestFn", Mod.get(), MMI.get());
   }


        


More information about the llvm-commits mailing list