[PATCH] D11654: Add a TargetMachine hook that verifies DataLayout compatibility
Mehdi AMINI
mehdi.amini at apple.com
Thu Jul 30 10:31:54 PDT 2015
joker.eph created this revision.
joker.eph added a reviewer: echristo.
joker.eph added a subscriber: llvm-commits.
Also provide the associated assertion when CodeGen starts.
http://reviews.llvm.org/D11654
Files:
include/llvm/Target/TargetMachine.h
lib/CodeGen/MachineFunction.cpp
Index: lib/CodeGen/MachineFunction.cpp
===================================================================
--- lib/CodeGen/MachineFunction.cpp
+++ lib/CodeGen/MachineFunction.cpp
@@ -85,6 +85,10 @@
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() {
Index: include/llvm/Target/TargetMachine.h
===================================================================
--- include/llvm/Target/TargetMachine.h
+++ include/llvm/Target/TargetMachine.h
@@ -133,6 +133,16 @@
/// 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 will be used for the CodeGen. This hook provide a target
+ /// specific check on the validity of this DataLayout. The default
+ /// implementation just check for an exact match but Targets can override it.
+ virtual 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11654.31047.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150730/587d198e/attachment.bin>
More information about the llvm-commits
mailing list