Our aim is to establish some new cases of the global Langlands correspondence for GLm. Along the way we obtain a new result on the description of the cohomology of some compact Shimura varieties. Let F be a CM field with complex conjugation c and Π be a cuspidal automorphic representation of GLm(AF ). Suppose that Π ∨ Π • c and that Π∞ is cohomological. A very mild condition on Π∞ is imposed if m is even. We prove that for each prime l there exists a continuous semisimple representation R l (Π) : Gal(F /F ) → GLm(Q l ) such that Π and R l (Π) correspond via the local Langlands correspondence (established by Harris-Taylor and Henniart) at every finite place w l of F ("local-global compatibility"). We also obtain several additional properties of R l (Π) and prove the RamanujanPetersson conjecture for Π. This improves the previous results obtained by Clozel, Kottwitz, Harris-Taylor and Taylor-Yoshida, where it was assumed in addition that Π is square integrable at a finite place. It is worth noting that the mild condition on Π∞ in our theorem is removed by a p-adic deformation argument, thanks to Chenevier-Harris.Our approach generalizes that of Harris-Taylor, which constructs Galois representations by studying the l-adic cohomology and bad reduction of certain compact Shimura varieties attached to unitary similitude groups. The central part of our work is the computation of the cohomology of the so-called Igusa varieties. Some of the main tools are the stabilized counting point formula for Igusa varieties and techniques in the stable and twisted trace formulas.Recently there have been results by Morel and Clozel-Harris-Labesse in a similar direction as ours. Our result is stronger in a few aspects. Most notably, we obtain information about R l (Π) at ramified places.