[llvm-bugs] [Bug 46629] New: Syntax warning in TableGen'd XXGenMCCodeEmitter.inc calling APInt LoadIntFromMemory utility function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 7 20:40:25 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46629

            Bug ID: 46629
           Summary: Syntax warning in TableGen'd XXGenMCCodeEmitter.inc
                    calling APInt LoadIntFromMemory utility function
           Product: tools
           Version: 10.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: TableGen
          Assignee: unassignedbugs at nondot.org
          Reporter: chris.sears at gmail.com
                CC: llvm-bugs at lists.llvm.org

TableGen supports large instructions, in my case, bits<128> Inst; This makes
TableGen generate APInt Insts rather than uint64_t or smaller. This is rarely
exercised code and so when I include the generated XXGenMCCodeEmitter.inc file,
I get a warning:

    warning: cast from 'const unsigned long long *' to 'unsigned char *' drops
const qualifier [-Wcast-qual]
    LoadIntFromMemory(Inst, (uint8_t*)&InstBits[opcode * 2], 16);

It's complaining because InstBits is declared as

    static const uint64_t InstBits[]

whereas LoadIntFromMemory()'s second argument is declared as 

    uint8_t *Src

Removing the const from InstBits does make the error message go away but it
seems to me that adding const to the LoadIntFromMemory Src argument is the
better solution. However, that may cause more warnings.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200708/9af7b56f/attachment.html>


More information about the llvm-bugs mailing list