diff --git a/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp b/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp index d9b2e3063143..023e642e648c 100644 --- a/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -86,6 +86,9 @@ bool IPCP::PropagateConstantsIntoArguments(Function &F) { unsigned NumNonconstant = 0; for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E; ++UI) { + // Ignore blockaddress uses. + if (isa(*UI)) continue; + // Used by a non-instruction, or not the callee of a function, do not // transform. if (!isa(*UI) && !isa(*UI)) diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 4e5fae8a0414..a348e20907e2 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1680,12 +1680,14 @@ static bool AddressIsTaken(GlobalValue *GV) { return true; // Storing addr of GV. } else if (isa(*UI) || isa(*UI)) { // Make sure we are calling the function, not passing the address. - CallSite CS = CallSite::get(cast(*UI)); - if (CS.hasArgument(GV)) + if (UI.getOperandNo() != 0) return true; } else if (LoadInst *LI = dyn_cast(*UI)) { if (LI->isVolatile()) return true; + } else if (isa(*UI)) { + // blockaddress doesn't take the address of the function, it takes addr + // of label. } else { return true; }