Skip to content

Commit 308c87f

Browse files
authored
Merge pull request swiftlang#39404 from lorentey/force-cx16-on-linux
2 parents 3e07369 + 872f971 commit 308c87f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,12 @@ importer::addCommonInvocationArguments(
781781
invocationArgStrs.push_back("-march=z13");
782782
}
783783

784+
if (triple.getArch() == llvm::Triple::x86_64) {
785+
// Enable double wide atomic intrinsics on every x86_64 target.
786+
// (This is the default on Darwin, but not so on other platforms.)
787+
invocationArgStrs.push_back("-mcx16");
788+
}
789+
784790
if (!importerOpts.Optimization.empty()) {
785791
invocationArgStrs.push_back(importerOpts.Optimization);
786792
}

test/IRGen/cx16.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -target x86_64-unknown-linux-gnu -disable-legacy-type-info -parse-stdlib -disable-objc-interop %s -module-name main -emit-ir -o - | %FileCheck %s
2+
// RUN: %target-swift-frontend -target x86_64-unknown-windows-msvc -disable-legacy-type-info -parse-stdlib -disable-objc-interop %s -module-name main -emit-ir -o - | %FileCheck %s
3+
// RUN: %target-swift-frontend -target x86_64-unknown-freebsd -disable-legacy-type-info -parse-stdlib -disable-objc-interop %s -module-name main -emit-ir -o - | %FileCheck %s
4+
// RUN: %target-swift-frontend -target x86_64-apple-macosx10.9 -disable-legacy-type-info -parse-stdlib -module-name main %s -emit-ir -o - | %FileCheck %s
5+
6+
// REQUIRES: CODEGENERATOR=X86
7+
8+
public func test() {
9+
}
10+
11+
// We expect double-wide atomic intrinsics to always be available on x86_64.
12+
// CHECK: "target-features"="{{.*}}+cx16,

0 commit comments

Comments
 (0)