diff --git a/llvm/test/CodeGen/X86/expand-frem-no-libcall.ll b/llvm/test/CodeGen/X86/expand-frem-no-libcall.ll deleted file mode 100644 index c29b072d96e8e..0000000000000 --- a/llvm/test/CodeGen/X86/expand-frem-no-libcall.ll +++ /dev/null @@ -1,31 +0,0 @@ -; This test underhandedly exploits a bug in llc's handling of -march. -; The module ends up with no triple, and thus treated as unknown arch -; with no library functions. - -; RUN: llc -march=x86-64 -stop-after=expand-ir-insts %s -o - | FileCheck --check-prefix=EXPAND %s -; RUN: llc -mtriple=x86_64-linux-gnu -stop-after=expand-ir-insts %s -o - | FileCheck --check-prefix=LIBCALL %s - -; When the fmod libcall is unavailable, expand-ir-insts must expand -; frem inline instead of leaving it for the DAG legalizer. - -; EXPAND-LABEL: define float @frem_f32 -; EXPAND-NOT: frem float -; EXPAND: fmul float - -; LIBCALL-LABEL: define float @frem_f32 -; LIBCALL: frem float -define float @frem_f32(float %a, float %b) { - %r = frem float %a, %b - ret float %r -} - -; EXPAND-LABEL: define double @frem_f64 -; EXPAND-NOT: frem double -; EXPAND: fmul double - -; LIBCALL-LABEL: define double @frem_f64 -; LIBCALL: frem double -define double @frem_f64(double %a, double %b) { - %r = frem double %a, %b - ret double %r -} diff --git a/llvm/test/tools/llc/module-triple-default.ll b/llvm/test/tools/llc/module-triple-default.ll new file mode 100644 index 0000000000000..161d76557450a --- /dev/null +++ b/llvm/test/tools/llc/module-triple-default.ll @@ -0,0 +1,14 @@ +; REQUIRES: aarch64-registered-target +; REQUIRES: default_triple + +;; Verify that llc correctly sets the module triple when one is not present. + +; RUN: llc -march=aarch64 -stop-after=finalize-isel -o - %s | FileCheck %s --check-prefix=MARCH +; RUN: llc -mtriple=aarch64-unknown-linux-gnu -stop-after=finalize-isel -o - %s | FileCheck %s --check-prefix=MTRIPLE +; RUN: llc -stop-after=finalize-isel -o - %s | FileCheck %s --check-prefix=DEFAULT + +; MARCH: target triple = "aarch64-{{.*}}-{{.*}}" +; MTRIPLE: target triple = "aarch64-unknown-linux-gnu" +; DEFAULT: target triple = "{{.*}}-{{.*}}-{{.*}}" + +define void @f() { ret void } diff --git a/llvm/test/tools/llc/module-triple.ll b/llvm/test/tools/llc/module-triple.ll new file mode 100644 index 0000000000000..6e26babbda080 --- /dev/null +++ b/llvm/test/tools/llc/module-triple.ll @@ -0,0 +1,16 @@ +; REQUIRES: aarch64-registered-target +; REQUIRES: x86-registered-target + +;; Verify that llc correctly sets the module triple when one is present. + +; RUN: llc -march=aarch64 -stop-after=finalize-isel -o - %s | FileCheck %s --check-prefix=MARCH +; RUN: llc -mtriple=aarch64-unknown-unknown -stop-after=finalize-isel -o - %s | FileCheck %s --check-prefix=MTRIPLE +; RUN: llc -stop-after=finalize-isel -o - %s | FileCheck %s --check-prefix=MODULE + +; MARCH: target triple = "aarch64-unknown-linux-gnu" +; MTRIPLE: target triple = "aarch64-unknown-unknown" +; MODULE: target triple = "x86_64-unknown-linux-gnu" + +target triple = "x86_64-unknown-linux-gnu" + +define void @f() { ret void } diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 4d00e0fcb048a..2c2a543862a28 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -675,8 +675,8 @@ static int compileModule(char **argv, SmallVectorImpl &PluginList, Err.print(argv[0], WithColor::error(errs(), argv[0])); return 1; } - if (!TargetTriple.empty()) - M->setTargetTriple(Triple(Triple::normalize(TargetTriple))); + + M->setTargetTriple(TheTriple); std::optional CM_IR = M->getCodeModel(); if (!CM && CM_IR)