[llvm] 9f88912 - [dsymutil] Avoid relocating DW_AT_call_pc twice

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 10:37:04 PDT 2020


Author: Vedant Kumar
Date: 2020-05-07T10:36:29-07:00
New Revision: 9f889125abbf8b99450cff7026041932228e9c95

URL: https://github.com/llvm/llvm-project/commit/9f889125abbf8b99450cff7026041932228e9c95
DIFF: https://github.com/llvm/llvm-project/commit/9f889125abbf8b99450cff7026041932228e9c95.diff

LOG: [dsymutil] Avoid relocating DW_AT_call_pc twice

Summary:
Avoid relocating DW_AT_call_pc, e.g. when a call PC is equal to the
function's low_pc as is the case in the test:

```
__Z5func1v:
0000000100007f94        b       __Z5func2v
```

rdar://62952440

Reviewers: friss, JDevlieghere

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79536

Added: 
    llvm/test/tools/dsymutil/ARM/call-pc-reloc.test
    llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64
    llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64.o

Modified: 
    llvm/lib/DWARFLinker/DWARFLinker.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 4e384d51103f..1d7ef350f63d 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -1344,6 +1344,8 @@ DIE *DWARFLinker::DIECloner::cloneDIE(const DWARFDie &InputDIE,
                                           std::numeric_limits<uint64_t>::max());
     AttrInfo.OrigCallReturnPc =
         dwarf::toAddress(InputDIE.find(dwarf::DW_AT_call_return_pc), 0);
+    AttrInfo.OrigCallPc =
+        dwarf::toAddress(InputDIE.find(dwarf::DW_AT_call_pc), 0);
   }
 
   // Reset the Offset to 0 as we will be working on the local copy of

diff  --git a/llvm/test/tools/dsymutil/ARM/call-pc-reloc.test b/llvm/test/tools/dsymutil/ARM/call-pc-reloc.test
new file mode 100644
index 000000000000..f34e682697b0
--- /dev/null
+++ b/llvm/test/tools/dsymutil/ARM/call-pc-reloc.test
@@ -0,0 +1,20 @@
+Instructions to reproduce
+-------------------------
+
+$ cat main.cpp
+void __attribute__((optnone)) func2() {}
+void __attribute__((noinline)) func1() { func2(); /* tail */ }
+int __attribute__((disable_tail_calls)) main() {
+  func1(); /* regular */
+  return 0;
+}
+
+# Adding `-isysroot $(xcrun -sdk iphoneos.internal -show-sdk-path)` can fix
+# linker warnings when building on macOS.
+$ clang -arch arm64 main.cpp -o main.arm64.o -c -g -O2
+$ clang -arch arm64 main.arm64.o -o main.arm64 -g
+
+RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/call_pc/main.arm64 -o %t.dSYM
+RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_pc
+
+CHECK: DW_AT_call_pc (0x0000000100007f94)

diff  --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64 b/llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64
new file mode 100755
index 000000000000..9d34f3c78759
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64 
diff er

diff  --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64.o
new file mode 100644
index 000000000000..abe448ffa5cd
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/call_pc/main.arm64.o 
diff er


        


More information about the llvm-commits mailing list