diff options
| author | Mehdi Amini <mehdi.amini@apple.com> | 2015-07-30 20:33:18 +0000 |
|---|---|---|
| committer | Mehdi Amini <mehdi.amini@apple.com> | 2015-07-30 20:33:18 +0000 |
| commit | d937c549449c7ad014f01c5215a39b41bfefed15 (patch) | |
| tree | 1a8ac67bdf6bf10dbf01dd2d876d7a0e15d5bb96 | |
| parent | 2c1f46dcc609a1bf61ab979eebdd72f81823ff74 (diff) | |
| download | bcm5719-llvm-d937c549449c7ad014f01c5215a39b41bfefed15.tar.gz bcm5719-llvm-d937c549449c7ad014f01c5215a39b41bfefed15.zip | |
Add a TargetMachine hook that verifies DataLayout compatibility
Summary: Also provide the associated assertion when CodeGen starts.
Reviewers: echristo
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11654
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 243682
| -rw-r--r-- | llvm/include/llvm/Target/TargetMachine.h | 9 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index bc8537c0daa..d707e7c0293 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/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/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 0a8309eb2f2..bd6f8771e7b 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -85,6 +85,10 @@ 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"); } MachineFunction::~MachineFunction() { |

