<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 11/16/2013 06:48 PM, David Blaikie
wrote:<br>
</div>
<blockquote
cite="mid:CAENS6EsRD+p0_teMb2fpFRYfPmf45PQ=QCKeH8HWkDGowCti=w@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Sat, Nov 16, 2013 at 12:30 PM,
Lewis Burns <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:lewisurn@gmail.com" target="_blank">lewisurn@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> <big>I've finally
figured out where a function </big>declaration is
lazily emitted. It is done in the
CodeGenModule::GetOrCreateLLVMFunction() function, which
is in turned called by EmitCall functions. I wrote a
function which is similar to the
CGDebugInfo::EmitFunctionStart() function and hooked it
into the GetOrCreateLLVMFunction function. It seems to
work, since it passed all LLVM & Clang regression
tests except two.<br>
<br>
I'm now having two other questions.<br>
<br>
(1) How to add a Clang command line option to control
the call to my function? The hook-up point in my code is
as follows:<br>
<br>
<font face="Courier New, Courier, monospace">llvm::Constant
*<br>
CodeGenModule::GetOrCreateLLVMFunction(StringRef
MangledName,<br>
llvm::Type *Ty,<br>
GlobalDecl D,
bool ForVTable,<br>
llvm::AttributeSet ExtraAttrs) {<br>
...<br>
llvm::Function *F = llvm::Function::Create(FTy,<br>
llvm::Function::ExternalLinkage,<br>
MangledName, &getModule());<br>
...<br>
if
(ExtraAttrs.hasAttributes(llvm::AttributeSet::FunctionIndex))
{<br>
llvm::AttrBuilder B(ExtraAttrs,
llvm::AttributeSet::FunctionIndex);<br>
F->addAttributes(llvm::AttributeSet::FunctionIndex,<br>
llvm::AttributeSet::get(VMContext,<br>
llvm::AttributeSet::FunctionIndex,<br>
B));<br>
}<br>
<br>
// Emit subprogram debug descriptor for this new
declaration<br>
// if "-gg" is given like clang -gg, then call this
function<br>
EmitFunctionDeclaration(D, F); </font><font
face="Courier New, Courier, monospace"><font
face="Courier New, Courier, monospace">-- hook up
line</font><br>
<br>
// This is the first use or definition of a mangled
name. If there is a<br>
// deferred decl with this name, remember that we
need to emit it at the end<br>
// of the file.<br>
llvm::StringMap<GlobalDecl>::iterator DDI =
DeferredDecls.find(MangledName);<br>
...<br>
}<br>
</font><br>
It seems to be very complicated to do this in Clang.
I've spent hours and still couldn't solve it.<br>
</div>
</blockquote>
<div><br>
</div>
<div>Have you looked at how other command line arguments are
handled in Clang?</div>
</div>
</div>
</div>
</blockquote>
Sure, I've followed other flags and examples, especially one from
here:
<a class="moz-txt-link-freetext" href="http://permalink.gmane.org/gmane.comp.compilers.clang.devel/27289">http://permalink.gmane.org/gmane.comp.compilers.clang.devel/27289</a>.
However, it worked finally when I changed -gg to some other value,
say -declaration-descriptor. Clang doesn't want to other people to
use "-gg." :(<br>
<br>
<br>
<pre class="moz-signature" cols="72">--
Lewis</pre>
</body>
</html>