[llvm-commits] [llvm] r140848 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp

Torok Edwin edwintorok at gmail.com
Fri Sep 30 05:32:01 PDT 2011


Author: edwin
Date: Fri Sep 30 07:31:57 2011
New Revision: 140848

URL: http://llvm.org/viewvc/llvm-project?rev=140848&view=rev
Log:
Instead of crashing when MCAsmInfo is NULL, add an assert.

This helps with porting code from 2.9 to 3.0 as TargetSelect.h changed location,
and if you include the old one by accident you will trigger this assert.

Modified:
    llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp

Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=140848&r1=140847&r2=140848&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Sep 30 07:31:57 2011
@@ -114,6 +114,11 @@
   : TargetMachine(T, Triple, CPU, FS) {
   CodeGenInfo = T.createMCCodeGenInfo(Triple, RM, CM);
   AsmInfo = T.createMCAsmInfo(Triple);
+  // TargetSelect.h moved to different directory between LLVM 2.9 and 3.0,
+  // and if the old one gets included then MCAsmInfo will be NULL and we'd crash
+  // later.
+  // Provide the user a useful error message about whats wrong.
+  assert(AsmInfo && "MCAsmInfo not initialized. Make sure you include the correct TargetSelect.h!");
 }
 
 bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,





More information about the llvm-commits mailing list