diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -171,7 +171,7 @@ return "-m:l"; if (T.isOSBinFormatMachO()) return "-m:o"; - if (T.isOSWindows() && T.isOSBinFormatCOFF()) + if ((T.isOSWindows() || T.isUEFI()) && T.isOSBinFormatCOFF()) return T.getArch() == Triple::x86 ? "-m:x" : "-m:w"; if (T.isOSBinFormatXCOFF()) return "-m:a"; diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -799,6 +799,8 @@ case Triple::x86_64: if (T.isOSWindows()) return Triple::COFF; + else if (T.isUEFI()) + return Triple::COFF; return Triple::ELF; case Triple::aarch64_be: diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp --- a/llvm/unittests/TargetParser/TripleTest.cpp +++ b/llvm/unittests/TargetParser/TripleTest.cpp @@ -462,6 +462,7 @@ EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::UEFI, T.getOS()); EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + EXPECT_EQ(Triple::COFF, T.getObjectFormat()); T = Triple("wasm32-unknown-unknown"); EXPECT_EQ(Triple::wasm32, T.getArch());