[PATCH] D135384: [AIX] Enable the use of the -pg flag
Michael Francis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 11 10:16:00 PDT 2022
francii updated this revision to Diff 466852.
francii added a comment.
Updated target triple check to use isOSAIX()
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135384/new/
https://reviews.llvm.org/D135384
Files:
clang/test/CodeGen/mcount-aix.c
llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===================================================================
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Dominators.h"
@@ -34,9 +35,25 @@
Func == "__mcount" ||
Func == "_mcount" ||
Func == "__cyg_profile_func_enter_bare") {
- FunctionCallee Fn = M.getOrInsertFunction(Func, Type::getVoidTy(C));
- CallInst *Call = CallInst::Create(Fn, "", InsertionPt);
- Call->setDebugLoc(DL);
+ const Twine targetTwine(M.getTargetTriple());
+ Triple targetTriple(targetTwine);
+ if (targetTriple.isOSAIX()) {
+ Type *SizeTy = M.getDataLayout().getIntPtrType(C);
+ Type *SizePtrTy = SizeTy->getPointerTo();
+ GlobalVariable *GV = new GlobalVariable(M, SizeTy, /*isConstant=*/false,
+ GlobalValue::InternalLinkage,
+ ConstantInt::get(SizeTy, 0));
+ CallInst *Call = CallInst::Create(
+ M.getOrInsertFunction(Func,
+ FunctionType::get(Type::getVoidTy(C), {SizePtrTy},
+ /*isVarArg=*/false)),
+ {GV}, "", InsertionPt);
+ Call->setDebugLoc(DL);
+ } else {
+ FunctionCallee Fn = M.getOrInsertFunction(Func, Type::getVoidTy(C));
+ CallInst *Call = CallInst::Create(Fn, "", InsertionPt);
+ Call->setDebugLoc(DL);
+ }
return;
}
Index: clang/test/CodeGen/mcount-aix.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/mcount-aix.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -pg -triple powerpc-ibm-aix7.2.0.0 -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -pg -triple powerpc64-ibm-aix7.2.0.0 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK64
+
+void foo() {
+}
+
+void bar() {
+ foo();
+}
+// CHECK: @[[GLOB0:[0-9]+]] = internal global i32 0
+// CHECK: @[[GLOB1:[0-9]+]] = internal global i32 0
+// CHECK64: @[[GLOB0:[0-9]+]] = internal global i64 0
+// CHECK64: @[[GLOB1:[0-9]+]] = internal global i64 0
+// CHECK-LABEL: @foo(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void @__mcount(ptr @[[GLOB0]])
+// CHECK64-LABEL: @foo(
+// CHECK64-NEXT: entry:
+// CHECK64-NEXT: call void @__mcount(ptr @[[GLOB0]])
+// CHECK-LABEL: @bar(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void @__mcount(ptr @[[GLOB1]])
+// CHECK64-LABEL: @bar(
+// CHECK64-NEXT: entry:
+// CHECK64-NEXT: call void @__mcount(ptr @[[GLOB1]])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135384.466852.patch
Type: text/x-patch
Size: 2878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221011/02328b95/attachment.bin>
More information about the llvm-commits
mailing list