[llvm-commits] [llvm-gcc-4.2] r57022 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Evan Cheng evan.cheng at apple.com
Fri Oct 3 11:05:41 PDT 2008


Author: evancheng
Date: Fri Oct  3 13:05:41 2008
New Revision: 57022

URL: http://llvm.org/viewvc/llvm-project?rev=57022&view=rev
Log:
Fix a bug in EmitCallOf which shows up only with assertion turned on. When it's processing a call argument that corresponds to eh_value or eh_select, grab the type of special variables ExceptionValue or ExceptionSelectorValue instead or it won't match the expected type.

With assertion turned off, this bug doesn't cause any miscompilation because pointer types are *compatible*. But it's a bug anyway.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=57022&r1=57021&r2=57022&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Oct  3 13:05:41 2008
@@ -2361,7 +2361,7 @@
   // parameter for the chain.
   Callee = BitCastToType(Callee, PointerType::getUnqual(Ty));
 
-  //EmitCall(exp, DestLoc);
+  // EmitCall(exp, DestLoc);
   Value *Result = EmitCallOf(Callee, exp, DestLoc, PAL);
 
   // If the function has the volatile bit set, then it is a "noreturn" function.
@@ -2694,8 +2694,19 @@
     }
 
     Attributes Attrs = Attribute::None;
-    ABIConverter.HandleArgument(TREE_TYPE(TREE_VALUE(arg)), ScalarArgs,
-                                &Attrs);
+    // See EmitEXC_PTR_EXPR and EmitFILTER_EXPR. Rather than handle the
+    // arguments themselves, process eh_value and eh_select.
+    if (TREE_CODE(TREE_VALUE(arg)) == EXC_PTR_EXPR) {
+      const Type *Ty = ExceptionValue->getType();
+      Ty = cast<PointerType>(Ty)->getElementType();
+      Client.HandleScalarArgument(Ty, 0);
+    } else if (TREE_CODE(TREE_VALUE(arg)) == FILTER_EXPR) {
+      const Type *Ty = ExceptionSelectorValue->getType();
+      Ty = cast<PointerType>(Ty)->getElementType();
+      Client.HandleScalarArgument(Ty, 0);
+    } else
+      ABIConverter.HandleArgument(TREE_TYPE(TREE_VALUE(arg)), ScalarArgs,
+                                  &Attrs);
     if (Attrs != Attribute::None)
       PAL = PAL.addAttr(CallOperands.size(), Attrs);
 





More information about the llvm-commits mailing list