[clang] [llvm] Reland "[X86] Remove knl/knm specific ISAs supports (#92883)" (PR #93136)

2024-05-23 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/93136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-22 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

LGTM but I'd like @RKSimon to take a second look.

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits


@@ -8,16 +8,12 @@ target triple = "x86_64-unknown-linux-gnu"
 define dso_local i32 @main() local_unnamed_addr #0 !dbg !7 {
 entry:
   tail call void @llvm.prefetch(ptr inttoptr (i64 291 to ptr), i32 0, i32 0, 
i32 1), !dbg !9
-  tail call void @llvm.x86.avx512.gatherpf.dpd.512(i8 97, <8 x i32> undef, ptr 
null, i32 1, i32 2), !dbg !10
   ret i32 291, !dbg !11
 }
 
 ; Function Attrs: inaccessiblemem_or_argmemonly nounwind
 declare void @llvm.prefetch(ptr nocapture readonly, i32, i32, i32) #1
 
-; Function Attrs: argmemonly nounwind
-declare void @llvm.x86.avx512.gatherpf.dpd.512(i8, <8 x i32>, ptr, i32, i32) #2
-
 attributes #0 = {"target-cpu"="x86-64" 
"target-features"="+avx512pf,+sse4.2,+ssse3"}

phoebewang wrote:

Remove `+avx512pf` or the whole `"target-features"="..."`

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits


@@ -268,30 +268,6 @@ define void @gather_qps(<8 x i64> %ind, <8 x float> %src, 
ptr %base, ptr %stbuf)
   ret void
 }
 
-declare  void @llvm.x86.avx512.gatherpf.qps.512(i8, <8 x i64>, ptr , i32, i32);

phoebewang wrote:

Surprise to see they were working without a avx512pf feature.

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits


@@ -23,7 +23,7 @@
 br i1 %6, label %4, label %5, !llvm.loop !9
   }
 
-  attributes #0 = { nofree norecurse nosync nounwind uwtable writeonly 
mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="generic" }
+  attributes #0 = { nofree norecurse nosync nounwind uwtable writeonly 
mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="generic" }

phoebewang wrote:

I think maybe we can do an NFC patch to remove these "target-features"="..." 
given we have already had "target-cpu"="xxx".

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits


@@ -1,373 +0,0 @@
-# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py

phoebewang wrote:

Why removing this?

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits


@@ -9265,6 +9265,33 @@ multiclass avx512_fp28_s opc, string 
OpcodeStr,X86VectorVTInfo _,
   }
 }
 
+multiclass avx512_fp28_s_ass opc, string OpcodeStr, X86VectorVTInfo _> 
{
+  let ExeDomain = _.ExeDomain, hasNoSchedulingInfo = 1 in {
+  defm r : AVX512_maskable_scalar, Sched<[WriteMove]>;
+  defm rb : AVX512_maskable_scalar, Sched<[WriteMove]>, EVEX_B;
+  defm m : AVX512_maskable_scalar, Sched<[WriteMove]>;
+  }
+}
+
+multiclass avx512_eri_s_ass opc, string OpcodeStr> {
+  defm SSZ : avx512_fp28_s_ass,
+ EVEX_CD8<32, CD8VT1>, VEX_LIG, T8, PD, EVEX, ;
+  defm SDZ : avx512_fp28_s_ass,
+ EVEX_CD8<64, CD8VT1>, VEX_LIG, REX_W, T8, PD, EVEX, ;
+}
+
+defm VRCP28   : avx512_eri_s_ass<0xCB, "vrcp28">;

phoebewang wrote:

Ok, I recalled we still want the enc/dec support.

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits


@@ -9325,6 +9345,43 @@ multiclass avx512_fp28_p_sae opc, string 
OpcodeStr, X86VectorVTInfo _,
 EVEX_B, Sched<[sched]>;
 }
 
+multiclass avx512_fp28_p_ass opc, string OpcodeStr, X86VectorVTInfo _> 
{
+  let ExeDomain = _.ExeDomain, hasNoSchedulingInfo = 1 in {
+  defm r : AVX512_maskable, Sched<[WriteMove]>;
+
+  defm m : AVX512_maskable, Sched<[WriteMove]>;
+
+  defm mb : AVX512_maskable, Sched<[WriteMove]>, EVEX_B;
+  }
+}
+multiclass avx512_fp28_p_sae_ass opc, string OpcodeStr, 
X86VectorVTInfo _> {
+  let ExeDomain = _.ExeDomain, Uses = [MXCSR] in
+  defm rb : AVX512_maskable, Sched<[WriteMove]>, EVEX_B;
+}
+
+multiclass  avx512_eri_ass opc, string OpcodeStr> {
+   defm PSZ : avx512_fp28_p_ass,
+  avx512_fp28_p_sae_ass,
+  T8, PD, EVEX_V512, EVEX_CD8<32, CD8VF>;
+   defm PDZ : avx512_fp28_p_ass,
+  avx512_fp28_p_sae_ass,
+  T8, PD, EVEX_V512, REX_W, EVEX_CD8<64, CD8VF>;
+}
+
+defm VRSQRT28 : avx512_eri_ass<0xCC, "vrsqrt28">, EVEX;

phoebewang wrote:

ditto.

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits


@@ -9265,6 +9265,33 @@ multiclass avx512_fp28_s opc, string 
OpcodeStr,X86VectorVTInfo _,
   }
 }
 
+multiclass avx512_fp28_s_ass opc, string OpcodeStr, X86VectorVTInfo _> 
{
+  let ExeDomain = _.ExeDomain, hasNoSchedulingInfo = 1 in {
+  defm r : AVX512_maskable_scalar, Sched<[WriteMove]>;
+  defm rb : AVX512_maskable_scalar, Sched<[WriteMove]>, EVEX_B;
+  defm m : AVX512_maskable_scalar, Sched<[WriteMove]>;
+  }
+}
+
+multiclass avx512_eri_s_ass opc, string OpcodeStr> {
+  defm SSZ : avx512_fp28_s_ass,
+ EVEX_CD8<32, CD8VT1>, VEX_LIG, T8, PD, EVEX, ;
+  defm SDZ : avx512_fp28_s_ass,
+ EVEX_CD8<64, CD8VT1>, VEX_LIG, REX_W, T8, PD, EVEX, ;
+}
+
+defm VRCP28   : avx512_eri_s_ass<0xCB, "vrcp28">;

phoebewang wrote:

Why still keep these instructions?

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)

2024-05-21 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Please note it in release notes.

https://github.com/llvm/llvm-project/pull/92883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)

2024-05-16 Thread Phoebe Wang via cfe-commits


@@ -41,6 +41,22 @@ typedef long long __m512i_u 
__attribute__((__vector_size__(64), __aligned__(1)))
 typedef unsigned char __mmask8;
 typedef unsigned short __mmask16;
 
+#ifdef __cplusplus
+typedef bool __vecmask2 __attribute__((__ext_vector_type__(2)));
+typedef bool __vecmask4 __attribute__((__ext_vector_type__(4)));
+typedef bool __vecmask8 __attribute__((__ext_vector_type__(8)));
+typedef bool __vecmask16 __attribute__((__ext_vector_type__(16)));
+typedef bool __vecmask32 __attribute__((__ext_vector_type__(32)));
+typedef bool __vecmask64 __attribute__((__ext_vector_type__(64)));
+#else
+typedef _Bool __vecmask2 __attribute__((__ext_vector_type__(2)));

phoebewang wrote:

I'm a bit concerning about the ABI when people abuse them in function call.

https://github.com/llvm/llvm-project/pull/91306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)

2024-05-16 Thread Phoebe Wang via cfe-commits


@@ -77,9 +77,9 @@ _mm512_cvtne2ps_pbh(__m512 __A, __m512 __B) {
 ///conversion of __B, and higher 256 bits come from conversion of __A.
 static __inline__ __m512bh __DEFAULT_FN_ATTRS512
 _mm512_mask_cvtne2ps_pbh(__m512bh __W, __mmask32 __U, __m512 __A, __m512 __B) {
-  return (__m512bh)__builtin_ia32_selectpbf_512((__mmask32)__U,
-(__v32bf)_mm512_cvtne2ps_pbh(__A, __B),
-(__v32bf)__W);
+  return (__m512bh)__builtin_selectvector(
+  (__v32bf)_mm512_cvtne2ps_pbh(__A, __B), (__v32bf)__W,
+  __builtin_bit_cast(__vecmask32, __U));

phoebewang wrote:

Can we use (__vecmask32) dirctly like `__v32bf` etc?

https://github.com/llvm/llvm-project/pull/91306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)

2024-05-16 Thread Phoebe Wang via cfe-commits


@@ -41,6 +41,22 @@ typedef long long __m512i_u 
__attribute__((__vector_size__(64), __aligned__(1)))
 typedef unsigned char __mmask8;
 typedef unsigned short __mmask16;
 
+#ifdef __cplusplus
+typedef bool __vecmask2 __attribute__((__ext_vector_type__(2)));
+typedef bool __vecmask4 __attribute__((__ext_vector_type__(4)));

phoebewang wrote:

We used `__mmask8` for `v2i1` and `v4i1` too. I don't we can bitcast them 
directly.

https://github.com/llvm/llvm-project/pull/91306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)

2024-05-16 Thread Phoebe Wang via cfe-commits


@@ -3019,6 +3019,26 @@ C-style cast applied to each element of the first 
argument.
 
 Query for this feature with ``__has_builtin(__builtin_convertvector)``.
 
+``__builtin_selectvector``
+--
+
+``__builtin_selectvector`` is used to express generic vector element selection.
+
+**Signature**:
+
+.. code-block:: c++
+
+  template 
+  simd_vec __builtin_selectvector(simd_vec lhs, simd_vec rhs,
+simd_vec cond)

phoebewang wrote:

Maybe put `cond` the first operand to match with `select` and the old X86 
builtins?

https://github.com/llvm/llvm-project/pull/91306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)

2024-05-16 Thread Phoebe Wang via cfe-commits


@@ -3744,6 +3744,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 return RValue::get(Result);
   }
 
+  case Builtin::BI__builtin_selectvector: {
+return RValue::get(Builder.CreateSelect(EmitScalarExpr(E->getArg(2)),

phoebewang wrote:

Should we check all one (or all zero) like we did in `EmitX86Select`?

https://github.com/llvm/llvm-project/pull/91306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-13 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> @phoebewang Can you add a release note for this on the PR for the release 
> branch and then add the release:note label.

Done.

https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-05-12 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Ping?

https://github.com/llvm/llvm-project/pull/88245
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][vectorcall] Pass built types byval when xmm0~6 exhausted (PR #91846)

2024-05-12 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/91846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-12 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> You'll be probably building 18.1.6 with 18.1.5... and that's when you'll 
> notice the issue. I'm just about finished building 18.1.5 with your patch. So 
> hopefully all those issues will be gone. I'll report back

Okay... This is a combined problem which I never thought before. Sorry for the 
inconvenience!

https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-12 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

@FireBurn Sorry, I just noticed #91719. The above comments were based on the 
issue #91076.

I didn't look at the source, but the command line doesn't have an AVX512 
option. So I'm assuming the code may related function multi-versioning with 
manually specified target attributes regarding to AVX512 features.

The reason is the same as #91719, but the scenarios may be more common in 
practice. The defect in previous patch does expose a known issue with the 
design of EVEX512, which we have noted in 
https://clang.llvm.org/docs/UsersManual.html#x86

In a word, when user uses target attributes with AVX512 features, they should 
add an explicit `evex512` or `no-evex512` for robustness since LLVM 18. Missing 
it may result in some unexpected codegen or error in some corner case.

https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-12 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> @tstellar Can a note be added somewhere about this? Folks upgrading to 
> llvm-18.1.6 will get errors unless they drop -march=native if they were on 
> 18.1.5

Although I agree we should add a note, I don't think this patch affects much. 
The problem only coccurs when combining `-march=native` with AVX512 options on 
a non AVX512 target. This actually is not a valid scenario. The compiled binary 
will contain AVX512 instruction which crashes it on the target. It violates the 
intention of using `-march=native`. I also don't see where the error from with 
18.1.6. If there were errors, it should come from 18.1.5.

https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][vectorcall] Pass built types byval when xmm0~6 exhausted (PR #91846)

2024-05-11 Thread Phoebe Wang via cfe-commits


@@ -792,7 +792,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState ,
 return ABIArgInfo::getDirect();
   return ABIArgInfo::getExpand();
 }
-return getIndirectResult(Ty, /*ByVal=*/false, State);
+return getIndirectResult(Ty, IsVectorCall && Ty->isBuiltinType(), State);

phoebewang wrote:

Done.

https://github.com/llvm/llvm-project/pull/91846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][vectorcall] Pass built types byval when xmm0~6 exhausted (PR #91846)

2024-05-11 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/91846

>From 844fb5283d654d7d9cb68c5712b338f0a70b384e Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Sat, 11 May 2024 16:07:00 +0800
Subject: [PATCH 1/2] [X86][vectorcall] Pass built types byval when xmm0~6
 exhausted

This is how MSVC handles it. https://godbolt.org/z/fG386bjnf
---
 clang/lib/CodeGen/Targets/X86.cpp |  2 +-
 clang/test/CodeGen/vectorcall.c   | 16 
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 717a27fc9c574..5c09339bd7137 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -792,7 +792,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState ,
 return ABIArgInfo::getDirect();
   return ABIArgInfo::getExpand();
 }
-return getIndirectResult(Ty, /*ByVal=*/false, State);
+return getIndirectResult(Ty, IsVectorCall && Ty->isBuiltinType(), State);
   }
 
   if (isAggregateTypeForABI(Ty)) {
diff --git a/clang/test/CodeGen/vectorcall.c b/clang/test/CodeGen/vectorcall.c
index cb53ecc70351d..97a532a9e3a25 100644
--- a/clang/test/CodeGen/vectorcall.c
+++ b/clang/test/CodeGen/vectorcall.c
@@ -140,4 +140,20 @@ void __vectorcall vectorcall_indirect_vec(
 // X86-SAME: ptr inreg noundef %0,
 // X86-SAME: i32 inreg noundef %edx,
 // X86-SAME: ptr noundef %1)
+
+void __vectorcall vectorcall_indirect_fp(
+double xmm0, double xmm1, double xmm2, double xmm3, double xmm4,
+v4f32 xmm5, v4f32 ecx, int edx, double mem) {
+}
+
+// X86: define dso_local x86_vectorcallcc void 
@"\01vectorcall_indirect_fp@@{{[0-9]+}}"
+// X86-SAME: (double inreg noundef %xmm0,
+// X86-SAME: double inreg noundef %xmm1,
+// X86-SAME: double inreg noundef %xmm2,
+// X86-SAME: double inreg noundef %xmm3,
+// X86-SAME: double inreg noundef %xmm4,
+// X86-SAME: <4 x float> inreg noundef %xmm5,
+// X86-SAME: ptr inreg noundef %0,
+// X86-SAME: i32 inreg noundef %edx,
+// X86-SAME: ptr noundef byval(double) align 4 %1)
 #endif

>From ec8be6b7ae2c85a1cab580de24883794eaef8027 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Sun, 12 May 2024 13:57:39 +0800
Subject: [PATCH 2/2] Address review comment

---
 clang/lib/CodeGen/Targets/X86.cpp | 4 +++-
 clang/test/CodeGen/vectorcall.c   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 5c09339bd7137..29d98aad8fcb4 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -792,7 +792,9 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState ,
 return ABIArgInfo::getDirect();
   return ABIArgInfo::getExpand();
 }
-return getIndirectResult(Ty, IsVectorCall && Ty->isBuiltinType(), State);
+if (IsVectorCall && Ty->isBuiltinType())
+  return ABIArgInfo::getDirect();
+return getIndirectResult(Ty, /*ByVal=*/false, State);
   }
 
   if (isAggregateTypeForABI(Ty)) {
diff --git a/clang/test/CodeGen/vectorcall.c b/clang/test/CodeGen/vectorcall.c
index 97a532a9e3a25..71dc3b0b9585a 100644
--- a/clang/test/CodeGen/vectorcall.c
+++ b/clang/test/CodeGen/vectorcall.c
@@ -155,5 +155,5 @@ void __vectorcall vectorcall_indirect_fp(
 // X86-SAME: <4 x float> inreg noundef %xmm5,
 // X86-SAME: ptr inreg noundef %0,
 // X86-SAME: i32 inreg noundef %edx,
-// X86-SAME: ptr noundef byval(double) align 4 %1)
+// X86-SAME: double noundef %mem)
 #endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][vectorcall] Pass built types byval when xmm0~6 exhausted (PR #91846)

2024-05-11 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/91846

This is how MSVC handles it. https://godbolt.org/z/fG386bjnf

>From 844fb5283d654d7d9cb68c5712b338f0a70b384e Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Sat, 11 May 2024 16:07:00 +0800
Subject: [PATCH] [X86][vectorcall] Pass built types byval when xmm0~6
 exhausted

This is how MSVC handles it. https://godbolt.org/z/fG386bjnf
---
 clang/lib/CodeGen/Targets/X86.cpp |  2 +-
 clang/test/CodeGen/vectorcall.c   | 16 
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 717a27fc9c574..5c09339bd7137 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -792,7 +792,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState ,
 return ABIArgInfo::getDirect();
   return ABIArgInfo::getExpand();
 }
-return getIndirectResult(Ty, /*ByVal=*/false, State);
+return getIndirectResult(Ty, IsVectorCall && Ty->isBuiltinType(), State);
   }
 
   if (isAggregateTypeForABI(Ty)) {
diff --git a/clang/test/CodeGen/vectorcall.c b/clang/test/CodeGen/vectorcall.c
index cb53ecc70351d..97a532a9e3a25 100644
--- a/clang/test/CodeGen/vectorcall.c
+++ b/clang/test/CodeGen/vectorcall.c
@@ -140,4 +140,20 @@ void __vectorcall vectorcall_indirect_vec(
 // X86-SAME: ptr inreg noundef %0,
 // X86-SAME: i32 inreg noundef %edx,
 // X86-SAME: ptr noundef %1)
+
+void __vectorcall vectorcall_indirect_fp(
+double xmm0, double xmm1, double xmm2, double xmm3, double xmm4,
+v4f32 xmm5, v4f32 ecx, int edx, double mem) {
+}
+
+// X86: define dso_local x86_vectorcallcc void 
@"\01vectorcall_indirect_fp@@{{[0-9]+}}"
+// X86-SAME: (double inreg noundef %xmm0,
+// X86-SAME: double inreg noundef %xmm1,
+// X86-SAME: double inreg noundef %xmm2,
+// X86-SAME: double inreg noundef %xmm3,
+// X86-SAME: double inreg noundef %xmm4,
+// X86-SAME: <4 x float> inreg noundef %xmm5,
+// X86-SAME: ptr inreg noundef %0,
+// X86-SAME: i32 inreg noundef %edx,
+// X86-SAME: ptr noundef byval(double) align 4 %1)
 #endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-10 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

/cherry-pick 
https://github.com/llvm/llvm-project/commit/87f3407856e61a73798af4e41b28bc33b5bf4ce6

https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-10 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang milestoned 
https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-09 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-09 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> Could you make getHostCPUFeatures only write the Features["evex512"] entry if 
> Features["avx512f"] is true? Instead of copying Features["avx512f"]?

Good idea, done.

https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-09 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/91694

>From 6ea15aa0ee6726cad8dccff10155f058afa0f013 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Fri, 10 May 2024 11:21:41 +0800
Subject: [PATCH 1/2] [X86][Driver] Do not add `-evex512` for `-march=native`
 when the target doesn't support AVX512

Users want `-march=sandybridge -mavx512f -mavx512vl` behaves the same as
`-march=native -mavx512f -mavx512vl` on a sandybridge target.

Fixes: #91076
---
 clang/lib/Driver/ToolChains/Arch/X86.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 53e26a9f8e229..c6d97ef4e971a 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -132,10 +132,14 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
   llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (llvm::sys::getHostCPUFeatures(HostFeatures)) {
+for (auto  : HostFeatures) {
+  if (!F.second && F.first() == "evex512")
+continue;
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
+}
+  }
 }
   }
 

>From d50ae3b317839f5603b091aa029414b3c3c42259 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Fri, 10 May 2024 12:02:09 +0800
Subject: [PATCH 2/2] Address review comment

---
 clang/lib/Driver/ToolChains/Arch/X86.cpp | 8 ++--
 llvm/lib/TargetParser/Host.cpp   | 3 ++-
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index c6d97ef4e971a..53e26a9f8e229 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -132,14 +132,10 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
   llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures)) {
-for (auto  : HostFeatures) {
-  if (!F.second && F.first() == "evex512")
-continue;
+  if (llvm::sys::getHostCPUFeatures(HostFeatures))
+for (auto  : HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
-}
-  }
 }
   }
 
diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 834f4536f93ac..c5156c6cb802c 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1802,7 +1802,8 @@ bool sys::getHostCPUFeatures(StringMap ) {
   Features["rtm"]= HasLeaf7 && ((EBX >> 11) & 1);
   // AVX512 is only supported if the OS supports the context save for it.
   Features["avx512f"]= HasLeaf7 && ((EBX >> 16) & 1) && HasAVX512Save;
-  Features["evex512"]= Features["avx512f"];
+  if (Features["avx512f"])
+Features["evex512"]  = true;
   Features["avx512dq"]   = HasLeaf7 && ((EBX >> 17) & 1) && HasAVX512Save;
   Features["rdseed"] = HasLeaf7 && ((EBX >> 18) & 1);
   Features["adx"]= HasLeaf7 && ((EBX >> 19) & 1);

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-09 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)

2024-05-09 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/91694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][Driver] Do not add `-evex512` for `-march=native` when the targ… (PR #91694)

2024-05-09 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/91694

…et doesn't support AVX512

Users want `-march=sandybridge -mavx512f -mavx512vl` behaves the same as 
`-march=native -mavx512f -mavx512vl` on a sandybridge target.

Fixes: #91076

>From 6ea15aa0ee6726cad8dccff10155f058afa0f013 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Fri, 10 May 2024 11:21:41 +0800
Subject: [PATCH] [X86][Driver] Do not add `-evex512` for `-march=native` when
 the target doesn't support AVX512

Users want `-march=sandybridge -mavx512f -mavx512vl` behaves the same as
`-march=native -mavx512f -mavx512vl` on a sandybridge target.

Fixes: #91076
---
 clang/lib/Driver/ToolChains/Arch/X86.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 53e26a9f8e229..c6d97ef4e971a 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -132,10 +132,14 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
   llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (llvm::sys::getHostCPUFeatures(HostFeatures)) {
+for (auto  : HostFeatures) {
+  if (!F.second && F.first() == "evex512")
+continue;
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
+}
+  }
 }
   }
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][CFE] Support EGPR in inline assembly. (PR #91323)

2024-05-07 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/91323
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][CFE] Support EGPR in inline assembly. (PR #91323)

2024-05-07 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -o /dev/null
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +egpr %s -o 
/dev/null
+
+int foo(void) {
+  register int a __asm__("ebx");
+#ifdef __EGPR__

phoebewang wrote:

Why just use `#ifdef __arm__` to distinguish ARM from X86?

https://github.com/llvm/llvm-project/pull/91323
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-05-05 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang reopened 
https://github.com/llvm/llvm-project/pull/88245
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-05-02 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/88245
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-27 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> For driver tests we prefer specifying a concrete target triple than making a 
> test dependent on the default target triple (controlled by `REQUIES: 
> coff-supported-target` in this case).
> 
> A concrete target triple (e.g. x86_64-windows) loses coverage for 
> aarch64-windows, but we generally accept the loss.

Thanks for the suggestion, updated.

https://github.com/llvm/llvm-project/pull/88245
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-27 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/88245

>From 569c7dfee58f7e4357d8af45b52a3135cb4e2e65 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 15:38:49 +0800
Subject: [PATCH 1/3] "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat
 only for COFF format" (#87987)", second try

This reverts commit 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 clang/test/Misc/win32-elf.c| 5 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From e6a326dc4b21f8180e03d9f2157fd63792a1dc14 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 17:02:23 +0800
Subject: [PATCH 2/3] Move codeview related tests to gcodeview-command-line.c

---
 clang/test/Driver/cl-options.c | 12 --
 clang/test/Driver/cl-outputs.c | 12 --
 clang/test/Driver/gcodeview-command-line.c | 26 +-
 clang/test/Driver/gcodeview-ghash.c|  1 +
 clang/test/lit.cfg.py  |  2 ++
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck 
-check-prefix=FioRACE2 %s
 // FioRACE2: "-E"
 // FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck 
-check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// 

[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-27 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/88245

>From 569c7dfee58f7e4357d8af45b52a3135cb4e2e65 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 15:38:49 +0800
Subject: [PATCH 1/3] "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat
 only for COFF format" (#87987)", second try

This reverts commit 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 clang/test/Misc/win32-elf.c| 5 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From e6a326dc4b21f8180e03d9f2157fd63792a1dc14 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 17:02:23 +0800
Subject: [PATCH 2/3] Move codeview related tests to gcodeview-command-line.c

---
 clang/test/Driver/cl-options.c | 12 --
 clang/test/Driver/cl-outputs.c | 12 --
 clang/test/Driver/gcodeview-command-line.c | 26 +-
 clang/test/Driver/gcodeview-ghash.c|  1 +
 clang/test/lit.cfg.py  |  2 ++
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck 
-check-prefix=FioRACE2 %s
 // FioRACE2: "-E"
 // FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck 
-check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// 

[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-27 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/88245

>From 569c7dfee58f7e4357d8af45b52a3135cb4e2e65 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 15:38:49 +0800
Subject: [PATCH 1/3] "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat
 only for COFF format" (#87987)", second try

This reverts commit 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 clang/test/Misc/win32-elf.c| 5 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From e6a326dc4b21f8180e03d9f2157fd63792a1dc14 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 17:02:23 +0800
Subject: [PATCH 2/3] Move codeview related tests to gcodeview-command-line.c

---
 clang/test/Driver/cl-options.c | 12 --
 clang/test/Driver/cl-outputs.c | 12 --
 clang/test/Driver/gcodeview-command-line.c | 26 +-
 clang/test/Driver/gcodeview-ghash.c|  1 +
 clang/test/lit.cfg.py  |  2 ++
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck 
-check-prefix=FioRACE2 %s
 // FioRACE2: "-E"
 // FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck 
-check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// 

[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-27 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/88245

>From 569c7dfee58f7e4357d8af45b52a3135cb4e2e65 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 15:38:49 +0800
Subject: [PATCH 1/3] "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat
 only for COFF format" (#87987)", second try

This reverts commit 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 clang/test/Misc/win32-elf.c| 5 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From e6a326dc4b21f8180e03d9f2157fd63792a1dc14 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 17:02:23 +0800
Subject: [PATCH 2/3] Move codeview related tests to gcodeview-command-line.c

---
 clang/test/Driver/cl-options.c | 12 --
 clang/test/Driver/cl-outputs.c | 12 --
 clang/test/Driver/gcodeview-command-line.c | 26 +-
 clang/test/Driver/gcodeview-ghash.c|  1 +
 clang/test/lit.cfg.py  |  2 ++
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck 
-check-prefix=FioRACE2 %s
 // FioRACE2: "-E"
 // FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck 
-check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// 

[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-27 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/88245

>From 569c7dfee58f7e4357d8af45b52a3135cb4e2e65 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 15:38:49 +0800
Subject: [PATCH 1/3] "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat
 only for COFF format" (#87987)", second try

This reverts commit 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 clang/test/Misc/win32-elf.c| 5 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From e6a326dc4b21f8180e03d9f2157fd63792a1dc14 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 17:02:23 +0800
Subject: [PATCH 2/3] Move codeview related tests to gcodeview-command-line.c

---
 clang/test/Driver/cl-options.c | 12 --
 clang/test/Driver/cl-outputs.c | 12 --
 clang/test/Driver/gcodeview-command-line.c | 26 +-
 clang/test/Driver/gcodeview-ghash.c|  1 +
 clang/test/lit.cfg.py  |  2 ++
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck 
-check-prefix=FioRACE2 %s
 // FioRACE2: "-E"
 // FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck 
-check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// 

[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-27 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/88245

>From 569c7dfee58f7e4357d8af45b52a3135cb4e2e65 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 15:38:49 +0800
Subject: [PATCH 1/3] "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat
 only for COFF format" (#87987)", second try

This reverts commit 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 clang/test/Misc/win32-elf.c| 5 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From e6a326dc4b21f8180e03d9f2157fd63792a1dc14 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 17:02:23 +0800
Subject: [PATCH 2/3] Move codeview related tests to gcodeview-command-line.c

---
 clang/test/Driver/cl-options.c | 12 --
 clang/test/Driver/cl-outputs.c | 12 --
 clang/test/Driver/gcodeview-command-line.c | 26 +-
 clang/test/Driver/gcodeview-ghash.c|  1 +
 clang/test/lit.cfg.py  |  2 ++
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck 
-check-prefix=FioRACE2 %s
 // FioRACE2: "-E"
 // FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck 
-check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | 
FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// 

[clang] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (PR #87149)

2024-04-26 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> I am curious what a `win32-elf` triple is. Does MSVC support generating ELF 
> object files?

No idea, but https://github.com/llvm/llvm-project/issues/87140 doesn't look 
like from fuzzing.
Consider Windows has WSL now, I'd not surprise it's supported or will be 
supported someday, see 
https://learn.microsoft.com/en-us/cpp/build/walkthrough-build-debug-wsl2?view=msvc-170

https://github.com/llvm/llvm-project/pull/87149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (PR #89446)

2024-04-19 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Sorry, I know nothing about it. But it looks to me it's to match with GCC, why 
don't borrow the value from GCC as a beginning?

https://github.com/llvm/llvm-project/pull/89446
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests, NFC (PR #88736)

2024-04-18 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests, NFC (PR #88736)

2024-04-18 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests (PR #88736)

2024-04-18 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests (PR #88736)

2024-04-17 Thread Phoebe Wang via cfe-commits


@@ -1,13 +1,22 @@
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=return %s | 
FileCheck %s --check-prefix=RETURN
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=branch %s | 
FileCheck %s --check-prefix=BRANCH
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=full %s   | 
FileCheck %s --check-prefix=FULL
+// RUN: %clang_cc1 -E -triple=x86_64 -dM -o - -fcf-protection=none %s | 
FileCheck %s --check-prefix=NOTCET
 // RUN: not %clang_cc1 -emit-llvm-only -triple i386 -target-cpu pentium-mmx 
-fcf-protection=branch %s 2>&1 | FileCheck %s --check-prefix=NOCFPROT
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=return %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTR
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=branch %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTB
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=full %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTF

phoebewang wrote:

```suggestion
// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=return %s -emit-llvm | 
FileCheck %s --check-prefixes=CFPROTR,CFPROTNONE
// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=branch %s -emit-llvm | 
FileCheck %s --check-prefixes=CFPROTB,CFPROTNONE
// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=full %s -emit-llvm | 
FileCheck %s --check-prefixes=CFPROTR,CFPROTB,CFPROTNONE
```

https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests (PR #88736)

2024-04-17 Thread Phoebe Wang via cfe-commits


@@ -1,13 +1,22 @@
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=return %s | 
FileCheck %s --check-prefix=RETURN
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=branch %s | 
FileCheck %s --check-prefix=BRANCH
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=full %s   | 
FileCheck %s --check-prefix=FULL
+// RUN: %clang_cc1 -E -triple=x86_64 -dM -o - -fcf-protection=none %s | 
FileCheck %s --check-prefix=NOTCET
 // RUN: not %clang_cc1 -emit-llvm-only -triple i386 -target-cpu pentium-mmx 
-fcf-protection=branch %s 2>&1 | FileCheck %s --check-prefix=NOCFPROT
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=return %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTR
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=branch %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTB
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=full %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTF
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=none %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTNONE
 
 // RETURN: #define __CET__ 2
 // BRANCH: #define __CET__ 1
 // FULL: #define __CET__ 3
-// CFPROT: !{i32 8, !"cf-protection-branch", i32 1}
-
+// NOTCET-NOT: #define __CET__
 // NOCFPROT: error: option 'cf-protection=branch' cannot be specified on this 
target
+// CFPROTR: !{i32 8, !"cf-protection-return", i32 1}
+// CFPROTB: !{i32 8, !"cf-protection-branch", i32 1}
+// CFPROTF: !{i32 8, !"cf-protection-return", i32 1}
+// CFPROTF-NEXT: !{i32 8, !"cf-protection-branch", i32 1}

phoebewang wrote:

```suggestion
// CFPROTNONE-NOT: cf-protection-
// CFPROTR: !{i32 8, !"cf-protection-return", i32 1}
// CFPROTB: !{i32 8, !"cf-protection-branch", i32 1}
// CFPROTNONE-NOT: cf-protection-
```

https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [SEH] Ignore async exception flag when the environment is not MSVC (PR #88101)

2024-04-16 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Thanks a lot @nico! I see the bot is still red, but not failed on this test any 
more.

https://github.com/llvm/llvm-project/pull/88101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [SEH] Ignore async exception flag when the environment is not MSVC (PR #88101)

2024-04-16 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/88101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests (PR #88736)

2024-04-15 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests (PR #88736)

2024-04-15 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests (PR #88736)

2024-04-15 Thread Phoebe Wang via cfe-commits


@@ -2,12 +2,20 @@
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=branch %s | 
FileCheck %s --check-prefix=BRANCH
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=full %s   | 
FileCheck %s --check-prefix=FULL
 // RUN: not %clang_cc1 -emit-llvm-only -triple i386 -target-cpu pentium-mmx 
-fcf-protection=branch %s 2>&1 | FileCheck %s --check-prefix=NOCFPROT
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=branch %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROT
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=full %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTF
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=none %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTNONE
+// RUN: %clang_cc1 -E -triple=x86_64 -dM -o - -fcf-protection=none %s | 
FileCheck %s --check-prefix=NOTCET
 
 // RETURN: #define __CET__ 2
 // BRANCH: #define __CET__ 1
 // FULL: #define __CET__ 3
 // CFPROT: !{i32 8, !"cf-protection-branch", i32 1}
 
 // NOCFPROT: error: option 'cf-protection=branch' cannot be specified on this 
target
+// CFPROTF: !{i32 8, !"cf-protection-return", i32 1}
+// CFPROTF-NEXT: !{i32 8, !"cf-protection-branch", i32 1}
+// CFPROTNONE-NOT: cf-protection-branch

phoebewang wrote:

Change to `cf-protection-` to cover both.

https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][test] Added extra cet tests (PR #88736)

2024-04-15 Thread Phoebe Wang via cfe-commits


@@ -2,12 +2,20 @@
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=branch %s | 
FileCheck %s --check-prefix=BRANCH
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=full %s   | 
FileCheck %s --check-prefix=FULL
 // RUN: not %clang_cc1 -emit-llvm-only -triple i386 -target-cpu pentium-mmx 
-fcf-protection=branch %s 2>&1 | FileCheck %s --check-prefix=NOCFPROT
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=branch %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROT
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=full %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTF
+// RUN: %clang_cc1 -triple=x86_64 -o - -fcf-protection=none %s -emit-llvm | 
FileCheck %s --check-prefix=CFPROTNONE
+// RUN: %clang_cc1 -E -triple=x86_64 -dM -o - -fcf-protection=none %s | 
FileCheck %s --check-prefix=NOTCET
 
 // RETURN: #define __CET__ 2
 // BRANCH: #define __CET__ 1
 // FULL: #define __CET__ 3
 // CFPROT: !{i32 8, !"cf-protection-branch", i32 1}

phoebewang wrote:

Add a `// CFPROT-NOT: cf-protection-branch`

https://github.com/llvm/llvm-project/pull/88736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)

2024-04-10 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/88245

This is a second try to reland https://github.com/llvm/llvm-project/pull/87149.

The previous commit exposed failures on some targets. The reason is only a few 
targets support COFF ObjectFormatType on Windows: 
https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Triple.cpp#L835-L842

With https://github.com/llvm/llvm-project/pull/87149, the targets don't support 
COFF will report "warning: argument unused during compilation: 
'-gcodeview-command-line' [-Wunused-command-line-argument]" in the test 
gcodeview-command-line.c

I was thinking `REQUIRES: *-registered-target` could solve the problem, but it 
didn't. We need to check the actual triple instead of just 
`*-registered-target`.

>From 569c7dfee58f7e4357d8af45b52a3135cb4e2e65 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 15:38:49 +0800
Subject: [PATCH 1/2] "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat
 only for COFF format" (#87987)", second try

This reverts commit 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 clang/test/Misc/win32-elf.c| 5 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From e6a326dc4b21f8180e03d9f2157fd63792a1dc14 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Wed, 10 Apr 2024 17:02:23 +0800
Subject: [PATCH 2/2] Move codeview related tests to gcodeview-command-line.c

---
 clang/test/Driver/cl-options.c | 12 --
 clang/test/Driver/cl-outputs.c | 12 --
 clang/test/Driver/gcodeview-command-line.c | 26 +-
 clang/test/Driver/gcodeview-ghash.c|  1 +
 clang/test/lit.cfg.py  |  2 ++
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck 

[clang] 299b636 - Revert "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format" (#87987)"

2024-04-10 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2024-04-10T14:40:07+08:00
New Revision: 299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6

URL: 
https://github.com/llvm/llvm-project/commit/299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6
DIFF: 
https://github.com/llvm/llvm-project/commit/299b636a8f1c9cb2382f9dce4cdf6ec6330a79c6.diff

LOG: Revert "Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF 
format" (#87987)"

This reverts commit 4a93872a4f57d2f205826052150fadc36490445f.

Sorry, there're still buildbot failures.

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.h
clang/test/Driver/gcodeview-command-line.c

Removed: 
clang/test/Misc/win32-elf.c



diff  --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 3950a8ed38e8b4..48369e030aade2 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,8 +61,9 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
-   : llvm::codegenoptions::DIF_DWARF;
+return getTriple().isOSBinFormatMachO()
+   ? llvm::codegenoptions::DIF_DWARF
+   : llvm::codegenoptions::DIF_CodeView;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning

diff  --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index 83542fc71aece4..da8708af322480 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,6 +1,5 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
-// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"

diff  --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
deleted file mode 100644
index f75281dc418727..00
--- a/clang/test/Misc/win32-elf.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// Check that basic use of win32-elf targets works.
-// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
-
-// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
-// DEBUG-INFO: -dwarf-version={{.*}}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format" (PR #87987)

2024-04-09 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/87987
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [SEH] Ignore async exception flag when the environment is not MSVC (PR #88101)

2024-04-09 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/88101

Fixes #62449

>From 66c4383e58cab7cf893edfa3f3507be166116fa6 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 9 Apr 2024 16:08:55 +0800
Subject: [PATCH] [SEH] Ignore async exception flag when the environment is not
 MSVC

Fixes #62449
---
 clang/lib/Driver/ToolChains/Clang.cpp | 28 +--
 .../test/Driver/windows-seh-async-verify.cpp  | 24 
 2 files changed, 44 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/Driver/windows-seh-async-verify.cpp

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 766a9b91e3c0ad..c1ed4bd2dcda06 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -346,11 +346,14 @@ static bool addExceptionArgs(const ArgList , 
types::ID InputType,
   bool EH = Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
  false);
 
-  bool EHa = Args.hasFlag(options::OPT_fasync_exceptions,
-  options::OPT_fno_async_exceptions, false);
-  if (EHa) {
-CmdArgs.push_back("-fasync-exceptions");
-EH = true;
+  // Async exceptions are Windows MSVC only.
+  if (Triple.isWindowsMSVCEnvironment()) {
+bool EHa = Args.hasFlag(options::OPT_fasync_exceptions,
+options::OPT_fno_async_exceptions, false);
+if (EHa) {
+  CmdArgs.push_back("-fasync-exceptions");
+  EH = true;
+}
   }
 
   // Obj-C exceptions are enabled by default, regardless of -fexceptions. This
@@ -8084,7 +8087,8 @@ struct EHFlags {
 ///  The 'a' modifier is unimplemented and fundamentally hard in LLVM IR.
 /// - c: Assume that extern "C" functions are implicitly nounwind.
 /// The default is /EHs-c-, meaning cleanups are disabled.
-static EHFlags parseClangCLEHFlags(const Driver , const ArgList ) {
+static EHFlags parseClangCLEHFlags(const Driver , const ArgList ,
+   bool isWindowsMSVC) {
   EHFlags EH;
 
   std::vector EHArgs =
@@ -8094,8 +8098,15 @@ static EHFlags parseClangCLEHFlags(const Driver , 
const ArgList ) {
   switch (EHVal[I]) {
   case 'a':
 EH.Asynch = maybeConsumeDash(EHVal, I);
-if (EH.Asynch)
+if (EH.Asynch) {
+  // Async exceptions are Windows MSVC only.
+  if (!isWindowsMSVC) {
+EH.Asynch = false;
+D.Diag(clang::diag::warn_drv_unused_argument) << "/EHa" << EHVal;
+continue;
+  }
   EH.Synch = false;
+}
 continue;
   case 'c':
 EH.NoUnwindC = maybeConsumeDash(EHVal, I);
@@ -8159,7 +8170,8 @@ void Clang::AddClangCLArgs(const ArgList , types::ID 
InputType,
 
   const Driver  = getToolChain().getDriver();
 
-  EHFlags EH = parseClangCLEHFlags(D, Args);
+  bool IsWindowsMSVC = getToolChain().getTriple().isWindowsMSVCEnvironment();
+  EHFlags EH = parseClangCLEHFlags(D, Args, IsWindowsMSVC);
   if (!isNVPTX && (EH.Synch || EH.Asynch)) {
 if (types::isCXX(InputType))
   CmdArgs.push_back("-fcxx-exceptions");
diff --git a/clang/test/Driver/windows-seh-async-verify.cpp 
b/clang/test/Driver/windows-seh-async-verify.cpp
new file mode 100644
index 00..5fda6a77dba049
--- /dev/null
+++ b/clang/test/Driver/windows-seh-async-verify.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang --target=x86_64-pc-windows -fasync-exceptions -fsyntax-only %s 
-### 2>&1 | FileCheck %s
+// RUN: %clang_cl --target=x86_64-pc-windows /EHa -fsyntax-only %s -### 2>&1 | 
FileCheck %s
+// RUN: %clang --target=x86_64-pc-windows-gnu -fasync-exceptions -fsyntax-only 
%s -### 2>&1 | FileCheck %s --check-prefixes=GNU-ALL,GNU
+// RUN: %clang_cl --target=x86_64-pc-windows-gnu /EHa -fsyntax-only %s -### 
2>&1 | FileCheck %s --check-prefixes=GNU-ALL,CL-GNU
+
+// CHECK-NOT: warning
+// GNU: warning: argument unused during compilation: '-fasync-exceptions' 
[-Wunused-command-line-argument]
+// CL-GNU: warning: argument unused during compilation: '/EHa' 
[-Wunused-command-line-argument]
+
+// CHECK: -fasync-exceptions
+// GNU-ALL-NOT: -fasync-exceptions
+struct S {
+union _Un {
+~_Un() {}
+char _Buf[12];
+};
+_Un _un;
+};
+
+struct Embed {
+S v2;
+};
+
+void PR62449() { Embed v{}; }

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format" (PR #87987)

2024-04-08 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/87987
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (PR #87987)

2024-04-08 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/87987

This relands #87149.

The previous commit exposed failures on some targets. The reason is only a few 
targets support COFF ObjectFormatType on Windows: 
https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Triple.cpp#L835-L842

With #87149, the targets don't support COFF will report "warning: argument 
unused during compilation: '-gcodeview-command-line' 
[-Wunused-command-line-argument]" in the test gcodeview-command-line.c

This patch limits gcodeview-command-line.c only run on targets support COFF.

>From 6d3dbfaa7c5fb6acb5e6cae70455567030c50cf8 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 8 Apr 2024 11:10:58 +0800
Subject: [PATCH 1/2] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only
 for COFF format (#87149)"

This reverts commit cd7517859eef14d8b38cec2d52c0625a58c645a2.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Misc/win32-elf.c| 5 +
 2 files changed, 7 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From a716712ee5fd797c47fecbe7a608675889917c77 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 8 Apr 2024 21:00:33 +0800
Subject: [PATCH 2/2] Linux gcodeview test for a few targets

---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cd75178 - Revert "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (#87149)"

2024-04-03 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2024-04-03T16:10:19+08:00
New Revision: cd7517859eef14d8b38cec2d52c0625a58c645a2

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

LOG: Revert "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format 
(#87149)"

This reverts commit 4b25053ae47f50095371a663391baadfd2694eb0.

There're failures in some target.

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.h

Removed: 
clang/test/Misc/win32-elf.c



diff  --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 3950a8ed38e8b4..48369e030aade2 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,8 +61,9 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
-   : llvm::codegenoptions::DIF_DWARF;
+return getTriple().isOSBinFormatMachO()
+   ? llvm::codegenoptions::DIF_DWARF
+   : llvm::codegenoptions::DIF_CodeView;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning

diff  --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
deleted file mode 100644
index f75281dc418727..00
--- a/clang/test/Misc/win32-elf.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// Check that basic use of win32-elf targets works.
-// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
-
-// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
-// DEBUG-INFO: -dwarf-version={{.*}}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (PR #87149)

2024-03-30 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/87149

>From 16fea4659909423319f0107b2a4d5bcc31185299 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Sat, 30 Mar 2024 17:29:06 +0800
Subject: [PATCH] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF
 format

We have many problems to use CodeView for a win32-elf target, e.g., #87140
and `error: .seh_* directives are not supported on this target`.

Fixes: #87140
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Misc/win32-elf.c| 5 +
 2 files changed, 7 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (PR #87149)

2024-03-30 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/87149

We have many problems to use CodeView for a win32-elf target, e.g., #87140 and 
`error: .seh_* directives are not supported on this target`.

Fixes: #87140

>From 745b2acb9dafbb54b00353f71dee464b3617c13a Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Sat, 30 Mar 2024 17:29:06 +0800
Subject: [PATCH] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF
 format

We have many problems to use CodeView for a win32-elf target, e.g., #87140
and `error: .seh_* directives are not supported on this target`.

Fixes: #87140
---
 clang/lib/Driver/ToolChains/MSVC.h | 6 +++---
 clang/test/Misc/win32-elf.c| 5 +
 2 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3a5975272c570f 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,9 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF()
+   ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)

2024-03-20 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/85862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)

2024-03-19 Thread Phoebe Wang via cfe-commits


@@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b)
 /// Compares two 256-bit vectors of [4 x double] and returns the greater
 ///of each pair of values.
 ///
+///If either value in a comparison is NaN, returns the value from \a __b.

phoebewang wrote:

Is it worth to mention the ±0 comparison?

https://github.com/llvm/llvm-project/pull/85862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86_64] fix empty structure vaarg in c++ (PR #77907)

2024-03-19 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Checked both pr77036.cpp and pr77036.c get the same result, so looks like a 
right fix. But I want to wait @efriedma-quic to sign off.

https://github.com/llvm/llvm-project/pull/77907
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86_64] fix empty structure vaarg in c++ (PR #77907)

2024-03-19 Thread Phoebe Wang via cfe-commits


@@ -3014,6 +3014,11 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction , 
Address VAListAddr,
   ABIArgInfo AI = classifyArgumentType(Ty, 0, neededInt, neededSSE,
/*isNamedArg*/false);
 
+  // Empty records are ignored for parameter passing purposes.
+  if (AI.isIgnore()) {
+return CGF.CreateMemTemp(Ty);
+  }

phoebewang wrote:

Does it behave differently between C and C++? Maybe adding a C test for it?

Besides, do not use parentheses for single line code.

https://github.com/llvm/llvm-project/pull/77907
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-15 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-15 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/8] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-15 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/8] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-15 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,247 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=i686 --relocation-model=pic -enable-tlsdesc | 
FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X32
+; RUN: llc < %s -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc | 
FileCheck %s --check-prefix=X64
+
+@x = thread_local global i32 0, align 4
+@y = internal thread_local global i32 0, align 4
+@z = internal thread_local global i32 1, align 4
+@t = external hidden thread_local global i32, align 4
+
+define ptr @f1() nounwind {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:pushl %ebx
+; X86-NEXT:pushl %edi
+; X86-NEXT:pushl %esi
+; X86-NEXT:pushl %eax
+; X86-NEXT:calll .L0$pb
+; X86-NEXT:  .L0$pb:
+; X86-NEXT:popl %ebx
+; X86-NEXT:  .Ltmp0:
+; X86-NEXT:addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %ebx
+; X86-NEXT:#APP
+; X86-NEXT:#NO_APP
+; X86-NEXT:movl %eax, (%esp) # 4-byte Spill
+; X86-NEXT:leal x@tlsdesc(%ebx), %eax
+; X86-NEXT:calll *x@tlscall(%eax)
+; X86-NEXT:addl %gs:0, %eax
+; X86-NEXT:movl (%esp), %ebx # 4-byte Reload
+; X86-NEXT:#APP
+; X86-NEXT:#NO_APP
+; X86-NEXT:addl $4, %esp
+; X86-NEXT:popl %esi
+; X86-NEXT:popl %edi
+; X86-NEXT:popl %ebx
+; X86-NEXT:popl %ebp
+; X86-NEXT:retl
+;
+; X32-LABEL: f1:
+; X32:   # %bb.0:
+; X32-NEXT:pushq %rax
+; X32-NEXT:#APP
+; X32-NEXT:#NO_APP
+; X32-NEXT:leal x@tlsdesc(%rip), %eax
+; X32-NEXT:callq *x@tlscall(%eax)
+; X32-NEXT:# kill: def $eax killed $eax def $rax
+; X32-NEXT:addl %fs:0, %eax
+; X32-NEXT:#APP
+; X32-NEXT:#NO_APP
+; X32-NEXT:popq %rcx
+; X32-NEXT:retq
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:pushq %rax
+; X64-NEXT:#APP
+; X64-NEXT:#NO_APP
+; X64-NEXT:leaq x@tlsdesc(%rip), %rax
+; X64-NEXT:callq *x@tlscall(%rax)
+; X64-NEXT:addq %fs:0, %rax
+; X64-NEXT:#APP
+; X64-NEXT:#NO_APP
+; X64-NEXT:popq %rcx
+; X64-NEXT:retq
+  %a = call { i32, i32, i32, i32, i32, i32 } asm sideeffect "", 
"=r,=r,=r,=r,=r,=r,~{dirflag},~{fpsr},~{flags}"()
+  %b = call ptr @llvm.threadlocal.address.p0(ptr @x)
+  %a.0 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 0
+  %a.1 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 1
+  %a.2 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 2
+  %a.3 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 3
+  %a.4 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 4
+  %a.5 = extractvalue { i32, i32, i32, i32, i32, i32 } %a, 5
+  call void asm sideeffect "", "r,r,r,r,r,r,~{dirflag},~{fpsr},~{flags}"(i32 
%a.0, i32 %a.1, i32 %a.2, i32 %a.3, i32 %a.4, i32 %a.5)
+  ret ptr %b
+}
+
+define i32 @f2() nounwind {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebx
+; X86-NEXT:calll .L1$pb
+; X86-NEXT:  .L1$pb:
+; X86-NEXT:popl %ebx
+; X86-NEXT:  .Ltmp1:
+; X86-NEXT:addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp1-.L1$pb), %ebx
+; X86-NEXT:movl %gs:0, %ecx
+; X86-NEXT:leal x@tlsdesc(%ebx), %eax
+; X86-NEXT:calll *x@tlscall(%eax)
+; X86-NEXT:movl (%eax,%ecx), %eax
+; X86-NEXT:popl %ebx
+; X86-NEXT:retl
+;
+; X32-LABEL: f2:
+; X32:   # %bb.0:
+; X32-NEXT:pushq %rax
+; X32-NEXT:movl %fs:0, %ecx
+; X32-NEXT:leal x@tlsdesc(%rip), %eax
+; X32-NEXT:callq *x@tlscall(%eax)
+; X32-NEXT:movl (%eax,%ecx), %eax
+; X32-NEXT:popq %rcx
+; X32-NEXT:retq
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:pushq %rax
+; X64-NEXT:movq %fs:0, %rcx
+; X64-NEXT:leaq x@tlsdesc(%rip), %rax
+; X64-NEXT:callq *x@tlscall(%rax)
+; X64-NEXT:movl (%rax,%rcx), %eax
+; X64-NEXT:popq %rcx
+; X64-NEXT:retq
+  %1 = tail call ptr @llvm.threadlocal.address.p0(ptr @x)
+  %2 = load i32, ptr %1
+  ret i32 %2
+}
+
+define ptr @f3() nounwind {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebx
+; X86-NEXT:calll .L2$pb
+; X86-NEXT:  .L2$pb:
+; X86-NEXT:popl %ebx
+; X86-NEXT:  .Ltmp2:
+; X86-NEXT:addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp2-.L2$pb), %ebx
+; X86-NEXT:leal x@tlsdesc(%ebx), %eax
+; X86-NEXT:calll *x@tlscall(%eax)
+; X86-NEXT:addl %gs:0, %eax
+; X86-NEXT:popl %ebx
+; X86-NEXT:retl
+;
+; X32-LABEL: f3:
+; X32:   # %bb.0:
+; X32-NEXT:pushq %rax
+; X32-NEXT:leal x@tlsdesc(%rip), %eax
+; X32-NEXT:callq *x@tlscall(%eax)
+; X32-NEXT:# kill: def $eax killed $eax def $rax
+; X32-NEXT:addl %fs:0, %eax
+; X32-NEXT:popq %rcx
+; X32-NEXT:retq
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:pushq %rax
+; X64-NEXT:leaq x@tlsdesc(%rip), %rax
+; X64-NEXT:callq *x@tlscall(%rax)
+; X64-NEXT:addq %fs:0, %rax
+; X64-NEXT:popq %rcx
+; X64-NEXT:retq
+  %1 = tail call ptr 

[clang] [Headers][X86] Add rounding and exception notes to conversions (PR #83447)

2024-03-14 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang approved this pull request.

Looks great, thanks!

https://github.com/llvm/llvm-project/pull/83447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-10 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Gentle ping~

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers][X86] Add rounding and exception notes to conversions (PR #83447)

2024-03-08 Thread Phoebe Wang via cfe-commits


@@ -1405,11 +1413,12 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS 
_mm_cvtss_sd(__m128d __a,
 
 /// Converts the two double-precision floating-point elements of a
 ///128-bit vector of [2 x double] into two signed 32-bit integer values,
-///returned in the lower 64 bits of a 128-bit vector of [4 x i32].
+///returned in the lower 64 bits of a 128-bit vector of [4 x i32],
+///truncating inexact results.

phoebewang wrote:

Oh, I took that simply as wrong infromation.

> Do you have a different suggestion for how to organize this information?

Not ideal, something like

```
/// Converts the two double-precision floating-point elements of a
///128-bit vector of [2 x double] into two signed truncated
///(rounded towards zero) 32-bit integer values,returned in the
///most negative integer.
```

https://github.com/llvm/llvm-project/pull/83447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers][X86] Add rounding and exception notes to conversions (PR #83447)

2024-03-08 Thread Phoebe Wang via cfe-commits


@@ -1405,11 +1413,12 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS 
_mm_cvtss_sd(__m128d __a,
 
 /// Converts the two double-precision floating-point elements of a
 ///128-bit vector of [2 x double] into two signed 32-bit integer values,
-///returned in the lower 64 bits of a 128-bit vector of [4 x i32].
+///returned in the lower 64 bits of a 128-bit vector of [4 x i32],
+///truncating inexact results.

phoebewang wrote:

The last sentence is not necessary and has ambiguity in truncating the 
fractional part or truncating higher bits to 32-bit.

https://github.com/llvm/llvm-project/pull/83447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Finally handle target of __builtin_ia32_cmp[p|s][s|d] from avx into sse/sse2/avx (PR #84136)

2024-03-08 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/84136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-07 Thread Phoebe Wang via cfe-commits


@@ -18543,7 +18552,19 @@ GetTLSADDR(SelectionDAG , SDValue Chain, 
GlobalAddressSDNode *GA,
   MFI.setHasCalls(true);
 
   SDValue Glue = Chain.getValue(1);
-  return DAG.getCopyFromReg(Chain, dl, ReturnReg, PtrVT, Glue);
+  SDValue Ret = DAG.getCopyFromReg(Chain, dl, ReturnReg, PtrVT, Glue);
+
+  if (!UseTLSDESC)
+return Ret;
+
+  const X86Subtarget  = DAG.getSubtarget();
+  unsigned Seg = Subtarget.is64Bit() ? X86AS::FS : X86AS::GS;
+
+  Value *Ptr = Constant::getNullValue(PointerType::get(*DAG.getContext(), 
Seg));
+  SDValue Offset =
+  DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), DAG.getIntPtrConstant(0, dl),

phoebewang wrote:

Quote from https://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-x86.txt

> An alternate design in which the function called through the TLS
descriptor returns not the TP offset, but rather the address of the
variable of interest, could refrain from adding %gs:0 to the value
returned by the call to compute the address of a symbol, and from
using the %gs: prefix when accessing the variable, but it would
require the use of a longer call instruction to enable proper
relaxation.  The call instruction would have to be 7, instead of 2
bytes long, such that the linker could relax it to `addl %gs:0, %eax'.
This would make code that accesses the variable 4 bytes longer on
average (5 bytes minus one used by the %gs prefix), whereas code that
computes its address would be shorter by only two bytes.  It's not
clear such a change would be profitable.

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-07 Thread Phoebe Wang via cfe-commits


@@ -18522,13 +18522,21 @@ GetTLSADDR(SelectionDAG , SDValue Chain, 
GlobalAddressSDNode *GA,
   MachineFrameInfo  = DAG.getMachineFunction().getFrameInfo();
   SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue);
   SDLoc dl(GA);
-  SDValue TGA = DAG.getTargetGlobalAddress(GA->getGlobal(), dl,
-   GA->getValueType(0),
-   GA->getOffset(),
-   OperandFlags);
+  SDValue TGA;
+  bool UseTLSDESC = DAG.getTarget().useTLSDESC();
+  if (LocalDynamic && UseTLSDESC) {
+TGA = DAG.getTargetExternalSymbol("_TLS_MODULE_BASE_", PtrVT, 
OperandFlags);
+auto UI = TGA->use_begin();
+if (UI != TGA->use_end())
+  return SDValue(*UI->use_begin()->use_begin(), 0);

phoebewang wrote:

Done.

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,165 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=i686-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X32
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X64
+
+@x = thread_local global i32 0, align 4
+@y = internal thread_local global i32 0, align 4

phoebewang wrote:

Added in `f5`.

> The ideal thing is probably not to use `_TLS_MODULE_BASE_` when its result is 
> used only once in the function

I think it is demonstrated by `f3`?

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/7] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> I assume that's what you're doing in the place I asked for a comment is 
> trying to avoid redundantly generating TLSDESC accesses for 
> _TLS_MODULE_BASE_. I see that we don't generate multiple accesses for 
> _TLS_MODULE_BASE_ in the test cases, but I thought that was only safe to do 
> when an earlier access dominates a later access.
> 
> Is my understanding here correct, or is there an interaction with
> 
> https://github.com/llvm/llvm-project/blob/04a271ebe4c2421f34a4fbf34c328df9f111/llvm/lib/Target/X86/X86InstrInfo.cpp#L10245
> 
> ?

Yes, you are correct.

I think SelectionDAG takes care of it. I checked it locally, it will generate 
two pairs of `_TLS_MODULE_BASE_` in `if ... else ...` branches respectively and 
one `_TLS_MODULE_BASE_` otherwise.

I admit I didn't know the code here when adding it to GetTLSADDR. But I think 
not to create the nodes at the beginning is slightly better than to remove it 
later if they have the same output. Not to mention dominator iteration is 
expensive.

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Finely handle target of __builtin_ia32_cmp[p|s][s|d] from avx into sse/sse2/avx (PR #84136)

2024-03-06 Thread Phoebe Wang via cfe-commits


@@ -34,6 +34,60 @@ __m128 test_mm_andnot_ps(__m128 A, __m128 B) {
   return _mm_andnot_ps(A, B);
 }
 
+__m128 test_mm_cmp_ps_eq_oq(__m128 a, __m128 b) {
+  // CHECK-LABEL: test_mm_cmp_ps_eq_oq
+  // CHECK: fcmp oeq <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_EQ_OQ);

phoebewang wrote:

I don't understand why moving them here. Shouldn't they emit error without avx?

https://github.com/llvm/llvm-project/pull/84136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits


@@ -18515,20 +18515,20 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   return LowerGlobalOrExternal(Op, DAG, /*ForCall=*/false);
 }
 
-static SDValue
-GetTLSADDR(SelectionDAG , SDValue Chain, GlobalAddressSDNode *GA,
-   SDValue *InGlue, const EVT PtrVT, unsigned ReturnReg,
-   unsigned char OperandFlags, bool LocalDynamic = false) {
+static SDValue getTLSADDR(SelectionDAG , SDValue Chain,
+  GlobalAddressSDNode *GA, SDValue *InGlue,
+  const EVT PtrVT, unsigned ReturnReg,
+  unsigned char OperandFlags, bool UseTLSDESC = false,

phoebewang wrote:

Done. We don't need this arg now.

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,165 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=i686-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X32
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X64
+
+@x = thread_local global i32 0, align 4
+@y = internal thread_local global i32 0, align 4

phoebewang wrote:

Done.

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/6] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/6] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-06 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/5] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-05 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang deleted 
https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-05 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,165 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=i686-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X32
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X64
+
+@x = thread_local global i32 0, align 4
+@y = internal thread_local global i32 0, align 4

phoebewang wrote:

Thanks @frobtech for the explanation. IIUC, GCC will use `_TLS_MODULE_BASE_` if 
there are more than 1 local TLS variables, right?

I have no idea how to do it smartly in codegen in LLVM since we lower it 
statelessly. Maybe let's land this first? @MaskRay @frobtech 

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-04 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/4] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-03-03 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Ping~

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] [X86] Use generic CPU tuning when tune-cpu is empty (PR #83631)

2024-03-02 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

This is a turbulent change to both upstream and downstream tests without any 
profit as far as I can tell.

I did a similar change for 64-bit a few years ago: 
https://reviews.llvm.org/D129647

In comparison, this patch is not to solve a specific problem. It should not 
show any value because we don't care about 32-bit performance. Not to mention, 
we need to keep the test not changed as many as possible. The way we used in 
D129647 is to add an explicit "tune-cpu". We cannot blindly update tests in 
case distort the original intention.

https://github.com/llvm/llvm-project/pull/83631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers][X86] Add rounding and exception notes to conversions (PR #83447)

2024-03-01 Thread Phoebe Wang via cfe-commits


@@ -2211,7 +2213,12 @@ _mm256_cvtpd_ps(__m256d __a)
   return (__m128)__builtin_ia32_cvtpd2ps256((__v4df) __a);
 }
 
-/// Converts a vector of [8 x float] into a vector of [8 x i32].
+/// Converts a vector of [8 x float] into a vector of [8 x i32]. Rounds inexact
+///results according to the rounding control bits in the MXCSR register.
+///
+///If a converted value is larger than the maximum possible result,

phoebewang wrote:

Not only larger than, considering the negative number.

https://github.com/llvm/llvm-project/pull/83447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers][X86] Add rounding and exception notes to conversions (PR #83447)

2024-03-01 Thread Phoebe Wang via cfe-commits


@@ -2180,7 +2180,8 @@ _mm256_cvtepi32_pd(__m128i __a)
   return (__m256d)__builtin_convertvector((__v4si)__a, __v4df);
 }
 
-/// Converts a vector of [8 x i32] into a vector of [8 x float].
+/// Converts a vector of [8 x i32] into a vector of [8 x float]. Rounds inexact
+///results according to the rounding control bits in the MXCSR register.

phoebewang wrote:

I think we don't need to mention it. This is the default behavior if not 
mentioned otherwise.

https://github.com/llvm/llvm-project/pull/83447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-02-28 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,165 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=i686-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X32
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X64
+
+@x = thread_local global i32 0, align 4
+@y = internal thread_local global i32 0, align 4

phoebewang wrote:

Done.

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-02-28 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/83136

>From cdc9ee6c322af0ceed162f3f714bcd0a22e020c3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Tue, 27 Feb 2024 22:16:38 +0800
Subject: [PATCH 1/3] [X86] Add Support for X86 TLSDESC Relocations

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   3 +-
 clang/test/Driver/tls-dialect.c   |   2 +-
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  14 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |   2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  98 +++
 llvm/lib/Target/X86/X86MCInstLower.cpp|  30 +++-
 llvm/test/CodeGen/X86/tls-desc.ll | 165 ++
 7 files changed, 273 insertions(+), 41 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/tls-desc.ll

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index faceee85a2f8dc..c66e3ee12e50c4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -740,7 +740,8 @@ bool tools::isTLSDESCEnabled(const ToolChain ,
 SupportedArgument = V == "desc" || V == "trad";
 EnableTLSDESC = V == "desc";
   } else if (Triple.isX86()) {
-SupportedArgument = V == "gnu";
+SupportedArgument = V == "gnu" || V == "gnu2";
+EnableTLSDESC = V == "gnu2";
   } else {
 Unsupported = true;
   }
diff --git a/clang/test/Driver/tls-dialect.c b/clang/test/Driver/tls-dialect.c
index f73915b28ec2a3..a808dd81531ce7 100644
--- a/clang/test/Driver/tls-dialect.c
+++ b/clang/test/Driver/tls-dialect.c
@@ -2,6 +2,7 @@
 // RUN: %clang -### --target=riscv64-linux -mtls-dialect=trad %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
 // RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck 
--check-prefix=NODESC %s
 // RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | 
FileCheck --check-prefix=NODESC %s
+// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=DESC %s
 
 /// Android supports TLSDESC by default on RISC-V
 /// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
@@ -18,7 +19,6 @@
 
 /// Unsupported argument
 // RUN: not %clang -### --target=riscv64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
-// RUN: not %clang -### --target=x86_64-linux -mtls-dialect=gnu2 %s 2>&1 | 
FileCheck --check-prefix=UNSUPPORTED-ARG %s
 
 // DESC:   "-cc1" {{.*}}"-enable-tlsdesc"
 // NODESC-NOT: "-enable-tlsdesc"
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 4442b80861b61a..1877550f8c40bb 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -431,6 +431,20 @@ enum TOF {
   /// See 'ELF Handling for Thread-Local Storage' for more details.
   ///SYMBOL_LABEL @TLSLDM
   MO_TLSLDM,
+  /// MO_TLSCALL - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor function for the symbol. Used in both
+  /// the IA32 and x86-64 local dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSCALL
+  MO_TLSCALL,
+  /// MO_TLSDESC - On a symbol operand this indicates that the immediate is
+  /// the index of the TLS descriptor argument for the symbol. When this
+  /// argument is passed to a call getting from index@TLSCALL, the function 
will
+  /// return the offset for the symbol. Used in both the IA32 and x86-64 local
+  /// dynamic TLS access model.
+  /// See 'RFC-TLSDESC-x86' for more details.
+  ///SYMBOL_LABEL @TLSDESC
+  MO_TLSDESC,
   /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
   /// the offset of the GOT entry with the thread-pointer offset for the
   /// symbol. Used in the x86-64 initial exec TLS access model.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp 
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 3395a13545e454..d8e111db1cec42 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -271,6 +271,8 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand 
,
   case X86II::MO_TLSGD: O << "@TLSGD"; break;
   case X86II::MO_TLSLD: O << "@TLSLD"; break;
   case X86II::MO_TLSLDM:O << "@TLSLDM";break;
+  case X86II::MO_TLSDESC:   O << "@TLSDESC";   break;
+  case X86II::MO_TLSCALL:   O << "@TLSCALL";   break;
   case X86II::MO_GOTTPOFF:  O << "@GOTTPOFF";  break;
   case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
   case X86II::MO_TPOFF: O << "@TPOFF"; break;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a86f13135173b0..88314bcf510e9a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18515,17 +18515,17 @@ X86TargetLowering::LowerGlobalAddress(SDValue Op, 
SelectionDAG ) const {
   

[clang] [Headers][X86] Add specific results to comparisons (PR #83316)

2024-02-28 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/83316
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Add Support for X86 TLSDESC Relocations (PR #83136)

2024-02-28 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,165 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=i686-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X32
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown --relocation-model=pic 
-enable-tlsdesc | FileCheck %s --check-prefix=X64
+
+@x = thread_local global i32 0, align 4
+@y = internal thread_local global i32 0, align 4

phoebewang wrote:

Thanks for the info! In that way, we need to define a new pseudo instruction 
that only clobbers the two register.
I'll try to do it in the next reversion.

https://github.com/llvm/llvm-project/pull/83136
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >