When lowering direct calls, lower them to use a targetglobaladress directly
authorChris Lattner <sabre@nondot.org>
Thu, 17 Nov 2005 05:56:14 +0000 (05:56 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Nov 2005 05:56:14 +0000 (05:56 +0000)
instead of a globaladdress.  This has no effect on the generated code at all.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24386 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCISelDAGToDAG.cpp
lib/Target/PowerPC/PPCISelLowering.cpp

index ad0a0a02193cc9352d26f5b40134cc2fb4ac4962..cc7a59aa977cc1b4709548858c285ca96e0e37fb 100644 (file)
@@ -753,8 +753,7 @@ SDOperand PPCDAGToDAGISel::SelectCALL(SDOperand Op) {
   if (GlobalAddressSDNode *GASD =
       dyn_cast<GlobalAddressSDNode>(N->getOperand(1))) {
     CallOpcode = PPC::BL;
-    CallOperands.push_back(CurDAG->getTargetGlobalAddress(GASD->getGlobal(),
-                                                          MVT::i32));
+    CallOperands.push_back(N->getOperand(1));
   } else if (ExternalSymbolSDNode *ESSDN =
              dyn_cast<ExternalSymbolSDNode>(N->getOperand(1))) {
     CallOpcode = PPC::BL;
index 30525cffd067ea00f694f98850fa15518159caf1..d196c10fae772d8a83a299261e43376973703088 100644 (file)
@@ -691,6 +691,11 @@ PPCTargetLowering::LowerCallTo(SDOperand Chain,
     RetVals.push_back(ActualRetTyVT);
   RetVals.push_back(MVT::Other);
   
+  // If the callee is a GlobalAddress node (quite common, every direct call is)
+  // turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
+  if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
+    Callee = DAG.getTargetGlobalAddress(G->getGlobal(), MVT::i32);
+  
   SDOperand TheCall = SDOperand(DAG.getCall(RetVals,
                                             Chain, Callee, args_to_use), 0);
   Chain = TheCall.getValue(RetTyVT != MVT::isVoid);