summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjCGNU.cpp
diff options
context:
space:
mode:
authorDavid Chisnall <csdavec@swan.ac.uk>2012-04-09 15:42:15 +0000
committerDavid Chisnall <csdavec@swan.ac.uk>2012-04-09 15:42:15 +0000
commit4ec2af2fab89f8a63f681de9db139b69165e16b3 (patch)
tree3f3f60af68f4d148b80e08da63491deca781b549 /clang/lib/CodeGen/CGObjCGNU.cpp
parent2eec367227d2d08c3b6460efe6fe5d0a9375b2b2 (diff)
downloadbcm5719-llvm-4ec2af2fab89f8a63f681de9db139b69165e16b3.tar.gz
bcm5719-llvm-4ec2af2fab89f8a63f681de9db139b69165e16b3.zip
Add -fobjc-trace to emit a call before and after each Objective-C message send
for hooking in code flow visualisation applications. llvm-svn: 154321
Diffstat (limited to 'clang/lib/CodeGen/CGObjCGNU.cpp')
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index db0bd951c1e..6cf370f79ea 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -322,6 +322,11 @@ private:
/// Function used for non-object declared property setters.
LazyRuntimeFunction SetStructPropertyFn;
+ /// Function called before message sends, when tracing
+ LazyRuntimeFunction TraceEnterFn;
+ /// Function called after message sends, when tracing
+ LazyRuntimeFunction TraceExitFn;
+
/// The version of the runtime that this class targets. Must match the
/// version in the runtime.
int RuntimeVersion;
@@ -768,6 +773,9 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
SetStructPropertyFn.init(&CGM, "objc_setPropertyStruct", VoidTy, PtrTy, PtrTy,
PtrDiffTy, BoolTy, BoolTy, NULL);
+ TraceEnterFn.init(&CGM, "objc_trace_enter", VoidTy, IdTy, SelectorTy, NULL);
+ TraceExitFn.init(&CGM, "objc_trace_exit", VoidTy, IdTy, SelectorTy, NULL);
+
// IMP type
llvm::Type *IMPArgs[] = { IdTy, SelectorTy };
IMPTy = llvm::PointerType::getUnqual(llvm::FunctionType::get(IdTy, IMPArgs,
@@ -1212,12 +1220,19 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF,
ActualArgs[0] = CallArg(RValue::get(Receiver), ASTIdTy, false);
imp = EnforceType(Builder, imp, MSI.MessengerType);
+ if (CGM.getCodeGenOpts().ObjCTrace) {
+ Builder.CreateCall2(TraceEnterFn, Receiver, cmd);
+ }
llvm::Instruction *call;
RValue msgRet = CGF.EmitCall(MSI.CallInfo, imp, Return, ActualArgs,
0, &call);
call->setMetadata(msgSendMDKind, node);
+ if (CGM.getCodeGenOpts().ObjCTrace) {
+ Builder.CreateCall2(TraceExitFn, Receiver, cmd);
+ }
+
if (!isPointerSizedReturn) {
messageBB = CGF.Builder.GetInsertBlock();
OpenPOWER on IntegriCloud