I believe this worked OK with GHC 9.2.5
$ ~/.ghcup/ghc/9.4.4/bin/ghc --make -fllvm -O2 test.hs
Loaded package environment from /home/dunham/.ghc/x86_64-linux-9.4.4/environments/default
[1 of 2] Compiling Main ( test.hs, test.o )
Cannot specify -O# and --passes=/--foo-pass, use -passes='default<O#>,other-pass'
<no location info>: error:
`opt' failed in phase `LLVM Optimiser'. (Exit code: 1)
However
$ ~/.ghcup/ghc/9.4.4/bin/ghc --make -fllvm test.hs
Loaded package environment from /home/dunham/.ghc/x86_64-linux-9.4.4/environments/default
[1 of 2] Compiling Main ( test.hs, test.o )
[2 of 2] Linking test
and
/.ghcup/ghc/9.4.4/bin/ghc --make -O2 test.hs
Loaded package environment from /home/dunham/.ghc/x86_64-linux-9.4.4/environments/default
[1 of 2] Compiling Main ( test.hs, test.o )
[2 of 2] Linking test