[llvm] 5d476c9 - [AsmPrinter] Don't compute Darwin triple on non-Darwin (#97069)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 09:47:19 PDT 2024


Author: Alexis Engelke
Date: 2024-06-28T18:47:16+02:00
New Revision: 5d476c9ef4cccce7f534d5607f953b3107d770af

URL: https://github.com/llvm/llvm-project/commit/5d476c9ef4cccce7f534d5607f953b3107d770af
DIFF: https://github.com/llvm/llvm-project/commit/5d476c9ef4cccce7f534d5607f953b3107d770af.diff

LOG: [AsmPrinter] Don't compute Darwin triple on non-Darwin (#97069)

There's no point in computing (=parsing) a triple on non-MachO/Darwin
platforms.

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 2e787f4cd3db0..6d6ceed053fd0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -478,11 +478,13 @@ bool AsmPrinter::doInitialization(Module &M) {
   // use the directive, where it would need the same conditionalization
   // anyway.
   const Triple &Target = TM.getTargetTriple();
-  Triple TVT(M.getDarwinTargetVariantTriple());
-  OutStreamer->emitVersionForTarget(
-      Target, M.getSDKVersion(),
-      M.getDarwinTargetVariantTriple().empty() ? nullptr : &TVT,
-      M.getDarwinTargetVariantSDKVersion());
+  if (Target.isOSBinFormatMachO() && Target.isOSDarwin()) {
+    Triple TVT(M.getDarwinTargetVariantTriple());
+    OutStreamer->emitVersionForTarget(
+        Target, M.getSDKVersion(),
+        M.getDarwinTargetVariantTriple().empty() ? nullptr : &TVT,
+        M.getDarwinTargetVariantSDKVersion());
+  }
 
   // Allow the target to emit any magic that it wants at the start of the file.
   emitStartOfAsmFile(M);


        


More information about the llvm-commits mailing list