Skip to content

Commit

Permalink
[ELF][RISCV] Support RISC-V in getBitcodeMachineKind
Browse files Browse the repository at this point in the history
Add Triple::riscv64 and Triple::riscv32 to getBitcodeMachineKind for get right
e_machine during LTO.

Reviewed By: ruiu, MaskRay

Differential Revision: https://reviews.llvm.org/D52165

llvm-svn: 364996
  • Loading branch information
kito-cheng committed Jul 3, 2019
1 parent 80177ca commit eb9bc38
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lld/ELF/InputFiles.cpp
Expand Up @@ -1402,6 +1402,9 @@ static uint8_t getBitcodeMachineKind(StringRef Path, const Triple &T) {
case Triple::ppc64:
case Triple::ppc64le:
return EM_PPC64;
case Triple::riscv32:
case Triple::riscv64:
return EM_RISCV;
case Triple::x86:
return T.isOSIAMCU() ? EM_IAMCU : EM_386;
case Triple::x86_64:
Expand Down
10 changes: 10 additions & 0 deletions lld/test/ELF/lto/riscv32.ll
@@ -0,0 +1,10 @@
; REQUIRES: riscv

; RUN: llvm-as %s -o %t.o
; RUN: ld.lld %t.o -o %t
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
target triple = "riscv32-unknown-elf"

define void @f() {
ret void
}
10 changes: 10 additions & 0 deletions lld/test/ELF/lto/riscv64.ll
@@ -0,0 +1,10 @@
; REQUIRES: riscv

; RUN: llvm-as %s -o %t.o
; RUN: ld.lld %t.o -o %t
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
target triple = "riscv64-unknown-elf"

define void @f() {
ret void
}

0 comments on commit eb9bc38

Please sign in to comment.