[PATCH] Fix "-mno-global-merge" option for clang

Eric Christopher echristo at gmail.com
Tue Aug 5 16:16:55 PDT 2014


Looking at it a bit the options handling is all frightening.

I.e.

dzur:~/tmp> ~/builds/build-llvm/Debug+Asserts/bin/clang -target
armv7-apple-darwin10 foo.c -### -mno-global-merge -v -S

clang version 3.6.0 (trunk 214924) (llvm/trunk 214925)

Target: armv7-apple-darwin10

Thread model: posix

"/usr/local/google/home/echristo/builds/build-llvm/Debug+Asserts/bin/clang"
"-cc1" "-triple" "thumbv7-apple-ios5.0.0" "-S" "-disable-free"
"-main-file-name" "foo.c" "-mrelocation-model" "pic" "-pic-level" "2"
"-mdisable-fp-elim" "-masm-verbose" "-target-cpu" "cortex-a8"
"-target-feature" "+soft-float-abi" "-target-abi" "apcs-gnu"
"-mfloat-abi" "soft" "-mno-global-merge" "-target-linker-version"
"2.24.51.20140310" "-v" "-dwarf-column-info" "-coverage-file"
"/usr/local/google/home/echristo/tmp/foo.s" "-resource-dir"
"/usr/local/google/home/echristo/builds/build-llvm/Debug+Asserts/bin/../lib/clang/3.6.0"
"-fdebug-compilation-dir" "/usr/local/google/home/echristo/tmp"
"-ferror-limit" "19" "-fmessage-length" "238" "-stack-protector" "1"
"-mstackrealign" "-fblocks" "-fobjc-runtime=ios-5.0.0"
"-fencode-extended-block-signature" "-fsjlj-exceptions"
"-fmax-type-align=16" "-fdiagnostics-show-option"
"-fcolor-diagnostics" "-o" "foo.s" "-x" "c" "foo.c"

Passes -mno-global-merge to -cc1.

dzur:~/tmp> ~/builds/build-llvm/Debug+Asserts/bin/clang -target
thumbv7-apple-darwin10 foo.c -### -mno-global-merge -v -S

clang version 3.6.0 (trunk 214924) (llvm/trunk 214925)

Target: thumbv7-apple-darwin10

Thread model: posix

clang: warning: argument unused during compilation: '-mno-global-merge'

"/usr/local/google/home/echristo/builds/build-llvm/Debug+Asserts/bin/clang"
"-cc1" "-triple" "unknown-apple-macosx10.6.0" "-S" "-disable-free"
"-main-file-name" "foo.c" "-mrelocation-model" "pic" "-pic-level" "2"
"-mdisable-fp-elim" "-masm-verbose" "-target-linker-version"
"2.24.51.20140310" "-v" "-dwarf-column-info" "-coverage-file"
"/usr/local/google/home/echristo/tmp/foo.s" "-resource-dir"
"/usr/local/google/home/echristo/builds/build-llvm/Debug+Asserts/bin/../lib/clang/3.6.0"
"-fdebug-compilation-dir" "/usr/local/google/home/echristo/tmp"
"-ferror-limit" "19" "-fmessage-length" "238" "-stack-protector" "1"
"-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-10.6.0"
"-fencode-extended-block-signature" "-fmax-type-align=16"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "foo.s" "-x"
"c" "foo.c"

fails to parse the triple even if it's what we wanted in the first place. Fun.

dzur:~/tmp> ~/builds/build-llvm/Debug+Asserts/bin/clang -target
arm-none-eabi foo.c -### -mno-global-merge -v -S -munaligned-access

clang version 3.6.0 (trunk 214924) (llvm/trunk 214925)

Target: arm-none--eabi

Thread model: posix

"/usr/local/google/home/echristo/builds/build-llvm/Debug+Asserts/bin/clang"
"-cc1" "-triple" "armv4t-none--eabi" "-S" "-disable-free"
"-main-file-name" "foo.c" "-mrelocation-model" "static"
"-mdisable-fp-elim" "-fmath-errno" "-masm-verbose"
"-mconstructor-aliases" "-target-cpu" "arm7tdmi" "-target-feature"
"+soft-float-abi" "-target-abi" "aapcs" "-mfloat-abi" "soft"
"-backend-option" "-arm-no-strict-align" "-mno-global-merge"
"-target-linker-version" "2.24.51.20140310" "-v" "-dwarf-column-info"
"-coverage-file" "/usr/local/google/home/echristo/tmp/foo.s"
"-resource-dir"
"/usr/local/google/home/echristo/builds/build-llvm/Debug+Asserts/bin/../lib/clang/3.6.0"
"-fdebug-compilation-dir" "/usr/local/google/home/echristo/tmp"
"-ferror-limit" "19" "-fmessage-length" "238" "-mstackrealign"
"-fno-signed-char" "-fobjc-runtime=gcc" "-fdiagnostics-show-option"
"-fcolor-diagnostics" "-o" "foo.s" "-x" "c" "foo.c"

has -munaligned-access as a -backend-option, and -mno-global-merge as not.

but yes, if it isn't passed via -backend-option (and -backend-option
is bad) I agree it's impossible to test without an API testing
infrastructure we don't have/use at the moment. Thanks for looking
though.

-eric



On Fri, Aug 1, 2014 at 3:54 PM, Steven Wu <stevenwu at apple.com> wrote:
> It doesn’t have to be linked but BackendArgs will not show up with -###.
> -mno-global-merge flag will be passed as it is to cc1, but it will become -enable-global-merge=false when pass to llc. The only way I can think a test is to run the actual command but it is not a good test case apparently.
>
> Steven
>
>> On Jul 25, 2014, at 4:47 PM, Steven Wu <stevenwu at apple.com> wrote:
>>
>> <global_merge.patch>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list