From 378e97e50c4385095b4d0f482e57159c8de3164c Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Mon, 17 Aug 2015 10:58:03 +0000 Subject: [PATCH] Revert "Disable targetdatalayoutcheck" I committed by accident a local hack that should not have made it upstream. Sorry for the noise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245212 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetMachine.h | 9 +++++++++ lib/CodeGen/MachineFunction.cpp | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index bc8537c0daa..d707e7c0293 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -133,6 +133,15 @@ public: /// Create a DataLayout. const DataLayout createDataLayout() const { return DL; } + /// Test if a DataLayout if compatible with the CodeGen for this target. + /// + /// The LLVM Module owns a DataLayout that is used for the target independent + /// optimizations and code generation. This hook provides a target specific + /// check on the validity of this DataLayout. + bool isCompatibleDataLayout(const DataLayout &Candidate) const { + return DL == Candidate; + } + /// Get the pointer size for this target. /// /// This is the only time the DataLayout in the TargetMachine is used. diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 5a797f84843..cf9213b84c4 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -87,6 +87,11 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM, FunctionNumber = FunctionNum; JumpTableInfo = nullptr; + + assert(TM.isCompatibleDataLayout(getDataLayout()) && + "Can't create a MachineFunction using a Module with a " + "Target-incompatible DataLayout attached\n"); + PSVManager = llvm::make_unique(); } -- 2.34.1