]> granicus.if.org Git - clang/commitdiff
[PowerPC] Make -pg generate calls to _mcount not mcount
authorHal Finkel <hfinkel@anl.gov>
Sun, 30 Mar 2014 13:00:06 +0000 (13:00 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sun, 30 Mar 2014 13:00:06 +0000 (13:00 +0000)
At least on REL6 (Linux/glibc 2.12), the proper symbol for generating gprof
data is _mcount, not mcount. Prior to this change, compiling with -pg would
generate linking errors (because of unresolved references to mcount), after
this change -pg seems at least minimally functional.

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

lib/Basic/Targets.cpp
test/CodeGen/mcount.c

index 6811b3096a115d1ecdc5ee08c2a0a71ac4e70909..3d294cefa001d5f39c2a63f96b41d57f00e197ae 100644 (file)
@@ -355,6 +355,16 @@ public:
   LinuxTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
     this->UserLabelPrefix = "";
     this->WIntType = TargetInfo::UnsignedInt;
+
+    switch (Triple.getArch()) {
+    default:
+      break;
+    case llvm::Triple::ppc:
+    case llvm::Triple::ppc64:
+    case llvm::Triple::ppc64le:
+      this->MCountName = "_mcount";
+      break;
+    }
   }
 
   const char *getStaticInitSectionSpecifier() const override {
index 1cf3d6a071621cdb3d954d9cc03d7de48be32233..5c608bcd3657dc09b2e68682e6acc1d10977af4a 100644 (file)
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -pg -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -pg -triple powerpc-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-PPC %s
+// RUN: %clang_cc1 -pg -triple powerpc64-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-PPC %s
+// RUN: %clang_cc1 -pg -triple powerpc64le-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-PPC %s
 void foo(void) {
 // CHECK: call void @mcount()
+// CHECK-PPC: call void @_mcount()
 }