From 51d6fa246d21073dbc4982ee09ea8ac8d95ba227 Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Tue, 24 Oct 2017 17:29:03 +0000 Subject: [PATCH] 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 Acked-by: Alexei Starovoitov git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316469 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/BPF/BPFISelDAGToDAG.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Target/BPF/BPFISelDAGToDAG.cpp b/lib/Target/BPF/BPFISelDAGToDAG.cpp index 1f382f3e73f..5c545603668 100644 --- a/lib/Target/BPF/BPFISelDAGToDAG.cpp +++ b/lib/Target/BPF/BPFISelDAGToDAG.cpp @@ -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;) { -- 2.50.1