In the mold filling process, polymer melt will suffer the shear stress and stretch, which has important influences on the mechanical properties and surface quality of the final plastic products. In this paper a gas-liquid two-phase flow model for a viscoelastic fluid is proposed and used to simulate the mold filling process, in which the finitely extensible nonlinear elastic dumbbell with Peterlin closure (FENE-P) model and cross-WLF viscosity model combined with Tait state equation are used to describe the constitutive relationship and viscosity change of the viscoelastic melt, respectively. Meanwhile, the improved coupled level-set and volume-of-fluid method is used to trace the melt front, and the finite volume method on non-staggered grid is used to solve the mass, momentum, and energy conservation equations. Firstly, the R-function, an excellent implicit modeling tool of constructive solid geometry, is employed to establish the shape level-set function to describe the complex mold cavities based on the signed distance functions that represent basic geometries. And the immersed boundary method is applied to dealing with the complex mold cavities by using the shape level-set function. The benchmark problem of the flow past a cylinder is simulated to verify the validity of the FENE-P model, where the orientational ellipses are used to describe the molecular orientation and deformation. Moreover, the visualization of polymer molecular deformation is achieved. Then, the non-isothermal filling process of the viscoelastic fluid is simulated in an annular mold cavity with two circular insets, and the behaviors of the molecular orientation, temperature and stress in the filling process are shown and analyzed in detail. Finally, the problems are also discussed that how the injection velocity, melt and mold temperatures influences on the molecular conformation and solidified layer thickness. Numerical results show that the computational framework proposed in this paper can be successfully used to simulate the non-isothermal mold filling process in the complex mold cavity. Increasing properly the injection velocity can reduce the heat loss and improve the strength of the weld line. The higher the melt or mold temperature, the thinner the solidified layer is. Thus, increasing the injection velocity, as well as raising the melt and the mold temperatures will improve or remove the weld line in melt filling process.