From b23fde6184034f196e94984ef94dcbfc87a8b826 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sun, 30 Mar 2014 13:00:06 +0000 Subject: [PATCH] [PowerPC] Make -pg generate calls to _mcount not mcount 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 | 10 ++++++++++ test/CodeGen/mcount.c | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 6811b3096a..3d294cefa0 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -355,6 +355,16 @@ public: LinuxTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(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 { diff --git a/test/CodeGen/mcount.c b/test/CodeGen/mcount.c index 1cf3d6a071..5c608bcd36 100644 --- a/test/CodeGen/mcount.c +++ b/test/CodeGen/mcount.c @@ -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() } -- 2.40.0