Chromium Code Reviews| Index: src/llvm2ice.cpp |
| diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp |
| index 374d753769eff6b00403fb787bd52ce49430a428..9243d29bfb9b32a445245679b0a21552887c398d 100644 |
| --- a/src/llvm2ice.cpp |
| +++ b/src/llvm2ice.cpp |
| @@ -526,8 +526,30 @@ 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.") |
|
Jim Stichnoth
2014/06/10 22:58:28
I hate that std::string doesn't have a simple star
jvoung (off chromium)
2014/06/12 05:48:30
Done -- at some point we might want to just some s
Jim Stichnoth
2014/06/12 20:52:06
Sorry, I used the constant 5 in my suggestion just
jvoung (off chromium)
2014/06/16 20:51:58
Done.
|
| + Ice::IceString Name = Target->getName(); |
| + size_t Dot = Name.find('.'); |
| + if (Dot != Ice::IceString::npos && |
| + Name.substr(0, Dot) == Ice::IceString("llvm")) { |
| + Ice::IceString NameSuffix = Name.substr(Dot + 1); |
| + 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)); |
| } |