[llvm-commits] [llvm] r62373 - in /llvm/trunk: lib/Target/PowerPC/PPCISelDAGToDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp test/CodeGen/PowerPC/2009-01-16-DeclareISelBug.ll

Evan Cheng evan.cheng at apple.com
Fri Jan 16 14:57:33 PST 2009


Author: evancheng
Date: Fri Jan 16 16:57:32 2009
New Revision: 62373

URL: http://llvm.org/viewvc/llvm-project?rev=62373&view=rev
Log:
Fix PPC ISD::Declare isel and eliminate the need for PPCTargetLowering::LowerGlobalAddress to check if isVerifiedDebugInfoDesc() is true. Given the recent changes, it would falsely return true for a lot of GlobalAddressSDNode's.

Added:
    llvm/trunk/test/CodeGen/PowerPC/2009-01-16-DeclareISelBug.ll
Modified:
    llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp?rev=62373&r1=62372&r2=62373&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Fri Jan 16 16:57:32 2009
@@ -1100,6 +1100,26 @@
                                             Chain), 0);
     return CurDAG->SelectNodeTo(N, PPC::BCTR, MVT::Other, Chain);
   }
+  case ISD::DECLARE: {
+    SDValue Chain = N->getOperand(0);
+    SDValue N1 = N->getOperand(1);
+    SDValue N2 = N->getOperand(2);
+    FrameIndexSDNode *FINode = dyn_cast<FrameIndexSDNode>(N1);
+    if (!FINode)
+      break;
+    if (N2.getOpcode() == ISD::ADD &&
+        N2.getOperand(0).getOpcode() == PPCISD::Hi &&
+        N2.getOperand(1).getOpcode() == PPCISD::Lo)
+      N2 = N2.getOperand(0).getOperand(0);
+    if (!isa<GlobalAddressSDNode>(N2))
+      break;
+    int FI = cast<FrameIndexSDNode>(N1)->getIndex();
+    GlobalValue *GV = cast<GlobalAddressSDNode>(N2)->getGlobal();
+    SDValue Tmp1 = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
+    SDValue Tmp2 = CurDAG->getTargetGlobalAddress(GV, TLI.getPointerTy());
+    return CurDAG->SelectNodeTo(N, TargetInstrInfo::DECLARE,
+                                MVT::Other, Tmp1, Tmp2, Chain);
+  }
   }
   
   return SelectCode(Op);

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=62373&r1=62372&r2=62373&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Jan 16 16:57:32 2009
@@ -1134,14 +1134,11 @@
 }
 
 SDValue PPCTargetLowering::LowerGlobalAddress(SDValue Op, 
-                                                SelectionDAG &DAG) {
+                                              SelectionDAG &DAG) {
   MVT PtrVT = Op.getValueType();
   GlobalAddressSDNode *GSDN = cast<GlobalAddressSDNode>(Op);
   GlobalValue *GV = GSDN->getGlobal();
   SDValue GA = DAG.getTargetGlobalAddress(GV, PtrVT, GSDN->getOffset());
-  // If it's a debug information descriptor, don't mess with it.
-  if (DAG.isVerifiedDebugInfoDesc(Op))
-    return GA;
   SDValue Zero = DAG.getConstant(0, PtrVT);
   
   const TargetMachine &TM = DAG.getTarget();

Added: llvm/trunk/test/CodeGen/PowerPC/2009-01-16-DeclareISelBug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2009-01-16-DeclareISelBug.ll?rev=62373&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/2009-01-16-DeclareISelBug.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/2009-01-16-DeclareISelBug.ll Fri Jan 16 16:57:32 2009
@@ -0,0 +1,19 @@
+; RUN: llvm-as < %s | llc -mtriple=powerpc-apple-darwin9.5
+; rdar://6499616
+
+	%llvm.dbg.anchor.type = type { i32, i32 }
+	%llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8* }
+ at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }		; <%llvm.dbg.anchor.type*> [#uses=1]
+ at .str = internal constant [11 x i8] c"testcase.c\00"		; <[11 x i8]*> [#uses=1]
+ at .str1 = internal constant [30 x i8] c"/Volumes/SandBox/NightlyTest/\00"		; <[30 x i8]*> [#uses=1]
+ at .str2 = internal constant [57 x i8] c"4.2.1 (Based on Apple Inc. build 5628) (LLVM build 9999)\00"		; <[57 x i8]*> [#uses=1]
+ at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([11 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([30 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([57 x i8]* @.str2, i32 0, i32 0) }		; <%llvm.dbg.compile_unit.type*> [#uses=0]
+@"\01LC" = internal constant [13 x i8] c"conftest.val\00"		; <[13 x i8]*> [#uses=1]
+
+define i32 @main() nounwind {
+entry:
+	%0 = call i8* @fopen(i8* getelementptr ([13 x i8]* @"\01LC", i32 0, i32 0), i8* null) nounwind		; <i8*> [#uses=0]
+	unreachable
+}
+
+declare i8* @fopen(i8*, i8*)





More information about the llvm-commits mailing list