[llvm] r316469 - bpf: fix a bug in bpf-isel trunc-op optimization

Yonghong Song via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 10:29:04 PDT 2017


Author: yhs
Date: Tue Oct 24 10:29:03 2017
New Revision: 316469

URL: http://llvm.org/viewvc/llvm-project?rev=316469&view=rev
Log:
bpf: fix a bug in bpf-isel trunc-op optimization

In BPF backend, we try to optimize away redundant
trunc operations so that kernel verifier rewrite
remains valid. Previous implementation only works
for a single function.

This patch fixed the issue for multiple functions.
It clears internal map data structure before
performing optimization for each function.

Signed-off-by: Yonghong Song <yhs at fb.com>
Acked-by: Alexei Starovoitov <ast at kernel.org>

Modified:
    llvm/trunk/lib/Target/BPF/BPFISelDAGToDAG.cpp

Modified: llvm/trunk/lib/Target/BPF/BPFISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFISelDAGToDAG.cpp?rev=316469&r1=316468&r2=316469&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFISelDAGToDAG.cpp Tue Oct 24 10:29:03 2017
@@ -329,6 +329,11 @@ void BPFDAGToDAGISel::PreprocessISelDAG(
   //    are 32-bit registers, but later on, kernel verifier will rewrite
   //    it with 64-bit value. Therefore, truncating the value after the
   //    load will result in incorrect code.
+
+  // clear the load_to_vreg_ map so that we have a clean start
+  // for this function.
+  load_to_vreg_.clear();
+
   for (SelectionDAG::allnodes_iterator I = CurDAG->allnodes_begin(),
                                        E = CurDAG->allnodes_end();
        I != E;) {




More information about the llvm-commits mailing list