[llvm-commits] [llvm] r129107 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/trap.ll

Chris Lattner clattner at apple.com
Fri Apr 8 12:00:30 PDT 2011


On Apr 7, 2011, at 1:31 PM, Evan Cheng wrote:

> Author: evancheng
> Date: Thu Apr  7 15:31:12 2011
> New Revision: 129107
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=129107&view=rev
> Log:
> Add option to emit @llvm.trap as a function call instead of a trap instruction. rdar://9249183.

Evan, please do not add magic options like this.  Target configuration stuff should be in TargetOptions.h

-Chris

> 
> Modified:
>    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
>    llvm/trunk/test/CodeGen/ARM/trap.ll
> 
> Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=129107&r1=129106&r2=129107&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Apr  7 15:31:12 2011
> @@ -72,6 +72,11 @@
>   cl::desc("Enable / disable ARM interworking (for debugging only)"),
>   cl::init(true));
> 
> +static cl::opt<std::string>
> +TrapFuncName("arm-trap-func", cl::Hidden,
> +  cl::desc("Emit a call to trap function rather than a trap instruction"),
> +  cl::init(""));
> +
> void ARMTargetLowering::addTypeForNEON(EVT VT, EVT PromotedLdStVT,
>                                        EVT PromotedBitwiseVT) {
>   if (VT != PromotedLdStVT) {
> @@ -557,7 +562,10 @@
>   setOperationAction(ISD::GlobalTLSAddress, MVT::i32, Custom);
>   setOperationAction(ISD::BlockAddress, MVT::i32, Custom);
> 
> -  setOperationAction(ISD::TRAP, MVT::Other, Legal);
> +  if (TrapFuncName.size())
> +    setOperationAction(ISD::TRAP, MVT::Other, Custom);
> +  else
> +    setOperationAction(ISD::TRAP, MVT::Other, Legal);
> 
>   // Use the default implementation.
>   setOperationAction(ISD::VASTART,            MVT::Other, Custom);
> @@ -4690,6 +4698,19 @@
>   return N0;
> }
> 
> +static SDValue LowerTrap(SDValue Op, SelectionDAG &DAG) {
> +  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
> +  TargetLowering::ArgListTy Args;
> +  std::pair<SDValue, SDValue> CallResult =
> +    TLI.LowerCallTo(Op.getOperand(0), Type::getVoidTy(*DAG.getContext()),
> +                false, false, false, false, 0, CallingConv::C,
> +                /*isTailCall=*/false,
> +                /*isReturnValueUsed=*/true,
> +                DAG.getExternalSymbol(TrapFuncName.c_str(), TLI.getPointerTy()),
> +                Args, DAG, Op.getDebugLoc());
> +  return CallResult.second;
> +}
> +
> SDValue ARMTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
>   switch (Op.getOpcode()) {
>   default: llvm_unreachable("Don't know how to custom lower this!");
> @@ -4736,6 +4757,7 @@
>   case ISD::MUL:           return LowerMUL(Op, DAG);
>   case ISD::SDIV:          return LowerSDIV(Op, DAG);
>   case ISD::UDIV:          return LowerUDIV(Op, DAG);
> +  case ISD::TRAP:          return LowerTrap(Op, DAG);
>   }
>   return SDValue();
> }
> 
> Modified: llvm/trunk/test/CodeGen/ARM/trap.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/trap.ll?rev=129107&r1=129106&r2=129107&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/ARM/trap.ll (original)
> +++ llvm/trunk/test/CodeGen/ARM/trap.ll Thu Apr  7 15:31:12 2011
> @@ -1,10 +1,15 @@
> -; RUN: llc < %s -march=arm | FileCheck %s
> +; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s -check-prefix=INSTR
> +; RUN: llc < %s -mtriple=arm-apple-darwin -arm-trap-func=_trap | FileCheck %s -check-prefix=FUNC
> ; rdar://7961298
> +; rdar://9249183
> 
> define void @t() nounwind {
> entry:
> -; CHECK: t:
> -; CHECK: trap
> +; INSTR: t:
> +; INSTR: trap
> +
> +; FUNC: t:
> +; FUNC: bl __trap
>   call void @llvm.trap()
>   unreachable
> }
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list