If this matters, can we make the regular code path faster? Or make this be a separate function, for example on IRBuilder?<div><br></div><div> - Daniel<br><br><div class="gmail_quote">On Fri, Mar 20, 2009 at 11:53 PM, Chris Lattner <span dir="ltr"><<a href="mailto:sabre@nondot.org">sabre@nondot.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Author: lattner<br>
Date: Sat Mar 21 01:53:34 2009<br>
New Revision: 67434<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=67434&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=67434&view=rev</a><br>
Log:<br>
avoid making constant folding logic eliminate obviously dead bitcasts, speeding up PR3810<br>
by ~2%.<br>
<br>
Modified:<br>
cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=67434&r1=67433&r2=67434&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=67434&r1=67433&r2=67434&view=diff</a><br>
<br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Mar 21 01:53:34 2009<br>
@@ -824,7 +824,9 @@<br>
if (!Entry)<br>
Entry = EmitForwardFunctionDefinition(D, 0);<br>
<br>
- return llvm::ConstantExpr::getBitCast(Entry, PTy);<br>
+ if (Entry->getType() != PTy)<br>
+ return llvm::ConstantExpr::getBitCast(Entry, PTy);<br>
+ return Entry;<br>
}<br>
<br>
void CodeGenModule::EmitGlobalFunctionDefinition(const FunctionDecl *D) {<br>
@@ -954,8 +956,11 @@<br>
<br>
llvm::GlobalValue *&ExistingFn =<br>
GlobalDeclMap[getContext().Idents.get(Name).getName()];<br>
- if (ExistingFn)<br>
+ if (ExistingFn) {<br>
+ if (ExistingFn->getType() == Ty)<br>
+ return FunctionSlot = ExistingFn;<br>
return FunctionSlot = llvm::ConstantExpr::getBitCast(ExistingFn, Ty);<br>
+ }<br>
<br>
// FIXME: param attributes for sext/zext etc.<br>
return FunctionSlot = ExistingFn =<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>