1

For example I have two LLVM IR modules

the first is: arm64-apple-ios8.0.0 data layout 'e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32'

the second is: thumbv7-apple-ios10.0.0 data layout 'e-m:o-i64:64-i128:128-n32:64-S128'

If I try to link them, I get a warning about the triple and data layout mismatch.

Is it possible to recompile one of them with the triple and data layout of another module, so that they match?

Anton Kukoba
  • 265
  • 2
  • 12
  • What was the link command and the exact warning received? – underscore_d Jun 17 '20 at 08:29
  • warning: Linking two modules of different target triples: warning: Linking two modules of different data layouts: – Anton Kukoba Jun 17 '20 at 08:30
  • 1
    You might be lucky if the data layout is the same, but usually not, because the frontend will do things that depend on the data layout when it generates the IR. For example, it may evaluate sizeof(foo) at compile time by inspecting the data layout, or it may choose to use i32 or i64 depending on what suits the data layout. – arnt Jun 17 '20 at 08:35
  • But the question is about recomiplation, not about linking it successfully. – Anton Kukoba Jun 17 '20 at 08:57
  • you can compile the llvm-ir into c https://stackoverflow.com/questions/5180914/llvm-ir-back-to-human-readable-source-language and than compile it to the new target...maybe it can work... – yehudahs Jun 25 '20 at 11:56

1 Answers1

1

No, the LLVM toolchain has no tool to transform between incompatible triples.

The best third party option I am aware of would be to lift the IR to source code and recompile.

orestisf
  • 1,396
  • 1
  • 15
  • 30