Index: src/llvm2ice.cpp |
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp |
index 374d753769eff6b00403fb787bd52ce49430a428..180c5c2c5529d62f9c7c83ba0bde3f6911d55beb 100644 |
--- a/src/llvm2ice.cpp |
+++ b/src/llvm2ice.cpp |
@@ -526,8 +526,28 @@ private: |
unsigned NumArgs = Inst->getNumArgOperands(); |
// Note: Subzero doesn't (yet) do anything special with the Tail |
// flag in the bitcode, i.e. CallInst::isTailCall(). |
- Ice::InstCall *NewInst = |
- Ice::InstCall::create(Func, NumArgs, Dest, CallTarget); |
+ Ice::InstCall *NewInst = NULL; |
+ |
+ if (Ice::ConstantRelocatable *Target = |
+ llvm::dyn_cast<Ice::ConstantRelocatable>(CallTarget)) { |
+ // Check if this direct call is to an Intrinsic (starts with "llvm.") |
+ Ice::IceString Name = Target->getName(); |
+ if (Name.substr(0, 5) == "llvm.") { |
+ Ice::IceString NameSuffix = Name.substr(5); |
+ Ice::IntrinsicInfo Info = Ctx->getIntrinsicInfo(NameSuffix); |
+ if (Info == Ice::UnknownIntrinsicInfo) { |
+ report_fatal_error(std::string("Invalid PNaCl intrinsic call: ") + |
+ LLVMObjectAsString(Inst)); |
+ } |
+ NewInst = Ice::InstIntrinsicCall::create(Func, NumArgs, Dest, |
+ CallTarget, Info); |
+ } |
+ } |
+ |
+ // Not an intrinsic call. |
+ if (NewInst == NULL) { |
+ NewInst = Ice::InstCall::create(Func, NumArgs, Dest, CallTarget); |
+ } |
for (unsigned i = 0; i < NumArgs; ++i) { |
NewInst->addArg(convertOperand(Inst, i)); |
} |