[PATCH] D153906: [clang] Allow disassembly of multi-module bitcode files

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 10 22:03:12 PDT 2023


MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.



> [clang] Allow disassembly of multi-module bitcode files

The subject confused me as I did not recognize what disassembly means :)

> Clang currently exits with an error message if asked to disassemble a multi-module bitcode file. [...]

The description is hand-waving on how Clang uses multi-module bitcode files.
You can be more specific that multi-module bitcode files are for -fsanitize=cfi and -fwhole-program-vtables. And it will be more useful to include an example in the summary.

It seems that you want to do this:

  myclang -Xclang -flto-unit -fsplit-lto-unit -flto=thin a.c -c -o a.bc
  myclang -S -emit-llvm a.bc -o b.ll
  ls b.0.ll b.1.ll

This is a bit odd as the `-o` file may no longer an output. This could be fixed, but is this functionality really useful?

  % rm -f a.0.ll a.1.ll; myclang -c a.bc -o a.o ; ls a.[01].ll
  a.0.ll  a.1.ll

We can just disassemble a bitcode with `llvm-dis a.bc -o -`. The nicer thing is that llvm-dis additionally calls `ModuleSummaryIndex::print` to print the module summary index (if present).
`clang -S -emit-llvm -x ir a.bc` output doesn't have this information.



================
Comment at: clang/test/Frontend/split-lto-ir-support.cpp:1
+// RUN: %clang -c -flto=thin %s -o %t0.bc
+// RUN: mkdir %t1.d
----------------
MaskRay wrote:
> Without -fsanitize=cfi or -fwhole-program-vtables, -fsplit-lto-unit is not the default. You need to specify this option explicitly.
> 
> `%clang` is normally used for test/Driver tests. For other tests, prefer `%clang_cc1`.
We need to hard code a target triple as many targets don't support LTO.


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

https://reviews.llvm.org/D153906



More information about the cfe-commits mailing list