Skip to content

Support num_extra_inhabitants (introduced in LLVM 20.0) #299

@RyanGlScott

Description

@RyanGlScott

LLVM 20.0 adds a num_extra_inhabitants metadata field in llvm/llvm-project@f6617d6, which debuted in LLVM 20.0 (and debuted earlier in Apple LLVM 17.0, see swiftlang/llvm-project@89d458b, as well as #297). These fields are present both METADATA_BASIC_TYPE and METADATA_COMPOSITE_TYPE. For example, if you compile the following program:

#include <stdio.h>

void foo(void) {
   puts("hi");
}

Using Clang 20.0 like so:

$ clang -g -O0 -c -emit-llvm test.c

Then llvm-pretty-bc-parser will emit the following warnings when parsing the resulting bitcode:

ghci> mapM_ (print . ppParseWarnings . snd) =<< parseBitCodeFromFileWithWarnings "test.bc"
Encountered the following warnings during parsing:
    Invalid record size: 8
    Expected one of: [6, 7]
    from:
    	METADATA_BASIC_TYPE
    	METADATA_BLOCK
    	METADATA_BLOCK_ID
    	value symbol table
    	MODULE_BLOCK
    	Bitstream

    Invalid record size: 24
    Expected size between 16 and 22
    from:
    	METADATA_COMPOSITE_TYPE
    	METADATA_BLOCK
    	METADATA_BLOCK_ID
    	value symbol table
    	MODULE_BLOCK
    	Bitstream

Are you sure you're using a supported version of LLVM/Clang?
Check here: https://github.com/GaloisInc/llvm-pretty-bc-parser

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions