-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Cygwin] va_list must be treated like normal Windows #143115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Handling of va_list on Cygwin environment must be matched to normal Windows environment. A new test file is added as existing test contains a unsupported functionality.
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang Author: Tomohiro Kashiwada (kikairoya) ChangesHandling of va_list on Cygwin environment must be matched to normal Windows environment. Full diff: https://github.com/llvm/llvm-project/pull/143115.diff 2 Files Affected:
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 780385f9c9bc5..92aa9b5dc92cb 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -979,6 +979,9 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
}
+ BuiltinVaListKind getBuiltinVaListKind() const override {
+ return TargetInfo::CharPtrBuiltinVaList;
+ }
};
class LLVM_LIBRARY_VISIBILITY DarwinX86_64TargetInfo
diff --git a/clang/test/CodeGen/X86/cygwin-varargs.c b/clang/test/CodeGen/X86/cygwin-varargs.c
new file mode 100644
index 0000000000000..1d2b9af8a0225
--- /dev/null
+++ b/clang/test/CodeGen/X86/cygwin-varargs.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm < %s | FileCheck %s
+
+// copy ms_abi block only from ../ms_abi.c
+
+struct foo {
+ int x;
+ float y;
+ char z;
+};
+// CHECK: %[[STRUCT_FOO:.*]] = type { i32, float, i8 }
+
+void f(int a, ...) {
+ // CHECK-LABEL: define dso_local void @f
+ __builtin_va_list ap;
+ __builtin_va_start(ap, a);
+ // CHECK: %[[AP:.*]] = alloca ptr
+ // CHECK: call void @llvm.va_start
+ int b = __builtin_va_arg(ap, int);
+ // CHECK: %[[AP_CUR:.*]] = load ptr, ptr %[[AP]]
+ // CHECK-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, ptr %[[AP_CUR]], i64 8
+ // CHECK-NEXT: store ptr %[[AP_NEXT]], ptr %[[AP]]
+ double _Complex c = __builtin_va_arg(ap, double _Complex);
+ // CHECK: %[[AP_CUR2:.*]] = load ptr, ptr %[[AP]]
+ // CHECK-NEXT: %[[AP_NEXT2:.*]] = getelementptr inbounds i8, ptr %[[AP_CUR2]], i64 8
+ // CHECK-NEXT: store ptr %[[AP_NEXT2]], ptr %[[AP]]
+ // CHECK-NEXT: load ptr, ptr %[[AP_CUR2]]
+ struct foo d = __builtin_va_arg(ap, struct foo);
+ // CHECK: %[[AP_CUR3:.*]] = load ptr, ptr %[[AP]]
+ // CHECK-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, ptr %[[AP_CUR3]], i64 8
+ // CHECK-NEXT: store ptr %[[AP_NEXT3]], ptr %[[AP]]
+ __builtin_va_list ap2;
+ __builtin_va_copy(ap2, ap);
+ // CHECK: call void @llvm.va_copy
+ __builtin_va_end(ap);
+ // CHECK: call void @llvm.va_end
+}
|
Co-authored-by: jeremyd2019 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with one minor comment.
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm < %s | FileCheck %s | ||
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm < %s | FileCheck %s | ||
|
||
// copy ms_abi block only from ../ms_abi.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how relevant the comment about where it is copied from is, when looking at the test file in the future. (It's perhaps more relevant as part of the commit message.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated description.
Co-authored-by: jeremyd2019 <[email protected]>
…3115) Handling of va_list on Cygwin environment must be matched to normal Windows environment. The existing test `test/CodeGen/ms_abi.c` seems relevant, but it contains `__attribute__((sysv_abi))`, which is not supported on Cygwin. The new test is based on the `__attribute__((ms_abi))` portion of that test. --------- Co-authored-by: jeremyd2019 <[email protected]>
…3115) Handling of va_list on Cygwin environment must be matched to normal Windows environment. The existing test `test/CodeGen/ms_abi.c` seems relevant, but it contains `__attribute__((sysv_abi))`, which is not supported on Cygwin. The new test is based on the `__attribute__((ms_abi))` portion of that test. --------- Co-authored-by: jeremyd2019 <[email protected]>
…3115) Handling of va_list on Cygwin environment must be matched to normal Windows environment. The existing test `test/CodeGen/ms_abi.c` seems relevant, but it contains `__attribute__((sysv_abi))`, which is not supported on Cygwin. The new test is based on the `__attribute__((ms_abi))` portion of that test. --------- Co-authored-by: jeremyd2019 <[email protected]>
Handling of va_list on Cygwin environment must be matched to normal Windows environment.
The existing test
test/CodeGen/ms_abi.c
seems relevant, but it contains__attribute__((sysv_abi))
, which is not supported on Cygwin. The new test is based on the__attribute__((ms_abi))
portion of that test.