Graph Neural Networks (GNNs) have achieved remarkable performance in modeling graphs for various applications. However, most existing GNNs assume the graphs exhibit strong homophily in node labels, i.e., nodes with similar labels are connected in the graphs. They fail to generalize to heterophilic graphs where linked nodes may have dissimilar labels and attributes. Therefore, in this paper, we investigate a novel framework that performs well on graphs with either homophily or heterophily. More specifically, to address the challenge brought by the heterophily in graphs, we propose a label-wise message passing mechanism. In label-wise message-passing, neighbors with similar pseudo labels will be aggregated together, which will avoid the negative effects caused by aggregating dissimilar node representations. We further propose a bi-level optimization method to automatically select the model for graphs with homophily/heterophily. Extensive experiments demonstrate the effectiveness of our proposed framework for node classification on both homophilic and heterophilic graphs.