[PATCH] D106056: [CVP] processSwitch: Remove default case when switch cover all possible values.

Nathan Chancellor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 23 14:35:42 PDT 2021


nathanchance added a comment.

All I can go off of at this point is the `objtool` warning so here is a reduced C program that reproduces with this patch:

  $ cat chan.i
  enum { false, true };
  enum {
    IEEE80211_EDMG_BW_CONFIG_4 = 4,
    IEEE80211_EDMG_BW_CONFIG_5,
    IEEE80211_EDMG_BW_CONFIG_6,
    IEEE80211_EDMG_BW_CONFIG_7,
    IEEE80211_EDMG_BW_CONFIG_8,
    IEEE80211_EDMG_BW_CONFIG_9,
    IEEE80211_EDMG_BW_CONFIG_10,
    IEEE80211_EDMG_BW_CONFIG_11,
    IEEE80211_EDMG_BW_CONFIG_12,
    IEEE80211_EDMG_BW_CONFIG_13
  } cfg80211_edmg_chandef_valid_chandef_1;
  cfg80211_edmg_chandef_valid_max_contiguous;
  cfg80211_edmg_chandef_valid_num_of_enabled() {
    switch (cfg80211_edmg_chandef_valid_chandef_1)
    case IEEE80211_EDMG_BW_CONFIG_4:
    case IEEE80211_EDMG_BW_CONFIG_13:
      if (cfg80211_edmg_chandef_valid_max_contiguous)
        switch (cfg80211_edmg_chandef_valid_chandef_1) {
        case IEEE80211_EDMG_BW_CONFIG_4:
        case IEEE80211_EDMG_BW_CONFIG_5:
        case IEEE80211_EDMG_BW_CONFIG_6:
        case IEEE80211_EDMG_BW_CONFIG_7:
          break;
        case IEEE80211_EDMG_BW_CONFIG_8:
        case IEEE80211_EDMG_BW_CONFIG_9:
        case IEEE80211_EDMG_BW_CONFIG_10:
        case IEEE80211_EDMG_BW_CONFIG_11:
          if (cfg80211_edmg_chandef_valid_num_of_enabled < 2)
          case IEEE80211_EDMG_BW_CONFIG_12:
          case IEEE80211_EDMG_BW_CONFIG_13:
            if (cfg80211_edmg_chandef_valid_num_of_enabled < 2)
            default:
              return false;
        }
    return true;
  }
  
  $ clang -O2 -flto=thin -fsplit-lto-unit -fvisibility=hidden -c -o chan.o chan.i
  ...
  
  $ llvm-ar cDPrST chan.a chan.o
  
  $ ld.lld -m elf_x86_64 -r -o vmlinux.o --whole-archive chan.a
  
  $ ./objtool orc generate --duplicate --vmlinux --no-fp --no-unreachable --retpoline --uaccess vmlinux.o
  vmlinux.o: warning: objtool: cfg80211_edmg_chandef_valid_num_of_enabled()+0x35: can't find jump dest instruction at .text.cfg80211_edmg_chandef_valid_num_of_enabled+0x4a

The `objtool` binary and other files are available here <https://github.com/nathanchance/creduce-files/tree/9ca2f435a1fd0b5ada68d0701efd77bb587a7ed6/D106056>.

Hopefully that is enough to figure out what is going on here, I am happy to test or provide more information to the best of my ability.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106056



More information about the llvm-commits mailing list