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@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
llvm-svn: 316469
This commit is contained in:
Yonghong Song 2017-10-24 17:29:03 +00:00
parent fc46ff8dfa
commit 0f836d5dc5
1 changed files with 5 additions and 0 deletions

View File

@ -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;) {