[PATCH] [NVPTX] Fix issue introduced in D10321

Xuetian Weng xweng at google.com
Tue Jun 30 11:01:31 PDT 2015


Hi jingyue, jholewinski,

Really check if %SP is not used in other places, instead of checking only exact
one non-dbg use.

http://reviews.llvm.org/D10844

Files:
  lib/Target/NVPTX/NVPTXFrameLowering.cpp
  test/CodeGen/NVPTX/local-stack-frame.ll

Index: lib/Target/NVPTX/NVPTXFrameLowering.cpp
===================================================================
--- lib/Target/NVPTX/NVPTXFrameLowering.cpp
+++ lib/Target/NVPTX/NVPTXFrameLowering.cpp
@@ -47,20 +47,19 @@
     // cvta.local %SP, %SPL;
     if (static_cast<const NVPTXTargetMachine &>(MF.getTarget()).is64Bit()) {
       // Check if %SP is actually used
-      if (MR.hasOneNonDBGUse(NVPTX::VRFrame)) {
+      if (!MR.use_empty(NVPTX::VRFrame)) {
         MI = BuildMI(MBB, MI, dl, MF.getSubtarget().getInstrInfo()->get(
                                       NVPTX::cvta_local_yes_64),
                      NVPTX::VRFrame)
                  .addReg(NVPTX::VRFrameLocal);
       }
-
       BuildMI(MBB, MI, dl,
               MF.getSubtarget().getInstrInfo()->get(NVPTX::MOV_DEPOT_ADDR_64),
               NVPTX::VRFrameLocal)
           .addImm(MF.getFunctionNumber());
     } else {
       // Check if %SP is actually used
-      if (MR.hasOneNonDBGUse(NVPTX::VRFrame)) {
+      if (!MR.use_empty(NVPTX::VRFrame)) {
         MI = BuildMI(MBB, MI, dl, MF.getSubtarget().getInstrInfo()->get(
                                       NVPTX::cvta_local_yes),
                      NVPTX::VRFrame)
Index: test/CodeGen/NVPTX/local-stack-frame.ll
===================================================================
--- test/CodeGen/NVPTX/local-stack-frame.ll
+++ test/CodeGen/NVPTX/local-stack-frame.ll
@@ -56,3 +56,21 @@
   store i32 %a, i32* %2
   ret void
 }
+
+; PTX32:        cvta.local.u32   %SP, %SPL;
+; PTX32:        add.u32          {{%r[0-9]+}}, %SP, 0;
+; PTX32:        st.local.u32     [{{%r[0-9]+}}], {{%r[0-9]+}}
+; PTX32:        st.local.u32     [{{%r[0-9]+}}], {{%r[0-9]+}}
+; PTX64:        cvta.local.u64   %SP, %SPL;
+; PTX64:        add.u64          {{%rd[0-9]+}}, %SP, 0;
+; PTX64:        st.local.u32     [{{%rd[0-9]+}}], {{%r[0-9]+}}
+; PTX64:        st.local.u32     [{{%rd[0-9]+}}], {{%r[0-9]+}}
+define void @foo4() {
+  %A = alloca i32
+  %B = alloca i32
+  store i32 0, i32* %A
+  store i32 0, i32* %B
+  call void @bar(i32* %A)
+  call void @bar(i32* %B)
+  ret void
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10844.28799.patch
Type: text/x-patch
Size: 2110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150630/aa008f82/attachment.bin>


More information about the llvm-commits mailing list