Skip to content

Commit 5d476c9

Browse files
authored
[AsmPrinter] Don't compute Darwin triple on non-Darwin (llvm#97069)
There's no point in computing (=parsing) a triple on non-MachO/Darwin platforms.
1 parent f0bffb1 commit 5d476c9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,13 @@ bool AsmPrinter::doInitialization(Module &M) {
478478
// use the directive, where it would need the same conditionalization
479479
// anyway.
480480
const Triple &Target = TM.getTargetTriple();
481-
Triple TVT(M.getDarwinTargetVariantTriple());
482-
OutStreamer->emitVersionForTarget(
483-
Target, M.getSDKVersion(),
484-
M.getDarwinTargetVariantTriple().empty() ? nullptr : &TVT,
485-
M.getDarwinTargetVariantSDKVersion());
481+
if (Target.isOSBinFormatMachO() && Target.isOSDarwin()) {
482+
Triple TVT(M.getDarwinTargetVariantTriple());
483+
OutStreamer->emitVersionForTarget(
484+
Target, M.getSDKVersion(),
485+
M.getDarwinTargetVariantTriple().empty() ? nullptr : &TVT,
486+
M.getDarwinTargetVariantSDKVersion());
487+
}
486488

487489
// Allow the target to emit any magic that it wants at the start of the file.
488490
emitStartOfAsmFile(M);

0 commit comments

Comments
 (0)