Erik de Castro Lopo via llvm-dev
2015-Sep-16 16:17 UTC
[llvm-dev] Arm: disabling/disallowing Thumb instructions
Hi all, When I use Clang, I can add -mno-thumb to the command line and Clang generates pure Arm code without any use of Thumb instructions. However, I am messing about with the Glasgow Haskell Compiler (GHC) which generates LLVM IR code directly and then calls `opt` and `llc` on that IR code. The generated IR code currently has: target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32" target triple = "armv6-unknown-linux-gnueabihf" in the header, but the generated assembly uses both Arm and Thumb instructions. Any clues appreciated. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Tim Northover via llvm-dev
2015-Sep-16 16:37 UTC
[llvm-dev] Arm: disabling/disallowing Thumb instructions
On 16 September 2015 at 09:17, Erik de Castro Lopo via llvm-dev <llvm-dev at lists.llvm.org> wrote:> However, I am messing about with the Glasgow Haskell Compiler (GHC) > which generates LLVM IR code directly and then calls `opt` and `llc` on > that IR code. The generated IR code currently has: > > target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32" > target triple = "armv6-unknown-linux-gnueabihf" > > in the header, but the generated assembly uses both Arm and Thumb > instructions.That shouldn't be happening. The "armv6" ought to imply ARM mode. What Thumb instructions are you seeing, and do you have a .ll file that reproduces the issue with standard tools or is it just the way GHC is driving LLVM? Cheers. Tim.
Renato Golin via llvm-dev
2015-Sep-16 17:08 UTC
[llvm-dev] Arm: disabling/disallowing Thumb instructions
On 16 September 2015 at 17:17, Erik de Castro Lopo via llvm-dev <llvm-dev at lists.llvm.org> wrote:> in the header, but the generated assembly uses both Arm and Thumb > instructions.Hi Erik, That's really odd. Are you sure the Thumb part was really generated by the compiler, instead of some runtime chunks in GHC, or third-party static libraries? Can you dump assembly, or are you disassembling the object files? Or is this a whole-program disassembly, where all libraries are linked together? cheers, --renato
Erik de Castro Lopo via llvm-dev
2015-Sep-16 21:52 UTC
[llvm-dev] Arm: disabling/disallowing Thumb instructions
Tim Northover wrote:> That shouldn't be happening. The "armv6" ought to imply ARM mode. What > Thumb instructions are you seeing, and do you have a .ll file that > reproduces the issue with standard tools or is it just the way GHC is > driving LLVM?Sorry false alarm. I was a looking an object file produced by GCC compiling a C file, not an object file produced by GHC compiling a Haskell file. GHC on Linux uses GCC by default to compile C (GHC's runtime system is written in C) and LLC/OPT when compiling Haskell code. For some reason gcc on armhf/linux by default produces Thumb code. GCC needs to be passed -marm on the command line to force production of pure Arm code. This has finally got me to the bottom on one of the most difficult bugs I've ever worked on. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Maybe Matching Threads
- Arm: disabling/disallowing Thumb instructions
- [LLVMdev] ARM support status (GHC/ARM new calling convention)
- [LLVMdev] ARM support status (GHC/ARM new calling convention)
- [LLVMdev] Request for merge: GHC/ARM calling convention.
- [LLVMdev] Request for merge: GHC/ARM calling convention.