[llvm] r220205 - Fix Intrinsic::getType not working with vararg

Steven Wu stevenwu at apple.com
Mon Oct 20 08:47:25 PDT 2014


Author: steven_wu
Date: Mon Oct 20 10:47:24 2014
New Revision: 220205

URL: http://llvm.org/viewvc/llvm-project?rev=220205&view=rev
Log:
Fix Intrinsic::getType not working with vararg

VarArg Intrinsic functions are encoded with "void" type as the last
argument. Now Intrinsic::getType can correctly return all the intrinsic
function type.

Modified:
    llvm/trunk/lib/IR/Function.cpp

Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=220205&r1=220204&r2=220205&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Mon Oct 20 10:47:24 2014
@@ -739,6 +739,12 @@ FunctionType *Intrinsic::getType(LLVMCon
   while (!TableRef.empty())
     ArgTys.push_back(DecodeFixedType(TableRef, Tys, Context));
 
+  // DecodeFixedType returns Void for IITDescriptor::Void and IITDescriptor::VarArg
+  // If we see void type as the type of the last argument, it is vararg intrinsic
+  if (!ArgTys.empty() && ArgTys.back()->isVoidTy()) {
+    ArgTys.pop_back();
+    return FunctionType::get(ResultTy, ArgTys, true);
+  }
   return FunctionType::get(ResultTy, ArgTys, false);
 }
 





More information about the llvm-commits mailing list