[llvm-commits] [llvm] r85709 - in /llvm/trunk/lib/Transforms: IPO/IPConstantPropagation.cpp Scalar/SCCP.cpp
Chris Lattner
sabre at nondot.org
Sat Oct 31 23:11:54 PDT 2009
Author: lattner
Date: Sun Nov 1 01:11:53 2009
New Revision: 85709
URL: http://llvm.org/viewvc/llvm-project?rev=85709&view=rev
Log:
teach ipsccp and ipconstprop that a blockaddress doesn't 'take the address' of a function
in a way that should prevent ip constprop. This allows clang/test/CodeGen/indirect-goto.c
to pass with the new indirect goto lowering.
Modified:
llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Modified: llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp?rev=85709&r1=85708&r2=85709&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp Sun Nov 1 01:11:53 2009
@@ -86,6 +86,9 @@
unsigned NumNonconstant = 0;
for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E; ++UI) {
+ // Ignore blockaddress uses.
+ if (isa<BlockAddress>(*UI)) continue;
+
// Used by a non-instruction, or not the callee of a function, do not
// transform.
if (!isa<CallInst>(*UI) && !isa<InvokeInst>(*UI))
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85709&r1=85708&r2=85709&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Nov 1 01:11:53 2009
@@ -1680,12 +1680,14 @@
return true; // Storing addr of GV.
} else if (isa<InvokeInst>(*UI) || isa<CallInst>(*UI)) {
// Make sure we are calling the function, not passing the address.
- CallSite CS = CallSite::get(cast<Instruction>(*UI));
- if (CS.hasArgument(GV))
+ if (UI.getOperandNo() != 0)
return true;
} else if (LoadInst *LI = dyn_cast<LoadInst>(*UI)) {
if (LI->isVolatile())
return true;
+ } else if (isa<BlockAddress>(*UI)) {
+ // blockaddress doesn't take the address of the function, it takes addr
+ // of label.
} else {
return true;
}
More information about the llvm-commits
mailing list