Make "llvmc -opt" call "opt" for .ll files

Without this patch, opt is never called for llvm-assembly (.ll) files
when "-opt" is passed to llvmc:

$ llvmc -clang -v test.ll
llc -f -O2 test.ll -o /tmp/llvm_gvO2nK/test.s
as /tmp/llvm_gvO2nK/test.s -o /tmp/llvm_gvO2nK/test.o
llvm-ld -native -disable-internalize /tmp/llvm_gvO2nK/test.o -o a.out

$ llvmc -clang -opt -v test.ll
llc -f -O2 test.ll -o /tmp/llvm_2xiL86/test.s
as /tmp/llvm_2xiL86/test.s -o /tmp/llvm_2xiL86/test.o
llvm-ld -native -disable-internalize /tmp/llvm_2xiL86/test.o -o a.out

This patch makes a small change to tools/llvmc/src/Base.td so that
"-opt" is honored for .ll files. Invoking llvmc with this patch
results in:

$ llvmc -clang -v test.ll
llc -O2 test.ll -o /tmp/llvm_nbnJRg/test.s
as /tmp/llvm_nbnJRg/test.s -o /tmp/llvm_nbnJRg/test.o
llvm-ld -native -disable-internalize /tmp/llvm_nbnJRg/test.o -o a.out

$ llvmc -clang -opt -v test.ll
llvm-as test.ll -o /tmp/llvm_OoIRlO/test.bc
opt -f -O2 /tmp/llvm_OoIRlO/test.bc -o /tmp/llvm_OoIRlO/test.bc-GHASUE
llc -O2 /tmp/llvm_OoIRlO/test.bc-GHASUE -o /tmp/llvm_OoIRlO/test.s
as /tmp/llvm_OoIRlO/test.s -o /tmp/llvm_OoIRlO/test.o
llvm-ld -native -disable-internalize /tmp/llvm_OoIRlO/test.o -o a.out

llvm-opt-ll.diff (647 Bytes)

Without this patch, opt is never called for llvm-assembly (.ll) files
when "-opt" is passed to llvmc:

$ llvmc -clang -v test.ll
llc -f -O2 test.ll -o /tmp/llvm_gvO2nK/test.s
as /tmp/llvm_gvO2nK/test.s -o /tmp/llvm_gvO2nK/test.o
llvm-ld -native -disable-internalize /tmp/llvm_gvO2nK/test.o -o a.out

$ llvmc -clang -opt -v test.ll
llc -f -O2 test.ll -o /tmp/llvm_2xiL86/test.s
as /tmp/llvm_2xiL86/test.s -o /tmp/llvm_2xiL86/test.o
llvm-ld -native -disable-internalize /tmp/llvm_2xiL86/test.o -o a.out

This patch makes a small change to tools/llvmc/src/Base.td so that
"-opt" is honored for .ll files. Invoking llvmc with this patch
results in:

$ llvmc -clang -v test.ll
llc -O2 test.ll -o /tmp/llvm_nbnJRg/test.s
as /tmp/llvm_nbnJRg/test.s -o /tmp/llvm_nbnJRg/test.o
llvm-ld -native -disable-internalize /tmp/llvm_nbnJRg/test.o -o a.out

$ llvmc -clang -opt -v test.ll
llvm-as test.ll -o /tmp/llvm_OoIRlO/test.bc
opt -f -O2 /tmp/llvm_OoIRlO/test.bc -o /tmp/llvm_OoIRlO/test.bc-GHASUE
llc -O2 /tmp/llvm_OoIRlO/test.bc-GHASUE -o /tmp/llvm_OoIRlO/test.s
as /tmp/llvm_OoIRlO/test.s -o /tmp/llvm_OoIRlO/test.o
llvm-ld -native -disable-internalize /tmp/llvm_OoIRlO/test.o -o a.out

Cheers,
Kaelyn

llvm-opt-ll.diff (647 Bytes)

Hi,

Kaelyn Uhrain <kaelyn.alexi <at> gmail.com> writes:

Without this patch, opt is never called for llvm-assembly (.ll) files
when "-opt" is passed to llvmc:

[...]

Thanks, applied in r126000!