[llvm] r305245 - Inliner: Don't remove calls to readnone+nounwind (but not always_inline) functions in the AlwaysInliner
Mikael Holmén via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 04:02:07 PDT 2017
Hi David,
With this commit, opt crashes when doing:
opt -S -functionattrs -inline -instcombine -o - callgraph.ll
opt: ../include/llvm/Analysis/CallGraph.h:174:
llvm::CallGraphNode::~CallGraphNode(): Assertion `NumReferences == 0 &&
"Node deleted while references remain"' failed.
Regards,
Mikael
On 06/13/2017 01:01 AM, David Blaikie via llvm-commits wrote:
> Author: dblaikie
> Date: Mon Jun 12 18:01:17 2017
> New Revision: 305245
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305245&view=rev
> Log:
> Inliner: Don't remove calls to readnone+nounwind (but not always_inline) functions in the AlwaysInliner
>
> Modified:
> llvm/trunk/lib/Transforms/IPO/Inliner.cpp
> llvm/trunk/test/Transforms/Inline/always-inline.ll
>
> Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=305245&r1=305244&r2=305245&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Mon Jun 12 18:01:17 2017
> @@ -523,6 +523,16 @@ inlineCallsImpl(CallGraphSCC &SCC, CallG
> if (!Callee || Callee->isDeclaration())
> continue;
>
> + // FIXME for new PM: because of the old PM we currently generate ORE and
> + // in turn BFI on demand. With the new PM, the ORE dependency should
> + // just become a regular analysis dependency.
> + OptimizationRemarkEmitter ORE(Caller);
> +
> + // If the policy determines that we should inline this function,
> + // delete the call instead.
> + if (!shouldInline(CS, GetInlineCost, ORE))
> + continue;
> +
> // If this call site is dead and it is to a readonly function, we should
> // just delete the call instead of trying to inline it, regardless of
> // size. This happens because IPSCCP propagates the result out of the
> @@ -548,15 +558,6 @@ inlineCallsImpl(CallGraphSCC &SCC, CallG
> // Get DebugLoc to report. CS will be invalid after Inliner.
> DebugLoc DLoc = CS.getInstruction()->getDebugLoc();
> BasicBlock *Block = CS.getParent();
> - // FIXME for new PM: because of the old PM we currently generate ORE and
> - // in turn BFI on demand. With the new PM, the ORE dependency should
> - // just become a regular analysis dependency.
> - OptimizationRemarkEmitter ORE(Caller);
> -
> - // If the policy determines that we should inline this function,
> - // try to do so.
> - if (!shouldInline(CS, GetInlineCost, ORE))
> - continue;
>
> // Attempt to inline the function.
> using namespace ore;
>
> Modified: llvm/trunk/test/Transforms/Inline/always-inline.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/always-inline.ll?rev=305245&r1=305244&r2=305245&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/Inline/always-inline.ll (original)
> +++ llvm/trunk/test/Transforms/Inline/always-inline.ll Mon Jun 12 18:01:17 2017
> @@ -305,3 +305,14 @@ entry:
> ret void
> ; CHECK: ret void
> }
> +
> +define void @inner14() readnone nounwind {
> +; CHECK: define void @inner14
> + ret void
> +}
> +
> +define void @outer14() {
> +; CHECK: call void @inner14
> + call void @inner14()
> + ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
; ModuleID = 'bugpoint-reduced-simplified.bc'
; source_filename = "bugpoint-output-7c2cf05.bc"
; target datalayout = "E-B16-p:16:16-p21:32:16-p40:32:16-F40-i1:16-i8:16-i32:16-i64:16-f32:16-f64:16-v32:16:16-v64:16:16-v128:16:16-a:0:16-i24:16-i40:16-n16:32"
; target triple = "phoenix"
; opt -S -functionattrs -inline -instcombine -o -
%struct.a.0.4.8.12.16.20.24.28.32.36 = type { i16, i16 }
%struct.b.1.5.9.13.17.21.25.29.33.37 = type { i16, i16 }
%struct._bbiMcs_pageS.2.6.10.14.18.22.26.30.34.38 = type { i16, i16, i16 }
%struct._BbiMcs_pageS.3.7.11.15.19.23.27.31.35.39 = type { i16, i16 }
@i = external addrspace(21) global %struct.a.0.4.8.12.16.20.24.28.32.36, align 1
; Function Attrs: noinline nounwind
declare %struct.a.0.4.8.12.16.20.24.28.32.36 addrspace(21)* @foo() #0
; Function Attrs: noinline nounwind
define %struct.b.1.5.9.13.17.21.25.29.33.37 addrspace(21)* @bar() #0 {
entry:
ret %struct.b.1.5.9.13.17.21.25.29.33.37 addrspace(21)* undef
}
; Function Attrs: noinline nounwind
define %struct._bbiMcs_pageS.2.6.10.14.18.22.26.30.34.38 addrspace(21)* @bbiMcs_getPageAddr() #0 {
entry:
%call = call %struct._BbiMcs_pageS.3.7.11.15.19.23.27.31.35.39 addrspace(21)* @bbiMcs_cmAddr()
ret %struct._bbiMcs_pageS.2.6.10.14.18.22.26.30.34.38 addrspace(21)* undef
}
; Function Attrs: noinline nounwind
declare i16 @main(i16, i16**) #0
; Function Attrs: noinline nounwind
define internal %struct._BbiMcs_pageS.3.7.11.15.19.23.27.31.35.39 addrspace(21)* @bbiMcs_cmAddr() #0 {
entry:
ret %struct._BbiMcs_pageS.3.7.11.15.19.23.27.31.35.39 addrspace(21)* inttoptr (i32 4660 to %struct._BbiMcs_pageS.3.7.11.15.19.23.27.31.35.39 addrspace(21)*)
}
attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="phoenixIII" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.ident = !{!0}
!0 = !{!"clang version 5.0.0 (FLACC_FADER_6.64-1146-g84bf040774)"}
More information about the llvm-commits
mailing list