The eh_selector intrinsic wants global variables for its
extra arguments, but wasn't expecting to get... global
variables!  Only bitcasts of global variables.  Discovered
by the Ada f-e, fix attached.  Maybe it can be done more
neatly, but I don't know LLVM well enough to say.

Ciao,

Duncan.
Index: llvm.master/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===================================================================
--- llvm.master.orig/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	2007-04-14 14:48:28.000000000 +0200
+++ llvm.master/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	2007-04-14 15:14:41.000000000 +0200
@@ -2606,15 +2606,20 @@
       // MachineModuleInfo.
       std::vector<GlobalVariable *> TyInfo;
       for (unsigned i = 3, N = I.getNumOperands(); i < N; ++i) {
-        ConstantExpr *CE = dyn_cast<ConstantExpr>(I.getOperand(i));
-        if (CE && CE->getOpcode() == Instruction::BitCast &&
-            isa<GlobalVariable>(CE->getOperand(0))) {
-          TyInfo.push_back(cast<GlobalVariable>(CE->getOperand(0)));
+        Constant *C = cast<Constant>(I.getOperand(i));
+        if (isa<GlobalVariable>(C)) {
+          TyInfo.push_back(cast<GlobalVariable>(C));
         } else {
-          ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand(i));
-          assert(CI && CI->getZExtValue() == 0 &&
-            "TypeInfo must be a global variable typeinfo or NULL");
-          TyInfo.push_back(NULL);
+          ConstantExpr *CE = dyn_cast<ConstantExpr>(C);
+          if (CE && CE->getOpcode() == Instruction::BitCast &&
+              isa<GlobalVariable>(CE->getOperand(0))) {
+            TyInfo.push_back(cast<GlobalVariable>(CE->getOperand(0)));
+          } else {
+            ConstantInt *CI = dyn_cast<ConstantInt>(C);
+            assert(CI && CI->getZExtValue() == 0 &&
+                   "TypeInfo must be a global variable typeinfo or NULL");
+            TyInfo.push_back(NULL);
+          }
         }
       }
       MMI->addCatchTypeInfo(CurMBB, TyInfo);
Index: llvm.master/test/CodeGen/Generic/2007-04-14-EHSelectorCrash.ll
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ llvm.master/test/CodeGen/Generic/2007-04-14-EHSelectorCrash.ll	2007-04-14 17:30:00.000000000 +0200
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | llc -enable-eh
+
+; ModuleID = '2007-04-14-EHSelectorCrash.bc'
[EMAIL PROTECTED] = external constant i32		; <i32*> [#uses=1]
+
+define void @_ada_eh() {
+entry:
+	%eh_select = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector( i8* null, i8* bitcast (i32 (...)* @__gnat_eh_personality to i8*), i32* @__gnat_others_value )		; <i32> [#uses=0]
+	ret void
+}
+
+declare i32 @llvm.eh.selector(i8*, i8*, ...)
+
+declare i32 @__gnat_eh_personality(...)
_______________________________________________
llvm-commits mailing list
[EMAIL PROTECTED]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to