[llvm] [clang] [clang-tools-extra] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits

https://github.com/chenzheng1030 commented:

Maybe we can do some perf test between this expansion for set rounding mode and 
the system library's version for `fesetround()`. On AIX, I saw some 
improvements were introduced in the system library's implementation.

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


[llvm] [clang-tools-extra] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits

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


[clang] [clang-tools-extra] [llvm] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits


@@ -8900,6 +8900,82 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {
+uint64_t Mode = CVal->getZExtValue();
+assert(Mode < 4 && "Unsupported rounding mode!");
+unsigned InternalRnd = Mode ^ (~(Mode >> 1) & 1);
+SDNode *SetHi = DAG.getMachineNode(
+(InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(30, Dl, MVT::i32, true), Chain});
+SDNode *SetLo = DAG.getMachineNode(
+(InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(31, Dl, MVT::i32, true), SDValue(SetHi, 0)});
+return SDValue(SetLo, 0);
+  }
+
+  // Use x ^ (~(x >> 1) & 1) to transform LLVM rounding mode to Power format.
+  SDValue One = DAG.getConstant(1, Dl, MVT::i32);
+  SDValue SrcFlag = DAG.getNode(ISD::AND, Dl, MVT::i32, Op.getOperand(1),
+DAG.getConstant(3, Dl, MVT::i32));

chenzheng1030 wrote:

Can we add an assert here too if compiler can infer that the high 29 bits of 
operand 1 is non-zero?

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


[llvm] [clang-tools-extra] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits


@@ -8900,6 +8900,82 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {
+uint64_t Mode = CVal->getZExtValue();
+assert(Mode < 4 && "Unsupported rounding mode!");
+unsigned InternalRnd = Mode ^ (~(Mode >> 1) & 1);
+SDNode *SetHi = DAG.getMachineNode(
+(InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(30, Dl, MVT::i32, true), Chain});
+SDNode *SetLo = DAG.getMachineNode(
+(InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(31, Dl, MVT::i32, true), SDValue(SetHi, 0)});
+return SDValue(SetLo, 0);
+  }
+
+  // Use x ^ (~(x >> 1) & 1) to transform LLVM rounding mode to Power format.
+  SDValue One = DAG.getConstant(1, Dl, MVT::i32);
+  SDValue SrcFlag = DAG.getNode(ISD::AND, Dl, MVT::i32, Op.getOperand(1),
+DAG.getConstant(3, Dl, MVT::i32));
+  SDValue DstFlag = DAG.getNode(
+  ISD::XOR, Dl, MVT::i32, SrcFlag,
+  DAG.getNode(ISD::AND, Dl, MVT::i32,
+  DAG.getNOT(Dl,
+ DAG.getNode(ISD::SRL, Dl, MVT::i32, SrcFlag, One),
+ MVT::i32),
+  One));
+  SDValue MFFS = DAG.getNode(PPCISD::MFFS, Dl, {MVT::f64, MVT::Other}, Chain);
+  Chain = MFFS.getValue(1);
+  SDValue NewFPSCR;
+  if (isTypeLegal(MVT::i64)) {
+// Set the last two bits (rounding mode) of bitcasted FPSCR.
+NewFPSCR = DAG.getNode(
+ISD::OR, Dl, MVT::i64,
+DAG.getNode(ISD::AND, Dl, MVT::i64,
+DAG.getNode(ISD::BITCAST, Dl, MVT::i64, MFFS),
+DAG.getNOT(Dl, DAG.getConstant(3, Dl, MVT::i64), 
MVT::i64)),
+DAG.getNode(ISD::ZERO_EXTEND, Dl, MVT::i64, DstFlag));
+NewFPSCR = DAG.getNode(ISD::BITCAST, Dl, MVT::f64, NewFPSCR);
+  } else {
+// In 32-bit mode, store f64, load and update the lower half.
+int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false);
+SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT);
+Chain = DAG.getStore(Chain, Dl, MFFS, StackSlot, MachinePointerInfo());
+SDValue Addr;
+if (Subtarget.isLittleEndian())
+  Addr = StackSlot;
+else
+  Addr = DAG.getNode(ISD::ADD, Dl, PtrVT, StackSlot,
+ DAG.getConstant(4, Dl, PtrVT));
+SDValue Tmp = DAG.getLoad(MVT::i32, Dl, Chain, Addr, MachinePointerInfo());
+Chain = Tmp.getValue(1);
+
+Tmp = DAG.getNode(
+ISD::OR, Dl, MVT::i32,
+DAG.getNode(ISD::AND, Dl, MVT::i32, Tmp,
+DAG.getNOT(Dl, DAG.getConstant(3, Dl, MVT::i32), 
MVT::i32)),
+DstFlag);

chenzheng1030 wrote:

Can we use a single `rlwimi` to update the lowest 2 bits of `tmp`?

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


[clang-tools-extra] [llvm] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits


@@ -77,4 +77,196 @@ return: ; preds = %entry
ret i32 %retval3
 }
 
-declare i32 @llvm.get.rounding() nounwind
+define void @setrnd_tozero() {
+; PPC32-LABEL: setrnd_tozero:
+; PPC32:   # %bb.0: # %entry
+; PPC32-NEXT:mtfsb0 30
+; PPC32-NEXT:mtfsb1 31
+; PPC32-NEXT:blr
+;
+; PPC64-LABEL: setrnd_tozero:
+; PPC64:   # %bb.0: # %entry
+; PPC64-NEXT:mtfsb0 30
+; PPC64-NEXT:mtfsb1 31
+; PPC64-NEXT:blr
+;
+; PPC64LE-LABEL: setrnd_tozero:
+; PPC64LE:   # %bb.0: # %entry
+; PPC64LE-NEXT:mtfsb0 30
+; PPC64LE-NEXT:mtfsb1 31
+; PPC64LE-NEXT:blr
+;
+; DM-LABEL: setrnd_tozero:
+; DM:   # %bb.0: # %entry
+; DM-NEXT:mtfsb0 30
+; DM-NEXT:mtfsb1 31
+; DM-NEXT:blr
+entry:
+  call void @llvm.set.rounding(i32 0)
+  ret void
+}
+
+define void @setrnd_tonearest_tieeven() {
+; PPC32-LABEL: setrnd_tonearest_tieeven:
+; PPC32:   # %bb.0: # %entry
+; PPC32-NEXT:mtfsb0 30
+; PPC32-NEXT:mtfsb0 31
+; PPC32-NEXT:blr
+;
+; PPC64-LABEL: setrnd_tonearest_tieeven:
+; PPC64:   # %bb.0: # %entry
+; PPC64-NEXT:mtfsb0 30
+; PPC64-NEXT:mtfsb0 31
+; PPC64-NEXT:blr
+;
+; PPC64LE-LABEL: setrnd_tonearest_tieeven:
+; PPC64LE:   # %bb.0: # %entry
+; PPC64LE-NEXT:mtfsb0 30
+; PPC64LE-NEXT:mtfsb0 31
+; PPC64LE-NEXT:blr
+;
+; DM-LABEL: setrnd_tonearest_tieeven:
+; DM:   # %bb.0: # %entry
+; DM-NEXT:mtfsb0 30
+; DM-NEXT:mtfsb0 31
+; DM-NEXT:blr
+entry:
+  call void @llvm.set.rounding(i32 1)
+  ret void
+}
+
+define void @setrnd_toposinf() {
+; PPC32-LABEL: setrnd_toposinf:
+; PPC32:   # %bb.0: # %entry
+; PPC32-NEXT:mtfsb1 30
+; PPC32-NEXT:mtfsb0 31
+; PPC32-NEXT:blr
+;
+; PPC64-LABEL: setrnd_toposinf:
+; PPC64:   # %bb.0: # %entry
+; PPC64-NEXT:mtfsb1 30
+; PPC64-NEXT:mtfsb0 31
+; PPC64-NEXT:blr
+;
+; PPC64LE-LABEL: setrnd_toposinf:
+; PPC64LE:   # %bb.0: # %entry
+; PPC64LE-NEXT:mtfsb1 30
+; PPC64LE-NEXT:mtfsb0 31
+; PPC64LE-NEXT:blr
+;
+; DM-LABEL: setrnd_toposinf:
+; DM:   # %bb.0: # %entry
+; DM-NEXT:mtfsb1 30
+; DM-NEXT:mtfsb0 31
+; DM-NEXT:blr
+entry:
+  call void @llvm.set.rounding(i32 2)
+  ret void
+}
+
+define void @setrnd_toneginf() {
+; PPC32-LABEL: setrnd_toneginf:
+; PPC32:   # %bb.0: # %entry
+; PPC32-NEXT:mtfsb1 30
+; PPC32-NEXT:mtfsb1 31
+; PPC32-NEXT:blr
+;
+; PPC64-LABEL: setrnd_toneginf:
+; PPC64:   # %bb.0: # %entry
+; PPC64-NEXT:mtfsb1 30
+; PPC64-NEXT:mtfsb1 31
+; PPC64-NEXT:blr
+;
+; PPC64LE-LABEL: setrnd_toneginf:
+; PPC64LE:   # %bb.0: # %entry
+; PPC64LE-NEXT:mtfsb1 30
+; PPC64LE-NEXT:mtfsb1 31
+; PPC64LE-NEXT:blr
+;
+; DM-LABEL: setrnd_toneginf:
+; DM:   # %bb.0: # %entry
+; DM-NEXT:mtfsb1 30
+; DM-NEXT:mtfsb1 31
+; DM-NEXT:blr
+entry:
+  call void @llvm.set.rounding(i32 3)
+  ret void
+}
+
+define void @setrnd_var(i32 %x) {
+; PPC32-LABEL: setrnd_var:
+; PPC32:   # %bb.0: # %entry
+; PPC32-NEXT:stwu 1, -16(1)
+; PPC32-NEXT:.cfi_def_cfa_offset 16

chenzheng1030 wrote:

nit: no need for the cfi pseudos.

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


[llvm] [clang-tools-extra] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits


@@ -8900,6 +8900,82 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {
+uint64_t Mode = CVal->getZExtValue();
+assert(Mode < 4 && "Unsupported rounding mode!");
+unsigned InternalRnd = Mode ^ (~(Mode >> 1) & 1);
+SDNode *SetHi = DAG.getMachineNode(
+(InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(30, Dl, MVT::i32, true), Chain});
+SDNode *SetLo = DAG.getMachineNode(
+(InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(31, Dl, MVT::i32, true), SDValue(SetHi, 0)});
+return SDValue(SetLo, 0);
+  }
+
+  // Use x ^ (~(x >> 1) & 1) to transform LLVM rounding mode to Power format.

chenzheng1030 wrote:

The comment does not match below logic. x should be (x & 3)?

And the LLVM mode 4(`4 - to nearest, ties away from zero`) is mapped to Power 
mode 1(`1 - toward zero`)? I think LLVM mode 4 should map to Power mode 0(0- 
Round to Nearest)?

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


[llvm] [clang] [clang-tools-extra] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits


@@ -8900,6 +8900,82 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {

chenzheng1030 wrote:

Can we use `DAG.computeKnownBits()` to handle more cases instead of just the 
constant inputs?

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


[clang-tools-extra] [llvm] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-02 Thread Chen Zheng via cfe-commits


@@ -8900,6 +8900,82 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {
+uint64_t Mode = CVal->getZExtValue();
+assert(Mode < 4 && "Unsupported rounding mode!");
+unsigned InternalRnd = Mode ^ (~(Mode >> 1) & 1);
+SDNode *SetHi = DAG.getMachineNode(
+(InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(30, Dl, MVT::i32, true), Chain});
+SDNode *SetLo = DAG.getMachineNode(
+(InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(31, Dl, MVT::i32, true), SDValue(SetHi, 0)});
+return SDValue(SetLo, 0);
+  }
+
+  // Use x ^ (~(x >> 1) & 1) to transform LLVM rounding mode to Power format.
+  SDValue One = DAG.getConstant(1, Dl, MVT::i32);
+  SDValue SrcFlag = DAG.getNode(ISD::AND, Dl, MVT::i32, Op.getOperand(1),
+DAG.getConstant(3, Dl, MVT::i32));
+  SDValue DstFlag = DAG.getNode(
+  ISD::XOR, Dl, MVT::i32, SrcFlag,
+  DAG.getNode(ISD::AND, Dl, MVT::i32,
+  DAG.getNOT(Dl,
+ DAG.getNode(ISD::SRL, Dl, MVT::i32, SrcFlag, One),
+ MVT::i32),
+  One));
+  SDValue MFFS = DAG.getNode(PPCISD::MFFS, Dl, {MVT::f64, MVT::Other}, Chain);
+  Chain = MFFS.getValue(1);
+  SDValue NewFPSCR;
+  if (isTypeLegal(MVT::i64)) {

chenzheng1030 wrote:

maybe `Subtarget.isPPC64()` is more clear.

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


[clang-tools-extra] [clangd][RFC] Add container field to remote index Refs grpc method (PR #71605)

2024-01-02 Thread kadir çetinkaya via cfe-commits

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

thanks!

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


[clang] [X86] Emit Warnings for frontend options to enable knl/knm. (PR #75580)

2024-01-02 Thread Freddy Ye via cfe-commits

FreddyLeaf wrote:

ping for review
@RKSimon are we aligned on the direction to removing knl/knm supports in the 
end?

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


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2024-01-02 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

hi @5chmidti and @HighCommander4!

it was deliberate to cover `modernize-` checks as they're pretty similar to 
`-wdeprecated` in nature, and they're both explicit, user needs to annotate 
code or opt-in for particular clang-tidy checks.

feedback we received in the past was, these kind of findings are hard to 
surface during builds, due to sheer amount of such findings in an existing code 
base. surfacing these findings on editing/review workflows OTOH is quite 
desirable to decrease the amount of new violations, but it can easily clutter 
any aggregate finding views (e.g. VSCode's problems panel).

Hence we went with emitting these as `Hints` with `Remarks` tags. So that 
editors have some signals to prevent such cluttering, while still displaying 
these findings, especially near the cursor where new code usually lives.

That being said, what exactly is the motivation for this patch? You mentioned 
`inconsistencies`, is it inside clangd or in other places that surface 
clang-tidy findings?

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


[clang] [ARM] arm_acle.h add Coprocessor Instrinsics (PR #75440)

2024-01-02 Thread David Green via cfe-commits

https://github.com/davemgreen commented:

Thanks. This is looking good to me. I just have a few comments about different 
architecture revisions.

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


[clang] [ARM] arm_acle.h add Coprocessor Instrinsics (PR #75440)

2024-01-02 Thread David Green via cfe-commits


@@ -836,6 +837,70 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (Opts.RWPI)
 Builder.defineMacro("__ARM_RWPI", "1");
 
+  // Macros for enabling co-proc intrinsics
+  uint64_t FeatureCoprocBF = 0;
+  switch (ArchKind) {
+  default:
+break;
+  case llvm::ARM::ArchKind::ARMV4:
+// Filter __arm_ldcl and __arm_stcl in acle.h
+FeatureCoprocBF = FEATURE_COPROC_B1;
+break;
+  case llvm::ARM::ArchKind::ARM5T:
+FeatureCoprocBF = isThumb() ? 0 : FEATURE_COPROC_B1;
+break;
+  case llvm::ARM::ArchKind::ARMV5TE:
+  case llvm::ARM::ArchKind::ARMV5TEJ:
+if (!isThumb())
+  FeatureCoprocBF =
+  FEATURE_COPROC_B1 | FEATURE_COPROC_B2 | FEATURE_COPROC_B3;
+break;
+  case llvm::ARM::ArchKind::ARMV6:
+  case llvm::ARM::ArchKind::ARMV6K:
+  case llvm::ARM::ArchKind::ARMV6KZ:
+  case llvm::ARM::ArchKind::ARMV6T2:
+if (!isThumb() || ArchKind == llvm::ARM::ArchKind::ARMV6T2)
+  FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV7A:
+  case llvm::ARM::ArchKind::ARMV7R:
+  case llvm::ARM::ArchKind::ARMV7M:
+  case llvm::ARM::ArchKind::ARMV7S:
+  case llvm::ARM::ArchKind::ARMV7EM:
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+  FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV8A:
+  case llvm::ARM::ArchKind::ARMV8R:
+  case llvm::ARM::ArchKind::ARMV8_1A:
+  case llvm::ARM::ArchKind::ARMV8_2A:
+  case llvm::ARM::ArchKind::ARMV8_3A:
+  case llvm::ARM::ArchKind::ARMV8_4A:
+  case llvm::ARM::ArchKind::ARMV8_5A:
+  case llvm::ARM::ArchKind::ARMV8_6A:
+  case llvm::ARM::ArchKind::ARMV8_7A:
+  case llvm::ARM::ArchKind::ARMV8_8A:
+  case llvm::ARM::ArchKind::ARMV8_9A:
+// Filter __arm_cdp, __arm_ldcl, __arm_stcl in arm_acle.h
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B3;
+break;
+  case llvm::ARM::ArchKind::ARMV8MMainline:

davemgreen wrote:

Add ARMV8_1MMainline too.

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


[clang] [ARM] arm_acle.h add Coprocessor Instrinsics (PR #75440)

2024-01-02 Thread David Green via cfe-commits


@@ -836,6 +837,70 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (Opts.RWPI)
 Builder.defineMacro("__ARM_RWPI", "1");
 
+  // Macros for enabling co-proc intrinsics
+  uint64_t FeatureCoprocBF = 0;
+  switch (ArchKind) {
+  default:
+break;
+  case llvm::ARM::ArchKind::ARMV4:
+// Filter __arm_ldcl and __arm_stcl in acle.h
+FeatureCoprocBF = FEATURE_COPROC_B1;
+break;
+  case llvm::ARM::ArchKind::ARM5T:
+FeatureCoprocBF = isThumb() ? 0 : FEATURE_COPROC_B1;
+break;
+  case llvm::ARM::ArchKind::ARMV5TE:
+  case llvm::ARM::ArchKind::ARMV5TEJ:
+if (!isThumb())
+  FeatureCoprocBF =
+  FEATURE_COPROC_B1 | FEATURE_COPROC_B2 | FEATURE_COPROC_B3;
+break;
+  case llvm::ARM::ArchKind::ARMV6:
+  case llvm::ARM::ArchKind::ARMV6K:
+  case llvm::ARM::ArchKind::ARMV6KZ:
+  case llvm::ARM::ArchKind::ARMV6T2:
+if (!isThumb() || ArchKind == llvm::ARM::ArchKind::ARMV6T2)
+  FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV7A:
+  case llvm::ARM::ArchKind::ARMV7R:
+  case llvm::ARM::ArchKind::ARMV7M:
+  case llvm::ARM::ArchKind::ARMV7S:
+  case llvm::ARM::ArchKind::ARMV7EM:
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+  FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV8A:
+  case llvm::ARM::ArchKind::ARMV8R:
+  case llvm::ARM::ArchKind::ARMV8_1A:
+  case llvm::ARM::ArchKind::ARMV8_2A:
+  case llvm::ARM::ArchKind::ARMV8_3A:
+  case llvm::ARM::ArchKind::ARMV8_4A:
+  case llvm::ARM::ArchKind::ARMV8_5A:
+  case llvm::ARM::ArchKind::ARMV8_6A:
+  case llvm::ARM::ArchKind::ARMV8_7A:
+  case llvm::ARM::ArchKind::ARMV8_8A:
+  case llvm::ARM::ArchKind::ARMV8_9A:
+// Filter __arm_cdp, __arm_ldcl, __arm_stcl in arm_acle.h
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B3;
+break;
+  case llvm::ARM::ArchKind::ARMV8MMainline:
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+  FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV9A:
+  case llvm::ARM::ArchKind::ARMV9_1A:
+  case llvm::ARM::ArchKind::ARMV9_2A:
+  case llvm::ARM::ArchKind::ARMV9_3A:
+  case llvm::ARM::ArchKind::ARMV9_4A:

davemgreen wrote:

There is a ARMV9_5A now too. I think I would expect these to be the same as 
ARMV8.
Is this switch statement exhaustive? Could the default case be made the same as 
ARMV8 so we don't need to extend it every time an architecture is added?

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


[clang] [ARM] arm_acle.h add Coprocessor Instrinsics (PR #75440)

2024-01-02 Thread David Green via cfe-commits


@@ -756,6 +756,58 @@ __arm_st64bv0(void *__addr, data512_t __value) {
   __builtin_arm_mops_memset_tag(__tagged_address, __value, __size)
 #endif
 
+/* Coprocessor Intrinsics */
+#if defined(__ARM_FEATURE_COPROC)
+
+#if (__ARM_FEATURE_COPROC & 0x1)
+
+#if (__ARM_ARCH != 8)

davemgreen wrote:

Could this be < 8?
This doesn't apply to 8-m.main, right? The test looks OK.

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


[clang] [ARM] arm_acle.h add Coprocessor Instrinsics (PR #75440)

2024-01-02 Thread David Green via cfe-commits

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


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2024-01-02 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> You mentioned `inconsistencies`, is it inside clangd or in other places that 
> surface clang-tidy findings?

I understood it as, the appearance of `modernize-*` clang-tidy diagnostics in 
the editor is not consistent with the appearance of other (non-`modernize-*`) 
clang-tidy diagnostics.

(I don't have a strong opinion on this change, just providing clarification.)

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


[lldb] [compiler-rt] [libc] [clang] [libcxx] [clang-tools-extra] [llvm] [mlir] [openmp] [flang] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2024-01-02 Thread via cfe-commits

https://github.com/SunilKuravinakop updated 
https://github.com/llvm/llvm-project/pull/75709

>From fe931d64741f427629407bca3e68a61bec6f2b67 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Sat, 16 Dec 2023 11:43:35 -0600
Subject: [PATCH 1/3] Adding parameter to fail clause (i.e. memory order
 clause) for codegen.

  Changes to be committed:
modified:   clang/lib/CodeGen/CGStmtOpenMP.cpp
---
 clang/lib/CodeGen/CGStmtOpenMP.cpp | 51 +++---
 1 file changed, 47 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 478d6dbf9ca81d..a502db7ac3a5e0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6516,10 +6516,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
  IsPostfixUpdate, IsFailOnly, Loc);
 break;
   }
-  case OMPC_fail: {
-//TODO
-break;
-  }
   default:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
@@ -6527,6 +6523,8 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
 
 void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
   llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic;
+  // Fail Memory Clause Ordering.
+  llvm::AtomicOrdering FO = llvm::AtomicOrdering::Monotonic;
   bool MemOrderingSpecified = false;
   if (S.getSingleClause()) {
 AO = llvm::AtomicOrdering::SequentiallyConsistent;
@@ -6580,6 +6578,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();
+if (fC) {
+  OpenMPClauseKind fP = fC->getFailParameter();
+  if (fP == llvm::omp::OMPC_relaxed)
+FO = llvm::AtomicOrdering::Monotonic;
+  else if (fP == llvm::omp::OMPC_acquire)
+FO = llvm::AtomicOrdering::Acquire;
+  else if (fP == llvm::omp::OMPC_seq_cst)
+FO = llvm::AtomicOrdering::SequentiallyConsistent;
+}
+
+// Logic for 2 memory order clauses in the atomic directive.
+// e.g. #pragma omp atomic compare capture release fail(seq_cst)
+//  if(x > e) { x = j; } else { k = x; }
+// To provide the Memory Order clause in atomic directive
+// there are 2 instructions in LLVM IR atomicrmw & cmpxchgl.
+// 1) atomicrmw can use only 1 memory order clause and can contain the
+//operator in if condition.
+// 2) cmpxchgl can use 2 memory order clauses : Success memory order clause
+//& fail parameter memory clause. However, cmpxchgl uses only equality
+//operator.
+// We need to change atomicrmw to contain the fail parameter clause or add
+// a new instruction in LLVM IR. Changes in LLVM IR need to be done
+// seperately and at present we will use the logic of using the more strict
+// memory order clause of success or fail memory order clauses for the
+// atomicrmw. The following logic takes care of this change in the memory
+// order clause.
+if (AO == llvm::AtomicOrdering::Monotonic)
+  AO = FO;
+else if (FO == llvm::AtomicOrdering::Monotonic)
+  AO = AO;
+else if (AO == llvm::AtomicOrdering::SequentiallyConsistent ||
+ FO == llvm::AtomicOrdering::SequentiallyConsistent)
+  AO = llvm::AtomicOrdering::SequentiallyConsistent;
+else if (AO == llvm::AtomicOrdering::Acquire)
+  AO = llvm::AtomicOrdering::Acquire;
+else if (AO == llvm::AtomicOrdering::Release)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+else if (AO == llvm::AtomicOrdering::AcquireRelease)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+  }
+
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),

>From 9cc33631c89c4fd4dce8a274fed700febe5dfa90 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Tue, 19 Dec 2023 23:49:03 -0600
Subject: [PATCH 2/3] 1) Since the{if(x == e) {x = v;} else {d = x;}}
 results in generation of cmpxchg in the LLVM IR, the memory order clause in
 "fail" clause is now being added.In case of other operators ">" & "<"
 e.g.dx = dx > de ? de : dx; result in atomicrmw in the LLVM IR.
 "atomicrmw" can have only one memory order clause. Currently, the memory
 order clause is ignored. 2) Test cases for codegen 3) In SemaOpenMP.cpp,
 addedEncounteredAtomicKinds.contains(OMPC_compare) instead of AtomicKind
 == OMPC_compare. This was to accomodate where AtomicKind is OMPC_capture.

  Changes to be committed:
modified:   clang/lib/CodeGen/CGStmtOpenMP.cpp
modified:   clang/lib/Sema/SemaOpenMP.cpp
modified:   clang/test/OpenMP/atomic_compare_codegen.cpp
modified:   llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  

[clang] 5055eee - [Clang][AArch64] Add missing SME functions to header file. (#75791)

2024-01-02 Thread via cfe-commits

Author: Sander de Smalen
Date: 2024-01-02T09:43:30Z
New Revision: 5055eeea5205d938320590236eeb782c92e40911

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

LOG: [Clang][AArch64] Add missing SME functions to header file. (#75791)

This includes:
* __arm_in_streaming_mode()
* __arm_has_sme()
* __arm_za_disable()
* __svundef_za()

Added: 
clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c

Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_qcvtn.c
clang/utils/TableGen/SveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index 82a1ba3c82ad35..31ec84143f65c1 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -68,6 +68,9 @@ TARGET_BUILTIN(__builtin_arm_ldg, "v*v*", "t", "mte")
 TARGET_BUILTIN(__builtin_arm_stg, "vv*", "t", "mte")
 TARGET_BUILTIN(__builtin_arm_subp, "Uiv*v*", "t", "mte")
 
+// SME state function
+BUILTIN(__builtin_arm_get_sme_state, "vULi*ULi*", "n")
+
 // Memory Operations
 TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5081062da2862e..f71dbf1729a1d6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10430,6 +10430,26 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, HintID));
   }
 
+  if (BuiltinID == clang::AArch64::BI__builtin_arm_get_sme_state) {
+// Create call to __arm_sme_state and store the results to the two 
pointers.
+CallInst *CI = EmitRuntimeCall(CGM.CreateRuntimeFunction(
+llvm::FunctionType::get(StructType::get(CGM.Int64Ty, CGM.Int64Ty), {},
+false),
+"__arm_sme_state"));
+auto Attrs =
+AttributeList()
+.addFnAttribute(getLLVMContext(), "aarch64_pstate_sm_compatible")
+.addFnAttribute(getLLVMContext(), "aarch64_pstate_za_preserved");
+CI->setAttributes(Attrs);
+CI->setCallingConv(
+llvm::CallingConv::
+AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2);
+Builder.CreateStore(Builder.CreateExtractValue(CI, 0),
+EmitPointerWithAlignment(E->getArg(0)));
+return Builder.CreateStore(Builder.CreateExtractValue(CI, 1),
+   EmitPointerWithAlignment(E->getArg(1)));
+  }
+
   if (BuiltinID == clang::AArch64::BI__builtin_arm_rbit) {
 assert((getContext().getTypeSize(E->getType()) == 32) &&
"rbit of unusual size!");

diff  --git a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c 
b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c
new file mode 100644
index 00..282819c8ca3501
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c
@@ -0,0 +1,72 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -S -O1 
-Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -S -O1 
-Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -S 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+// CHECK-LABEL: @test_in_streaming_mode(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call aarch64_sme_preservemost_from_x2 { 
i64, i64 } @__arm_sme_state() #[[ATTR3:[0-9]+]]
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i64, i64 } [[TMP0]], 0
+// CHECK-NEXT:[[AND_I:%.*]] = and i64 [[TMP1]], 1
+// CHECK-NEXT:[[TOBOOL_I:%.*]] = icmp ne i64 [[AND_I]], 0
+// CHECK-NEXT:ret i1 [[TOBOOL_I]]
+//
+// CPP-CHECK-LABEL: @_Z22test_in_streaming_modev(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call 
aarch64_sme_preservemost_from_x2 { i64, i64 } @__arm_sme_state() 
#[[ATTR3:[0-9]+]]
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i64, i64 } [[TMP0]], 0
+// CPP-CHECK-NEXT:[[AND_I:%.*]] = and i64 [[TMP1]], 1
+// CPP-CHECK-NEXT:[[TOBOOL_I:%.*]] = icmp ne i64 [[AND_I]], 0
+// CPP-CHECK-NEXT:ret i1 [[TOBOOL_I]]
+//
+bool test_in_streaming_mode(void) __arm_streaming_compatible {
+  return __arm_in_streaming_mode();
+}
+
+// CHECK-LABEL: @test_za_disable(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @__arm_za_disable() #[[ATTR4:[0-9]+]]
+// CHECK-NEXT:ret void

[clang] [Clang][AArch64] Add missing SME functions to header file. (PR #75791)

2024-01-02 Thread Sander de Smalen via cfe-commits

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


[lld] [clang] [libcxx] [llvm] [mlir] [flang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-02 Thread via cfe-commits

DonatNagyE wrote:

Thanks for cleaning this up!

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


[clang] [analyzer] Add std::any checker (PR #76580)

2024-01-02 Thread via cfe-commits


@@ -87,6 +85,28 @@ bool isStdVariant(const Type *Type) {
   return isStdType(Type, llvm::StringLiteral("variant"));
 }
 
+bool isStdAny(const Type *Type) {
+  return isStdType(Type, llvm::StringLiteral("any"));
+}
+
+bool isVowel(char a) {
+  switch (a) {
+  case 'a':
+  case 'e':
+  case 'i':
+  case 'o':
+  case 'u':
+return true;
+  default:
+return false;
+  }
+}
+
+llvm::StringRef indefiniteArticleBasedOnVowel(char a) {
+  if (isVowel(a))
+return "an";
+  return "a";
+}

DonatNagyE wrote:

I'm bikeshedding this in the other direction, because I think that the length / 
verbosity of the messages is an important factor, so we shouldn't insert 
meaningless words just to simplify the code. We do not need absolutely perfect 
grammar, if we're attaching an article to an arbitrary variable name, it's OK 
if there are rare situations when it doesn't fit the pronunciation.

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


[clang] [analyzer] Add std::any checker (PR #76580)

2024-01-02 Thread via cfe-commits


@@ -0,0 +1,170 @@
+// RUN: %clang %s -std=c++17 -Xclang -verify --analyze \
+// RUN:   -Xclang -analyzer-checker=core \
+// RUN:   -Xclang -analyzer-checker=debug.ExprInspection \
+// RUN:   -Xclang -analyzer-checker=core,alpha.core.StdAny
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void clang_analyzer_warnIfReached();
+void clang_analyzer_eval(int);
+
+
+class DummyClass{
+  public:
+  void foo(){};
+};
+
+void nonInlined(std::any &a);
+void nonInlinedConst(const std::any & a);
+
+void inlined(std::any &a) {
+  a = 5;
+}
+
+using any_t = std::any;
+using any_tt = any_t;
+
+
+////
+// std::any_cast
+////
+void objectHeld() {
+  std::any a = DummyClass{};
+  DummyClass d = std::any_cast(a);
+  d.foo();
+}
+
+void formVariable() {
+  std::any a = 5;
+  int b = std::any_cast(a);
+  char c = std::any_cast(a); // expected-warning {{std::any 'a' held an 
'int', not a 'char'}}
+  (void)b;
+  (void)c;
+}
+
+void pointerHeld() {
+  int i = 5;
+  std::any a = &i;
+  int* x = std::any_cast(a);
+  char c = std::any_cast(a); // expected-warning {{std::any 'a' held an 
'int *', not a 'char'}}

DonatNagyE wrote:

(Yup, then in this situation either 'a' or 'an' would be valid output.)

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


[clang] [clang][Interp] Add inline descriptor to global variables (PR #72892)

2024-01-02 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= ,
Timm =?utf-8?q?B=C3=A4der?= 
Message-ID:
In-Reply-To: 


tbaederr wrote:

Ping

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


[clang] [analyzer] Add std::any checker (PR #76580)

2024-01-02 Thread Gábor Spaits via cfe-commits


@@ -87,6 +85,28 @@ bool isStdVariant(const Type *Type) {
   return isStdType(Type, llvm::StringLiteral("variant"));
 }
 
+bool isStdAny(const Type *Type) {
+  return isStdType(Type, llvm::StringLiteral("any"));
+}
+
+bool isVowel(char a) {
+  switch (a) {
+  case 'a':
+  case 'e':
+  case 'i':
+  case 'o':
+  case 'u':
+return true;
+  default:
+return false;
+  }
+}
+
+llvm::StringRef indefiniteArticleBasedOnVowel(char a) {
+  if (isVowel(a))
+return "an";
+  return "a";
+}

spaits wrote:

I think a good solution would be just to use the current text, but instead of 
deciding the indefinite article dynamically, we could just use `a(n)`. I think 
with this solution we would have correct grammar and a short warning. What do 
you think?

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


[clang] [analyzer] Add std::any checker (PR #76580)

2024-01-02 Thread via cfe-commits


@@ -87,6 +85,28 @@ bool isStdVariant(const Type *Type) {
   return isStdType(Type, llvm::StringLiteral("variant"));
 }
 
+bool isStdAny(const Type *Type) {
+  return isStdType(Type, llvm::StringLiteral("any"));
+}
+
+bool isVowel(char a) {
+  switch (a) {
+  case 'a':
+  case 'e':
+  case 'i':
+  case 'o':
+  case 'u':
+return true;
+  default:
+return false;
+  }
+}
+
+llvm::StringRef indefiniteArticleBasedOnVowel(char a) {
+  if (isVowel(a))
+return "an";
+  return "a";
+}

DonatNagyE wrote:

I think parenthesized `a(n)` in 100% of the messages is uglier than incorrectly 
applied `a` or `an` in <1% of the messages (in average English text, 1% of the 
words start with `u` [1] -- this may be different for type names, but the order 
of magnitude should be similar).

However, this is just bikesheddig, so I won't block any of the three solutions 
(decision based on `isVowel()`, using `a(n)` and using filler words to dodge 
the issue).

[1] https://www.johndcook.com/blog/2021/08/16/initial-letter-frequency/

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


[clang] [openmp] [flang] [lldb] [libc] [mlir] [llvm] [AMDGPU] GFX12 global_atomic_ordered_add_b64 instruction and intrinsic (PR #76149)

2024-01-02 Thread Jay Foad via cfe-commits

jayfoad wrote:

Ping!

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


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-02 Thread Matthew Devereau via cfe-commits

https://github.com/MDevereau created 
https://github.com/llvm/llvm-project/pull/76711

The ACLE defines these builtins as svmla[_single]_za32[_f32]_vg1x2, which means 
the SVE_ACLE_FUNC macro should test the overloaded forms as

SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x2)

https://github.com/ARM-software/acle/blob/b88cbf7e9c104100bb5016c848763171494dee44/main/acle.md?plain=1#L10170-L10205

>From 908da224bd01e4758392a98ba2191185d7296c6a Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Tue, 2 Jan 2024 11:36:33 +
Subject: [PATCH] [AArch64][SME2] Fix SME2 mla/mls tests

The ACLE defines these builtins as svmla[_single]_za32[_f32]_vg1x2,
which means the SVE_ACLE_FUNC macro should test the overloaded forms as

SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x2)

https://github.com/ARM-software/acle/blob/b88cbf7e9c104100bb5016c848763171494dee44/main/acle.md?plain=1#L10170-L10205
---
 .../test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c  | 8 
 .../test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c  | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
index f52edd9888daa9..2679f9cc8dfd0c 100644
--- a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
@@ -86,7 +86,7 @@ void test_svmla4_f32(uint32_t slice_base, svfloat32x4_t zn, 
svfloat32x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single2_f32(uint32_t slice_base, svfloat32x2_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za32,,_f32,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmla_single4_f32(
@@ -108,7 +108,7 @@ void test_svmla_single2_f32(uint32_t slice_base, 
svfloat32x2_t zn, svfloat32_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single4_f32(uint32_t slice_base, svfloat32x4_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za32,,_f32,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x4)(slice_base, zn, zm);
 }
 
 //
@@ -224,7 +224,7 @@ void test_svmla4_f64(uint32_t slice_base, svfloat64x4_t zn, 
svfloat64x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single2_f64(uint32_t slice_base, svfloat64x2_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za64,,_f64,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za64,_f64,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmla_single4_f64(
@@ -246,7 +246,7 @@ void test_svmla_single2_f64(uint32_t slice_base, 
svfloat64x2_t zn, svfloat64_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single4_f64(uint32_t slice_base, svfloat64x4_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za64,,_f64,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za64,_f64,_vg1x4)(slice_base, zn, zm);
 }
 
 //
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
index 6830a399e91d64..bb4cbbd5308c06 100644
--- a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
@@ -86,7 +86,7 @@ void test_svmls4_f32(uint32_t slice_base, svfloat32x4_t zn, 
svfloat32x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single2_f32(uint32_t slice_base, svfloat32x2_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za32,,_f32,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za32,_f32,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmls_single4_f32(
@@ -108,7 +108,7 @@ void test_svmls_single2_f32(uint32_t slice_base, 
svfloat32x2_t zn, svfloat32_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single4_f32(uint32_t slice_base, svfloat32x4_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za32,,_f32,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za32,_f32,_vg1x4)(slice_base, zn, zm);
 }
 
 //
@@ -224,7 +224,7 @@ void test_svmls4_f64(uint32_t slice_base, svfloat64x4_t zn, 
svfloat64x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single2_f64(uint32_t slice_base, svfloat64x2_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za64,,_f64,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za64,_f64,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmls_single4_f64(
@@ -246,7 +246,7 @@ void test_svmls_single2_f64(uint32_t slice_base, 
svfloat64x2_t zn, svfloat64_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single4_f64(uint32_t slice_base, svfloat64x4_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za

[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matthew Devereau (MDevereau)


Changes

The ACLE defines these builtins as svmla[_single]_za32[_f32]_vg1x2, which means 
the SVE_ACLE_FUNC macro should test the overloaded forms as

SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x2)

https://github.com/ARM-software/acle/blob/b88cbf7e9c104100bb5016c848763171494dee44/main/acle.md?plain=1#L10170-L10205

---
Full diff: https://github.com/llvm/llvm-project/pull/76711.diff


2 Files Affected:

- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c (+4-4) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c (+4-4) 


``diff
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
index f52edd9888daa9..2679f9cc8dfd0c 100644
--- a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
@@ -86,7 +86,7 @@ void test_svmla4_f32(uint32_t slice_base, svfloat32x4_t zn, 
svfloat32x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single2_f32(uint32_t slice_base, svfloat32x2_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za32,,_f32,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmla_single4_f32(
@@ -108,7 +108,7 @@ void test_svmla_single2_f32(uint32_t slice_base, 
svfloat32x2_t zn, svfloat32_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single4_f32(uint32_t slice_base, svfloat32x4_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za32,,_f32,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x4)(slice_base, zn, zm);
 }
 
 //
@@ -224,7 +224,7 @@ void test_svmla4_f64(uint32_t slice_base, svfloat64x4_t zn, 
svfloat64x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single2_f64(uint32_t slice_base, svfloat64x2_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za64,,_f64,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za64,_f64,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmla_single4_f64(
@@ -246,7 +246,7 @@ void test_svmla_single2_f64(uint32_t slice_base, 
svfloat64x2_t zn, svfloat64_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single4_f64(uint32_t slice_base, svfloat64x4_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za64,,_f64,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za64,_f64,_vg1x4)(slice_base, zn, zm);
 }
 
 //
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
index 6830a399e91d64..bb4cbbd5308c06 100644
--- a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
@@ -86,7 +86,7 @@ void test_svmls4_f32(uint32_t slice_base, svfloat32x4_t zn, 
svfloat32x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single2_f32(uint32_t slice_base, svfloat32x2_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za32,,_f32,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za32,_f32,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmls_single4_f32(
@@ -108,7 +108,7 @@ void test_svmls_single2_f32(uint32_t slice_base, 
svfloat32x2_t zn, svfloat32_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single4_f32(uint32_t slice_base, svfloat32x4_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za32,,_f32,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za32,_f32,_vg1x4)(slice_base, zn, zm);
 }
 
 //
@@ -224,7 +224,7 @@ void test_svmls4_f64(uint32_t slice_base, svfloat64x4_t zn, 
svfloat64x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single2_f64(uint32_t slice_base, svfloat64x2_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za64,,_f64,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za64,_f64,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmls_single4_f64(
@@ -246,7 +246,7 @@ void test_svmls_single2_f64(uint32_t slice_base, 
svfloat64x2_t zn, svfloat64_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single4_f64(uint32_t slice_base, svfloat64x4_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za64,,_f64,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za64,_f64,_vg1x4)(slice_base, zn, zm);
 }
 
 //

``




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


[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-02 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

Hello @Endilll Can I work on some other issues also till this PR get reviewed?
Thank you

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


[clang] [AArch64][SME2] Add __arm_streaming_compatible attribute to CLAMP bui… (PR #76712)

2024-01-02 Thread Dinar Temirbulatov via cfe-commits

https://github.com/dtemirbulatov created 
https://github.com/llvm/llvm-project/pull/76712

…ltins.

Patch-by: Caroline Concatto 

>From d21c30bb3d655ab66e1ecb2f9b26dc441ca8928a Mon Sep 17 00:00:00 2001
From: Dinar Temirbulatov 
Date: Tue, 2 Jan 2024 12:01:17 +
Subject: [PATCH] [AArch64][SME2] Add __arm_streaming_compatible attribute to
 CLAMP builtins.

Patch-by: Caroline Concatto 
---
 clang/include/clang/Basic/arm_sve.td|  4 ++--
 .../acle_sve2p1_fclamp.c| 14 ++
 .../acle_sve2p1_sclamp.c| 17 -
 .../acle_sve2p1_uclamp.c| 17 -
 4 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 91f62c4c76339d..9b88be633aa55c 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -2052,8 +2052,8 @@ def SVDOT_LANE_X2_F : SInst<"svdot_lane[_{d}_{2}_{3}]", 
"ddhhi", "f",  MergeNone
 }
 
 let TargetGuard = "sve2p1|sme" in {
-def SVSCLAMP : SInst<"svclamp[_{d}]", "", "csil", MergeNone, 
"aarch64_sve_sclamp", [], []>;
-def SVUCLAMP : SInst<"svclamp[_{d}]", "", "UcUsUiUl", MergeNone, 
"aarch64_sve_uclamp", [], []>;
+def SVSCLAMP : SInst<"svclamp[_{d}]", "", "csil", MergeNone, 
"aarch64_sve_sclamp", [IsStreamingCompatible], []>;
+def SVUCLAMP : SInst<"svclamp[_{d}]", "", "UcUsUiUl", MergeNone, 
"aarch64_sve_uclamp", [IsStreamingCompatible], []>;
 
 defm SVREVD : SInstZPZ<"svrevd", "csilUcUsUiUlbhfd", "aarch64_sve_revd">;
 }
diff --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
index 5d8c5b7b8a18c6..fd397292d1f2b6 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
@@ -10,7 +10,7 @@
 // RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 \
 // RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
-// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve \
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -DTEST_SME2 \
 // RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
 
 #include 
@@ -22,6 +22,12 @@
 #define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
 #endif
 
+#ifndef TEST_SME2
+#define ATTR
+#else
+#define ATTR __arm_streaming_compatible
+#endif
+
 // CHECK-LABEL: @test_svclamp_f16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv8f16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
@@ -32,7 +38,7 @@
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv8f16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat16_t test_svclamp_f16(svfloat16_t op1, svfloat16_t op2, svfloat16_t 
op3) {
+svfloat16_t test_svclamp_f16(svfloat16_t op1, svfloat16_t op2, svfloat16_t 
op3) ATTR {
   return SVE_ACLE_FUNC(svclamp, _f16, , )(op1, op2, op3);
 }
 
@@ -46,7 +52,7 @@ svfloat16_t test_svclamp_f16(svfloat16_t op1, svfloat16_t 
op2, svfloat16_t op3)
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv4f32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat32_t test_svclamp_f32(svfloat32_t op1, svfloat32_t op2, svfloat32_t 
op3) {
+svfloat32_t test_svclamp_f32(svfloat32_t op1, svfloat32_t op2, svfloat32_t 
op3) ATTR {
   return SVE_ACLE_FUNC(svclamp, _f32, , )(op1, op2, op3);
 }
 
@@ -60,7 +66,7 @@ svfloat32_t test_svclamp_f32(svfloat32_t op1, svfloat32_t 
op2, svfloat32_t op3)
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv2f64( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat64_t test_svclamp_f64(svfloat64_t op1, svfloat64_t op2, svfloat64_t 
op3) {
+svfloat64_t test_svclamp_f64(svfloat64_t op1, svfloat64_t op2, svfloat64_t 
op3) ATTR {
   return SVE_ACLE_FUNC(svclamp, _f64, , )(op1, op2, op3);
 }
 
diff --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
index 8c63a7455c79f4..54c4c1c1679d7a 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
@@ -10,6 +10,8 @@
 // RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-f

[clang] [AArch64][SME2] Add __arm_streaming_compatible attribute to CLAMP bui… (PR #76712)

2024-01-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Dinar Temirbulatov (dtemirbulatov)


Changes

…ltins.

Patch-by: Caroline Concatto 

---
Full diff: https://github.com/llvm/llvm-project/pull/76712.diff


4 Files Affected:

- (modified) clang/include/clang/Basic/arm_sve.td (+2-2) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c 
(+10-4) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c 
(+12-5) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c 
(+12-5) 


``diff
diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 91f62c4c76339d..9b88be633aa55c 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -2052,8 +2052,8 @@ def SVDOT_LANE_X2_F : SInst<"svdot_lane[_{d}_{2}_{3}]", 
"ddhhi", "f",  MergeNone
 }
 
 let TargetGuard = "sve2p1|sme" in {
-def SVSCLAMP : SInst<"svclamp[_{d}]", "", "csil", MergeNone, 
"aarch64_sve_sclamp", [], []>;
-def SVUCLAMP : SInst<"svclamp[_{d}]", "", "UcUsUiUl", MergeNone, 
"aarch64_sve_uclamp", [], []>;
+def SVSCLAMP : SInst<"svclamp[_{d}]", "", "csil", MergeNone, 
"aarch64_sve_sclamp", [IsStreamingCompatible], []>;
+def SVUCLAMP : SInst<"svclamp[_{d}]", "", "UcUsUiUl", MergeNone, 
"aarch64_sve_uclamp", [IsStreamingCompatible], []>;
 
 defm SVREVD : SInstZPZ<"svrevd", "csilUcUsUiUlbhfd", "aarch64_sve_revd">;
 }
diff --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
index 5d8c5b7b8a18c6..fd397292d1f2b6 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
@@ -10,7 +10,7 @@
 // RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 \
 // RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
-// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve \
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -DTEST_SME2 \
 // RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
 
 #include 
@@ -22,6 +22,12 @@
 #define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
 #endif
 
+#ifndef TEST_SME2
+#define ATTR
+#else
+#define ATTR __arm_streaming_compatible
+#endif
+
 // CHECK-LABEL: @test_svclamp_f16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv8f16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
@@ -32,7 +38,7 @@
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv8f16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat16_t test_svclamp_f16(svfloat16_t op1, svfloat16_t op2, svfloat16_t 
op3) {
+svfloat16_t test_svclamp_f16(svfloat16_t op1, svfloat16_t op2, svfloat16_t 
op3) ATTR {
   return SVE_ACLE_FUNC(svclamp, _f16, , )(op1, op2, op3);
 }
 
@@ -46,7 +52,7 @@ svfloat16_t test_svclamp_f16(svfloat16_t op1, svfloat16_t 
op2, svfloat16_t op3)
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv4f32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat32_t test_svclamp_f32(svfloat32_t op1, svfloat32_t op2, svfloat32_t 
op3) {
+svfloat32_t test_svclamp_f32(svfloat32_t op1, svfloat32_t op2, svfloat32_t 
op3) ATTR {
   return SVE_ACLE_FUNC(svclamp, _f32, , )(op1, op2, op3);
 }
 
@@ -60,7 +66,7 @@ svfloat32_t test_svclamp_f32(svfloat32_t op1, svfloat32_t 
op2, svfloat32_t op3)
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv2f64( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat64_t test_svclamp_f64(svfloat64_t op1, svfloat64_t op2, svfloat64_t 
op3) {
+svfloat64_t test_svclamp_f64(svfloat64_t op1, svfloat64_t op2, svfloat64_t 
op3) ATTR {
   return SVE_ACLE_FUNC(svclamp, _f64, , )(op1, op2, op3);
 }
 
diff --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
index 8c63a7455c79f4..54c4c1c1679d7a 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
@@ -10,6 +10,8 @@
 // RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 \
 // RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -fclang-abi-compat=

[libc] [clang] [lldb] [llvm] [openmp] [mlir] [flang] [AMDGPU] GFX12 global_atomic_ordered_add_b64 instruction and intrinsic (PR #76149)

2024-01-02 Thread Matt Arsenault via cfe-commits

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


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


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-01-02 Thread Alexey Bataev via cfe-commits


@@ -6106,6 +6106,8 @@ class OMPTeamsGenericLoopDirective final : public 
OMPLoopDirective {
 class OMPTargetTeamsGenericLoopDirective final : public OMPLoopDirective {
   friend class ASTStmtReader;
   friend class OMPExecutableDirective;
+  /// true if loop directive's associated loop can be a parallel for.
+  bool CanBeParallelFor = false;

alexey-bataev wrote:

Do you still need to this new field, taking into account that it does not 
affect sema anymore, only codegen? You don't need to store this flag, instead 
you can call teamsLoopCanBeParallelFor() directly in codegen

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


[openmp] [clang] [libc] [mlir] [lldb] [flang] [llvm] [AMDGPU] GFX12 global_atomic_ordered_add_b64 instruction and intrinsic (PR #76149)

2024-01-02 Thread Jay Foad via cfe-commits

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


[clang] [Sema] Fix crash on invalid code with parenthesized aggregate initialization (PR #76232)

2024-01-02 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

Thanks for reverting it and sorry for the trouble, I will make sure to check 
libc++ tests before a reland.
Clang does report less errors now, but that's expected. The errors were 
spurious, caused by Clang trying to initialize an "invalid" class (more details 
below in case you're interested).

Failed `static_assert` is what made the class invalid in the first place and 
Clang fails parenthesized initialization of such classes early now. We should 
not do parenthesized initialization here as it should only be applied to 
aggregates, this class has constructors and is not an aggregate in the first 
place. The only reason we attempted aggregate init is because invalid classes 
are left internally in inconsistent states sometimes (there are many reasons 
why class is invalid). So less errors is better here, they were only adding 
noise and confusion in the first place.

I will reland the commit with updated libc++ tests. The commit did not change 
the set of correct programs that we compile, it's just showing less spurious 
errors.

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


[clang] 687c51a - [clang][Interp][NFC] Remove unused using alias

2024-01-02 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-01-02T14:18:29+01:00
New Revision: 687c51a3972af17b3f225e692e79fd898a1b6f95

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

LOG: [clang][Interp][NFC] Remove unused using alias

Added: 


Modified: 
clang/lib/AST/Interp/Interp.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index a240d74d63425e..828d4ea35526d6 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -37,7 +37,6 @@
 namespace clang {
 namespace interp {
 
-using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 
 /// Convert a value to an APValue.



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


[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2024-01-02 Thread Fangrui Song via cfe-commits


@@ -214,6 +214,14 @@
 // RUN: -mnan=legacy -mnan=2008 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NAN2008 %s
 // CHECK-NAN2008: "-target-feature" "+nan2008"
+// CHECK-NAN2008: "-target-feature" "+abs2008"
+//
+// -mnan=2008 -mabs=legacy
+// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \

MaskRay wrote:

`--target=`

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


[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2024-01-02 Thread Fangrui Song via cfe-commits

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


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


[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2024-01-02 Thread Fangrui Song via cfe-commits

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


[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2024-01-02 Thread Fangrui Song via cfe-commits


@@ -214,6 +214,14 @@
 // RUN: -mnan=legacy -mnan=2008 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NAN2008 %s
 // CHECK-NAN2008: "-target-feature" "+nan2008"
+// CHECK-NAN2008: "-target-feature" "+abs2008"

MaskRay wrote:

If abs2008 is adjacent, just place it after "+nan2008" so that it's clear there 
is no other option in between.

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


[clang-tools-extra] [clang] [llvm] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-02 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/75456

>From 0e190f131862dd8f4b07891c3ee712a0a163f936 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Thu, 14 Dec 2023 01:33:17 -0800
Subject: [PATCH] [clang] Accept recursive non-dependent calls to functions
 with deduced return type

Treat such calls as dependent since it is much easier to implement.

Fixes https://github.com/llvm/llvm-project/issues/71015
---
 clang/docs/ReleaseNotes.rst   |  3 ++
 clang/lib/AST/ComputeDependence.cpp   |  2 ++
 clang/lib/Sema/SemaOverload.cpp   | 18 ++
 .../SemaCXX/deduced-return-type-cxx14.cpp | 33 +++
 4 files changed, 56 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 05d59d0da264f3..9ffc7500414981 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -688,6 +688,9 @@ Bug Fixes in This Version
 - Fixed false positive error emitted when templated alias inside a class
   used private members of the same class.
   Fixes (`#41693 `_)
+- Clang now accepts recursive non-dependent calls to functions with deduced 
return
+  type.
+  Fixes (`#71015 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index 097753fd3267b5..584b58473294be 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -603,6 +603,8 @@ ExprDependence clang::computeDependence(PredefinedExpr *E) {
 ExprDependence clang::computeDependence(CallExpr *E,
 llvm::ArrayRef PreArgs) {
   auto D = E->getCallee()->getDependence();
+  if (E->getType()->isDependentType())
+D |= ExprDependence::Type;
   for (auto *A : llvm::ArrayRef(E->getArgs(), E->getNumArgs())) {
 if (A)
   D |= A->getDependence();
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5026e1d603e5ee..9fb767101e1eb7 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -13994,6 +13994,24 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, 
Expr *Fn,
   OverloadCandidateSet::iterator Best;
   OverloadingResult OverloadResult =
   CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best);
+  FunctionDecl *FDecl = Best->Function;
+
+  // Model the case with a call to a templated function whose definition
+  // encloses the call and whose return type contains a placeholder type as if
+  // the UnresolvedLookupExpr was type-dependent.
+  if (OverloadResult == OR_Success && FDecl &&
+  FDecl->isTemplateInstantiation() &&
+  FDecl->getReturnType()->isUndeducedType()) {
+if (auto TP = FDecl->getTemplateInstantiationPattern(false)) {
+  if (TP->willHaveBody()) {
+CallExpr *CE =
+CallExpr::Create(Context, Fn, Args, Context.DependentTy, 
VK_PRValue,
+ RParenLoc, CurFPFeatureOverrides());
+result = CE;
+return result;
+  }
+}
+  }
 
   return FinishOverloadedCallExpr(*this, S, Fn, ULE, LParenLoc, Args, 
RParenLoc,
   ExecConfig, &CandidateSet, &Best,
diff --git a/clang/test/SemaCXX/deduced-return-type-cxx14.cpp 
b/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
index 6344d1df3fbaeb..1da597499d34f5 100644
--- a/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
+++ b/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
@@ -640,3 +640,36 @@ namespace PR46637 {
   template struct Y { T x; };
   Y auto> y; // expected-error {{'auto' not allowed in template 
argument}}
 }
+
+namespace GH71015 {
+
+// Check that there is no error in case a templated function is recursive and
+// has a placeholder return type.
+struct Node {
+  int value;
+  Node* left;
+  Node* right;
+};
+
+bool parse(const char*);
+Node* parsePrimaryExpr();
+
+auto parseMulExpr(auto node) { // cxx14-error {{'auto' not allowed in function 
prototype}}
+  if (node == nullptr) node = parsePrimaryExpr();
+  if (!parse("*")) return node;
+  return parseMulExpr(new Node{.left = node, .right = parsePrimaryExpr()});
+}
+
+template 
+auto parseMulExpr2(T node) {
+  if (node == nullptr) node = parsePrimaryExpr();
+  if (!parse("*")) return node;
+  return parseMulExpr2(new Node{.left = node, .right = parsePrimaryExpr()});
+}
+
+auto f(auto x) { // cxx14-error {{'auto' not allowed in function prototype}}
+  if (x == 0) return 0;
+  return f(1) + 1;
+}
+
+}

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


[clang] [clang-format] Add common attribute macros to Google style (PR #76239)

2024-01-02 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

This change did not aim to change the behavior, it's quite the opposite, I 
tried to guide `clang-format` parsing to recognize attribute and format the 
code in the way we always intended it to.

If there is a way to do that without adding the macro names to the 
configuration explicitly, it would definitely be preferable for us too. I just 
went with what I thought to be the easiest path as I don't really expect people 
to use the macro names for other purposes. Definitely not `ABSL_GUARDED_BY`, 
although I can see why `GUARDED_BY` might be more contentious.

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


[clang-tools-extra] [clang] [llvm] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2024-01-02 Thread James Y Knight via cfe-commits

jyknight wrote:

Ping!

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


[clang] [clang][Interp] Fix diagnosing non-const variables pre-C++11 (PR #76718)

2024-01-02 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= 
Message-ID: 
In-Reply-To:


https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/76718

Depends on https://github.com/llvm/llvm-project/pull/71919

In CheckConstant(), consider that in C++98 const variables may not be
read at all, and diagnose that accordingly.


>From f0496851aae146bd8ee1587f00a75c0a3ec93005 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 9 Nov 2023 15:45:05 +0100
Subject: [PATCH 1/2] [clang][Interp] Diagnose reads from non-const global
 variables

---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp |  2 +-
 clang/lib/AST/Interp/Interp.cpp  | 44 ++--
 clang/lib/AST/Interp/Interp.h| 14 
 clang/lib/AST/Interp/Opcodes.td  |  1 +
 clang/test/AST/Interp/arrays.cpp | 32 +
 clang/test/AST/Interp/cxx23.cpp  | 22 
 clang/test/AST/Interp/literals.cpp   | 27 +--
 7 files changed, 122 insertions(+), 20 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e6b3097a80d8f7..edbcf4005aedbf 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2330,7 +2330,7 @@ bool ByteCodeExprGen::visitDecl(const VarDecl 
*VD) {
 auto GlobalIndex = P.getGlobal(VD);
 assert(GlobalIndex); // visitVarDecl() didn't return false.
 if (VarT) {
-  if (!this->emitGetGlobal(*VarT, *GlobalIndex, VD))
+  if (!this->emitGetGlobalUnchecked(*VarT, *GlobalIndex, VD))
 return false;
 } else {
   if (!this->emitGetPtrGlobal(*GlobalIndex, VD))
diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index a82d1c3c7c622a..5c4280382565dc 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -53,6 +53,18 @@ static bool Jf(InterpState &S, CodePtr &PC, int32_t Offset) {
   return true;
 }
 
+static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
+ const ValueDecl *VD) {
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  S.FFDiag(Loc,
+   VD->getType()->isIntegralOrEnumerationType()
+   ? diag::note_constexpr_ltor_non_const_int
+   : diag::note_constexpr_ltor_non_constexpr,
+   1)
+  << VD;
+  S.Note(VD->getLocation(), diag::note_declared_at);
+}
+
 static bool CheckActive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
 AccessKinds AK) {
   if (Ptr.isActive())
@@ -159,9 +171,7 @@ bool CheckExtern(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
 
   if (!S.checkingPotentialConstantExpression() && S.getLangOpts().CPlusPlus) {
 const auto *VD = Ptr.getDeclDesc()->asValueDecl();
-const SourceInfo &Loc = S.Current->getSource(OpPC);
-S.FFDiag(Loc, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
-S.Note(VD->getLocation(), diag::note_declared_at);
+diagnoseNonConstVariable(S, OpPC, VD);
   }
   return false;
 }
@@ -204,6 +214,24 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer 
&Ptr,
   return true;
 }
 
+bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
+  assert(Desc);
+  if (const auto *D = Desc->asValueDecl()) {
+if (const auto *VD = dyn_cast(D);
+VD && VD->hasGlobalStorage() &&
+!(VD->isConstexpr() || VD->getType().isConstQualified())) {
+  diagnoseNonConstVariable(S, OpPC, VD);
+  return false;
+}
+  }
+
+  return true;
+}
+
+static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+  return CheckConstant(S, OpPC, Ptr.getDeclDesc());
+}
+
 bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
   return !Ptr.isZero() && !Ptr.isDummy();
 }
@@ -292,6 +320,8 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
   if (!CheckDummy(S, OpPC, Ptr))
 return false;
+  if (!CheckConstant(S, OpPC, Ptr))
+return false;
   if (!CheckLive(S, OpPC, Ptr, AK_Read))
 return false;
   if (!CheckExtern(S, OpPC, Ptr))
@@ -593,13 +623,7 @@ bool CheckDeclRef(InterpState &S, CodePtr OpPC, const 
DeclRefExpr *DR) {
 }
   } else if (const auto *VD = dyn_cast(D)) {
 if (!VD->getType().isConstQualified()) {
-  S.FFDiag(E,
-   VD->getType()->isIntegralOrEnumerationType()
-   ? diag::note_constexpr_ltor_non_const_int
-   : diag::note_constexpr_ltor_non_constexpr,
-   1)
-  << VD;
-  S.Note(VD->getLocation(), diag::note_declared_at) << 
VD->getSourceRange();
+  diagnoseNonConstVariable(S, OpPC, VD);
   return false;
 }
 
diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 828d4ea35526d6..a6a52d2ab006fc 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -77,6 +77,9 @@ bool CheckSubobj

[clang] [clang][Interp] Fix diagnosing non-const variables pre-C++11 (PR #76718)

2024-01-02 Thread via cfe-commits
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Depends on https://github.com/llvm/llvm-project/pull/71919

In CheckConstant(), consider that in C++98 const variables may not be
read at all, and diagnose that accordingly.


---
Full diff: https://github.com/llvm/llvm-project/pull/76718.diff


9 Files Affected:

- (modified) clang/lib/AST/Interp/ByteCodeExprGen.cpp (+1-1) 
- (modified) clang/lib/AST/Interp/Interp.cpp (+61-10) 
- (modified) clang/lib/AST/Interp/Interp.h (+14) 
- (modified) clang/lib/AST/Interp/Opcodes.td (+1) 
- (modified) clang/test/AST/Interp/arrays.cpp (+32) 
- (added) clang/test/AST/Interp/cxx11.cpp (+24) 
- (modified) clang/test/AST/Interp/cxx23.cpp (+16-6) 
- (added) clang/test/AST/Interp/cxx98.cpp (+36) 
- (modified) clang/test/AST/Interp/literals.cpp (+24-3) 


``diff
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e6b3097a80d8f7..edbcf4005aedbf 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2330,7 +2330,7 @@ bool ByteCodeExprGen::visitDecl(const VarDecl 
*VD) {
 auto GlobalIndex = P.getGlobal(VD);
 assert(GlobalIndex); // visitVarDecl() didn't return false.
 if (VarT) {
-  if (!this->emitGetGlobal(*VarT, *GlobalIndex, VD))
+  if (!this->emitGetGlobalUnchecked(*VarT, *GlobalIndex, VD))
 return false;
 } else {
   if (!this->emitGetPtrGlobal(*GlobalIndex, VD))
diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index a82d1c3c7c622a..fb4696e21d80f2 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -53,6 +53,25 @@ static bool Jf(InterpState &S, CodePtr &PC, int32_t Offset) {
   return true;
 }
 
+static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
+ const ValueDecl *VD) {
+  if (!S.getLangOpts().CPlusPlus)
+return;
+
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+
+  if (VD->getType()->isIntegralOrEnumerationType())
+S.FFDiag(Loc, diag::note_constexpr_ltor_non_const_int, 1) << VD;
+  else
+S.FFDiag(Loc,
+ S.getLangOpts().CPlusPlus11
+ ? diag::note_constexpr_ltor_non_constexpr
+ : diag::note_constexpr_ltor_non_integral,
+ 1)
+<< VD << VD->getType();
+  S.Note(VD->getLocation(), diag::note_declared_at);
+}
+
 static bool CheckActive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
 AccessKinds AK) {
   if (Ptr.isActive())
@@ -159,9 +178,7 @@ bool CheckExtern(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
 
   if (!S.checkingPotentialConstantExpression() && S.getLangOpts().CPlusPlus) {
 const auto *VD = Ptr.getDeclDesc()->asValueDecl();
-const SourceInfo &Loc = S.Current->getSource(OpPC);
-S.FFDiag(Loc, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
-S.Note(VD->getLocation(), diag::note_declared_at);
+diagnoseNonConstVariable(S, OpPC, VD);
   }
   return false;
 }
@@ -204,6 +221,44 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer 
&Ptr,
   return true;
 }
 
+bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
+  assert(Desc);
+
+  auto IsConstType = [&S](const VarDecl *VD) -> bool {
+if (VD->isConstexpr())
+  return true;
+
+if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11)
+  return false;
+
+QualType T = VD->getType();
+if (T.isConstQualified())
+  return true;
+
+if (const auto *RT = T->getAs())
+  return RT->getPointeeType().isConstQualified();
+
+if (const auto *PT = T->getAs())
+  return PT->getPointeeType().isConstQualified();
+
+return false;
+  };
+
+  if (const auto *D = Desc->asValueDecl()) {
+if (const auto *VD = dyn_cast(D);
+VD && VD->hasGlobalStorage() && !IsConstType(VD)) {
+  diagnoseNonConstVariable(S, OpPC, VD);
+  return S.inConstantContext();
+}
+  }
+
+  return true;
+}
+
+static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+  return CheckConstant(S, OpPC, Ptr.getDeclDesc());
+}
+
 bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
   return !Ptr.isZero() && !Ptr.isDummy();
 }
@@ -292,6 +347,8 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
   if (!CheckDummy(S, OpPC, Ptr))
 return false;
+  if (!CheckConstant(S, OpPC, Ptr))
+return false;
   if (!CheckLive(S, OpPC, Ptr, AK_Read))
 return false;
   if (!CheckExtern(S, OpPC, Ptr))
@@ -593,13 +650,7 @@ bool CheckDeclRef(InterpState &S, CodePtr OpPC, const 
DeclRefExpr *DR) {
 }
   } else if (const auto *VD = dyn_cast(D)) {
 if (!VD->getType().isConstQualified()) {
-  S.FFDiag(E,
-   VD->getType()->isIntegralOrEnumerationType()

[clang] [Clang] Use const pointer to eliminate warning with libxml 2.12.0 (PR #76719)

2024-01-02 Thread via cfe-commits

https://github.com/FantasqueX created 
https://github.com/llvm/llvm-project/pull/76719

Currently, if `CLANG_HAVE_LIBXML` is defined, and the version of libxml2 is 
above 2.12.0, there will be two warnings when building clang.

warning: initializing 'xmlErrorPtr' (aka 'struct _xmlError *') with an 
expression of type 'const xmlError *' (aka 'const struct _xmlError *') discards 
qualifiers

Since this commit
https://gitlab.gnome.org/GNOME/libxml2/-/commit/45470611b047db78106dcb2fdbd4164163c15ab7,
 libxml2 makes cmlGetLastError return a const error. This patch follows 
libxml2. Making the result a const pointer should be compatible with versions 
before 2.12.0.

Tested on ArchLinux with libxml2 2.12.3 installed.

>From 603f9c000f4bdecb20449b22c55d6c2eda88f134 Mon Sep 17 00:00:00 2001
From: Letu Ren 
Date: Tue, 2 Jan 2024 21:50:45 +0800
Subject: [PATCH] [Clang] Use const pointer to eliminate warning with libxml
 2.12.0

Currently, if `CLANG_HAVE_LIBXML` is defined, and the version of libxml2
is above 2.12.0, there will be two warnings when building clang.

warning: initializing 'xmlErrorPtr' (aka 'struct _xmlError *') with an
expression of type 'const xmlError *' (aka 'const struct _xmlError *')
discards qualifiers

Since this commit
https://gitlab.gnome.org/GNOME/libxml2/-/commit/45470611b047db78106dcb2fdbd4164163c15ab7,
libxml2 makes cmlGetLastError return a const error. This patch follows
libxml2. Making the result a const pointer should be compatible with
versions before 2.12.0.

Tested on ArchLinux with libxml2 2.12.3 installed.
---
 clang/tools/c-index-test/c-index-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/tools/c-index-test/c-index-test.c 
b/clang/tools/c-index-test/c-index-test.c
index 6fa400a0675b7a..a79da8eac30972 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -695,7 +695,7 @@ static void ValidateCommentXML(const char *Str, const char 
*CommentSchemaFile) {
   Doc = xmlParseDoc((const xmlChar *) Str);
 
   if (!Doc) {
-xmlErrorPtr Error = xmlGetLastError();
+const xmlError *Error = xmlGetLastError();
 printf(" CommentXMLInvalid [not well-formed XML: %s]", Error->message);
 return;
   }
@@ -705,7 +705,7 @@ static void ValidateCommentXML(const char *Str, const char 
*CommentSchemaFile) {
   if (!status)
 printf(" CommentXMLValid");
   else if (status > 0) {
-xmlErrorPtr Error = xmlGetLastError();
+const xmlError *Error = xmlGetLastError();
 printf(" CommentXMLInvalid [not valid XML: %s]", Error->message);
   } else
 printf(" libXMLError");

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


[clang] [Clang] Use const pointer to eliminate warning with libxml 2.12.0 (PR #76719)

2024-01-02 Thread via cfe-commits

github-actions[bot] wrote:

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [Clang] Use const pointer to eliminate warning with libxml 2.12.0 (PR #76719)

2024-01-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: FantasqueX (FantasqueX)


Changes

Currently, if `CLANG_HAVE_LIBXML` is defined, and the version of libxml2 is 
above 2.12.0, there will be two warnings when building clang.

warning: initializing 'xmlErrorPtr' (aka 'struct _xmlError *') with an 
expression of type 'const xmlError *' (aka 'const struct _xmlError *') discards 
qualifiers

Since this commit
https://gitlab.gnome.org/GNOME/libxml2/-/commit/45470611b047db78106dcb2fdbd4164163c15ab7,
 libxml2 makes cmlGetLastError return a const error. This patch follows 
libxml2. Making the result a const pointer should be compatible with versions 
before 2.12.0.

Tested on ArchLinux with libxml2 2.12.3 installed.

---
Full diff: https://github.com/llvm/llvm-project/pull/76719.diff


1 Files Affected:

- (modified) clang/tools/c-index-test/c-index-test.c (+2-2) 


``diff
diff --git a/clang/tools/c-index-test/c-index-test.c 
b/clang/tools/c-index-test/c-index-test.c
index 6fa400a0675b7a..a79da8eac30972 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -695,7 +695,7 @@ static void ValidateCommentXML(const char *Str, const char 
*CommentSchemaFile) {
   Doc = xmlParseDoc((const xmlChar *) Str);
 
   if (!Doc) {
-xmlErrorPtr Error = xmlGetLastError();
+const xmlError *Error = xmlGetLastError();
 printf(" CommentXMLInvalid [not well-formed XML: %s]", Error->message);
 return;
   }
@@ -705,7 +705,7 @@ static void ValidateCommentXML(const char *Str, const char 
*CommentSchemaFile) {
   if (!status)
 printf(" CommentXMLValid");
   else if (status > 0) {
-xmlErrorPtr Error = xmlGetLastError();
+const xmlError *Error = xmlGetLastError();
 printf(" CommentXMLInvalid [not valid XML: %s]", Error->message);
   } else
 printf(" libXMLError");

``




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


[clang] [APINotes] Upstream Sema logic to apply API Notes to decls (PR #73017)

2024-01-02 Thread Egor Zhdan via cfe-commits

egorzhdan wrote:

@compnerd ping ;)

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


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2024-01-02 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

There is also the use-case to keep a relatively modern code-base in a modern 
state. In that case, the user might want to know about 
modernizations/deprecations right in the editor.
Example (vscode):
![image](https://github.com/llvm/llvm-project/assets/44101708/e66b4fc8-7e3a-4edb-8fbe-602bdce4a969)
'After removing the unused variable, I have no more problems/diagnostics', but 
the for-loop could be a range-for, and the 
function can use a trailing return type.

The mentioned 'inconsistency' is that vscode will not tell you about remarks as 
problems (right side of the `Problems` tab):
![image](https://github.com/llvm/llvm-project/assets/44101708/16d7fb96-2cf7-4886-817e-5f141ff5de28)
and the only way to find the diagnostics `modernize-` or `deprecated` is to 
find code with strike-throughs.

Maybe a configuration option would be better?
```yaml
Diagnostics:
  ModernizationDiagnosticSeverity: <>
  [W]DeprecatedDiagnosticSeverity: <>
```
or
```yaml
Diagnostics:
  Severity:
Modernize: <>
Deprecated: <>
```

Or change the severity from `Remark` to `Note` (`getSeverity` shows that `Note` 
has a higher severity than `Remark`, which differs from 
`DiagnosticEngine::Level`/`DiagnosticIDs`), which will show up more visible and 
as a distinct entry in `Problems` and can be filtered by (screenshot above). 
The inline highlighting is kept even when filtering in the `Problems` tab.
![image](https://github.com/llvm/llvm-project/assets/44101708/f420aa31-a49d-46d7-a71d-574f21211f8e)

This pr is probably not the way to do this, my personal take is that the 
configuration option is the most flexible. I guess an issue would have been a 
better fit to talk about this :)

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-01-02 Thread Michael Platings via cfe-commits

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-01-02 Thread Michael Platings via cfe-commits

https://github.com/mplatings commented:

I'd be disinclined to add `CachedExceptionsMode`:
* It's more code to maintain.
* Most toolchains will never use it so for them it's a small extra runtime cost 
with no benefit.

I think you could calculate the exceptions mode in `getMultilibFlags` when 
needed.

I'm not actively working on LLVM any more so I'm going to remove myself as 
reviewer now.

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-01-02 Thread Michael Platings via cfe-commits


@@ -77,10 +77,21 @@ static ToolChain::RTTIMode CalculateRTTIMode(const ArgList 
&Args,
   return NoRTTI ? ToolChain::RM_Disabled : ToolChain::RM_Enabled;
 }
 
+static ToolChain::ExceptionsMode CalculateExceptionsMode(const ArgList &Args) {
+
+  Arg *exceptionsArg = Args.getLastArg(options::OPT_fno_exceptions);
+  if (exceptionsArg &&
+  exceptionsArg->getOption().matches(options::OPT_fno_exceptions)) {
+return ToolChain::EM_Disabled;
+  }
+  return ToolChain::EM_Enabled;

mplatings wrote:

This is incorrect. There are plenty of examples across the clang code of how to 
check whether exceptions should be enabled or not.

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


[clang] [clang][Interp] Add inline descriptor to global variables (PR #72892)

2024-01-02 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/72892

>From 14873b8729e97425049e654adf40fb239ccfab6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 20 Nov 2023 11:53:40 +0100
Subject: [PATCH 1/3] [clang][Interp] Add inline descriptor to global variables

---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp | 15 ++-
 clang/lib/AST/Interp/Descriptor.cpp  | 27 ++--
 clang/lib/AST/Interp/Descriptor.h|  6 ++-
 clang/lib/AST/Interp/Interp.cpp  | 16 +++
 clang/lib/AST/Interp/Interp.h| 23 +++---
 clang/lib/AST/Interp/Pointer.cpp |  4 +-
 clang/lib/AST/Interp/Pointer.h   | 30 +
 clang/lib/AST/Interp/Program.cpp | 56 +---
 clang/test/AST/Interp/cxx17.cpp  | 23 --
 clang/test/AST/Interp/cxx23.cpp  | 24 +++---
 clang/test/AST/Interp/literals.cpp   | 17 +++
 11 files changed, 185 insertions(+), 56 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e6b3097a80d8f7..26c8f263aa38f8 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -823,13 +823,26 @@ bool ByteCodeExprGen::VisitInitListExpr(const 
InitListExpr *E) {
 return this->visitInitList(E->inits(), E);
 
   if (T->isArrayType()) {
-// FIXME: Array fillers.
 unsigned ElementIndex = 0;
 for (const Expr *Init : E->inits()) {
   if (!this->visitArrayElemInit(ElementIndex, Init))
 return false;
   ++ElementIndex;
 }
+
+// Expand the filler expression.
+// FIXME: This should go away.
+if (const Expr *Filler = E->getArrayFiller()) {
+  const ConstantArrayType *CAT =
+  Ctx.getASTContext().getAsConstantArrayType(E->getType());
+  uint64_t NumElems = CAT->getSize().getZExtValue();
+
+  for (; ElementIndex != NumElems; ++ElementIndex) {
+if (!this->visitArrayElemInit(ElementIndex, Filler))
+  return false;
+  }
+}
+
 return true;
   }
 
diff --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index 59a952135a2d80..7330295132618e 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -243,18 +243,19 @@ Descriptor::Descriptor(const DeclTy &D, PrimType Type, 
MetadataSize MD,
bool IsMutable)
 : Source(D), ElemSize(primSize(Type)), Size(ElemSize * NumElems),
   MDSize(MD.value_or(0)),
-  AllocSize(align(Size) + sizeof(InitMapPtr) + MDSize), IsConst(IsConst),
-  IsMutable(IsMutable), IsTemporary(IsTemporary), IsArray(true),
-  CtorFn(getCtorArrayPrim(Type)), DtorFn(getDtorArrayPrim(Type)),
-  MoveFn(getMoveArrayPrim(Type)) {
+  AllocSize(align(MDSize) + align(Size) + sizeof(InitMapPtr)),
+  IsConst(IsConst), IsMutable(IsMutable), IsTemporary(IsTemporary),
+  IsArray(true), CtorFn(getCtorArrayPrim(Type)),
+  DtorFn(getDtorArrayPrim(Type)), MoveFn(getMoveArrayPrim(Type)) {
   assert(Source && "Missing source");
 }
 
 /// Primitive unknown-size arrays.
-Descriptor::Descriptor(const DeclTy &D, PrimType Type, bool IsTemporary,
-   UnknownSize)
-: Source(D), ElemSize(primSize(Type)), Size(UnknownSizeMark), MDSize(0),
-  AllocSize(alignof(void *) + sizeof(InitMapPtr)), IsConst(true),
+Descriptor::Descriptor(const DeclTy &D, PrimType Type, MetadataSize MD,
+   bool IsTemporary, UnknownSize)
+: Source(D), ElemSize(primSize(Type)), Size(UnknownSizeMark),
+  MDSize(MD.value_or(0)),
+  AllocSize(MDSize + sizeof(InitMapPtr) + alignof(void *)), IsConst(true),
   IsMutable(false), IsTemporary(IsTemporary), IsArray(true),
   CtorFn(getCtorArrayPrim(Type)), DtorFn(getDtorArrayPrim(Type)),
   MoveFn(getMoveArrayPrim(Type)) {
@@ -275,12 +276,12 @@ Descriptor::Descriptor(const DeclTy &D, const Descriptor 
*Elem, MetadataSize MD,
 }
 
 /// Unknown-size arrays of composite elements.
-Descriptor::Descriptor(const DeclTy &D, Descriptor *Elem, bool IsTemporary,
-   UnknownSize)
+Descriptor::Descriptor(const DeclTy &D, Descriptor *Elem, MetadataSize MD,
+   bool IsTemporary, UnknownSize)
 : Source(D), ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),
-  Size(UnknownSizeMark), MDSize(0),
-  AllocSize(alignof(void *) + sizeof(InitMapPtr)), ElemDesc(Elem),
-  IsConst(true), IsMutable(false), IsTemporary(IsTemporary), IsArray(true),
+  Size(UnknownSizeMark), MDSize(MD.value_or(0)),
+  AllocSize(MDSize + alignof(void *)), ElemDesc(Elem), IsConst(true),
+  IsMutable(false), IsTemporary(IsTemporary), IsArray(true),
   CtorFn(ctorArrayDesc), DtorFn(dtorArrayDesc), MoveFn(moveArrayDesc) {
   assert(Source && "Missing source");
 }
diff --git a/clang/lib/AST

[clang] Multilib support for libraries with exceptions (PR #75031)

2024-01-02 Thread Michael Platings via cfe-commits

mplatings wrote:

> I'm not actively working on LLVM any more so I'm going to remove myself as 
> reviewer now.

Or at least I would if GitHub would let me! 
https://github.com/orgs/community/discussions/23054

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


[clang] [clang][Interp] Implement IntegralAP::{div, rem} (PR #72614)

2024-01-02 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Ping

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


[clang] [clang][Interp] Add an EvaluationResult class (PR #71315)

2024-01-02 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/71315

>From c4c9473b8be62028f204e85066ad7b0cf7dda29b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 31 Oct 2023 14:57:51 +0100
Subject: [PATCH] EvaluationResult

---
 clang/lib/AST/CMakeLists.txt  |   1 +
 clang/lib/AST/ExprConstant.cpp|  23 ++-
 clang/lib/AST/Interp/ByteCodeEmitter.cpp  |  13 +-
 clang/lib/AST/Interp/ByteCodeEmitter.h|   5 +-
 clang/lib/AST/Interp/ByteCodeExprGen.cpp  |   4 +-
 clang/lib/AST/Interp/ByteCodeExprGen.h|   4 -
 clang/lib/AST/Interp/Context.cpp  | 106 
 clang/lib/AST/Interp/Context.h|   3 +
 clang/lib/AST/Interp/EvalEmitter.cpp  | 174 +--
 clang/lib/AST/Interp/EvalEmitter.h|  11 +-
 clang/lib/AST/Interp/EvaluationResult.cpp | 196 ++
 clang/lib/AST/Interp/EvaluationResult.h   | 111 
 clang/lib/AST/Interp/Interp.cpp   |  92 --
 clang/lib/AST/Interp/Interp.h |  16 +-
 clang/lib/AST/Interp/Opcodes.td   |   2 -
 clang/lib/AST/Interp/Pointer.cpp  | 154 ++---
 clang/lib/AST/Interp/Pointer.h|   3 +-
 clang/test/AST/Interp/records.cpp |   1 -
 18 files changed, 596 insertions(+), 323 deletions(-)
 create mode 100644 clang/lib/AST/Interp/EvaluationResult.cpp
 create mode 100644 clang/lib/AST/Interp/EvaluationResult.h

diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index fe3f8c485ec1c5..ebcb3952198a5b 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -75,6 +75,7 @@ add_clang_library(clangAST
   Interp/Function.cpp
   Interp/InterpBuiltin.cpp
   Interp/Floating.cpp
+  Interp/EvaluationResult.cpp
   Interp/Interp.cpp
   Interp/InterpBlock.cpp
   Interp/InterpFrame.cpp
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f6aeee1a4e935d..fb11d72d8a7280 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15439,11 +15439,13 @@ static bool EvaluateAsRValue(EvalInfo &Info, const 
Expr *E, APValue &Result) {
   if (Info.EnableNewConstInterp) {
 if (!Info.Ctx.getInterpContext().evaluateAsRValue(Info, E, Result))
   return false;
-  } else {
-if (!::Evaluate(Result, Info, E))
-  return false;
+return CheckConstantExpression(Info, E->getExprLoc(), E->getType(), Result,
+   ConstantExprKind::Normal);
   }
 
+  if (!::Evaluate(Result, Info, E))
+return false;
+
   // Implicit lvalue-to-rvalue cast.
   if (E->isGLValue()) {
 LValue LV;
@@ -15671,6 +15673,13 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, 
const ASTContext &Ctx,
   EvalInfo Info(Ctx, Result, EM);
   Info.InConstantContext = true;
 
+  if (Info.EnableNewConstInterp) {
+if (!Info.Ctx.getInterpContext().evaluate(Info, this, Result.Val))
+  return false;
+return CheckConstantExpression(Info, getExprLoc(),
+   getStorageType(Ctx, this), Result.Val, 
Kind);
+  }
+
   // The type of the object we're initializing is 'const T' for a class NTTP.
   QualType T = getType();
   if (Kind == ConstantExprKind::ClassTemplateArgument)
@@ -15746,10 +15755,16 @@ bool Expr::EvaluateAsInitializer(APValue &Value, 
const ASTContext &Ctx,
   Info.setEvaluatingDecl(VD, Value);
   Info.InConstantContext = IsConstantInitialization;
 
+  SourceLocation DeclLoc = VD->getLocation();
+  QualType DeclTy = VD->getType();
+
   if (Info.EnableNewConstInterp) {
 auto &InterpCtx = const_cast(Ctx).getInterpContext();
 if (!InterpCtx.evaluateAsInitializer(Info, VD, Value))
   return false;
+
+return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,
+   ConstantExprKind::Normal);
   } else {
 LValue LVal;
 LVal.set(VD);
@@ -15767,8 +15782,6 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const 
ASTContext &Ctx,
   llvm_unreachable("Unhandled cleanup; missing full expression marker?");
   }
 
-  SourceLocation DeclLoc = VD->getLocation();
-  QualType DeclTy = VD->getType();
   return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,
  ConstantExprKind::Normal) &&
  CheckMemoryLeaks(Info);
diff --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index 045263447cbc91..92c069263a5ee5 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -20,8 +20,7 @@
 using namespace clang;
 using namespace clang::interp;
 
-Expected
-ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
+Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
   // Set up argument indices.
   unsigned ParamOffset = 0;
   SmallVector ParamTypes;
@@ -120,10 +119,6 @@ ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) 
{
 
   // Compile the function body.
  

[llvm] [clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2024-01-02 Thread Yeting Kuo via cfe-commits

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


[llvm] [clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2024-01-02 Thread Yeting Kuo via cfe-commits

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


[llvm] [clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2024-01-02 Thread Yeting Kuo via cfe-commits

https://github.com/yetingk updated 
https://github.com/llvm/llvm-project/pull/68075

>From be70878169742f7e9cbb276a05254019c586897b Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 3 Oct 2023 16:08:06 +0800
Subject: [PATCH 1/4] [RISCV] Implement shadow stack on shadow stack mode with
 Zicfiss.

There are two shadow stack implements with Zicfiss in [spec] now.
In Shadow stack mode, programs still store the return address to regular 
address.
In Control stack mode, programs only store the return address to shadow stack.
This patch only supports the shadow stack mode.

[spec]: 
https://github.com/riscv/riscv-cfi/blob/main/cfi_backward.adoc#push-to-and-pop-from-the-shadow-stack
---
 llvm/lib/Target/RISCV/RISCVFrameLowering.cpp |  14 +-
 llvm/test/CodeGen/RISCV/shadowcallstack.ll   | 130 +++
 2 files changed, 142 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index 8dfea6d3862057..6f043ade98f409 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -51,9 +51,14 @@ static void emitSCSPrologue(MachineFunction &MF, 
MachineBasicBlock &MBB,
   CSI, [&](CalleeSavedInfo &CSR) { return CSR.getReg() == RAReg; }))
 return;
 
+  const RISCVInstrInfo *TII = STI.getInstrInfo();
+  if (STI.hasFeature(RISCV::FeatureStdExtZicfiss)) {
+BuildMI(MBB, MI, DL, TII->get(RISCV::SSPUSH)).addReg(RAReg);
+return;
+  }
+
   Register SCSPReg = RISCVABI::getSCSPReg();
 
-  const RISCVInstrInfo *TII = STI.getInstrInfo();
   bool IsRV64 = STI.hasFeature(RISCV::Feature64Bit);
   int64_t SlotSize = STI.getXLen() / 8;
   // Store return address to shadow call stack
@@ -106,9 +111,14 @@ static void emitSCSEpilogue(MachineFunction &MF, 
MachineBasicBlock &MBB,
   CSI, [&](CalleeSavedInfo &CSR) { return CSR.getReg() == RAReg; }))
 return;
 
+  const RISCVInstrInfo *TII = STI.getInstrInfo();
+  if (STI.hasFeature(RISCV::FeatureStdExtZicfiss)) {
+BuildMI(MBB, MI, DL, TII->get(RISCV::SSPOPCHK)).addReg(RAReg);
+return;
+  }
+
   Register SCSPReg = RISCVABI::getSCSPReg();
 
-  const RISCVInstrInfo *TII = STI.getInstrInfo();
   bool IsRV64 = STI.hasFeature(RISCV::Feature64Bit);
   int64_t SlotSize = STI.getXLen() / 8;
   // Load return address from shadow call stack
diff --git a/llvm/test/CodeGen/RISCV/shadowcallstack.ll 
b/llvm/test/CodeGen/RISCV/shadowcallstack.ll
index fee067ee3ad141..8fbe7ed9ca0766 100644
--- a/llvm/test/CodeGen/RISCV/shadowcallstack.ll
+++ b/llvm/test/CodeGen/RISCV/shadowcallstack.ll
@@ -3,6 +3,10 @@
 ; RUN:   | FileCheck %s --check-prefix=RV32
 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s --check-prefix=RV64
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicfiss -verify-machineinstrs 
< %s \
+; RUN:   | FileCheck %s --check-prefix=RV32-ZICFISS
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zicfiss -verify-machineinstrs 
< %s \
+; RUN:   | FileCheck %s --check-prefix=RV64-ZICFISS
 
 define void @f1() shadowcallstack {
 ; RV32-LABEL: f1:
@@ -12,6 +16,14 @@ define void @f1() shadowcallstack {
 ; RV64-LABEL: f1:
 ; RV64:   # %bb.0:
 ; RV64-NEXT:ret
+;
+; RV32-ZICFISS-LABEL: f1:
+; RV32-ZICFISS:   # %bb.0:
+; RV32-ZICFISS-NEXT:ret
+;
+; RV64-ZICFISS-LABEL: f1:
+; RV64-ZICFISS:   # %bb.0:
+; RV64-ZICFISS-NEXT:ret
   ret void
 }
 
@@ -25,6 +37,14 @@ define void @f2() shadowcallstack {
 ; RV64-LABEL: f2:
 ; RV64:   # %bb.0:
 ; RV64-NEXT:tail foo@plt
+;
+; RV32-ZICFISS-LABEL: f2:
+; RV32-ZICFISS:   # %bb.0:
+; RV32-ZICFISS-NEXT:tail foo@plt
+;
+; RV64-ZICFISS-LABEL: f2:
+; RV64-ZICFISS:   # %bb.0:
+; RV64-ZICFISS-NEXT:tail foo@plt
   tail call void @foo()
   ret void
 }
@@ -65,6 +85,32 @@ define i32 @f3() shadowcallstack {
 ; RV64-NEXT:addi gp, gp, -8
 ; RV64-NEXT:.cfi_restore gp
 ; RV64-NEXT:ret
+;
+; RV32-ZICFISS-LABEL: f3:
+; RV32-ZICFISS:   # %bb.0:
+; RV32-ZICFISS-NEXT:sspush ra
+; RV32-ZICFISS-NEXT:addi sp, sp, -16
+; RV32-ZICFISS-NEXT:.cfi_def_cfa_offset 16
+; RV32-ZICFISS-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
+; RV32-ZICFISS-NEXT:.cfi_offset ra, -4
+; RV32-ZICFISS-NEXT:call bar@plt
+; RV32-ZICFISS-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
+; RV32-ZICFISS-NEXT:addi sp, sp, 16
+; RV32-ZICFISS-NEXT:sspopchk ra
+; RV32-ZICFISS-NEXT:ret
+;
+; RV64-ZICFISS-LABEL: f3:
+; RV64-ZICFISS:   # %bb.0:
+; RV64-ZICFISS-NEXT:sspush ra
+; RV64-ZICFISS-NEXT:addi sp, sp, -16
+; RV64-ZICFISS-NEXT:.cfi_def_cfa_offset 16
+; RV64-ZICFISS-NEXT:sd ra, 8(sp) # 8-byte Folded Spill
+; RV64-ZICFISS-NEXT:.cfi_offset ra, -8
+; RV64-ZICFISS-NEXT:call bar@plt
+; RV64-ZICFISS-NEXT:ld ra, 8(sp) # 8-byte Folded Reload
+; RV64-ZICFISS-NEXT:addi sp, sp, 16
+; RV64-ZICFISS-NEXT:sspopchk ra
+; RV64-ZICFISS-NEXT:ret
   %res = call i32 @bar()
   %res1 = add i32 %res, 1
   ret

[clang] 02347fc - Reapply "[Sema] Fix crash on invalid code with parenthesized aggregate initialization" (#76272)

2024-01-02 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2024-01-02T16:00:55+01:00
New Revision: 02347fc7191ff4d073f439dde6523add3f5496de

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

LOG: Reapply "[Sema] Fix crash on invalid code with parenthesized aggregate 
initialization" (#76272)

With updates the libc++ tests.

This reverts commit 2205d2334f3c859ad9f6c65ed950bfb3bb6f7cbe and relands
86dc6e15f22610bbb53eb4efda0a178ecefc933a and
7ab16fb5207fe187ab999f882069bd632d2e68e5.

Original commit was reverted because of failing libc++ tests, see #76232 for
the discussion.

The errors in the tests are spurious in the first place (coming from 
initialization
of invalid classes), so update the tests to match new behavior that does
not show those errors.

Added: 
clang/test/SemaCXX/crash-GH76228.cpp

Modified: 
clang/lib/Sema/SemaInit.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp

libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp

libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 61d244f3bb9798..cc9db5ded1149a 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5512,6 +5512,14 @@ static void TryOrBuildParenListInitialization(
   } else if (auto *RT = Entity.getType()->getAs()) {
 bool IsUnion = RT->isUnionType();
 const CXXRecordDecl *RD = cast(RT->getDecl());
+if (RD->isInvalidDecl()) {
+  // Exit early to avoid confusion when processing members.
+  // We do the same for braced list initialization in
+  // `CheckStructUnionTypes`.
+  Sequence.SetFailed(
+  clang::InitializationSequence::FK_ParenthesizedListInitFailed);
+  return;
+}
 
 if (!IsUnion) {
   for (const CXXBaseSpecifier &Base : RD->bases()) {

diff  --git a/clang/test/SemaCXX/crash-GH76228.cpp 
b/clang/test/SemaCXX/crash-GH76228.cpp
new file mode 100644
index 00..33a9395823127e
--- /dev/null
+++ b/clang/test/SemaCXX/crash-GH76228.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// Check we don't crash on incomplete members and bases when handling 
parenthesized initialization.
+class incomplete; // expected-note@-0 3  {{forward declaration of 
'incomplete'}}
+struct foo {
+  int a;
+  incomplete b;
+  // expected-error@-1 {{incomplete type}}
+};
+foo a1(0);
+
+struct one_int {
+int a;
+};
+struct bar : one_int, incomplete {};
+// expected-error@-1 {{incomplete type}}
+bar a2(0);
+
+incomplete a3[3](1,2,3);
+// expected-error@-1 {{incomplete type}}
+
+struct qux : foo {
+};
+qux a4(0);
+
+struct fred {
+foo a[3];
+};
+fred a5(0);

diff  --git a/clang/test/SemaCXX/paren-list-agg-init.cpp 
b/clang/test/SemaCXX/paren-list-agg-init.cpp
index f60b20e0d46568..c1964a5a9eb005 100644
--- a/clang/test/SemaCXX/paren-list-agg-init.cpp
+++ b/clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -289,7 +289,7 @@ int test() {
   // used to crash
   S a(0, 1);
   S b(0);
-  S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' 
from a parenthesized list of values is a C++20 extension}}
+  S c(0, 0, 1);
 
   S d {0, 1};
   S e {0};

diff  --git 
a/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp
 
b/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp
index 965e82a7b40346..3260a8cbc7f8e6 100644
--- 
a/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp
+++ 
b/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp
@@ -46,11 +46,9 @@ void test() {
   {
 std::expected e;
 e.transform_error(return_unexpected); // expected-error-re@*:* 
{{static assertion failed {{.*}}The result of {{.*}} must be a valid template 
argument for unexpected}}
-// expected-error-re@*:* (excess elements in struct initializer|no 
matching constructor for initialization of)}}{{.*
 // expected-error-re@*:* {{static assertion failed 
{{.*}}[expected.object.general] A program that instantiates the definition of 
template expected for {{.*}} is ill-formed.}}
 
 e.transform_error(return_no_object); // expected-error-re@*:* 
{{static assertion failed {{.*}}The result of {{.*}} must be a valid template 
argument for unexpected}}
-// expected-error-re@*:* (excess elements in struct initializer|no 
matching constructor for initialization of)}}{{.*
 // expected-error-re@*:* {{static assertion failed 
{{.*}}[expected.object.general] A program that instantiates the definition of 
template expected for {{.*}} is ill-formed.}}
   }
 
@@ -58,27 +56,21 @@ void test() {
   {
 const std::expected e;
  

[llvm] [clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2024-01-02 Thread Yeting Kuo via cfe-commits

yetingk wrote:

Rebase and ping. I also update the first comment of the first comment of this 
pr since the control stack mode is removed and we add new feature 
`forced-sw-shadow-stack`.

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


[clang] [clang-tools-extra] [mlir] [llvm] [compiler-rt] [flang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-02 Thread Mehdi Amini via cfe-commits


@@ -866,16 +866,41 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
 this->setHasBoundedRewriteRecursion();
   }
 
+  static void getMaskBufferLoadIndices(OpTy xferOp, Value castedMaskBuffer,
+   SmallVector &loadIndices,

joker-eph wrote:

```suggestion
   SmallVectorImpl &loadIndices,
```

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


[mlir] [flang] [clang-tools-extra] [llvm] [compiler-rt] [clang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-02 Thread Mehdi Amini via cfe-commits


@@ -897,7 +921,8 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
   } else {
 // It's safe to assume the mask buffer can be unpacked if the data
 // buffer was unpacked.
-auto castedMaskType = *unpackOneDim(maskBufferType);
+auto maskBufferType = dyn_cast(maskBuffer.getType());

joker-eph wrote:

Why are you introducing a `dyn_cast` here?

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


[flang] [clang-tools-extra] [clang] [mlir] [llvm] [compiler-rt] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-02 Thread Mehdi Amini via cfe-commits


@@ -866,16 +866,41 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
 this->setHasBoundedRewriteRecursion();
   }
 
+  static void getMaskBufferLoadIndices(OpTy xferOp, Value castedMaskBuffer,
+   SmallVector &loadIndices,
+   Value iv) {
+assert(xferOp.getMask() && "Expected transfer op to have mask");
+
+// Add load indices from the previous iteration.
+// The mask buffer depends on the permutation map, which makes determining
+// the indices quite complex, so this is why we need to "look back" to the
+// previous iteration to find the right indices.
+Value maskBuffer = getMaskBuffer(xferOp);
+for (OpOperand &use : maskBuffer.getUses()) {
+  // If there is no previous load op, then the indices are empty.
+  if (auto loadOp = dyn_cast(use.getOwner())) {

joker-eph wrote:

```suggestion
for (Operation *user : maskBuffer.getUsers()) {
  // If there is no previous load op, then the indices are empty.
  if (auto loadOp = dyn_cast(user)) {
```

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


[clang] [Clang][RISCV] Forward --no-relax option to linker for RISC-V (PR #76432)

2024-01-02 Thread Andreu Carminati via cfe-commits

https://github.com/andcarminati updated 
https://github.com/llvm/llvm-project/pull/76432

>From 13648eaf3becc5650924c3399fb1dc1ecb9fa7c7 Mon Sep 17 00:00:00 2001
From: Andreu Carminati 
Date: Wed, 27 Dec 2023 09:47:54 +0100
Subject: [PATCH 1/2] [Clang][RISCV] Forward --no-relax option to linker for
 RISC-V

In the case of -mno-relax option. Otherwise, we cannot prevent relaxation
if we split compilation and linking using Clang driver.

One can consider the following use case:

clang [...] -c -o myobject.o (just compile)
clang [...] myobject.o -o myobject.elf -mno-relax (linking)

In this case, myobject.elf will be relaxed, the -mno-relax will be silently 
ignored.
---
 clang/lib/Driver/ToolChains/BareMetal.cpp  |  3 +++
 clang/lib/Driver/ToolChains/RISCVToolchain.cpp |  3 +++
 clang/test/Driver/baremetal.cpp| 12 
 clang/test/Driver/riscv32-toolchain.c  | 16 
 clang/test/Driver/riscv64-toolchain.c  | 16 
 5 files changed, 50 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 42c8336e626c7b..007a24f2b81ae7 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -443,6 +443,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   CmdArgs.push_back("-Bstatic");
 
+  if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
+CmdArgs.push_back("--no-relax");
+
   if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
 if (IsBigEndian)
diff --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp 
b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
index 7e6abd14442878..0be7d1a8899495 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -156,6 +156,9 @@ void RISCV::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
+  if (Args.hasArg(options::OPT_mno_relax))
+CmdArgs.push_back("--no-relax");
+
   bool IsRV64 = ToolChain.getArch() == llvm::Triple::riscv64;
   CmdArgs.push_back("-m");
   if (IsRV64) {
diff --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index c04f4506a0994d..7511d7d1adb4dd 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -460,3 +460,15 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
 // CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
 // CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"
+
+// Check that "--no-relax" is forwarded to the linker for RISC-V.
+// RUN: %clang %s -### 2>&1 --target=riscv64-unknown-elf -nostdinc -mno-relax \
+// RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-NORELAX %s
+// CHECK-RV64-NORELAX: "--no-relax"
+
+// Check that "--no-relax" is not forwarded to the linker for RISC-V.
+// RUN: %clang %s -### 2>&1 --target=riscv64-unknown-elf -nostdinc \
+// RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-RELAX %s
+// CHECK-RV64-RELAX-NOT: "--no-relax"
\ No newline at end of file
diff --git a/clang/test/Driver/riscv32-toolchain.c 
b/clang/test/Driver/riscv32-toolchain.c
index 63690c946ca0bc..701da05da9189d 100644
--- a/clang/test/Driver/riscv32-toolchain.c
+++ b/clang/test/Driver/riscv32-toolchain.c
@@ -215,6 +215,22 @@
 
 // RUN: %clang --target=riscv32 %s -emit-llvm -S -o - | FileCheck %s
 
+// Check that "--no-relax" is forwarded to the linker for RISC-V 
(RISCVToolchain.cpp).
+// RUN: env "PATH=" %clang %s -### 2>&1 -mno-relax \
+// RUN:   --target=riscv32-unknown-elf --rtlib=platform --unwindlib=platform 
--sysroot= \
+// RUN:   -march=rv32imac -mabi=lp32\
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-NORELAX %s
+// CHECK-RV32-NORELAX: "--no-relax"
+
+// Check that "--no-relax" is not forwarded to the linker for RISC-V 
(RISCVToolchain.cpp).
+// RUN:env "PATH=" %clang %s -### 2>&1 \
+// RUN:   --target=riscv32-unknown-elf --rtlib=platform --unwindlib=platform 
--sysroot= \
+// RUN:   -march=rv32imac -mabi=lp32\
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-RELAX %s
+// CHECK-RV32-RELAX-NOT: "--no-relax"
+
 typedef __builtin_va_list va_list;
 typedef __SIZE_TYPE__ size_t;
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
diff --git a/clang/test/Driver/riscv64-toolchain.c 
b/clang/test/Driver/riscv64-toolchain.c
index f177bff33dd4d7..da07c57d8e1fc4 100644
--- a/clang/test/Driver/riscv64-toolchain.c
+++ b/clang/test/Driver/riscv64-toolchain.c
@@ -171,6 +171,22 @@
 
 // RUN: %clang --target=riscv64 %s -emit-llvm -S -o - | FileCheck %s
 
+// Check that "--no-relax" is forwarded to the link

[clang] [Clang][RISCV] Forward --no-relax option to linker for RISC-V (PR #76432)

2024-01-02 Thread Andreu Carminati via cfe-commits

andcarminati wrote:

> Should this also be done in `tools::gnutools::Linker::ConstructJob`?

Addressed with a new commit.

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


[llvm] [clang-tools-extra] [clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2024-01-02 Thread Tom Ritter via cfe-commits

tomrittervg wrote:

> However, what should we do if multiple (N) classes implement Base? Trying 
> each N, and basically splitting the state to (N+1) ways is not going to 
> scale. Unless N is of course really small, like 2 or 3 at most.

That's kind of what I imagined - try them all.  The Analyzer has a built-in 
timeout mechanism that will come into play.  

If you wanted to be fancy, there could be an obscure config option, with a 
default of N=3.  If config value is not set, and N>3 it asserts, alerting the 
user to the situation. If config value is set, it limits to analyzing the first 
N.

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


[clang] [AArch64][SME2] Add __arm_streaming_compatible attribute to CLAMP bui… (PR #76712)

2024-01-02 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm requested changes to this pull request.

Perhaps I'm missing something obvious here, but it looks like this patch is 
implementing the opposite of #75958 ?

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


[clang] [AArch64][SME2] Add __arm_streaming_compatible attribute to CLAMP bui… (PR #76712)

2024-01-02 Thread Dinar Temirbulatov via cfe-commits

dtemirbulatov wrote:

I missed that implemtation in https://github.com/llvm/llvm-project/pull/75958, 
Closing then.

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


[clang] [AArch64][SME2] Add __arm_streaming_compatible attribute to CLAMP bui… (PR #76712)

2024-01-02 Thread Dinar Temirbulatov via cfe-commits

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


[clang-tools-extra] [clang] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-02 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/76729

Without function bodies, we cannot tell whether a function is a coroutine or 
not.
The analysis of coroutine wrappers is not useful when this information is not 
available.

We therefore now skip this analysis for skipped function bodies.

>From c0baa45c2541bc688f377a6bd2c9281532b4d541 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 2 Jan 2024 16:49:28 +0100
Subject: [PATCH] [coroutines] Do not check coroutine wrappers for skipped
 function bodies

---
 .../clangd/unittests/DiagnosticsTests.cpp | 54 +++
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 37643e5afa2304..a5744cdd4cbe6f 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -420,6 +420,60 @@ TEST(DiagnosticTest, MakeUnique) {
"no matching constructor for initialization of 'S'")));
 }
 
+TEST(DiagnosticTest, CoroutineInHeader) {
+  StringRef CoroutineH = R"cpp(
+namespace std {
+template 
+struct coroutine_traits { using promise_type = typename Ret::promise_type; };
+
+template 
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise &promise);
+  constexpr void* address() const noexcept;
+};
+template <>
+struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void* address() const noexcept;
+};
+
+struct awaitable {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+} // namespace std
+  )cpp";
+
+  StringRef Header = R"cpp(
+#include "coroutine.h"
+template  struct [[clang::coro_return_type]] Gen {
+  struct promise_type {
+Gen get_return_object() {
+  return {};
+}
+std::awaitable  initial_suspend();
+std::awaitable  final_suspend() noexcept;
+void unhandled_exception();
+void return_value(T t);
+  };
+};
+
+Gen foo_coro(int b) { co_return b; }
+  )cpp";
+  Annotations Main(R"cpp(
+#include "header.hpp"
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["coroutine.h"] = std::string(CoroutineH);
+  TU.AdditionalFiles["header.hpp"] = std::string(Header);
+  TU.ExtraArgs.push_back("--std=c++20");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 TEST(DiagnosticTest, MakeShared) {
   // We usually miss diagnostics from header functions as we don't parse them.
   // std::make_shared is only parsed when --parse-forwarding-functions is set
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ffbe317d559995..8329c00f1d16c1 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15845,7 +15845,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD)
+  if (!FD || FD->hasSkippedBody())
 return;
   RecordDecl *RD = FD->getReturnType()->getAsRecordDecl();
   if (!RD || !RD->getUnderlyingDecl()->hasAttr())

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


[clang] [clang-tools-extra] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-02 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clangd

Author: Utkarsh Saxena (usx95)


Changes

Without function bodies, we cannot tell whether a function is a coroutine or 
not.
The analysis of coroutine wrappers is not useful when this information is not 
available.

We therefore now skip this analysis for skipped function bodies.

---
Full diff: https://github.com/llvm/llvm-project/pull/76729.diff


2 Files Affected:

- (modified) clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp (+54) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 


``diff
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 37643e5afa2304..a5744cdd4cbe6f 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -420,6 +420,60 @@ TEST(DiagnosticTest, MakeUnique) {
"no matching constructor for initialization of 'S'")));
 }
 
+TEST(DiagnosticTest, CoroutineInHeader) {
+  StringRef CoroutineH = R"cpp(
+namespace std {
+template 
+struct coroutine_traits { using promise_type = typename Ret::promise_type; };
+
+template 
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise &promise);
+  constexpr void* address() const noexcept;
+};
+template <>
+struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void* address() const noexcept;
+};
+
+struct awaitable {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+} // namespace std
+  )cpp";
+
+  StringRef Header = R"cpp(
+#include "coroutine.h"
+template  struct [[clang::coro_return_type]] Gen {
+  struct promise_type {
+Gen get_return_object() {
+  return {};
+}
+std::awaitable  initial_suspend();
+std::awaitable  final_suspend() noexcept;
+void unhandled_exception();
+void return_value(T t);
+  };
+};
+
+Gen foo_coro(int b) { co_return b; }
+  )cpp";
+  Annotations Main(R"cpp(
+#include "header.hpp"
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["coroutine.h"] = std::string(CoroutineH);
+  TU.AdditionalFiles["header.hpp"] = std::string(Header);
+  TU.ExtraArgs.push_back("--std=c++20");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 TEST(DiagnosticTest, MakeShared) {
   // We usually miss diagnostics from header functions as we don't parse them.
   // std::make_shared is only parsed when --parse-forwarding-functions is set
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ffbe317d559995..8329c00f1d16c1 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15845,7 +15845,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD)
+  if (!FD || FD->hasSkippedBody())
 return;
   RecordDecl *RD = FD->getReturnType()->getAsRecordDecl();
   if (!RD || !RD->getUnderlyingDecl()->hasAttr())

``




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


[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2024-01-02 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/71157

>From 4e1b075a26db2831d981bad61ae883ede890bd58 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Fri, 3 Nov 2023 03:30:52 -0400
Subject: [PATCH] Clang/MIPS: Use -mnan value for -mabs if not specified

On most hardware, FCSR.ABS2008 is set the value same with FCSR.NAN2008.
Let's use this behaivor by default.

With this commit, `clang -target mips -mnan=2008 -c fabs.c` will
imply `-mabs=2008`.

And of course, `clang -mnan=2008 -mabs=legacy` can continue workable
like previous.
---
 clang/lib/Driver/ToolChains/Arch/Mips.cpp | 8 ++--
 clang/test/Driver/mips-features.c | 8 +++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index f9f14c01b2b9f0..fe9d112b8800b1 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -221,6 +221,7 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   bool IsN64 = ABIName == "64";
   bool IsPIC = false;
   bool NonPIC = false;
+  bool HasNaN2008Opt = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
 options::OPT_fpic, options::OPT_fno_pic,
@@ -285,9 +286,10 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) {
 StringRef Val = StringRef(A->getValue());
 if (Val == "2008") {
-  if (mips::getIEEE754Standard(CPUName) & mips::Std2008)
+  if (mips::getIEEE754Standard(CPUName) & mips::Std2008) {
 Features.push_back("+nan2008");
-  else {
+HasNaN2008Opt = true;
+  } else {
 Features.push_back("-nan2008");
 D.Diag(diag::warn_target_unsupported_nan2008) << CPUName;
   }
@@ -323,6 +325,8 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Val;
 }
+  } else if (HasNaN2008Opt) {
+Features.push_back("+abs2008");
   }
 
   AddTargetFeature(Args, Features, options::OPT_msingle_float,
diff --git a/clang/test/Driver/mips-features.c 
b/clang/test/Driver/mips-features.c
index 5ae566774959f1..fad6009ffb89ba 100644
--- a/clang/test/Driver/mips-features.c
+++ b/clang/test/Driver/mips-features.c
@@ -213,7 +213,13 @@
 // RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
 // RUN: -mnan=legacy -mnan=2008 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NAN2008 %s
-// CHECK-NAN2008: "-target-feature" "+nan2008"
+// CHECK-NAN2008: "-target-feature" "+nan2008" "-target-feature" "+abs2008"
+//
+// -mnan=2008 -mabs=legacy
+// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
+// RUN: -mabs=legacy -mnan=2008 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABSLEGACYNAN2008 %s
+// CHECK-ABSLEGACYNAN2008: "-target-feature" "+nan2008" "-target-feature" 
"-abs2008"
 //
 // -mnan=legacy
 // RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \

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


[clang] [clang][ASTImporter][StructuralEquivalence] improve StructuralEquivalence on recordType (PR #76226)

2024-01-02 Thread Balázs Kéri via cfe-commits


@@ -1491,6 +1492,12 @@ static bool 
IsRecordContextStructurallyEquivalent(RecordDecl *D1,
 return false;
 }
 
+if (auto *D1Spec = dyn_cast(DC1)) {
+  auto *D2Spec = dyn_cast(DC2);

balazske wrote:

It would be better to check if `D2Spec` is null.

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


[clang] [llvm] [clang][AArch64] Add a -mbranch-protection option to enable GCS (PR #75486)

2024-01-02 Thread John Brawn via cfe-commits

https://github.com/john-brawn-arm updated 
https://github.com/llvm/llvm-project/pull/75486

>From cceb8766d2c93cadc940b45f0817abc5e6d0a225 Mon Sep 17 00:00:00 2001
From: John Brawn 
Date: Wed, 13 Dec 2023 16:20:33 +
Subject: [PATCH] [clang][AArch64] Add a -mbranch-protection option to enable
 GCS

-mbranch-protection=gcs (enabled by -mbranch-protection=standard)
causes generated objects to be marked with the gcs feature. This is
done via the guarded-control-stack module flag, in a similar way to
branch-target-enforcement and sign-return-address.

Enabling GCS causes the GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit to be
set on generated objects. No code generation changes are required, as
GCS just requires that functions are called using BL and returned from
using RET (or other similar variant instructions), which is already
the case.
---
 clang/include/clang/Basic/LangOptions.def |  1 +
 clang/include/clang/Basic/TargetInfo.h|  1 +
 clang/include/clang/Driver/Options.td |  2 ++
 clang/lib/Basic/Targets/AArch64.cpp   |  7 +
 clang/lib/CodeGen/CodeGenModule.cpp   |  2 ++
 clang/lib/CodeGen/Targets/AArch64.cpp |  2 ++
 clang/lib/Driver/ToolChains/Clang.cpp |  6 +++-
 .../CodeGen/aarch64-branch-protection-attr.c  | 28 +++
 clang/test/CodeGen/aarch64-targetattr.c   |  2 +-
 clang/test/Driver/aarch64-security-options.c  | 11 +---
 .../Preprocessor/aarch64-target-features.c| 15 ++
 .../llvm/TargetParser/ARMTargetParserCommon.h |  1 +
 llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp |  5 
 .../TargetParser/ARMTargetParserCommon.cpp|  5 
 .../CodeGen/AArch64/note-gnu-property-gcs.ll  | 20 +
 15 files changed, 90 insertions(+), 18 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/note-gnu-property-gcs.ll

diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 21abc346cf17ac..0428b70c602062 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -457,6 +457,7 @@ ENUM_LANGOPT(SignReturnAddressKey, 
SignReturnAddressKeyKind, 1, SignReturnAddres
  "Key used for return address signing")
 LANGOPT(BranchTargetEnforcement, 1, 0, "Branch-target enforcement enabled")
 LANGOPT(BranchProtectionPAuthLR, 1, 0, "Use PC as a diversifier using PAuthLR 
NOP instructions.")
+LANGOPT(GuardedControlStack, 1, 0, "Guarded control stack enabled")
 
 LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load hardening enabled")
 
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index ac3c324c6c29c4..3eb23ebdacf0ed 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1373,6 +1373,7 @@ class TargetInfo : public TransferrableTargetInfo,
 LangOptions::SignReturnAddressKeyKind::AKey;
 bool BranchTargetEnforcement = false;
 bool BranchProtectionPAuthLR = false;
+bool GuardedControlStack = false;
   };
 
   /// Determine if the Architecture in this TargetInfo supports branch
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2b93ddf033499c..457e4e7a7e0c33 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7002,6 +7002,8 @@ def mbranch_target_enforce : Flag<["-"], 
"mbranch-target-enforce">,
   MarshallingInfoFlag>;
 def mbranch_protection_pauth_lr : Flag<["-"], "mbranch-protection-pauth-lr">,
   MarshallingInfoFlag>;
+def mguarded_control_stack : Flag<["-"], "mguarded-control-stack">,
+  MarshallingInfoFlag>;
 def fno_dllexport_inlines : Flag<["-"], "fno-dllexport-inlines">,
   MarshallingInfoNegativeFlag>;
 def cfguard_no_checks : Flag<["-"], "cfguard-no-checks">,
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 2f8395cb8932f2..9ebaf4d40cd7e5 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -226,6 +226,7 @@ bool AArch64TargetInfo::validateBranchProtection(StringRef 
Spec, StringRef,
 
   BPI.BranchTargetEnforcement = PBP.BranchTargetEnforcement;
   BPI.BranchProtectionPAuthLR = PBP.BranchProtectionPAuthLR;
+  BPI.GuardedControlStack = PBP.GuardedControlStack;
   return true;
 }
 
@@ -532,6 +533,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (Opts.BranchTargetEnforcement)
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
+  if (Opts.GuardedControlStack)
+Builder.defineMacro("__ARM_FEATURE_GCS_DEFAULT", "1");
+
   if (HasLS64)
 Builder.defineMacro("__ARM_FEATURE_LS64", "1");
 
@@ -544,6 +548,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasD128)
 Builder.defineMacro("__ARM_FEATURE_SYSREG128", "1");
 
+  if (HasGCS)
+Builder.defineMacro("__ARM_FEATURE_GCS", "1");
+
   if (*ArchInfo == llvm::AArch64::ARMV8_1A)
 getTargetDefinesARMV81

[clang] [Clang][Parser] Fix crash of clang when using C++ constructs like :: in C code (PR #74926)

2024-01-02 Thread via cfe-commits

https://github.com/ChipsSpectre updated 
https://github.com/llvm/llvm-project/pull/74926

>From 92ae6f1d822e704cfc8f03d6582772758af3aa66 Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Tue, 2 Jan 2024 17:14:21 +0100
Subject: [PATCH] [clang][Parse] `TryAnnotateCXXScopeToken` to be called only
 when parsing C++

Assume `TryAnnotateCXXScopeToken` to be parsing C++ code in all of its paths.

Fixes: https://github.com/llvm/llvm-project/issues/73559.
---
 clang/docs/ReleaseNotes.rst  | 6 --
 clang/lib/Parse/ParseDecl.cpp| 3 ++-
 clang/lib/Parse/ParseDeclCXX.cpp | 2 ++
 clang/test/Parser/cxx-in-c.c | 3 +++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c8fec691bf3c9..9a1f7d9f0bcd33 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -685,9 +685,11 @@ Bug Fixes in This Version
   (`#65568 `_)
 - Fix an issue where clang doesn't respect detault template arguments that
   are added in a later redeclaration for CTAD.
-  Fixes (#69987 `_)
+  Fixes (`#69987 `_)
 - Fix an issue where CTAD fails for explicit type conversion.
-  Fixes (#64347 `_)
+  Fixes (`#64347 `_)
+- Fix crash when using C++ only tokens like ``::`` in C compiler clang.
+  Fixes (`#73559 `_)
 
 
 Bug Fixes to Compiler Builtins
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ed006f9d67de45..b60ae293ef8c20 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3483,7 +3483,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 case tok::coloncolon: // ::foo::bar
   // C++ scope specifier.  Annotate and loop, or bail out on error.
-  if (TryAnnotateCXXScopeToken(EnteringContext)) {
+  if (getLangOpts().CPlusPlus &&
+  TryAnnotateCXXScopeToken(EnteringContext)) {
 if (!DS.hasTypeSpecifier())
   DS.SetTypeSpecError();
 goto DoneWithDeclSpec;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 910112ecae964c..d97081da4200de 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2679,6 +2679,8 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes &AccessAttrs,
const ParsedTemplateInfo &TemplateInfo,
ParsingDeclRAIIObject *TemplateDiags) {
+  assert(getLangOpts().CPlusPlus &&
+ "ParseCXXClassMemberDeclaration should only be called in C++ mode");
   if (Tok.is(tok::at)) {
 if (getLangOpts().ObjC && NextToken().isObjCAtKeyword(tok::objc_defs))
   Diag(Tok, diag::err_at_defs_cxx);
diff --git a/clang/test/Parser/cxx-in-c.c b/clang/test/Parser/cxx-in-c.c
index f5fa39bd0cb99b..034a44cdf12bfa 100644
--- a/clang/test/Parser/cxx-in-c.c
+++ b/clang/test/Parser/cxx-in-c.c
@@ -3,3 +3,6 @@
 // PR9137
 void f0(int x) : {}; // expected-error{{expected function body after function 
declarator}}
 void f1(int x) try {}; // expected-error{{expected function body after 
function declarator}}
+
+// GH73559
+::; // expected-error{{expected identifier or '('}}

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


[clang] [Clang][Parser] Fix crash of clang when using C++ constructs like :: in C code (PR #74926)

2024-01-02 Thread via cfe-commits

ChipsSpectre wrote:

Sorry @tbaederr, I made a mistake in fixing the ReleaseNotes.

Now I added the missing brackets to the link for this issue in the ReleaseNotes.

Could you merge the pull request now?

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


[clang] [clang-tools-extra] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-02 Thread Ilya Biryukov via cfe-commits


@@ -15845,7 +15845,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD)
+  if (!FD || FD->hasSkippedBody())

ilya-biryukov wrote:

Suggestion: a comment would be appropriate here, e.g. `// if we skip function 
body, we can't tell if a function is a coroutine`.

More serious request is to move this check up the call stack where we inspect 
`FSI` and call `isCoroutine()`. `CheckCoroutineWrapper` does not even look if 
the function is a coroutine or not, it merely looks at an attribute, which is 
available even if we skip the function body.

It's the calling code that should make sure `CheckCoroutineWrapper` should not 
be called for coroutines, so it's caller's responsibility to ensure this 
function is not called when it can't tell if a function is a coroutine or not.


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


[compiler-rt] [clang] [llvm] [clang-tools-extra] [Profile] Allow profile merging with multiple correlate files. (PR #75957)

2024-01-02 Thread Zequan Wu via cfe-commits


@@ -481,3 +509,49 @@ Error 
BinaryInstrProfCorrelator::correlateProfileNameImpl() {
   this->Names.append(this->Ctx->NameStart, this->Ctx->NameSize);
   return Error::success();
 }
+
+llvm::Expected> 
InstrProfCorrelators::get(
+ArrayRef>
+CorrelateInputs,
+uint32_t MaxWarnings) {
+  StringMap> CorrelatorMap;
+  StringMap FileMap;
+  auto WarnCounter =
+  std::make_unique(MaxWarnings);
+  std::unique_ptr CorrelateLock = std::make_unique();
+  std::unique_ptr WarnLock = std::make_unique();
+  for (const auto &Input : CorrelateInputs) {
+std::unique_ptr Correlator;
+if (auto Err = InstrProfCorrelator::get(Input.first, Input.second,
+*CorrelateLock.get(),
+*WarnLock.get(), WarnCounter.get())
+   .moveInto(Correlator))
+  return Err;
+std::string BuildID = toHex(Correlator->getBuildID());
+FileMap.try_emplace(BuildID, Input.first);
+bool Inserted =
+CorrelatorMap.try_emplace(BuildID, std::move(Correlator)).second;
+if (!Inserted && WarnCounter->shouldEmitWarning()) {
+  std::lock_guard Guard(*WarnLock);
+  WithColor::warning() << format(
+  "Duplicate build id (%s) found for %s and %s\n", BuildID.c_str(),
+  FileMap[BuildID].str().c_str(), Input.first.str().c_str());
+}
+  }
+  return std::make_unique(
+  std::move(CorrelatorMap), std::move(CorrelateLock), std::move(WarnLock),
+  std::move(WarnCounter));
+}
+
+llvm::Expected
+InstrProfCorrelators::getCorrelator(object::BuildIDRef BuildID) const {
+  std::string BuildIDStr = toHex(BuildID);
+  auto I = CorrelatorMap.find(BuildIDStr);
+  if (I == CorrelatorMap.end())
+return make_error(
+instrprof_error::unable_to_correlate_profile,
+"missing correlator file with build id " + BuildIDStr + "\n");
+  if (auto Err = I->getValue()->correlateProfileData())

ZequanWu wrote:

Right now, the parsing of correlation files is done before the parallelization 
starts. For each raw profiles, it parallelly associate parsed correlation info 
with lightweight raw profiles (which basically returns pointers to constant 
data and constant names)

> I guess we would still need an atomic counter to make sure we don't emit too 
> many warnings.

The warnings are only emitted at the time when parsing the correlation files 
which is before the parallelization starts. So, at least for now, we don't need 
atomic counter. If we want to parallelly parse correlation files, then we need 
lock or atomic counter to handle warning emissions.

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


[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-02 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/76733

Reuse the patterns governing the previous input file being formatted if the the 
current input file is from the same directory.

>From 7f8da18dc59706df8f1ee15d22076b4794881579 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 1 Jan 2024 19:10:30 -0800
Subject: [PATCH] [clang-format] Optimize processing .clang-format-ignore files

Reuse the patterns governing the previous input file being formatted if the
the current input file is from the same directory.
---
 clang/docs/ClangFormat.rst|  6 ++-
 clang/test/Format/clang-format-ignore.cpp | 17 +-
 clang/tools/clang-format/ClangFormat.cpp  | 65 ---
 3 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 8d4017b29fb8ee..819d9ee9f9cde1 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -131,6 +131,9 @@ An easy way to create the ``.clang-format`` file is:
 
 Available style options are described in :doc:`ClangFormatStyleOptions`.
 
+.clang-format-ignore
+
+
 You can create ``.clang-format-ignore`` files to make ``clang-format`` ignore
 certain files. A ``.clang-format-ignore`` file consists of patterns of file 
path
 names. It has the following format:
@@ -141,7 +144,8 @@ names. It has the following format:
 * A non-comment line is a single pattern.
 * The slash (``/``) is used as the directory separator.
 * A pattern is relative to the directory of the ``.clang-format-ignore`` file
-  (or the root directory if the pattern starts with a slash).
+  (or the root directory if the pattern starts with a slash). Patterns
+  containing drive names (e.g. ``C:``) are not supported.
 * Patterns follow the rules specified in `POSIX 2.13.1, 2.13.2, and Rule 1 of
   2.13.3 `_.
diff --git a/clang/test/Format/clang-format-ignore.cpp 
b/clang/test/Format/clang-format-ignore.cpp
index 0d6396a64a668d..4d0c4073308edc 100644
--- a/clang/test/Format/clang-format-ignore.cpp
+++ b/clang/test/Format/clang-format-ignore.cpp
@@ -29,5 +29,18 @@
 // RUN: grep "Formatting \[1/2] foo.c" %t.stderr
 // RUN: not grep "Formatting \[2/2] foo.js" %t.stderr
 
-// RUN: cd ../../..
-// RUN: rm -rf %t.dir
+// RUN: cd ../..
+// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
+// RUN: grep "Formatting \[1/5] level1/level2/foo.c" %t.stderr
+// RUN: not grep "Formatting \[2/5] level1/level2/foo.js" %t.stderr
+
+// RUN: rm .clang-format-ignore
+// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
+// RUN: grep "Formatting \[1/5] foo.cc" %t.stderr
+// RUN: grep "Formatting \[2/5] level1/bar.cc" %t.stderr
+// RUN: grep "Formatting \[3/5] level1/baz.c" %t.stderr
+// RUN: grep "Formatting \[4/5] level1/level2/foo.c" %t.stderr
+// RUN: not grep "Formatting \[5/5] level1/level2/foo.js" %t.stderr
+
+// RUN: cd ..
+// RUN: rm -r %t.dir
diff --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index be34dbbe886a15..787e56a6eccc0e 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -571,6 +571,11 @@ static int dumpConfig(bool IsSTDIN) {
   return 0;
 }
 
+using String = SmallString<128>;
+static String IgnoreDir; // Directory of .clang-format-ignore file.
+static StringRef PrevDir;// Directory of previous `FilePath`.
+static SmallVector Patterns; // Patterns in .clang-format-ignore file.
+
 // Check whether `FilePath` is ignored according to the nearest
 // .clang-format-ignore file based on the rules below:
 // - A blank line is skipped.
@@ -586,33 +591,50 @@ static bool isIgnored(StringRef FilePath) {
   if (!is_regular_file(FilePath))
 return false;
 
-  using namespace llvm::sys::path;
-  SmallString<128> Path, AbsPath{FilePath};
+  String Path;
+  String AbsPath{FilePath};
 
+  using namespace llvm::sys::path;
   make_absolute(AbsPath);
   remove_dots(AbsPath, /*remove_dot_dot=*/true);
 
-  StringRef IgnoreDir{AbsPath};
-  do {
-IgnoreDir = parent_path(IgnoreDir);
-if (IgnoreDir.empty())
+  if (StringRef Dir{parent_path(AbsPath)}; PrevDir != Dir) {
+PrevDir = Dir;
+
+for (;;) {
+  Path = Dir;
+  append(Path, ".clang-format-ignore");
+  if (is_regular_file(Path))
+break;
+  Dir = parent_path(Dir);
+  if (Dir.empty())
+return false;
+}
+
+IgnoreDir = convert_to_slash(Dir);
+
+std::ifstream IgnoreFile{Path.c_str()};
+if (!IgnoreFile.good())
   return false;
 
-Path = IgnoreDir;
-append(Path, ".clang-format-ignore");
-  } while (!is_regular_file(Path));
+Patterns.clear();
 
-  std::ifstream IgnoreFile{Path.c_str()};
-  if (!IgnoreFile.good())
-return false;
+for (std::string Line; std::getline(IgnoreFile, Line);) {
+  if (

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Owen Pan (owenca)


Changes

Reuse the patterns governing the previous input file being formatted if the the 
current input file is from the same directory.

---
Full diff: https://github.com/llvm/llvm-project/pull/76733.diff


3 Files Affected:

- (modified) clang/docs/ClangFormat.rst (+5-1) 
- (modified) clang/test/Format/clang-format-ignore.cpp (+15-2) 
- (modified) clang/tools/clang-format/ClangFormat.cpp (+45-20) 


``diff
diff --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 8d4017b29fb8ee..819d9ee9f9cde1 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -131,6 +131,9 @@ An easy way to create the ``.clang-format`` file is:
 
 Available style options are described in :doc:`ClangFormatStyleOptions`.
 
+.clang-format-ignore
+
+
 You can create ``.clang-format-ignore`` files to make ``clang-format`` ignore
 certain files. A ``.clang-format-ignore`` file consists of patterns of file 
path
 names. It has the following format:
@@ -141,7 +144,8 @@ names. It has the following format:
 * A non-comment line is a single pattern.
 * The slash (``/``) is used as the directory separator.
 * A pattern is relative to the directory of the ``.clang-format-ignore`` file
-  (or the root directory if the pattern starts with a slash).
+  (or the root directory if the pattern starts with a slash). Patterns
+  containing drive names (e.g. ``C:``) are not supported.
 * Patterns follow the rules specified in `POSIX 2.13.1, 2.13.2, and Rule 1 of
   2.13.3 `_.
diff --git a/clang/test/Format/clang-format-ignore.cpp 
b/clang/test/Format/clang-format-ignore.cpp
index 0d6396a64a668d..4d0c4073308edc 100644
--- a/clang/test/Format/clang-format-ignore.cpp
+++ b/clang/test/Format/clang-format-ignore.cpp
@@ -29,5 +29,18 @@
 // RUN: grep "Formatting \[1/2] foo.c" %t.stderr
 // RUN: not grep "Formatting \[2/2] foo.js" %t.stderr
 
-// RUN: cd ../../..
-// RUN: rm -rf %t.dir
+// RUN: cd ../..
+// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
+// RUN: grep "Formatting \[1/5] level1/level2/foo.c" %t.stderr
+// RUN: not grep "Formatting \[2/5] level1/level2/foo.js" %t.stderr
+
+// RUN: rm .clang-format-ignore
+// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
+// RUN: grep "Formatting \[1/5] foo.cc" %t.stderr
+// RUN: grep "Formatting \[2/5] level1/bar.cc" %t.stderr
+// RUN: grep "Formatting \[3/5] level1/baz.c" %t.stderr
+// RUN: grep "Formatting \[4/5] level1/level2/foo.c" %t.stderr
+// RUN: not grep "Formatting \[5/5] level1/level2/foo.js" %t.stderr
+
+// RUN: cd ..
+// RUN: rm -r %t.dir
diff --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index be34dbbe886a15..787e56a6eccc0e 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -571,6 +571,11 @@ static int dumpConfig(bool IsSTDIN) {
   return 0;
 }
 
+using String = SmallString<128>;
+static String IgnoreDir; // Directory of .clang-format-ignore file.
+static StringRef PrevDir;// Directory of previous `FilePath`.
+static SmallVector Patterns; // Patterns in .clang-format-ignore file.
+
 // Check whether `FilePath` is ignored according to the nearest
 // .clang-format-ignore file based on the rules below:
 // - A blank line is skipped.
@@ -586,33 +591,50 @@ static bool isIgnored(StringRef FilePath) {
   if (!is_regular_file(FilePath))
 return false;
 
-  using namespace llvm::sys::path;
-  SmallString<128> Path, AbsPath{FilePath};
+  String Path;
+  String AbsPath{FilePath};
 
+  using namespace llvm::sys::path;
   make_absolute(AbsPath);
   remove_dots(AbsPath, /*remove_dot_dot=*/true);
 
-  StringRef IgnoreDir{AbsPath};
-  do {
-IgnoreDir = parent_path(IgnoreDir);
-if (IgnoreDir.empty())
+  if (StringRef Dir{parent_path(AbsPath)}; PrevDir != Dir) {
+PrevDir = Dir;
+
+for (;;) {
+  Path = Dir;
+  append(Path, ".clang-format-ignore");
+  if (is_regular_file(Path))
+break;
+  Dir = parent_path(Dir);
+  if (Dir.empty())
+return false;
+}
+
+IgnoreDir = convert_to_slash(Dir);
+
+std::ifstream IgnoreFile{Path.c_str()};
+if (!IgnoreFile.good())
   return false;
 
-Path = IgnoreDir;
-append(Path, ".clang-format-ignore");
-  } while (!is_regular_file(Path));
+Patterns.clear();
 
-  std::ifstream IgnoreFile{Path.c_str()};
-  if (!IgnoreFile.good())
-return false;
+for (std::string Line; std::getline(IgnoreFile, Line);) {
+  if (const auto Pattern{StringRef{Line}.trim()};
+  // Skip empty and comment lines.
+  !Pattern.empty() && Pattern[0] != '#') {
+Patterns.push_back(Pattern);
+  }
+}
+  }
 
-  const auto Pathname = convert_to_slash(AbsPath);
-  for (std::string Line; std::ge

[compiler-rt] [clang] [llvm] [clang-tools-extra] [Profile] Allow profile merging with multiple correlate files. (PR #75957)

2024-01-02 Thread Zequan Wu via cfe-commits


@@ -118,18 +118,18 @@ cl::opt ProfiledBinary(
 "profiled-binary", cl::init(""),
 cl::desc("Path to binary from which the profile was collected."),
 cl::sub(ShowSubcommand), cl::sub(MergeSubcommand));
-cl::opt DebugInfoFilename(
-"debug-info", cl::init(""),
+cl::list DebugInfoFilenames(
+"debug-info",
 cl::desc(
 "For show, read and extract profile metadata from debug info and show "
 "the functions it found. For merge, use the provided debug info to "
 "correlate the raw profile."),
 cl::sub(ShowSubcommand), cl::sub(MergeSubcommand));
-cl::opt
-BinaryFilename("binary-file", cl::init(""),
-   cl::desc("For merge, use the provided unstripped bianry to "
-"correlate the raw profile."),
-   cl::sub(MergeSubcommand));
+cl::list
+BinaryFilenames("binary-file",
+cl::desc("For merge, use the provided unstripped bianry to 
"
+ "correlate the raw profile."),
+cl::sub(MergeSubcommand));

ZequanWu wrote:

> Another option would be to extend the pattern strings to support %b to expand 
> to the binary id or the binary name. Do you think that would work?

If the binary is built with binary id embedded, the raw profiles will also have 
binary id embedded. So there's no need to make `%b` expand to the binary id. 
The point for accepting multiple correlation files is to avoid some customizing 
scripts which associate raw profiles with different binaries. 

The output indexed profile file will contain profile information for multiple 
binaries. I'm not sure if this will cause problems/inconvenience for 
processing. What's your thoughts on this @gulfemsavrun @petrhosek?

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


[lld] [flang] [llvm] [libcxx] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -245,6 +267,18 @@ public:
 #  endif
   _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode 
__mode);
   basic_filebuf* close();
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
+_LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");

mordante wrote:

Yes, but we don't always write tests for it. If you write a test it should be 
new standalone test. This test won't be executed in all configurations. 
https://github.com/llvm/llvm-project/blob/main/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp
 is a nice example how to test this.

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


[clang] [X86] Emit Warnings for frontend options to enable knl/knm. (PR #75580)

2024-01-02 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

I think if we have an approach that allows people to emulate a very basic 
KNL/KNM implementation with the equivalent of "-march=x86-64-v3 -mavx512f 
-mavx512cd" then that would be sufficient. I do think we should be keeping 
-march/tune support though for the knl/knm cpu model names, but we shouldn't 
need to support the xeon phi specific ISAs.

We should keep asm handling for avx512er/avx512pf/etc but no need for 
attributes/intrinsics handling for them - if somebody needs to write assembly 
for them we shouldn't prevent it.

We should retain -march=native detection if we can, but not mandatory.

I also think we need a policy regarding what test coverage we need for various 
avx512 features (when should we assume avx512vl etc.)

Does that sound OK?

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


[polly] [clang] [llvm] [X86] Remove Intel Xeon Phi Supports. (PR #76383)

2024-01-02 Thread Simon Pilgrim via cfe-commits

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


[llvm] [polly] [clang] [X86] Remove Intel Xeon Phi Supports. (PR #76383)

2024-01-02 Thread Simon Pilgrim via cfe-commits


@@ -159,8 +159,6 @@
 #define bit_AVX512IFMA  0x0020
 #define bit_CLFLUSHOPT  0x0080
 #define bit_CLWB0x0100
-#define bit_AVX512PF0x0400
-#define bit_AVX512ER0x0800

RKSimon wrote:

I'd probably keep these for future reference.

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


[clang] [polly] [llvm] [X86] Remove Intel Xeon Phi Supports. (PR #76383)

2024-01-02 Thread Simon Pilgrim via cfe-commits

https://github.com/RKSimon commented:

I still think we should keep the knl/knm cpu models in place, even if they 
don't support all features anymore.

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


[clang] [llvm] [clang-tools-extra] Add out-of-line-atomics support to GlobalISel (PR #74588)

2024-01-02 Thread Thomas Preud'homme via cfe-commits

RoboTux wrote:

My apologies @arsenm, I had missed your review comments. All fixed now.

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


[clang] [clang][Darwin] Remove legacy framework search path logic in the frontend (PR #75841)

2024-01-02 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

same in our stage 2 build

```
 [4643/5157] Building CXX object 
tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o
 FAILED: tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o 
 
/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-bootstrap-install/bin/clang++
 -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/tools/dsymutil
 -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/tools/dsymutil 
-I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/include
 -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/include 
-isystem 
/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build-tools/zstd-1.5.5/cmake_build/install/include
 -DSANITIZER_OVERRIDE_INTERCEPTORS 
-I/Volumes/Work/s/w/ir/cache/builder/src/tools/clang/scripts/sanitizers 
-DLIBXML_STATIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-fprofile-instr-use="/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-instrumented/profdata.prof"
 -O3 -DNDEBUG -std=c++17 -isysroot 
/Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk
 -mmacosx-version-min=10.12  -fno-exceptions -fno-unwind-tables 
-fno-asynchronous-unwind-tables -fno-rtti -MD -MT 
tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o -MF 
tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o.d -o 
tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o -c 
/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/tools/dsymutil/CFBundle.cpp
 
/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/tools/dsymutil/CFBundle.cpp:15:10:
 fatal error: 'CoreFoundation/CoreFoundation.h' file not found
15 | #include 
   |  ^
 1 error generated.
```

if this is intended to be NFC but isn't, then we should probably revert

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


[flang] [libcxx] [llvm] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits

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


[libcxx] [lld] [llvm] [clang] [flang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -245,6 +267,18 @@ public:
 #  endif
   _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode 
__mode);
   basic_filebuf* close();
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
+_LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");
+#if defined(_LIBCPP_WIN32API)
+return __filebuf_windows_native_handle(__file_);

mordante wrote:

```suggestion
return std::__filebuf_windows_native_handle(__file_);
```

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


[lld] [llvm] [libcxx] [flang] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,81 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#if _LIBCPP_STD_VER >= 26
+
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+
+#  if defined(_LIBCPP_WIN32API)
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#  else
+#include 
+#  endif
+
+#  include "platform_support.h"
+
+#  if defined(_LIBCPP_WIN32API)
+using HandleT = void*; // HANDLE
+
+bool is_handle_valid(void* handle) {

mordante wrote:

```suggestion
inline bool is_handle_valid(void* handle) {
```
The same for the other functions in the header.

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


[libcxx] [lld] [flang] [llvm] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits

https://github.com/mordante requested changes to this pull request.

I did a full review. There are a number of comments, once these are addressed 
the patch is ready.

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


[llvm] [lld] [flang] [libcxx] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -245,6 +267,18 @@ public:
 #  endif
   _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode 
__mode);
   basic_filebuf* close();
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
+_LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");
+#if defined(_LIBCPP_WIN32API)
+return __filebuf_windows_native_handle(__file_);
+#elif __has_include()
+return fileno(__file_);
+#else
+#  error "Provide a way to determine the file native handle!"
+#endif
+  }
+#  endif

mordante wrote:

```suggestion
#  endif //  _LIBCPP_STD_VER >= 26
```

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


[lld] [flang] [llvm] [libcxx] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,81 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#if _LIBCPP_STD_VER >= 26

mordante wrote:

I would remove this, it's only called from code that uses C++26.

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


[clang] [lld] [libcxx] [llvm] [flang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,58 @@
+//===--===//

mordante wrote:

Not related to this file. But I miss tests for the typedefs added to the 4 
classes. These are typically in the types tests. For example, 
libcxx/test/std/input.output/file.streams/fstreams/filebuf/types.pass.cpp. When 
adding the test make sure you test all the wording
```
The type native_handle_type represents a platform-specific native handle
to a file. It is trivially copyable and models semiregular.
```

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


[lld] [llvm] [clang] [libcxx] [flang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,58 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// class basic_filebuf;
+
+// native_handle_type native_handle() const noexcept;
+
+#include 
+#include 
+#include 
+#include 
+
+#include "platform_support.h"
+#include "test_macros.h"
+#include "../test_helpers.h"
+
+template 
+void test() {
+  HandleT native_handle{};
+  HandleT const_native_handle{};
+
+  {
+std::basic_filebuf f;
+assert(!f.is_open());

mordante wrote:

We don't need this assert, the second `is_open()` assert could be replaced by
`assert(f.open(p, std::ios_base::in) != nullptr);

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


[lld] [flang] [libcxx] [llvm] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-02 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,81 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#if _LIBCPP_STD_VER >= 26
+
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+
+#  if defined(_LIBCPP_WIN32API)

mordante wrote:

We shouldn't use libc++ macro's in our tests. Other libraries can also use 
them. MSVC STL does. Use the appropriate macro from platform_support.h.

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


  1   2   3   >