[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

Nathan Chancellor via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 14 12:14:29 PST 2022


nathanchance added a subscriber: nickdesaulniers.
nathanchance added a comment.

In D105169#3242949 <https://reviews.llvm.org/D105169#3242949>, @hyeongyukim wrote:

> @nathanchance Hi, I analyzed all four warnings.

Thanks a lot for doing this!

> Warning #1: can be handled by x86-backend. filled issue #53118 <https://github.com/llvm/llvm-project/issues/53118>

This is the warning in `drivers/net/ethernet/wiznet/w5100.lto.o` if I am reading the issue, right? I would have thought that would be warnings #2 and #3.

> Warning #2: bug in the kernel, fixed in the next version.
> Warning #3: same reason with #2

I think this refers to `drivers/net/ethernet/renesas/ravb.lto.o`, which is indeed fixed by https://git.kernel.org/linus/d9f31aeaa1e5aefa68130878af3c3513d41c1e2d.

> Warning #4: It was not reproduced in the latest clang.

I can still see this with clang @1441ffe6a6da90e9c4800914eb0005b1087aa5d2  and Linux @ 112450df61b7373529b0fe4c122ad13b89d80a8a built with `KCFLAGS="-Xclang -enable-noundef-analysis"`. Your small reproducer has it as well:

  $ clang --version | head -1
  ClangBuiltLinux clang version 14.0.0 (https://github.com/llvm/llvm-project 1441ffe6a6da90e9c4800914eb0005b1087aa5d2)
  
  $ clang -O2 -flto=thin -fsanitize=integer-divide-by-zero -fsanitize-coverage=trace-pc -Xclang -enable-noundef-analysis -c -o intelfb.{o,i}
  
  $ ld.lld -m elf_x86_64 -r -o intelfb.lto.o --whole-archive intelfb.o
  
  $ ./objtool orc generate --module --no-fp --no-unreachable --uaccess --mcount intelfb.lto.o
  intelfb.lto.o: warning: objtool: .text.intelfbhw_validate_mode: unexpected end of section



> As you see, one of this patch's advantages is that it exposed some bugs in the kernel!
> All issues are either identified or will be fixed soon. Is it okay to recommit this patch?

I just went to go hammer on this option to how many warnings I see on the next version of Linux ("linux-next") [1] with `allmodconfig` (which in turn enables `CONFIG_UBSAN`) + `CONFIG_LTO_CLANG_THIN=y` . I think I see a lot more warnings there versus Linus' tree as the kernel no longer uses `-fsanitize=object-size` there, which potentially hides some of these?

  $ echo "CONFIG_GCOV_KERNEL=n
  CONFIG_KASAN=n
  CONFIG_LTO_CLANG_THIN=y
  CONFIG_WERROR=n" >allmod.config
  
  $ make -skj"$(nproc)" KCFLAGS="-Xclang -enable-noundef-analysis" KCONFIG_ALLCONFIG=1 LLVM=1 allmodconfig all
  ...
  drivers/video/fbdev/omap2/omapfb/dss/omapdss.lto.o: warning: objtool: .text.dsi_cio_timings: unexpected end of section
  drivers/soc/qcom/qcom_rpmh.lto.o: warning: objtool: .text.rpmh_rsc_write_ctrl_data: unexpected end of section
  net/tipc/tipc.lto.o: warning: objtool: .text.tipc_nl_compat_link_stat_dump: unexpected end of section
  drivers/scsi/mpi3mr/mpi3mr.lto.o: warning: objtool: .text.mpi3mr_op_request_post: unexpected end of section
  drivers/md/bcache/bcache.lto.o: warning: objtool: .text.bch_cache_show: unexpected end of section
  drivers/scsi/dc395x.lto.o: warning: objtool: .text.msgin_phase0: unexpected end of section
  ...
  fs/ocfs2/cluster/ocfs2_nodemanager.lto.o: warning: objtool: .text.o2hb_setup_one_bio: unexpected end of section
  drivers/video/fbdev/intelfb/intelfb.lto.o: warning: objtool: .text.intelfbhw_validate_mode: unexpected end of section
  drivers/net/ethernet/wiznet/w5100.lto.o: warning: objtool: .text.w5100_tx_skb: unexpected end of section
  drivers/net/ethernet/wiznet/w5100.lto.o: warning: objtool: .text.w5100_rx_skb: unexpected end of section
  drivers/gpu/drm/amd/amdgpu/amdgpu.lto.o: warning: objtool: .text.dqm_debugfs_hqds: unexpected end of section
  ...

Without `KCFLAGS="-Xclang -enable-noundef-analysis"`, I only see the `mpi3mr_op_request_post` warning, so that is probably unrelated to this (probably some recent change regressed this, I'll see if I can hunt that down).

Without ThinLTO, I see:

  $ echo CONFIG_WERROR=n >allmod.config
  
  $ make -skj"$(nproc)" KCFLAGS="-Xclang -enable-noundef-analysis" KCONFIG_ALLCONFIG=1 LLVM=1 allmodconfig all
  ...
  drivers/soc/qcom/rpmh-rsc.o: warning: objtool: rpmh_rsc_write_ctrl_data() falls through to next function trace_raw_output_rpmh_tx_done()
  drivers/gpu/drm/radeon/sumo_dpm.o: warning: objtool: sumo_dpm_set_power_state() falls through to next function sumo_dpm_post_set_power_state()
  ...
  drivers/scsi/mpi3mr/mpi3mr_fw.o: warning: objtool: mpi3mr_op_request_post() falls through to next function mpi3mr_check_rh_fault_ioc()
  drivers/net/ethernet/wiznet/w5100.o: warning: objtool: w5100_tx_skb() falls through to next function w5100_get_drvinfo()
  drivers/net/ethernet/wiznet/w5100.o: warning: objtool: w5100_rx_skb() falls through to next function w5100_mmio_probe()
  ...

Some of the same warnings, which likely have the same root cause as above but no LTO might make this easier to look into. Without `KCFLAGS="-Xclang -enable-noundef-analysis"`, same as above, I only see the `mpi3mr_op_request_post` warning.

I can reduce all of these down for you and/or I can start an email thread with the `objtool` maintainers to see if there is a way to fix or avoid these warnings on the `objtool` side and include you in that discussion, if LLVM is not really doing anything wrong here. I am by no means an expert in this area and I don't want to delay this anymore but I want to avoid regressing our builds, as `objtool` regularly helps us spot compiler bugs. Perhaps @nickdesaulniers has some other thoughts?

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105169/new/

https://reviews.llvm.org/D105169



More information about the cfe-commits mailing list