Add a TargetMachine hook that verifies DataLayout compatibility
[oota-llvm.git] / lib / CodeGen / MachineFunction.cpp
index 9856e70edaef0d2ce0f44c699568b135f7b2da12..bd6f8771e7b46afbb578f1d944450bafe4ebd8f1 100644 (file)
@@ -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() {
@@ -322,6 +326,13 @@ MachineFunction::extractStoreMemRefs(MachineInstr::mmo_iterator Begin,
   return std::make_pair(Result, Result + Num);
 }
 
+const char *MachineFunction::createExternalSymbolName(StringRef Name) {
+  char *Dest = Allocator.Allocate<char>(Name.size() + 1);
+  std::copy(Name.begin(), Name.end(), Dest);
+  Dest[Name.size()] = 0;
+  return Dest;
+}
+
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 void MachineFunction::dump() const {
   print(dbgs());