aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
index 60f910bceab8..53af1b1969c2 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ b/contrib/llvm-project/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,24 @@ static void insertCall(Function &CurFn, StringRef Func,
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);
+ Triple TargetTriple(M.getTargetTriple());
+ if (TargetTriple.isOSAIX() && Func == "__mcount") {
+ 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;
}