[PATCH] D115492: [LTO] Ignore unreachable virtual functions in WPD in hybrid LTO

2021-12-09 Thread Mingming Liu via Phabricator via cfe-commits
luna created this revision.
Herald added subscribers: ormris, pengfei, arphaman, steven_wu, hiraditya, 
inglorion.
luna requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

- In FunctionSummary, add a new bit `mustBeUnreachable`.

- In ModuleSummaryAnalysis, set this bit to 1 if a function is unreachable.

- For hybrid LTO, ignore unreachable functions (by reading from index) when 
finding virtual functions. This helps to de-virtualize. See the test case in 
llvm/test/ThinLTO/X86/devirt_hybrid_after_filtering_unreachable.ll


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115492

Files:
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  clang/test/CodeGen/thinlto-distributed-cfi.ll
  clang/test/CodeGen/thinlto-funcattr-prop.ll
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/Assembler/thinlto-summary.ll
  llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
  llvm/test/Bitcode/thinlto-type-vcalls.ll
  llvm/test/ThinLTO/X86/Inputs/devirt_hybrid_after_filtering_unreachable_lib.ll
  llvm/test/ThinLTO/X86/devirt_hybrid_after_filtering_unreachable.ll
  llvm/test/ThinLTO/X86/devirt_single_hybrid.ll
  llvm/test/ThinLTO/X86/dot-dumper.ll
  llvm/test/ThinLTO/X86/dot-dumper2.ll
  llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
  llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll

Index: llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
===
--- llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
+++ llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
@@ -23,4 +23,4 @@
 }
 
 attributes #0 = { alwaysinline nounwind uwtable }
-; CHECK2: ^2 = gv: (guid: {{.*}}, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 1, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0
+; CHECK2: ^2 = gv: (guid: {{.*}}, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 1, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0
Index: llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
===
--- llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
+++ llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
@@ -48,9 +48,9 @@
 ; CHECK-DAG: attributes [[ATTR_NOUNWIND]] = { norecurse nounwind }
 ; CHECK-DAG: attributes [[ATTR_MAYTHROW]] = { norecurse }
 
-; SUMMARY-DAG: = gv: (name: "cleanupret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
-; SUMMARY-DAG: = gv: (name: "resume", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
-; SUMMARY-DAG: = gv: (name: "catchret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 5, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "cleanupret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "resume", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0,

[PATCH] D115320: Avoid setting tbaa information on store of return type of call to inline assember

2021-12-09 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added a comment.

In D115320#3182581 , 
@jeroen.dobbelaere wrote:

> When I try out the example on llvm-13, I get a 'omnipotent char' tbaa 
> description. That should be ok in general. When I replace the 'float 
> _Complex' with 'double', I do get the 'double' tbaa. That might be a better 
> example for the testcase ?

Good point. I updated the test with this suggestion. Thank you.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115320/new/

https://reviews.llvm.org/D115320

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


[PATCH] D115320: Avoid setting tbaa information on store of return type of call to inline assember

2021-12-09 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 393381.
schittir added a comment.

Updated test per Jeroen's suggestion


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115320/new/

https://reviews.llvm.org/D115320

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/avoidTBAAonASMstore.cpp


Index: clang/test/CodeGen/avoidTBAAonASMstore.cpp
===
--- /dev/null
+++ clang/test/CodeGen/avoidTBAAonASMstore.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -disable-llvm-passes 
-fasm-blocks %s -emit-llvm -o - | FileCheck %s
+double foo(double z) {
+// CHECK-LABEL: define{{.*}} double @_Z3food
+   unsigned short ControlWord;
+   __asm { fnstcw word ptr[ControlWord] };
+// CHECK: store i64 %2, i64* %1, align 4
+// CHECK-NOT: !tbaa
+   return z;
+}
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -746,6 +746,9 @@
   /// an object of the given type.
   TBAAAccessInfo getTBAAAccessInfo(QualType AccessType);
 
+  /// returnNullTBAA - Return empty TBAA constructor
+  TBAAAccessInfo returnNullTBAA();
+
   /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an
   /// access to a virtual table pointer.
   TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -935,6 +935,8 @@
   return TBAA->getAccessInfo(AccessType);
 }
 
+TBAAAccessInfo CodeGenModule::returnNullTBAA() { return TBAAAccessInfo(); }
+
 TBAAAccessInfo
 CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType) {
   if (!TBAA)
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2504,6 +2504,13 @@
 BaseInfo, TBAAInfo);
   }
 
+  LValue
+  MakeAddrLValueWithoutTBAA(Address Addr, QualType T,
+AlignmentSource Source = AlignmentSource::Type) {
+return LValue::MakeAddr(Addr, T, getContext(), LValueBaseInfo(Source),
+CGM.returnNullTBAA());
+  }
+
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
   LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T);
 
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2454,7 +2454,7 @@
 const ABIArgInfo &RetAI = CurFnInfo->getReturnInfo();
 if (RetAI.isDirect() || RetAI.isExtend()) {
   // Make a fake lvalue for the return value slot.
-  LValue ReturnSlot = MakeAddrLValue(ReturnValue, FnRetTy);
+  LValue ReturnSlot = MakeAddrLValueWithoutTBAA(ReturnValue, FnRetTy);
   CGM.getTargetCodeGenInfo().addReturnRegisterOutputs(
   *this, ReturnSlot, Constraints, ResultRegTypes, ResultTruncRegTypes,
   ResultRegDests, AsmString, S.getNumOutputs());


Index: clang/test/CodeGen/avoidTBAAonASMstore.cpp
===
--- /dev/null
+++ clang/test/CodeGen/avoidTBAAonASMstore.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -disable-llvm-passes -fasm-blocks %s -emit-llvm -o - | FileCheck %s
+double foo(double z) {
+// CHECK-LABEL: define{{.*}} double @_Z3food
+	unsigned short ControlWord;
+	__asm { fnstcw word ptr[ControlWord] };
+// CHECK: store i64 %2, i64* %1, align 4
+// CHECK-NOT: !tbaa
+	return z;
+}
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -746,6 +746,9 @@
   /// an object of the given type.
   TBAAAccessInfo getTBAAAccessInfo(QualType AccessType);
 
+  /// returnNullTBAA - Return empty TBAA constructor
+  TBAAAccessInfo returnNullTBAA();
+
   /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an
   /// access to a virtual table pointer.
   TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -935,6 +935,8 @@
   return TBAA->getAccessInfo(AccessType);
 }
 
+TBAAAccessInfo CodeGenModule::returnNullTBAA() { return TBAAAccessInfo(); }
+
 TBAAAccessInfo
 CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType) {
   if (!TBAA)
Index: clang/lib/CodeGen/CodeGenFunction.h

[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-12-09 Thread Yueh-Ting Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4bf1b449dc0: [RISCV] Unify depedency check and extension 
implication parsing logics (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112359/new/

https://reviews.llvm.org/D112359

Files:
  clang/test/CodeGen/RISCV/riscv-metadata.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c
  clang/test/CodeGen/riscv32-ilp32d-abi.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/attribute-arch-invalid.s
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -33,47 +33,46 @@
 .attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
-.attribute arch, "rv32iv"
+## Experimental extensions require version string to be explicitly specified
+
+.attribute arch, "rv32iv0p10"
 # CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
 
-.attribute arch, "rv32izba"
+.attribute arch, "rv32izba1p0"
 # CHECK: attribute  5, "rv32i2p0_zba1p0"
 
-.attribute arch, "rv32izbb"
+.attribute arch, "rv32izbb1p0"
 # CHECK: attribute  5, "rv32i2p0_zbb1p0"
 
-.attribute arch, "rv32izbc"
+.attribute arch, "rv32izbc1p0"
 # CHECK: attribute  5, "rv32i2p0_zbc1p0"
 
-.attribute arch, "rv32izbe"
+.attribute arch, "rv32izbe0p93"
 # CHECK: attribute  5, "rv32i2p0_zbe0p93"
 
-.attribute arch, "rv32izbf"
+.attribute arch, "rv32izbf0p93"
 # CHECK: attribute  5, "rv32i2p0_zbf0p93"
 
-.attribute arch, "rv32izbm"
+.attribute arch, "rv32izbm0p93"
 # CHECK: attribute  5, "rv32i2p0_zbm0p93"
 
-.attribute arch, "rv32izbp"
+.attribute arch, "rv32izbp0p93"
 # CHECK: attribute  5, "rv32i2p0_zbp0p93"
 
-.attribute arch, "rv32izbr"
+.attribute arch, "rv32izbr0p93"
 # CHECK: attribute  5, "rv32i2p0_zbr0p93"
 
-.attribute arch, "rv32izbs"
+.attribute arch, "rv32izbs1p0"
 # CHECK: attribute  5, "rv32i2p0_zbs1p0"
 
-.attribute arch, "rv32izbt"
+.attribute arch, "rv32izbt0p93"
 # CHECK: attribute  5, "rv32i2p0_zbt0p93"
 
-.attribute arch, "rv32ifzfhmin"
+.attribute arch, "rv32ifzfhmin0p1"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfhmin0p1"
 
-.attribute arch, "rv32ifzfh"
+.attribute arch, "rv32ifzfh0p1"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1_zfhmin0p1"
 
-.attribute arch, "rv32ivzvamo_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
-
-.attribute arch, "rv32iv_zvamo0p10_zvlsseg"
+.attribute arch, "rv32iv0p10zvamo0p10_zvlsseg0p10"
 # CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
Index: llvm/test/MC/RISCV/attribute-arch-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/attribute-arch-invalid.s
@@ -0,0 +1,48 @@
+## Invalid arch string
+
+# RUN: not llvm-mc -triple riscv32 < %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -triple riscv64 < %s 2>&1 | FileCheck %s
+
+## Version strings are required for experimental extensions
+
+.attribute arch, "rv32iv"
+# CHECK: error: invalid arch name 'rv32iv', experimental extension requires explicit version number `v`
+
+.attribute arch, "rv32izba"
+# CHECK: error: invalid arch name 'rv32izba', experimental extension requires explicit version number `zba`
+
+.attribute arch, "rv32izbb"
+# CHECK: error: invalid arch name 'rv32izbb', experimental extension requires explicit version number `zbb`
+
+.attribute arch, "rv32izbc"
+# CHECK: error: invalid arch name 'rv32izbc', experimental extension requires explicit version number `zbc`
+
+.attribute arch, "rv32izbe"
+# CHECK:  error: invalid arch name 'rv32izbe', experimental extension requires explicit version number `zbe`
+
+.attribute arch, "rv32izbf"
+# CHECK: error: invalid arch name 'rv32izbf', experimental extension requires explicit version number `zbf`
+
+.attribute arch, "rv32izbm"
+# CHECK: error: invalid arch name 'rv32izbm', experimental extension requires explicit version number `zbm`
+
+.attribute arch, "rv32izbp"
+# CHECK: error: invalid arch name 'rv32izbp', experimental extension requires explicit version number `zbp`
+
+.attribute arch, "rv32izbr"
+# CHECK: error: invalid arch name 'rv32izbr', experimental extension requires explicit version number `zbr`
+
+.attribute arch, "rv32izbs"
+# CHECK: error: invalid arch name 'rv32izbs', experimental extension requires explicit version number `zbs`
+
+.attribute arch, "rv32izbt"
+# CHECK: error: invalid arch name 'rv32izbt', experim

[clang] a4bf1b4 - [RISCV] Unify depedency check and extension implication parsing logics

2021-12-09 Thread via cfe-commits

Author: eopXD
Date: 2021-12-09T21:16:04-08:00
New Revision: a4bf1b449dc0691e182db879bfb53bc52fbf11b7

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

LOG: [RISCV] Unify depedency check and extension implication parsing logics

Originially there are two places that does parsing - `parseArchString` and
`parseFeatures`, each with its code on dependency check and implication.
This patch extracts common parts of the two  as functions of `RISCVISAInfo`
and let them 2 use it.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D112359

Added: 
llvm/test/MC/RISCV/attribute-arch-invalid.s

Modified: 
clang/test/CodeGen/RISCV/riscv-metadata.c
clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c
clang/test/CodeGen/riscv32-ilp32d-abi.cpp
llvm/include/llvm/Support/RISCVISAInfo.h
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/attribute-arch.s

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/riscv-metadata.c 
b/clang/test/CodeGen/RISCV/riscv-metadata.c
index 19bde4ca73beb..3e5b2b855bf5c 100644
--- a/clang/test/CodeGen/RISCV/riscv-metadata.c
+++ b/clang/test/CodeGen/RISCV/riscv-metadata.c
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | 
FileCheck -check-prefix=ILP32 %s
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
-// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-feature +f 
-target-abi ilp32d -emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
 // RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | 
FileCheck -check-prefix=LP64 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-feature +f 
-target-abi lp64d -emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
 
 // ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
 // ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}

diff  --git a/clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
index 1bf953d39038b..5a5c47a3088cd 100644
--- a/clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
+++ b/clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
@@ -3,7 +3,7 @@
 // RUN:   | FileCheck %s -check-prefixes=CHECK,CHECK-FORCEINT128
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm %s -o - \
 // RUN: | FileCheck %s
-// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm %s -o - \
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-feature +f 
-target-abi ilp32d -emit-llvm %s -o - \
 // RUN: | FileCheck %s
 
 // This file contains test cases that will have the same output for the ilp32,

diff  --git a/clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
index 39a210a89ae79..523a4668ff6e7 100644
--- a/clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
+++ b/clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm %s -o - \
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-feature +f 
-target-abi ilp32d -emit-llvm %s -o - \
 // RUN: | FileCheck %s
 
 #include 

diff  --git a/clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
index e887d986f96a3..1de7d51c4fbc4 100644
--- a/clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
+++ b/clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm %s -o - \
 // RUN: | FileCheck %s
-// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm %s -o - \
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-feature +f 
-target-abi ilp32d -emit-llvm %s -o - \
 // RUN: | FileCheck %s
 
 #include 

diff  --git a/clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c 
b/clang/test/CodeGen/RIS

[PATCH] D109215: [RISCV] Fix arch string parsing for multi-character extensions

2021-12-09 Thread Yueh-Ting Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe308b8e0c71b: [RISCV] Fix arch string parsing for 
multi-character extensions (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109215/new/

https://reviews.llvm.org/D109215

Files:
  clang/test/Driver/riscv-arch.c
  llvm/lib/Support/RISCVISAInfo.cpp


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -72,6 +72,28 @@
   return Ext.consume_front("experimental-");
 }
 
+// This function finds the first character that doesn't belong to a version
+// (e.g. zbe0p93 is extension 'zbe' of version '0p93'). So the function will
+// consume [0-9]*p[0-9]* starting from the backward. An extension name will not
+// end with a digit or the letter 'p', so this function will parse correctly.
+// NOTE: This function is NOT able to take empty strings or strings that only
+// have version numbers and no extension name. It assumes the extension name
+// will be at least more than one character.
+static size_t findFirstNonVersionCharacter(const StringRef &Ext) {
+  if (Ext.size() == 0)
+llvm_unreachable("Already guarded by if-statement in ::parseArchString");
+
+  int Pos = Ext.size() - 1;
+  while (Pos > 0 && isDigit(Ext[Pos]))
+Pos--;
+  if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) {
+Pos--;
+while (Pos > 0 && isDigit(Ext[Pos]))
+  Pos--;
+  }
+  return Pos;
+}
+
 struct FindByName {
   FindByName(StringRef Ext) : Ext(Ext){};
   StringRef Ext;
@@ -638,7 +660,7 @@
 
 StringRef Type = getExtensionType(Ext);
 StringRef Desc = getExtensionTypeDesc(Ext);
-auto Pos = Ext.find_if(isDigit);
+size_t Pos = findFirstNonVersionCharacter(Ext) + 1;
 StringRef Name(Ext.substr(0, Pos));
 StringRef Vers(Ext.substr(Pos));
 
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -392,7 +392,7 @@
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izbb1p0zbp0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE %s
-// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb1p0zbp0p93', multi-character extensions must be separated by 
underscores
+// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb1p0zbp0p93', unsupported version number 0.93 for extension 'zbb1p0zbp'
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izba1p0 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBA %s


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -72,6 +72,28 @@
   return Ext.consume_front("experimental-");
 }
 
+// This function finds the first character that doesn't belong to a version
+// (e.g. zbe0p93 is extension 'zbe' of version '0p93'). So the function will
+// consume [0-9]*p[0-9]* starting from the backward. An extension name will not
+// end with a digit or the letter 'p', so this function will parse correctly.
+// NOTE: This function is NOT able to take empty strings or strings that only
+// have version numbers and no extension name. It assumes the extension name
+// will be at least more than one character.
+static size_t findFirstNonVersionCharacter(const StringRef &Ext) {
+  if (Ext.size() == 0)
+llvm_unreachable("Already guarded by if-statement in ::parseArchString");
+
+  int Pos = Ext.size() - 1;
+  while (Pos > 0 && isDigit(Ext[Pos]))
+Pos--;
+  if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) {
+Pos--;
+while (Pos > 0 && isDigit(Ext[Pos]))
+  Pos--;
+  }
+  return Pos;
+}
+
 struct FindByName {
   FindByName(StringRef Ext) : Ext(Ext){};
   StringRef Ext;
@@ -638,7 +660,7 @@
 
 StringRef Type = getExtensionType(Ext);
 StringRef Desc = getExtensionTypeDesc(Ext);
-auto Pos = Ext.find_if(isDigit);
+size_t Pos = findFirstNonVersionCharacter(Ext) + 1;
 StringRef Name(Ext.substr(0, Pos));
 StringRef Vers(Ext.substr(Pos));
 
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -392,7 +392,7 @@
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izbb1p0zbp0p93 -menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE %s
-// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 'rv32izbb1p0zbp0p93', multi-character extensions must be separated by underscores
+// RV32-EXPERIMENTAL-ZBB-

[clang] e308b8e - [RISCV] Fix arch string parsing for multi-character extensions

2021-12-09 Thread via cfe-commits

Author: eopXD
Date: 2021-12-09T21:13:44-08:00
New Revision: e308b8e0c71b5ce783035d73722f59d395245cf9

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

LOG: [RISCV] Fix arch string parsing for multi-character extensions

Current implementation can't parse extension names that contains digits
correctly (e.g. `zvl128b`). This patch fixes it.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D109215

Added: 


Modified: 
clang/test/Driver/riscv-arch.c
llvm/lib/Support/RISCVISAInfo.cpp

Removed: 




diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index bbbc0f3ded78a..5b99643309a57 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -392,7 +392,7 @@
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izbb1p0zbp0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE %s
-// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb1p0zbp0p93', multi-character extensions must be separated by 
underscores
+// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb1p0zbp0p93', unsupported version number 0.93 for extension 'zbb1p0zbp'
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izba1p0 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBA %s

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 8e984002f90d2..1ca2120c40750 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -72,6 +72,28 @@ static bool stripExperimentalPrefix(StringRef &Ext) {
   return Ext.consume_front("experimental-");
 }
 
+// This function finds the first character that doesn't belong to a version
+// (e.g. zbe0p93 is extension 'zbe' of version '0p93'). So the function will
+// consume [0-9]*p[0-9]* starting from the backward. An extension name will not
+// end with a digit or the letter 'p', so this function will parse correctly.
+// NOTE: This function is NOT able to take empty strings or strings that only
+// have version numbers and no extension name. It assumes the extension name
+// will be at least more than one character.
+static size_t findFirstNonVersionCharacter(const StringRef &Ext) {
+  if (Ext.size() == 0)
+llvm_unreachable("Already guarded by if-statement in ::parseArchString");
+
+  int Pos = Ext.size() - 1;
+  while (Pos > 0 && isDigit(Ext[Pos]))
+Pos--;
+  if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) {
+Pos--;
+while (Pos > 0 && isDigit(Ext[Pos]))
+  Pos--;
+  }
+  return Pos;
+}
+
 struct FindByName {
   FindByName(StringRef Ext) : Ext(Ext){};
   StringRef Ext;
@@ -638,7 +660,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool 
EnableExperimentalExtension,
 
 StringRef Type = getExtensionType(Ext);
 StringRef Desc = getExtensionTypeDesc(Ext);
-auto Pos = Ext.find_if(isDigit);
+size_t Pos = findFirstNonVersionCharacter(Ext) + 1;
 StringRef Name(Ext.substr(0, Pos));
 StringRef Vers(Ext.substr(Pos));
 



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


[PATCH] D114728: [Coroutine] Remove the prologue data of `-fsanitize=function` for split functions

2021-12-09 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D114728#3159303 , @rjmccall wrote:

> I agree that coroutine resumption functions have a different formal type from 
> the ramp function and so would need different treatment from 
> `-fsanitize=functions` if it wants to sanitize the resumption calls, which I 
> guess it currently doesn't.  So something here may be a necessary fix.
>
> However, I don't think it's a sufficient fix for PR 50345, because the way 
> that the frontend currently creates these prologue attributes is deeply 
> problematic for any number of function transformations, not just coroutine 
> splitting.  For example, any sort of function-cloning transformation will end 
> up constructing an incorrect relative reference.  I expect that this 
> self-reference will also interfere with DCE.  So in addition to whatever 
> function-type fix we need for coroutines, we just need to change how we 
> create this prologue.  I recommend the design I laid out in the PR:
>
> - Have the frontend emit a more abstract attribute, like 
> `sanitize_function_type(i8** @1)`
> - Either lower this abstract attribute in a codegen pass by turning it into a 
> `prologue` attribute or just handle it directly in the appropriate backend.
>
> The coroutine part of the fix would then simply be to remove the 
> `sanitize_function_type` attribute from the resumption function clones; or 
> better yet, switch the coro.switch lowering to use the "prototype" design 
> used by coro.retcon and coro.async, and then set the appropriate attribute 
> (if any) on the prototype so that it will be cloned into the resumption 
> functions.
>
> In the meantime, this sanitizer should be disabled in 13.x.

Hi @rjmccall, I gave this some thought, this `sanitize_function_type` attribute 
would be a prefix/prologue thing instead of a function attribute since it needs 
to take a constant value 
(https://github.com/llvm/llvm-project/blob/a32c2c380863d02eb0fd5e8757a62d96114b9519/llvm/lib/IR/Function.cpp#L1854)
 for the RTTI global variable. Then it needs some corresponding change in the 
bitcode representation. It seems easier just represent it as a metadata node 
attached to a function. This aligns with the intention

In D114728#3159303 , @rjmccall wrote:

> I agree that coroutine resumption functions have a different formal type from 
> the ramp function and so would need different treatment from 
> `-fsanitize=functions` if it wants to sanitize the resumption calls, which I 
> guess it currently doesn't.  So something here may be a necessary fix.
>
> However, I don't think it's a sufficient fix for PR 50345, because the way 
> that the frontend currently creates these prologue attributes is deeply 
> problematic for any number of function transformations, not just coroutine 
> splitting.  For example, any sort of function-cloning transformation will end 
> up constructing an incorrect relative reference.  I expect that this 
> self-reference will also interfere with DCE.  So in addition to whatever 
> function-type fix we need for coroutines, we just need to change how we 
> create this prologue.  I recommend the design I laid out in the PR:
>
> - Have the frontend emit a more abstract attribute, like 
> `sanitize_function_type(i8** @1)`
> - Either lower this abstract attribute in a codegen pass by turning it into a 
> `prologue` attribute or just handle it directly in the appropriate backend.
>
> The coroutine part of the fix would then simply be to remove the 
> `sanitize_function_type` attribute from the resumption function clones; or 
> better yet, switch the coro.switch lowering to use the "prototype" design 
> used by coro.retcon and coro.async, and then set the appropriate attribute 
> (if any) on the prototype so that it will be cloned into the resumption 
> functions.
>
> In the meantime, this sanitizer should be disabled in 13.x.

Hi @rjmccall , I'm working on a patch for this with the 
`sanitize_function_type` attribute idea. However, I'm wondering if it makes 
sense to you to use a metadata node on the function instead.  A function 
attribute may not work because it can not point to the RTTI global variable. 
Something equivalent to the "function 
prologue"(https://llvm.org/docs/LangRef.html#prologue-data, it is basically a 
hidden operand of a function) is possible but that requires bitcode & IR 
text/parsing changes, which I'm trying to avoid (unless I have to). WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114728/new/

https://reviews.llvm.org/D114728

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


[PATCH] D115490: [clangd] Include fixer for missing functions in C

2021-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

A function call `unresolved()` in C will generate an implicit declaration
of the missing function and warn `ext_implicit_function_decl` or so.
(Compared to in C++ where we get `err_undeclared_var_use`).
We want to try to resolve these names.

Unfortunately typo correction is disabled in sema for performance
reasons unless this warning is promoted to error.
(We need typo correction for include-fixer.)
It's not clear to me where a switch to force this correction on should
go, include-fixer is kind of a hack. So hack more by telling sema we're
promoting them to error.

Fixes https://github.com/clangd/clangd/issues/937


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115490

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/lib/Sema/SemaDecl.cpp

Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14985,7 +14985,21 @@
 diag_id = diag::ext_implicit_function_decl;
   else
 diag_id = diag::warn_implicit_function_decl;
+
+  TypoCorrection Corrected;
+  // Because typo correction is expensive, only do it if the implicit
+  // function declaration is going to be treated as an error.
+  if (S && !ExternCPrev &&
+  (Diags.getDiagnosticLevel(diag_id, Loc) >= DiagnosticsEngine::Error)) {
+DeclFilterCCC CCC{};
+Corrected = CorrectTypo(DeclarationNameInfo(&II, Loc), LookupOrdinaryName,
+S, nullptr, CCC, CTK_NonError);
+  }
+
   Diag(Loc, diag_id) << &II;
+  if (Corrected)
+diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
+ /*ErrorRecovery*/ false);
 
   // If we found a prior declaration of this function, don't bother building
   // another one. We've already pushed that one into scope, so there's nothing
@@ -14993,18 +15007,6 @@
   if (ExternCPrev)
 return ExternCPrev;
 
-  // Because typo correction is expensive, only do it if the implicit
-  // function declaration is going to be treated as an error.
-  if (Diags.getDiagnosticLevel(diag_id, Loc) >= DiagnosticsEngine::Error) {
-TypoCorrection Corrected;
-DeclFilterCCC CCC{};
-if (S && (Corrected =
-  CorrectTypo(DeclarationNameInfo(&II, Loc), LookupOrdinaryName,
-  S, nullptr, CCC, CTK_NonError)))
-  diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
-   /*ErrorRecovery*/false);
-  }
-
   // Set a Declarator for the implicit definition: int foo();
   const char *Dummy;
   AttributeFactory attrFactory;
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1222,6 +1222,31 @@
   "Include  for symbol printf");
 }
 
+TEST(IncludeFixerTest, CImplicitFunctionDecl) {
+  Annotations Test("void x() { [[foo]](); }");
+  auto TU = TestTU::withCode(Test.code());
+  TU.Filename = "test.c";
+
+  Symbol Sym = func("foo");
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.CanonicalDeclaration.FileURI = "unittest:///foo.h";
+  Sym.IncludeHeaders.emplace_back("\"foo.h\"", 1);
+
+  SymbolSlab::Builder Slab;
+  Slab.insert(Sym);
+  auto Index =
+  MemIndex::build(std::move(Slab).build(), RefSlab(), RelationSlab());
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  ElementsAre(AllOf(
+  Diag(Test.range(),
+   "implicit declaration of function 'foo' is invalid in C99"),
+  WithFix(Fix(Range{}, "#include \"foo.h\"\n",
+  "Include \"foo.h\" for symbol foo");
+}
+
 TEST(DiagsInHeaders, DiagInsideHeader) {
   Annotations Main(R"cpp(
 #include [["a.h"]]
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -30,6 +30,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -37,17 +38,10 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
-#include "clang/Frontend/Utils.h"
-#include "clang/Index/Index

[PATCH] D114569: [PowerPC] Require htm feature for HTM builtins

2021-12-09 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision as: jsji.
jsji added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for fixing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114569/new/

https://reviews.llvm.org/D114569

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


[PATCH] D114782: [X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits

2021-12-09 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

Oh, that makes sense to me. Reverted and I will investigate it. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114782/new/

https://reviews.llvm.org/D114782

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


[clang] 925ec98 - Revert "[X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits"

2021-12-09 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2021-12-10T10:31:09+08:00
New Revision: 925ec98d000a9df7749e93e8831282cbbb5839b2

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

LOG: Revert "[X86][clang] Emit diagnostic for float and double when we have 
features -x87 and -sse on 64-bits"

This reverts commit 4a2c827b178f89d4cdeb56153d9440ad4ba786a3.

Need to fix the problem when using `-mno-sse` together with "x86intrin.h"

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Basic/Targets/X86.cpp
clang/lib/Sema/Sema.cpp
clang/test/CodeGen/X86/x86_64-mno-sse.c
clang/test/Sema/x86_64-no-x87.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4e113e9afee24..0598be3a167f9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10731,8 +10731,6 @@ def err_omp_wrong_dependency_iterator_type : Error<
 def err_target_unsupported_type
 : Error<"%0 requires %select{|%2 bit size}1 %3 %select{|return }4type 
support,"
 " but target '%5' does not support it">;
-def err_target_unsupported_type_without_sse : Error<
-  "SSE register return with SSE disabled">;
 def err_omp_lambda_capture_in_declare_target_not_to : Error<
   "variable captured in declare target region must appear in a to clause">;
 def err_omp_device_type_mismatch : Error<

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index bf5481a1e03d7..5c4bd364b06a3 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -387,9 +387,6 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   if (!HasX87 && LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
 HasLongDouble = false;
 
-  if (SSELevel < SSE1 && getTriple().getArch() == llvm::Triple::x86_64)
-HasFPReturn = false;
-
   return true;
 }
 

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 96f3d648dc7c7..734ed0f62ec65 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1957,7 +1957,15 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation 
Loc, ValueDecl *D) {
 bool IsDouble = UnqualTy == Context.DoubleTy;
 bool IsFloat = UnqualTy == Context.FloatTy;
 if (IsRetTy && !TI.hasFPReturn() && (IsDouble || IsFloat)) {
-  if (Diag(Loc, diag::err_target_unsupported_type_without_sse)) {
+  PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type);
+  if (D)
+PD << D;
+  else
+PD << "expression";
+
+  if (Diag(Loc, PD, FD)
+  << false /*show bit size*/ << 0 << Ty << true /*return*/
+  << Context.getTargetInfo().getTriple().str()) {
 if (D)
   D->setInvalidDecl();
   }

diff  --git a/clang/test/CodeGen/X86/x86_64-mno-sse.c 
b/clang/test/CodeGen/X86/x86_64-mno-sse.c
index ec9995c929256..43a695ae3cd3d 100644
--- a/clang/test/CodeGen/X86/x86_64-mno-sse.c
+++ b/clang/test/CodeGen/X86/x86_64-mno-sse.c
@@ -1,16 +1,15 @@
 // RUN: %clang_cc1 -triple x86_64-linux -target-feature -sse -target-feature 
-sse2 -S -o /dev/null -verify %s
 // REQUIRES: x86-registered-target
 
-// expected-error@+2{{SSE register return with SSE disabled}}
-// expected-note@+1{{'f1' defined here}}
-double f1(void) {
+double f1(void) { // expected-error {{SSE register return with SSE disabled}}
   return 1.4;
 }
 extern double g;
-void f2(void) {
+void f2(void) { // expected-error {{SSE register return with SSE disabled}}
   g = f1();
 }
 void take_double(double);
 void pass_double(void) {
-  take_double(1.5);
+  // FIXME: Still asserts.
+  //take_double(1.5);
 }

diff  --git a/clang/test/Sema/x86_64-no-x87.cpp 
b/clang/test/Sema/x86_64-no-x87.cpp
index a89c1ff7de93f..b47e69e4b350c 100644
--- a/clang/test/Sema/x86_64-no-x87.cpp
+++ b/clang/test/Sema/x86_64-no-x87.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu 
-target-feature -x87 -target-feature -sse -DERROR_LONGDOUBLE -DERROR_NOSSE
-// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu 
-target-feature -x87 -DERROR_LONGDOUBLE
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu 
-target-feature -x87
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -DNOERROR
 
 #ifdef NOERROR
@@ -19,45 +18,45 @@ long_double decl_ld_del(long_double) = delete;
 double decl_ld_del(double) = delete;
 float decl_ld_del(float) = delete;
 
-#ifdef ERROR_LONGDOUBLE
+#ifndef NOERROR
 // expected-error@+4{{'def' requires  'long_double' (aka 'long double') type 
support, but target 'x86_64-unknown-linux-gnu' does not support it}}
 // expected-note@+3{{'def' defined here}}
 // expected-note@+2{{'x' defi

[PATCH] D115355: Fix build failure with GCC 11 in C++20 mode

2021-12-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM but I want to give a chance for others to chime in.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115355/new/

https://reviews.llvm.org/D115355

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


[PATCH] D115471: [clang] number labels in asm goto strings after tied inputs

2021-12-09 Thread Andrew Pinski via Phabricator via cfe-commits
apinski-cavium added a comment.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98096
GCC even documents it this way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115471/new/

https://reviews.llvm.org/D115471

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


[PATCH] D115471: [clang] number labels in asm goto strings after tied inputs

2021-12-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D115471#3184384 , @jyknight wrote:

> It's rather sad that GCC made the quite-unintuitive decision to number the 
> arguments in this way -- LONG AFTER clang had already implemented the other 
> way...

I doubt it was intentional or tested or that it's too late to at least file a 
bug report.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103640


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115471/new/

https://reviews.llvm.org/D115471

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


[PATCH] D115225: [X86][MS-InlineAsm] Make the constraint *m to be simple place holder

2021-12-09 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115225/new/

https://reviews.llvm.org/D115225

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


[clang] d7c07f6 - [X86][MS-InlineAsm] Make the constraint *m to be simple place holder

2021-12-09 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2021-12-10T09:29:38+08:00
New Revision: d7c07f60b35f901f5bd9153b11807124a9bdde60

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

LOG: [X86][MS-InlineAsm] Make the constraint *m to be simple place holder

D113096 solved the "undefined reference to xxx" issue by adding
constraint *m for the global var. But it has strong side effect due to
the symbol in the assembly being replaced with constraint variable.
This leads to some lowering fails. https://godbolt.org/z/h3nWoerPe

This patch fix the problem by use the constraint *m as place holder
rather than real constraint. It has negligible effect for the existing
code generation.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D115225

Added: 


Modified: 
clang/test/CodeGen/X86/ms_fmul.c
clang/test/CodeGen/ms-inline-asm-functions.c
clang/test/CodeGen/ms-inline-asm-static-variable.c
clang/test/CodeGen/ms-inline-asm-variables.c
llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/lib/Target/X86/AsmParser/X86Operand.h
llvm/test/CodeGen/X86/ms-inline-asm-array.ll

Removed: 




diff  --git a/clang/test/CodeGen/X86/ms_fmul.c 
b/clang/test/CodeGen/X86/ms_fmul.c
index d1cfcef814625..a0a1be9e217c5 100644
--- a/clang/test/CodeGen/X86/ms_fmul.c
+++ b/clang/test/CodeGen/X86/ms_fmul.c
@@ -18,4 +18,4 @@ void __attribute__ ((naked)) foo(void)
 }}
 
 // CHECK-LABEL: foo
-// CHECK: call void asm sideeffect inteldialect "fmul qword ptr $0[edx + 
$$240]\0A\09ret"
+// CHECK: call void asm sideeffect inteldialect "fmul qword ptr 
static_const_table[edx + $$240]\0A\09ret"

diff  --git a/clang/test/CodeGen/ms-inline-asm-functions.c 
b/clang/test/CodeGen/ms-inline-asm-functions.c
index 1a6ead9286dff..c958d88038716 100644
--- a/clang/test/CodeGen/ms-inline-asm-functions.c
+++ b/clang/test/CodeGen/ms-inline-asm-functions.c
@@ -39,7 +39,7 @@ int bar() {
 int baz() {
   // CHECK-LABEL: _baz:
   __asm mov eax, k;
-  // CHECK: movl_k, %eax
+  // CHECK: movlk, %eax
   __asm mov eax, kptr;
   // CHECK: movl_kptr, %eax
 }

diff  --git a/clang/test/CodeGen/ms-inline-asm-static-variable.c 
b/clang/test/CodeGen/ms-inline-asm-static-variable.c
index fb80bf7b2f74f..8099ea5ac8cf3 100644
--- a/clang/test/CodeGen/ms-inline-asm-static-variable.c
+++ b/clang/test/CodeGen/ms-inline-asm-static-variable.c
@@ -5,6 +5,6 @@
 static int arr[10];
 void t1() {
   // CHECK: @arr = internal global [10 x i32]
-  // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0[edx * 
$$4],edx", "=*m,{{.*}}([10 x i32]* @arr)
+  // CHECK: call void asm sideeffect inteldialect "mov dword ptr arr[edx * 
$$4],edx", "=*m,{{.*}}([10 x i32]* @arr)
   __asm mov  dword ptr arr[edx*4],edx
 }

diff  --git a/clang/test/CodeGen/ms-inline-asm-variables.c 
b/clang/test/CodeGen/ms-inline-asm-variables.c
index 7d0cb3fbcc8f8..0997c55c559bf 100644
--- a/clang/test/CodeGen/ms-inline-asm-variables.c
+++ b/clang/test/CodeGen/ms-inline-asm-variables.c
@@ -3,19 +3,19 @@
 
 int gVar;
 void t1() {
-  // CHECK: add eax, dword ptr ${{[0-9]}}[eax]
+  // CHECK: add eax, dword ptr gVar[eax]
   __asm add eax, dword ptr gVar[eax]
-  // CHECK: add dword ptr ${{[0-9]}}[eax], eax
+  // CHECK: add dword ptr gVar[eax], eax
   __asm add dword ptr [eax+gVar], eax
-  // CHECK: add ebx, dword ptr ${{[0-9]}}[ebx + $$270]
+  // CHECK: add ebx, dword ptr gVar[ebx + $$270]
   __asm add ebx, dword ptr gVar[271 - 82 + 81 + ebx]
-  // CHECK: add dword ptr ${{[0-9]}}[ebx + $$828], ebx
+  // CHECK: add dword ptr gVar[ebx + $$828], ebx
   __asm add dword ptr [ebx + gVar + 828], ebx
-  // CHECK: add ecx, dword ptr ${{[0-9]}}[ecx + ecx * $$4 + $$4590]
+  // CHECK: add ecx, dword ptr gVar[ecx + ecx * $$4 + $$4590]
   __asm add ecx, dword ptr gVar[4590 + ecx + ecx*4]
-  // CHECK: add dword ptr ${{[0-9]}}[ecx + ecx * $$8 + $$73], ecx
+  // CHECK: add dword ptr gVar[ecx + ecx * $$8 + $$73], ecx
   __asm add dword ptr [gVar + ecx + 45 + 23 - 53 + 60 - 2 + ecx*8], ecx
-  // CHECK: add ${{[0-9]}}[ecx + ebx + $$7], eax
+  // CHECK: add gVar[ecx + ebx + $$7], eax
   __asm add 1 + 1 + 2 + 3[gVar + ecx + ebx], eax
 }
 

diff  --git a/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h 
b/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
index abb95628c2a98..faf0a4474c8a4 100644
--- a/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
+++ b/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/MC/MCInstrDesc.h"
 #include "llvm/Support/SMLoc.h"
 #include 
 
@@ -76,6 +77,10 @@ class MCParsedAsmOperand {
   /// assembly.
   virtual bool isOffsetOfLocal() const { return f

[PATCH] D115225: [X86][MS-InlineAsm] Make the constraint *m to be simple place holder

2021-12-09 Thread Phoebe Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7c07f60b35f: [X86][MS-InlineAsm] Make the constraint *m to 
be simple place holder (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115225/new/

https://reviews.llvm.org/D115225

Files:
  clang/test/CodeGen/X86/ms_fmul.c
  clang/test/CodeGen/ms-inline-asm-functions.c
  clang/test/CodeGen/ms-inline-asm-static-variable.c
  clang/test/CodeGen/ms-inline-asm-variables.c
  llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86Operand.h
  llvm/test/CodeGen/X86/ms-inline-asm-array.ll

Index: llvm/test/CodeGen/X86/ms-inline-asm-array.ll
===
--- llvm/test/CodeGen/X86/ms-inline-asm-array.ll
+++ llvm/test/CodeGen/X86/ms-inline-asm-array.ll
@@ -5,7 +5,7 @@
 ; CHECK: movl%edx, arr(,%rdx,4)
 define dso_local i32 @main() #0 {
 entry:
-  call void asm sideeffect inteldialect "mov dword ptr $0[rdx * $$4],edx", "=*m,~{dirflag},~{fpsr},~{flags}"([10 x i32]* @arr) #1, !srcloc !4
+  call void asm sideeffect inteldialect "mov dword ptr arr[rdx * $$4],edx", "=*m,~{dirflag},~{fpsr},~{flags}"([10 x i32]* @arr) #1, !srcloc !4
   ret i32 0
 }
 
Index: llvm/lib/Target/X86/AsmParser/X86Operand.h
===
--- llvm/lib/Target/X86/AsmParser/X86Operand.h
+++ llvm/lib/Target/X86/AsmParser/X86Operand.h
@@ -285,6 +285,13 @@
 
   bool isOffsetOfLocal() const override { return isImm() && Imm.LocalRef; }
 
+  bool isMemPlaceholder(const MCInstrDesc &Desc) const override {
+// Add more restrictions to avoid the use of global symbols. This helps
+// with reducing the code size.
+return !Desc.isRematerializable() && !Desc.isCall() && isMem() &&
+   !Mem.BaseReg && !Mem.IndexReg;
+  }
+
   bool needAddressOf() const override { return AddressOf; }
 
   bool isMem() const override { return Kind == Memory; }
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2551,8 +2551,6 @@
   StringRef ErrMsg;
   unsigned BaseReg = SM.getBaseReg();
   unsigned IndexReg = SM.getIndexReg();
-  if (IndexReg && BaseReg == X86::RIP)
-BaseReg = 0;
   unsigned Scale = SM.getScale();
   if (!PtrInOperand)
 Size = SM.getElementSize() << 3;
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -6012,12 +6012,13 @@
 
   bool isOutput = (i == 1) && Desc.mayStore();
   SMLoc Start = SMLoc::getFromPointer(SymName.data());
+  int64_t Size = Operand.isMemPlaceholder(Desc) ? 0 : SymName.size();
   if (isOutput) {
 ++InputIdx;
 OutputDecls.push_back(OpDecl);
 OutputDeclsAddressOf.push_back(Operand.needAddressOf());
 OutputConstraints.push_back(("=" + Constraint).str());
-AsmStrRewrites.emplace_back(AOK_Output, Start, SymName.size());
+AsmStrRewrites.emplace_back(AOK_Output, Start, Size);
   } else {
 InputDecls.push_back(OpDecl);
 InputDeclsAddressOf.push_back(Operand.needAddressOf());
@@ -6025,7 +6026,7 @@
 if (Desc.OpInfo[i - 1].isBranchTarget())
   AsmStrRewrites.emplace_back(AOK_CallInput, Start, SymName.size());
 else
-  AsmStrRewrites.emplace_back(AOK_Input, Start, SymName.size());
+  AsmStrRewrites.emplace_back(AOK_Input, Start, Size);
   }
 }
 
@@ -6140,13 +6141,17 @@
   OS << Ctx.getAsmInfo()->getPrivateLabelPrefix() << AR.Label;
   break;
 case AOK_Input:
-  OS << '$' << InputIdx++;
+  if (AR.Len)
+OS << '$' << InputIdx;
+  ++InputIdx;
   break;
 case AOK_CallInput:
   OS << "${" << InputIdx++ << ":P}";
   break;
 case AOK_Output:
-  OS << '$' << OutputIdx++;
+  if (AR.Len)
+OS << '$' << OutputIdx;
+  ++OutputIdx;
   break;
 case AOK_SizeDirective:
   switch (AR.Val) {
Index: llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
===
--- llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
+++ llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/MC/MCInstrDesc.h"
 #include "llvm/Support/SMLoc.h"
 #include 
 
@@ -76,6 +77,10 @@
   /// assembly.
   virtual bool isOffsetOfLocal() const { return false; }
 
+  /// isMemPlaceholder - Do we need to ignore the constraint, rather than emit
+  /// code? Only valid when parsing MS-style inline assembly.
+  virtual bool 

[PATCH] D114782: [X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits

2021-12-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D114782#3184406 , @phosek wrote:

> In D114782#3184317 , @pengfei wrote:
>
>> Hi @phosek , thanks for reporting it.
>> I would consider it as a misuse of the header file when SSE is not usable, 
>> especially we now have the specific header "x86gprintrin.h" for such 
>> scenarios. Can you help to try if changing to "x86gprintrin.h" works?
>
> It's a normal practice to compile with `-mno-{sse,avx}` and then use SSE/AVX 
> intrinsics explicitly inside runtime cpuid conditionals.  The function 
> calling the intrinsic might be marked with `__attribute__((target("avx")))`, 
> but the source file's ambient `-mo-{sse,avx}` will be in force when `#include 
> ` is done. This change breaks that practice which is likely 
> going to affect existing codebases.

I'd also point out that other compilers like GCC don't report the same error so 
this change makes Clang's behavior inconsistent.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114782/new/

https://reviews.llvm.org/D114782

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


[PATCH] D114782: [X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits

2021-12-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D114782#3184317 , @pengfei wrote:

> Hi @phosek , thanks for reporting it.
> I would consider it as a misuse of the header file when SSE is not usable, 
> especially we now have the specific header "x86gprintrin.h" for such 
> scenarios. Can you help to try if changing to "x86gprintrin.h" works?

It's a normal practice to compile with `-mno-{sse,avx}` and then use SSE/AVX 
intrinsics explicitly inside runtime cpuid conditionals.  The function calling 
the intrinsic might be marked with `__attribute__((target("avx")))`, but the 
source file's ambient `-mo-{sse,avx}` will be in force when `#include 
` is done. This change breaks that practice which is likely going 
to affect existing codebases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114782/new/

https://reviews.llvm.org/D114782

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


[PATCH] D115471: [clang] number labels in asm goto strings after tied inputs

2021-12-09 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

It's rather sad that GCC made the quite-unintuitive decision to number the 
arguments in this way -- LONG AFTER clang had already implemented the other 
way...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115471/new/

https://reviews.llvm.org/D115471

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


[PATCH] D114564: Fix the use of -fno-approx-func along with -Ofast or -ffast-math

2021-12-09 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2760
 case options::OPT_fno_honor_nans:   HonorNaNs = false;break;
 case options::OPT_fapprox_func: ApproxFunc = true;break;
 case options::OPT_fno_approx_func:  ApproxFunc = false;   break;

masoud.ataei wrote:
> masoud.ataei wrote:
> > andrew.w.kaylor wrote:
> > > Should this also imply "MathErrno = false"?
> > I don't think setting ApproxFunc to true should imply "MathErrno = false". 
> > 
> > Let say someone have a math library that compute approximate result for 
> > none special input/output but returns NaN, INF and errno correctly 
> > otherwise. That is actually can be fairly common, because performance in 
> > the none special cases are much more important that the special ones. So 
> > returning errno in the special outputs theoretically should not effect the 
> > performance on the main path. Therefore, I think compiler should not assume 
> > anything about MathErrno value based on ApproxFunc value.
> I am not sure what I was suggesting in my last comment is correct or not. Can 
> one of the more experienced reviewers confirm?
> The question is: Should "ApproxFunc=ture" implies "MathErrno=false"?
They seem pretty orthogonal to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114564/new/

https://reviews.llvm.org/D114564

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


[PATCH] D115484: [clangd] Include-fixer: handle more "incomplete type" diags, clean up tests

2021-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay, ilya-biryukov.
Herald added a reviewer: jdoerfert.
Herald added a project: clang-tools-extra.

I started adding tests for all diags but found there were just too many cases.
Still I think cleaning up the tests and adding a few more is worthwhile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115484

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/TestIndex.cpp
  clang-tools-extra/clangd/unittests/TestIndex.h

Index: clang-tools-extra/clangd/unittests/TestIndex.h
===
--- clang-tools-extra/clangd/unittests/TestIndex.h
+++ clang-tools-extra/clangd/unittests/TestIndex.h
@@ -10,7 +10,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTINDEX_H
 
 #include "index/Index.h"
-#include "index/Merge.h"
 
 namespace clang {
 namespace clangd {
@@ -26,6 +25,8 @@
 Symbol func(llvm::StringRef Name);
 // Creates a class symbol.
 Symbol cls(llvm::StringRef Name);
+// Creates an enum symbol.
+Symbol enm(llvm::StringRef Name);
 // Creates a variable symbol.
 Symbol var(llvm::StringRef Name);
 // Creates a namespace symbol.
Index: clang-tools-extra/clangd/unittests/TestIndex.cpp
===
--- clang-tools-extra/clangd/unittests/TestIndex.cpp
+++ clang-tools-extra/clangd/unittests/TestIndex.cpp
@@ -65,6 +65,10 @@
   return sym(Name, index::SymbolKind::Class, "@S@\\0");
 }
 
+Symbol enm(llvm::StringRef Name) {
+  return sym(Name, index::SymbolKind::Enum, "@E@\\0");
+}
+
 Symbol var(llvm::StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
 }
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -70,6 +70,8 @@
   return Field(&Diag::Tags, Contains(TagMatcher));
 }
 
+MATCHER_P(HasRange, Range, "") { return arg.Range == Range; }
+
 MATCHER_P2(Diag, Range, Message,
"Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
   return arg.Range == Range && arg.Message == Message;
@@ -831,95 +833,81 @@
 }
 
 TEST(IncludeFixerTest, IncompleteType) {
-  Annotations Test(R"cpp(// error-ok
-$insert[[]]namespace ns {
-  class X;
-  $nested[[X::]]Nested n;
-}
-class Y : $base[[public ns::X]] {};
-void test(ns::X *x, ns::X& ref_x) {
-  x$access[[->]]f();
-  auto& $type[[[]]a] = *x;
+  auto TU = TestTU::withHeaderCode("namespace ns { class X; } ns::X *x;");
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
+  TU.ExternalIndex = Index.get();
 
-  ns::X $incomplete[[var]];
-  $tag[[ref_x]]->f();
-  $use[[ns::X()]];
-  $sizeof[[sizeof]](ns::X);
-  for (auto it : $for[[ref_x]]);
+  std::vector> Tests{
+  {"incomplete_nested_name_spec", "[[ns::X::]]Nested n;"},
+  {"incomplete_base_class", "class Y : [[ns::X]] {};"},
+  {"incomplete_member_access", "auto i = x[[->]]f();"},
+  {"incomplete_type", "auto& [[[]]m] = *x;"},
+  {"init_incomplete_type",
+   "struct C { static int f(ns::X&); }; int i = C::f([[{]]});"},
+  {"bad_cast_incomplete", "auto a = [[static_cast]](0);"},
+  {"template_nontype_parm_incomplete", "template  int a;"},
+  {"typecheck_decl_incomplete_type", "ns::X [[var]];"},
+  {"typecheck_incomplete_tag", "auto i = [[(*x)]]->f();"},
+  {"typecheck_nonviable_condition_incomplete",
+   "struct A { operator ns::X(); } a; const ns::X &[[b]] = a;"},
+  {"invalid_incomplete_type_use", "auto var = [[ns::X()]];"},
+  {"sizeof_alignof_incomplete_or_sizeless_type",
+   "auto s = [[sizeof]](ns::X);"},
+  {"for_range_incomplete_type", "void foo() { for (auto i : [[*]]x ) {} }"},
+  {"func_def_incomplete_result", "ns::X [[func]] () {}"},
+  {"field_incomplete_or_sizeless", "class M { ns::X [[member]]; };"},
+  {"array_incomplete_or_sizeless_type", "auto s = [[(ns::X[]){}]];"},
+  {"call_incomplete_return", "ns::X f(); auto fp = &f; auto z = [[fp()]];"},
+  {"call_function_incomplete_return", "ns::X foo(); auto a = [[foo()]];"},
+  {"call_incomplete_argument", "int m(ns::X); int i = m([[*x]]);"},
+  {"switch_incomplete_class_type", "void a() { [[switch]](*x) {} }"},
+  {"delete_incomplete_class_type", "void f() { [[delete]] *x; }"},
+  {"-Wdelete-incomplete", "void f() { [[delete]] x; }"},
+  {"dereference_incomplete_type",
+   R"cpp(void f() { asm("" : "=r"([[*]]x)::); })cpp"},
+  };
+  for (auto Case : Tests) {
+Annotations Main(Case.second);
+T

[PATCH] D53608: [builtins] Build float128 soft float builtins for x86_64.

2021-12-09 Thread Siddhartha Bagaria via Phabricator via cfe-commits
starsid added a comment.

I have tried my best to follow the conversation here and complete this patch. 
Please let me know if it is missing something, or if I need to assign new 
reviewers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53608/new/

https://reviews.llvm.org/D53608

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


[PATCH] D53608: [builtins] Build float128 soft float builtins for x86_64.

2021-12-09 Thread Siddhartha Bagaria via Phabricator via cfe-commits
starsid updated this revision to Diff 393340.
starsid added a comment.

fix commit author name and email


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53608/new/

https://reviews.llvm.org/D53608

Files:
  compiler-rt/lib/builtins/extendhftf2.c
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/powitf2.c
  compiler-rt/lib/builtins/trunctfdf2.c
  compiler-rt/lib/builtins/trunctfhf2.c
  compiler-rt/lib/builtins/trunctfsf2.c


Index: compiler-rt/lib/builtins/trunctfsf2.c
===
--- compiler-rt/lib/builtins/trunctfsf2.c
+++ compiler-rt/lib/builtins/trunctfsf2.c
@@ -14,6 +14,6 @@
 #define DST_SINGLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI float __trunctfsf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI float __trunctfsf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfhf2.c
===
--- compiler-rt/lib/builtins/trunctfhf2.c
+++ compiler-rt/lib/builtins/trunctfhf2.c
@@ -16,8 +16,6 @@
 #define DST_HALF
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI _Float16 __trunctfhf2(long double a) {
-  return __truncXfYf2__(a);
-}
+COMPILER_RT_ABI _Float16 __trunctfhf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfdf2.c
===
--- compiler-rt/lib/builtins/trunctfdf2.c
+++ compiler-rt/lib/builtins/trunctfdf2.c
@@ -14,6 +14,6 @@
 #define DST_DOUBLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI double __trunctfdf2(long double a) { return __truncXfYf2__(a); 
}
+COMPILER_RT_ABI double __trunctfdf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/powitf2.c
===
--- compiler-rt/lib/builtins/powitf2.c
+++ compiler-rt/lib/builtins/powitf2.c
@@ -17,9 +17,9 @@
 
 // Returns: a ^ b
 
-COMPILER_RT_ABI long double __powitf2(long double a, int b) {
+COMPILER_RT_ABI fp_t __powitf2(fp_t a, int b) {
   const int recip = b < 0;
-  long double r = 1;
+  fp_t r = 1;
   while (1) {
 if (b & 1)
   r *= a;
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -105,12 +105,17 @@
 COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b);
 
 #elif defined QUAD_PRECISION
-#if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
+#if (__LDBL_MANT_DIG__ == 113 || defined(__x86_64__)) &&   
\
+defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
 typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+typedef __float128 fp_t;
+#else
 typedef long double fp_t;
+#endif
 #define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
Index: compiler-rt/lib/builtins/extendhftf2.c
===
--- compiler-rt/lib/builtins/extendhftf2.c
+++ compiler-rt/lib/builtins/extendhftf2.c
@@ -16,8 +16,6 @@
 #define DST_QUAD
 #include "fp_extend_impl.inc"
 
-COMPILER_RT_ABI long double __extendhftf2(_Float16 a) {
-  return __extendXfYf2__(a);
-}
+COMPILER_RT_ABI fp_t __extendhftf2(_Float16 a) { return __extendXfYf2__(a); }
 
 #endif


Index: compiler-rt/lib/builtins/trunctfsf2.c
===
--- compiler-rt/lib/builtins/trunctfsf2.c
+++ compiler-rt/lib/builtins/trunctfsf2.c
@@ -14,6 +14,6 @@
 #define DST_SINGLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI float __trunctfsf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI float __trunctfsf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfhf2.c
===
--- compiler-rt/lib/builtins/trunctfhf2.c
+++ compiler-rt/lib/builtins/trunctfhf2.c
@@ -16,8 +16,6 @@
 #define DST_HALF
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI _Float16 __trunctfhf2(long double a) {
-  return __truncXfYf2__(a);
-}
+COMPILER_RT_ABI _Float16 __trunctfhf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfdf2.c
===
--- compiler-rt/lib/builtins/trunctfdf2.c
+++ compiler-rt/lib/builtins/trunctfdf2.c
@@ -14,6 +14,6 @@
 #define DST_DOUBLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI double __trunctfdf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI double __trunctfdf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/powitf2.c
===
--- compiler-rt/lib/builtins/powitf2.c
+++ compiler-

[PATCH] D114782: [X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits

2021-12-09 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

Hi @phosek , thanks for reporting it.
I would consider it as a misuse of the header file when SSE is not usable, 
especially we now have the specific header "x86gprintrin.h" for such scenarios. 
Can you help to try if changing to "x86gprintrin.h" works?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114782/new/

https://reviews.llvm.org/D114782

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


[PATCH] D53608: [builtins] Build float128 soft float builtins for x86_64.

2021-12-09 Thread Siddhartha Bagaria via Phabricator via cfe-commits
starsid updated this revision to Diff 393335.
starsid added a comment.

rebase and resurrect


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53608/new/

https://reviews.llvm.org/D53608

Files:
  compiler-rt/lib/builtins/extendhftf2.c
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/powitf2.c
  compiler-rt/lib/builtins/trunctfdf2.c
  compiler-rt/lib/builtins/trunctfhf2.c
  compiler-rt/lib/builtins/trunctfsf2.c


Index: compiler-rt/lib/builtins/trunctfsf2.c
===
--- compiler-rt/lib/builtins/trunctfsf2.c
+++ compiler-rt/lib/builtins/trunctfsf2.c
@@ -14,6 +14,6 @@
 #define DST_SINGLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI float __trunctfsf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI float __trunctfsf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfhf2.c
===
--- compiler-rt/lib/builtins/trunctfhf2.c
+++ compiler-rt/lib/builtins/trunctfhf2.c
@@ -16,8 +16,6 @@
 #define DST_HALF
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI _Float16 __trunctfhf2(long double a) {
-  return __truncXfYf2__(a);
-}
+COMPILER_RT_ABI _Float16 __trunctfhf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfdf2.c
===
--- compiler-rt/lib/builtins/trunctfdf2.c
+++ compiler-rt/lib/builtins/trunctfdf2.c
@@ -14,6 +14,6 @@
 #define DST_DOUBLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI double __trunctfdf2(long double a) { return __truncXfYf2__(a); 
}
+COMPILER_RT_ABI double __trunctfdf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/powitf2.c
===
--- compiler-rt/lib/builtins/powitf2.c
+++ compiler-rt/lib/builtins/powitf2.c
@@ -17,9 +17,9 @@
 
 // Returns: a ^ b
 
-COMPILER_RT_ABI long double __powitf2(long double a, int b) {
+COMPILER_RT_ABI fp_t __powitf2(fp_t a, int b) {
   const int recip = b < 0;
-  long double r = 1;
+  fp_t r = 1;
   while (1) {
 if (b & 1)
   r *= a;
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -105,12 +105,17 @@
 COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b);
 
 #elif defined QUAD_PRECISION
-#if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
+#if (__LDBL_MANT_DIG__ == 113 || defined(__x86_64__)) &&   
\
+defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
 typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+typedef __float128 fp_t;
+#else
 typedef long double fp_t;
+#endif
 #define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
Index: compiler-rt/lib/builtins/extendhftf2.c
===
--- compiler-rt/lib/builtins/extendhftf2.c
+++ compiler-rt/lib/builtins/extendhftf2.c
@@ -16,8 +16,6 @@
 #define DST_QUAD
 #include "fp_extend_impl.inc"
 
-COMPILER_RT_ABI long double __extendhftf2(_Float16 a) {
-  return __extendXfYf2__(a);
-}
+COMPILER_RT_ABI fp_t __extendhftf2(_Float16 a) { return __extendXfYf2__(a); }
 
 #endif


Index: compiler-rt/lib/builtins/trunctfsf2.c
===
--- compiler-rt/lib/builtins/trunctfsf2.c
+++ compiler-rt/lib/builtins/trunctfsf2.c
@@ -14,6 +14,6 @@
 #define DST_SINGLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI float __trunctfsf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI float __trunctfsf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfhf2.c
===
--- compiler-rt/lib/builtins/trunctfhf2.c
+++ compiler-rt/lib/builtins/trunctfhf2.c
@@ -16,8 +16,6 @@
 #define DST_HALF
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI _Float16 __trunctfhf2(long double a) {
-  return __truncXfYf2__(a);
-}
+COMPILER_RT_ABI _Float16 __trunctfhf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfdf2.c
===
--- compiler-rt/lib/builtins/trunctfdf2.c
+++ compiler-rt/lib/builtins/trunctfdf2.c
@@ -14,6 +14,6 @@
 #define DST_DOUBLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI double __trunctfdf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI double __trunctfdf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/powitf2.c
===
--- compiler-rt/lib/builtins/powitf2.c
+++ compiler-rt/lib/built

[PATCH] D114782: [X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits

2021-12-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Note that GCC had the same issue in the past 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80298 which was later addressed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114782/new/

https://reviews.llvm.org/D114782

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


[PATCH] D114782: [X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits

2021-12-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This change broke our kernel build. I believe that the issue is that the 
compiler doesn't consider function attributes.

This can be trivially reproduced as:

  $ cat >t.c <
  EOF
  $ ./bin/clang -c t.c -o t.o -mno-sse
  In file included from t.c:1:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/x86intrin.h:13:
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/ia32intrin.h:251:1: 
error: SSE register return with SSE disabled
  _castu32_f32(unsigned int __A) {
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/ia32intrin.h:251:1: 
note: '_castu32_f32' defined here
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/ia32intrin.h:266:1: 
error: SSE register return with SSE disabled
  _castu64_f64(unsigned long long __A) {
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/ia32intrin.h:266:1: 
note: '_castu64_f64' defined here
  In file included from t.c:1:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/x86intrin.h:15:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/immintrin.h:26:
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/xmmintrin.h:1607:1: 
error: SSE register return with SSE disabled
  _mm_cvtss_f32(__m128 __a)
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/xmmintrin.h:1607:1: 
note: '_mm_cvtss_f32' defined here
  In file included from t.c:1:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/x86intrin.h:15:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/immintrin.h:31:
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/emmintrin.h:1566:1: 
error: SSE register return with SSE disabled
  _mm_cvtsd_f64(__m128d __a)
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/emmintrin.h:1566:1: 
note: '_mm_cvtsd_f64' defined here
  In file included from t.c:1:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/x86intrin.h:15:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/immintrin.h:66:
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avxintrin.h:2257:1: 
error: SSE register return with SSE disabled
  _mm256_cvtsd_f64(__m256d __a)
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avxintrin.h:2257:1: 
note: '_mm256_cvtsd_f64' defined here
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avxintrin.h:2290:1: 
error: SSE register return with SSE disabled
  _mm256_cvtss_f32(__m256 __a)
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avxintrin.h:2290:1: 
note: '_mm256_cvtss_f32' defined here
  In file included from t.c:1:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/x86intrin.h:15:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/immintrin.h:76:
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/f16cintrin.h:39:1: 
error: SSE register return with SSE disabled
  _cvtsh_ss(unsigned short __a)
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/f16cintrin.h:39:1: 
note: '_cvtsh_ss' defined here
  In file included from t.c:1:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/x86intrin.h:15:
  In file included from 
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/immintrin.h:104:
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:4090:1:
 error: SSE register return with SSE disabled
  _mm512_cvtsd_f64(__m512d __a)
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:4090:1:
 note: '_mm512_cvtsd_f64' defined here
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:4096:1:
 error: SSE register return with SSE disabled
  _mm512_cvtss_f32(__m512 __a)
  ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:4096:1:
 note: '_mm512_cvtss_f32' defined here
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:9358:10:
 error: SSE register return with SSE disabled
return __builtin_ia32_reduce_fadd_pd512(-0.0, __W);
   ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:9358:10:
 note: '__builtin_ia32_reduce_fadd_pd512' defined here
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:9357:48:
 error: SSE register return with SSE disabled
  static __inline__ double __DEFAULT_FN_ATTRS512 _mm512_reduce_add_pd(__m512d 
__W) {
 ^
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:9357:48:
 note: '_mm512_reduce_add_pd' defined here
  
/src/clang-llvm/llvm-build/fuchsia/lib/clang/14.0.0/include/avx512fintrin.h:9362:10:
 error: SSE register return with SSE disa

[PATCH] D115441: [X86][MS] Add 80bit long double support for Windows

2021-12-09 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D115441#3182938 , @craig.topper 
wrote:

> Doesn’t icc also emit code into main to change the FPCW precision control 
> field? Is making long double 80 bits useful if you don’t increase the 
> precision in hardware?

Yes, but it is controlled by an independent option `/Qpc80`. We can do a 
follow-up if it is required. Currently, I think it's still useful for library 
build and functional compatibility with ICC. Even considering the missing 
`/Qpc80`, we can still get the less precise result rather than the wrong one 
when linking each other. Besides, users are always able to set it manually.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115441/new/

https://reviews.llvm.org/D115441

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


[PATCH] D104099: [NewPM] Remove SpeculateAroundPHIs pass

2021-12-09 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot added a comment.

I'm trying to understand the problem in this pass.
It looks both of @thopre's and @lebedev.ri's problems are loop related. Is 
there any other regression not loop related?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104099/new/

https://reviews.llvm.org/D104099

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


[clang] 5336bef - [NFC][tools] Return underlying strings directly instead of OS.str()

2021-12-09 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2021-12-09T16:05:46-08:00
New Revision: 5336befe8c3cde08cec020583700b4d2ba25ac16

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

LOG: [NFC][tools] Return underlying strings directly instead of OS.str()

This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b13610a5226b84889b923bae884ba395ad084d,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374

Added: 


Modified: 
clang/lib/Tooling/Syntax/Tokens.cpp
clang/lib/Tooling/Syntax/Tree.cpp
clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Syntax/Tokens.cpp 
b/clang/lib/Tooling/Syntax/Tokens.cpp
index 8a31e776d0302..e2014f965c900 100644
--- a/clang/lib/Tooling/Syntax/Tokens.cpp
+++ b/clang/lib/Tooling/Syntax/Tokens.cpp
@@ -927,5 +927,5 @@ std::string TokenBuffer::dumpForTests() const {
   M.EndExpanded);
 }
   }
-  return OS.str();
+  return Dump;
 }

diff  --git a/clang/lib/Tooling/Syntax/Tree.cpp 
b/clang/lib/Tooling/Syntax/Tree.cpp
index 1e3a90f3a3167..c813865e95cd8 100644
--- a/clang/lib/Tooling/Syntax/Tree.cpp
+++ b/clang/lib/Tooling/Syntax/Tree.cpp
@@ -263,7 +263,7 @@ std::string syntax::Node::dumpTokens(const SourceManager 
&SM) const {
   OS << " ";
 }
   });
-  return OS.str();
+  return Storage;
 }
 
 void syntax::Node::assertInvariants() const {

diff  --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp 
b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
index beb51bcfe5948..bf694e575a9dc 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -139,7 +139,7 @@ static std::string OptLLVM(const std::string &IR, 
CodeGenOpt::Level OLvl) {
 
   Passes.run(*M);
 
-  return OS.str();
+  return outString;
 }
 
 // Takes a function and runs it on a set of inputs



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


[clang] 5276002 - [NFC][Sema] Return underlying strings directly instead of OS.str()

2021-12-09 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2021-12-09T16:05:46-08:00
New Revision: 5276002a89b9aeb4c5f920d627630b1637c68ddc

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

LOG: [NFC][Sema] Return underlying strings directly instead of OS.str()

This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b13610a5226b84889b923bae884ba395ad084d,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374

Added: 


Modified: 
clang/lib/Sema/CodeCompleteConsumer.cpp
clang/lib/Sema/SemaAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/CodeCompleteConsumer.cpp 
b/clang/lib/Sema/CodeCompleteConsumer.cpp
index 6c47cedfccf3f..0a2ca54e244ad 100644
--- a/clang/lib/Sema/CodeCompleteConsumer.cpp
+++ b/clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -335,7 +335,7 @@ std::string CodeCompletionString::getAsString() const {
   break;
 }
   }
-  return OS.str();
+  return Result;
 }
 
 const char *CodeCompletionString::getTypedText() const {
@@ -640,7 +640,7 @@ static std::string getOverloadAsString(const 
CodeCompletionString &CCS) {
   break;
 }
   }
-  return OS.str();
+  return Result;
 }
 
 void PrintingCodeCompleteConsumer::ProcessOverloadCandidates(

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 100f8e36a9b86..b694927688489 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -792,7 +792,7 @@ 
attrMatcherRuleListToString(ArrayRef Rules) {
   OS << (I.index() == Rules.size() - 1 ? ", and " : ", ");
 OS << "'" << attr::getSubjectMatchRuleSpelling(I.value()) << "'";
   }
-  return OS.str();
+  return Result;
 }
 
 } // end anonymous namespace



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


[clang] 0cf6f7b - [NFC][clang] Return underlying strings directly instead of OS.str()

2021-12-09 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2021-12-09T16:05:46-08:00
New Revision: 0cf6f7b128dd457711ba5c0ebfcb8143dc1632f8

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

LOG: [NFC][clang] Return underlying strings directly instead of OS.str()

This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b13610a5226b84889b923bae884ba395ad084d,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374

Added: 


Modified: 
clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
clang/lib/Basic/SourceLocation.cpp
clang/lib/Basic/Version.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/TestModuleFileExtension.cpp
clang/lib/Rewrite/HTMLRewrite.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp 
b/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
index ba2f49e6b6238..41ab0ed70fda4 100644
--- a/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
@@ -204,7 +204,7 @@ std::string Diagnostics::toString() const {
   std::string S;
   llvm::raw_string_ostream OS(S);
   printToStream(OS);
-  return OS.str();
+  return S;
 }
 
 void Diagnostics::printToStreamFull(llvm::raw_ostream &OS) const {
@@ -223,7 +223,7 @@ std::string Diagnostics::toStringFull() const {
   std::string S;
   llvm::raw_string_ostream OS(S);
   printToStreamFull(OS);
-  return OS.str();
+  return S;
 }
 
 }  // namespace dynamic

diff  --git a/clang/lib/Basic/SourceLocation.cpp 
b/clang/lib/Basic/SourceLocation.cpp
index 6986fcd322f26..6e5e55fb09cef 100644
--- a/clang/lib/Basic/SourceLocation.cpp
+++ b/clang/lib/Basic/SourceLocation.cpp
@@ -90,7 +90,7 @@ SourceLocation::printToString(const SourceManager &SM) const {
   std::string S;
   llvm::raw_string_ostream OS(S);
   print(OS, SM);
-  return OS.str();
+  return S;
 }
 
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
@@ -149,7 +149,7 @@ SourceRange::printToString(const SourceManager &SM) const {
   std::string S;
   llvm::raw_string_ostream OS(S);
   print(OS, SM);
-  return OS.str();
+  return S;
 }
 
 
//===--===//

diff  --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index af3118b0f6da4..e205da7adec1d 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -82,7 +82,7 @@ std::string getClangFullRepositoryVersion() {
   OS << LLVMRepo << ' ';
 OS << LLVMRev << ')';
   }
-  return OS.str();
+  return buf;
 }
 
 std::string getClangFullVersion() {
@@ -102,7 +102,7 @@ std::string getClangToolFullVersion(StringRef ToolName) {
 OS << " " << repo;
   }
 
-  return OS.str();
+  return buf;
 }
 
 std::string getClangFullCPPVersion() {
@@ -120,7 +120,7 @@ std::string getClangFullCPPVersion() {
 OS << " " << repo;
   }
 
-  return OS.str();
+  return buf;
 }
 
 } // end namespace clang

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f760eb284e75f..5d795bfd37ae7 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1285,7 +1285,7 @@ static std::string 
serializeXRayInstrumentationBundle(const XRayInstrSet &S) {
   std::string Buffer;
   llvm::raw_string_ostream OS(Buffer);
   llvm::interleave(BundleParts, OS, [&OS](StringRef Part) { OS << Part; }, 
",");
-  return OS.str();
+  return Buffer;
 }
 
 // Set the profile kind using fprofile-instrument-use-path.

diff  --git a/clang/lib/Frontend/TestModuleFileExtension.cpp 
b/clang/lib/Frontend/TestModuleFileExtension.cpp
index ea737e6891bfe..2d5145d0c54c8 100644
--- a/clang/lib/Frontend/TestModuleFileExtension.cpp
+++ b/clang/lib/Frontend/TestModuleFileExtension.cpp
@@ -133,5 +133,5 @@ std::string TestModuleFileExtension::str() const {
   llvm::raw_string_ostream OS(Buffer);
   OS << BlockName << ":" << MajorVersion << ":" << MinorVersion << ":" << 
Hashed
  << ":" << UserInfo;
-  return OS.str();
+  return Buffer;
 }

diff  --git a/clang/lib/Rewrite/HTMLRewrite.cpp 
b/clang/lib/Rewrite/HTMLRewrite.cpp
index 371557a624c9c..e9b678b695946 100644
--- a/clang/lib/Rewrite/HTMLRewrite.cpp
+++ b/clang/lib/Rewrite/HTMLRewrite.cpp
@@ -203,7 +203,7 @@ std::string html::EscapeText(StringRef s, bool 
EscapeSpaces, bool ReplaceTabs) {
 }
   }
 
-  return os.str();
+  return Str;
 }
 
 static void AddLineNumber(RewriteBuffer &RB, unsigned LineNo,



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


[PATCH] D115374: [NFC][clang] Return std::strings built from raw_string_ostreams more efficiently

2021-12-09 Thread Logan Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG715c72b4fbf4: [NFC][analyzer] Return underlying strings 
directly instead of OS.str() (authored by logan-5).

Changed prior to commit:
  https://reviews.llvm.org/D115374?vs=393262&id=393319#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115374/new/

https://reviews.llvm.org/D115374

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -444,7 +444,7 @@
   std::string s;
   llvm::raw_string_ostream os(s);
   dumpToStream(os);
-  return os.str();
+  return s;
 }
 
 void MemRegion::dumpToStream(raw_ostream &os) const {
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -437,7 +437,7 @@
   for (auto BI : *Buf)
 os << BI;
 
-  return os.str();
+  return file;
 }
 
 void HTMLDiagnostics::dumpCoverageData(
@@ -534,7 +534,7 @@
 
 )<<<";
 
-  return os.str();
+  return s;
 }
 
 void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
@@ -1202,7 +1202,7 @@
   std::string Result;
   llvm::raw_string_ostream OS(Result);
   OS << "";
-  return OS.str();
+  return Result;
 }
 
 std::string getSpanBeginForControlStart(unsigned Index) {
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -389,7 +389,7 @@
 llvm::raw_string_ostream OS(SBuf);
 OS << "Function '" << FuncDecl->getDeclName()
<< "' returns an open handle";
-return OS.str();
+return SBuf;
   } else
 return "";
 });
@@ -405,7 +405,7 @@
 llvm::raw_string_ostream OS(SBuf);
 OS << "Function '" << FuncDecl->getDeclName()
<< "' returns an unowned handle";
-return OS.str();
+return SBuf;
   } else
 return "";
 });
@@ -439,7 +439,7 @@
   llvm::raw_string_ostream OS(SBuf);
   OS << "Handle released through " << ParamDiagIdx
  << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter";
-  return OS.str();
+  return SBuf;
 } else
   return "";
   });
@@ -453,7 +453,7 @@
 llvm::raw_string_ostream OS(SBuf);
 OS << "Handle allocated through " << ParamDiagIdx
<< llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter";
-return OS.str();
+return SBuf;
   } else
 return "";
 });
@@ -467,7 +467,7 @@
 llvm::raw_string_ostream OS(SBuf);
 OS << "Unowned handle allocated through " << ParamDiagIdx
<< llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter";
-return OS.str();
+return SBuf;
   } else
 return "";
 });
Index: clang/lib/Analysis/AnalysisDeclContext.cpp
===
--- clang/lib/Analysis/AnalysisDeclContext.cpp
+++ clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -387,7 +387,7 @@
 OS << ' ' << OMD->getSelector().getAsString() << ']';
   }
 
-  return OS.str();
+  return Str;
 }
 
 LocationContextManager &AnalysisDeclContext::getLocationContextManager() {
Index: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
===
--- clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
+++ clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
@@ -32,7 +32,7 @@
 std::string Str;
 llvm::raw_string_ostream OS(Str);
 S->printPretty(OS, nullptr, PrintingPolicy(ACtx.getLangOpts()));
-return OS.str();
+return Str;
   }
 
   bool isThisObject(const SymbolicRegion *R) {
@@ -69,7 +69,7 @@
 std::string Str;
 llvm::raw_string_ostream OS(Str);
 OS << "concrete memory address '" << I << "'";
-return OS.str();
+return Str;
   }
 
   std::string VisitNonLocSymbolVal(nonloc::SymbolVal V) {
@@ -82,7 +82,7 @@
 llvm::raw_string_ostream OS(Str);
 OS << (I.isSigned() ? "signed " : "unsigned ") << I.getBitWidth()
<< "-bit integer '" << I << "'";
-return OS.str();
+return Str;
   }
 
   std::string VisitNonLocLazyCompoundVal(nonloc::LazyCompoundVal V

[clang] 08eb614 - [NFC][testing] Return underlying strings directly instead of OS.str()

2021-12-09 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2021-12-09T16:05:46-08:00
New Revision: 08eb614e309048b695a9eb0d94e636b2324de094

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

LOG: [NFC][testing] Return underlying strings directly instead of OS.str()

This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b13610a5226b84889b923bae884ba395ad084d,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374

Added: 


Modified: 
clang/include/clang/Testing/TestClangConfig.h
clang/unittests/AST/ASTTraverserTest.cpp
clang/unittests/Analysis/MacroExpansionContextTest.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Testing/TestClangConfig.h 
b/clang/include/clang/Testing/TestClangConfig.h
index 5d6be4f65d0ad..92d5cc3cff994 100644
--- a/clang/include/clang/Testing/TestClangConfig.h
+++ b/clang/include/clang/Testing/TestClangConfig.h
@@ -73,7 +73,7 @@ struct TestClangConfig {
 std::string Result;
 llvm::raw_string_ostream OS(Result);
 OS << "{ Language=" << Language << ", Target=" << Target << " }";
-return OS.str();
+return Result;
   }
 
   friend std::ostream &operator<<(std::ostream &OS,

diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index d633f90b57d2d..b8eff747e3b50 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -111,7 +111,7 @@ template  std::string 
dumpASTString(NodeType &&... N) {
 
   Dumper.Visit(std::forward(N)...);
 
-  return OS.str();
+  return Buffer;
 }
 
 template 
@@ -126,7 +126,7 @@ std::string dumpASTString(TraversalKind TK, NodeType &&... 
N) {
 
   Dumper.Visit(std::forward(N)...);
 
-  return OS.str();
+  return Buffer;
 }
 
 const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,

diff  --git a/clang/unittests/Analysis/MacroExpansionContextTest.cpp 
b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
index 2e86457d276ca..7cee64c1b9b0c 100644
--- a/clang/unittests/Analysis/MacroExpansionContextTest.cpp
+++ b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
@@ -95,14 +95,14 @@ class MacroExpansionContextTest : public ::testing::Test {
 std::string Buf;
 llvm::raw_string_ostream OS{Buf};
 Ctx.dumpExpandedTextsToStream(OS);
-return OS.str();
+return Buf;
   }
 
   static std::string dumpExpansionRanges(const MacroExpansionContext &Ctx) {
 std::string Buf;
 llvm::raw_string_ostream OS{Buf};
 Ctx.dumpExpansionRangesToStream(OS);
-return OS.str();
+return Buf;
   }
 };
 

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 06da4e80156a4..d2acd324b9ca9 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -203,7 +203,7 @@ class ListTest : public SyntaxTreeTest {
 
 OS << "]";
 
-return OS.str();
+return Storage;
   }
 
   std::string dumpNodes(ArrayRef Nodes) {
@@ -218,7 +218,7 @@ class ListTest : public SyntaxTreeTest {
 
 OS << "]";
 
-return OS.str();
+return Storage;
   }
 };
 



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


[clang] ad17ea1 - [NFC][AST] Return underlying strings directly instead of OS.str()

2021-12-09 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2021-12-09T16:05:46-08:00
New Revision: ad17ea12e70abb05b6984f530618131181be9dad

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

LOG: [NFC][AST] Return underlying strings directly instead of OS.str()

This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b13610a5226b84889b923bae884ba395ad084d,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374

Added: 


Modified: 
clang/lib/AST/ASTDiagnostic.cpp
clang/lib/AST/AttrImpl.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclarationName.cpp
clang/lib/AST/OpenMPClause.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 4865f3f706b3f..2e512195fd15e 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -335,7 +335,7 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType 
Ty,
   OS << "'" << S << "' (vector of " << VTy->getNumElements() << " '"
  << VTy->getElementType().getAsString(Context.getPrintingPolicy())
  << "' " << Values << ")";
-  return OS.str();
+  return DecoratedString;
 }
   }
 

diff  --git a/clang/lib/AST/AttrImpl.cpp b/clang/lib/AST/AttrImpl.cpp
index a3b46752c5113..c2f13cf638309 100644
--- a/clang/lib/AST/AttrImpl.cpp
+++ b/clang/lib/AST/AttrImpl.cpp
@@ -60,7 +60,7 @@ std::string LoopHintAttr::getValueString(const PrintingPolicy 
&Policy) const {
   else
 OS << "disable";
   OS << ")";
-  return OS.str();
+  return ValueName;
 }
 
 // Return a string suitable for identifying this attribute in diagnostics.

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index c033563592d28..e63560f1b6fea 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1589,7 +1589,7 @@ std::string NamedDecl::getQualifiedNameAsString() const {
   std::string QualName;
   llvm::raw_string_ostream OS(QualName);
   printQualifiedName(OS, getASTContext().getPrintingPolicy());
-  return OS.str();
+  return QualName;
 }
 
 void NamedDecl::printQualifiedName(raw_ostream &OS) const {

diff  --git a/clang/lib/AST/DeclarationName.cpp 
b/clang/lib/AST/DeclarationName.cpp
index 56cf4b457a485..b2232ddfced32 100644
--- a/clang/lib/AST/DeclarationName.cpp
+++ b/clang/lib/AST/DeclarationName.cpp
@@ -236,7 +236,7 @@ std::string DeclarationName::getAsString() const {
   std::string Result;
   llvm::raw_string_ostream OS(Result);
   OS << *this;
-  return OS.str();
+  return Result;
 }
 
 void *DeclarationName::getFETokenInfoSlow() const {
@@ -460,7 +460,7 @@ std::string DeclarationNameInfo::getAsString() const {
   std::string Result;
   llvm::raw_string_ostream OS(Result);
   OS << *this;
-  return OS.str();
+  return Result;
 }
 
 raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {

diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index f721e56f7fdd1..56e140f107105 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -2454,7 +2454,7 @@ std::string OMPTraitInfo::getMangledName() const {
 Property.RawString);
 }
   }
-  return OS.str();
+  return MangledName;
 }
 
 OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {



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


[clang] 715c72b - [NFC][analyzer] Return underlying strings directly instead of OS.str()

2021-12-09 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2021-12-09T16:05:46-08:00
New Revision: 715c72b4fbf43d00909ebc9677d59ce8bb24bc23

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

LOG: [NFC][analyzer] Return underlying strings directly instead of OS.str()

This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b13610a5226b84889b923bae884ba395ad084d,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
clang/lib/Analysis/AnalysisDeclContext.cpp
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h 
b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
index 31a4ed50a7230..48cd3395e936d 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
+++ b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
@@ -32,7 +32,7 @@ class SValExplainer : public FullSValVisitor {
 std::string Str;
 llvm::raw_string_ostream OS(Str);
 S->printPretty(OS, nullptr, PrintingPolicy(ACtx.getLangOpts()));
-return OS.str();
+return Str;
   }
 
   bool isThisObject(const SymbolicRegion *R) {
@@ -69,7 +69,7 @@ class SValExplainer : public FullSValVisitor {
 std::string Str;
 llvm::raw_string_ostream OS(Str);
 OS << "concrete memory address '" << I << "'";
-return OS.str();
+return Str;
   }
 
   std::string VisitNonLocSymbolVal(nonloc::SymbolVal V) {
@@ -82,7 +82,7 @@ class SValExplainer : public FullSValVisitor {
 llvm::raw_string_ostream OS(Str);
 OS << (I.isSigned() ? "signed " : "unsigned ") << I.getBitWidth()
<< "-bit integer '" << I << "'";
-return OS.str();
+return Str;
   }
 
   std::string VisitNonLocLazyCompoundVal(nonloc::LazyCompoundVal V) {
@@ -123,7 +123,7 @@ class SValExplainer : public FullSValVisitor {
 OS << "(" << Visit(S->getLHS()) << ") "
<< std::string(BinaryOperator::getOpcodeStr(S->getOpcode())) << " "
<< S->getRHS();
-return OS.str();
+return Str;
   }
 
   // TODO: IntSymExpr doesn't appear in practice.
@@ -177,7 +177,7 @@ class SValExplainer : public FullSValVisitor {
 else
   OS << "'" << Visit(R->getIndex()) << "'";
 OS << " of " + Visit(R->getSuperRegion());
-return OS.str();
+return Str;
   }
 
   std::string VisitNonParamVarRegion(const NonParamVarRegion *R) {

diff  --git a/clang/lib/Analysis/AnalysisDeclContext.cpp 
b/clang/lib/Analysis/AnalysisDeclContext.cpp
index d8466ac34a3d4..06f1f813aeedd 100644
--- a/clang/lib/Analysis/AnalysisDeclContext.cpp
+++ b/clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -387,7 +387,7 @@ std::string AnalysisDeclContext::getFunctionName(const Decl 
*D) {
 OS << ' ' << OMD->getSelector().getAsString() << ']';
   }
 
-  return OS.str();
+  return Str;
 }
 
 LocationContextManager &AnalysisDeclContext::getLocationContextManager() {

diff  --git a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
index e3f4be0726c85..6e4801aa8e91b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -389,7 +389,7 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
&Call,
 llvm::raw_string_ostream OS(SBuf);
 OS << "Function '" << FuncDecl->getDeclName()
<< "' returns an open handle";
-return OS.str();
+return SBuf;
   } else
 return "";
 });
@@ -405,7 +405,7 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
&Call,
 llvm::raw_string_ostream OS(SBuf);
 OS << "Function '" << FuncDecl->getDeclName()
<< "' returns an unowned handle";
-return OS.str();
+return SBuf;
   } else
 return "";
 });
@@ -439,7 +439,7 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
&Call,
   llvm::raw_string_ostream OS(SBuf);
   OS << "Handle released through " << ParamDiagIdx
  << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter";
-  return OS.str();
+  return SBuf;
 } else
   return "";
   });
@@ -453,7 +453,7 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
&Call,
 llvm::raw_string_ostream OS(SBuf);
 OS << "Handle allocated through " << ParamDiagIdx
<< llvm::get

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-12-09 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D111617#3183146 , @HsiangKai wrote:

> Release build:
> Before this patch:
>
>  text data bssdec hex
>   115471733   7987112  443760 123902605   7629a8d ./bin/clang
>
> After this patch:
>
>  text data bssdec hex
>   117568981   7996376  443760 126009117   782bf1d ./bin/clang  (+1.7%)
>
> Debug build:
> Before this patch:
>
>  text data bssdec hex
>   265437945   9544132  494152 275476229   106b6f05./bin/clang
>
> After this patch:
>
>  text data bssdec hex
>   272133359   9553380  494152 282180891   10d1bd1b
> ./bin/clang. (+2.4%)

cmake options:
Release build:

  cmake -DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang-10 \
-DCMAKE_CXX_COMPILER=clang++-10 \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_PARALLEL_LINK_JOBS=8 \
-DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-elf" \
-G "Ninja" $SOURCE

Debug build:

  cmake -DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang-10 \
-DCMAKE_CXX_COMPILER=clang++-10 \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_PARALLEL_LINK_JOBS=8 \
-G "Ninja" $SOURCE


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111617/new/

https://reviews.llvm.org/D111617

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


[PATCH] D113943: Add `withIntrospection` matcher.

2021-12-09 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added a comment.

Nit:
Personally, I would prefer the name `withDebugOutput` over `withIntrospection`, 
as it more clearly describes the intent of this matcher.
At least to me, "introspection" is usually something done programatically, i.e. 
the matcher somehow reflects about its own state, but in this case all we are 
doing is printing some debug output to stderr.

Code looks good to me, but I don't know the LLVM coding guidelines and hence 
can't provide an actual code review




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3000-3001
+  const internal::Matcher &InnerMatcher) {
+  return internal::Matcher(new internal::WithIntrospectionMatcher(
+  BeforeTag, AfterTag, InnerMatcher));
+}

std::move(BeforeTag), std::move(AfterTag)

No need to create additional copies of those strings. Here and other places


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113943/new/

https://reviews.llvm.org/D113943

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


[PATCH] D115346: [clang][deps] Squash caches for original and minimized files

2021-12-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:106-108
+  std::unique_ptr OriginalContents;
+  std::unique_ptr MinimizedContents;
   PreprocessorSkippedRangeMapping PPSkippedRangeMapping;

jansvoboda11 wrote:
> dexonsmith wrote:
> > I'm finding it a bit subtle detecting if there are races on access / 
> > setting of these, but I think it's correct.
> > - I think I verified that they are "set once".
> > - All the setters are guarded by locks.
> > - The first getter per "local" cache is guarded by a lock.
> > - Subsequent getters are not.
> > 
> > The key question: are the subsequent getters ONLY used when the first 
> > getter was successful?
> > 
> > One way to make it more obvious:
> > ```
> > lang=c++
> >   struct ContentWithPPRanges {
> > std::unique_ptr Content;
> > PreprocessorSkippedRangeMapping PPSkippedRangeMapping;
> >   };
> > 
> > private:
> >   // Always accessed,mutated under a lock. Not mutated after they escape.
> >   std::unique_ptr Original;
> >   std::unique_ptr Minimized;
> >   PreprocessorSkippedRangeMapping PPSkippedRangeMapping;
> > 
> >   // Used in getters. Pointed-at memory immutable after these are set.
> >   std::atomic OriginalAccess;
> >   std::atomic MinimizedAccess;
> >   std::atomic PPRangesAccess;
> > ```
> > I don't think this is the only approach though.
> > 
> I think there are no races on the original contents. The pointer is 
> unconditionally set on creation of `CachedFileSystemEntry` under a lock that 
> no threads get past without having set the pointer (or failing and never 
> accessing the pointer).
> 
> For minimized contents, the latest revision adds check at the beginning of 
> the main function (`needsMinimization`) outside the critical section. There 
> are three paths I can think of:
> * The check returns `true` in thread A (pointer is `null`), thread A enters 
> critical section, minimizes the contents and initializes the pointer.
> * The check returns `true` in thread A, but thread B entered the critical 
> section, minimized contents and initialized the pointer. When thread A enters 
> the critical section, it performs the check again, figures that out and skips 
> minimization.
> * The check returns `false` and the local cache entry is returned.
> 
> So there definitely is a race here, but I believe it's benign. Do you agree? 
> Do you think it's worth addressing?
I don't trust myself to evaluate whether it's benign, but if there's no atomic 
mutation, then I think it's possible that when the setter changes a value from 
"x" to "y" then the racing reader can see a third value "z". You might gain 
some confidence by using `-fsanitize=thread` on a workload that's going to 
include this sort of thing -- probably hard to exercise: PCH already exists, 
try minimizing something that uses the PCH, and then try minimizing something 
that doesn't.

I'd rather just avoid the race entirely so we don't need to guess though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115346/new/

https://reviews.llvm.org/D115346

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


[PATCH] D113237: [RISCV] Support I extension version 2.1

2021-12-09 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Outside of the I/F/D special cases, where F/D don't really matter and I2p0 is 
just I2p1Zicsr2p0_Zifencei2p0,, I thought the new policy was that ratified 
extensions would never be changed, only new extensions published, and thus 
version numbers are basically irrelevant other than to distinguish ratified 
from pre-ratified?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113237/new/

https://reviews.llvm.org/D113237

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


[PATCH] D115471: [clang] number labels in asm goto strings after tied inputs

2021-12-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: void, efriedma, jyknight, craig.topper.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I noticed that the following case would compile in Clang but not GCC:

  void *x(void) {
void *p = &&foo;
asm goto ("# %0\n\t# %l1":"+r"(p):::foo);
foo:;
return p;
  }

Changing the output template above from %l2 would compile in GCC but not
Clang.

This demonstrates that when using tied outputs (say via the "+r" output
constraint), the hidden inputs occur or are numbered BEFORE the labels,
at least with GCC.

For the sake of compatibility, I think it's worthwhile to just make this
change.

It's better to use symbolic names for compatibility (especially now
between released version of Clang that support asm goto with outputs).
ie. %l1 from the above would be %l[foo].

Also, I cleaned up some cruft in GCCAsmStmt::getNamedOperand. AFAICT,
NumPlusOperands was no longer used, though I couldn't find which commit
didn't clean that up correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115471

Files:
  clang/lib/AST/Stmt.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/asm-goto.c

Index: clang/test/CodeGen/asm-goto.c
===
--- clang/test/CodeGen/asm-goto.c
+++ clang/test/CodeGen/asm-goto.c
@@ -55,14 +55,14 @@
 
 int test4(int out1, int out2) {
   // CHECK-LABEL: define{{.*}} i32 @test4(
-  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${3:l}", "={si},={di},r,i,i,0,1
+  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${5:l}", "={si},={di},r,0,1,i,i
   // CHECK: to label %asm.fallthrough [label %label_true, label %loop]
   // CHECK-LABEL: asm.fallthrough:
   if (out1 < out2)
-asm volatile goto("jne %l3" : "+S"(out1), "+D"(out2) : "r"(out1) :: label_true, loop);
+asm volatile goto("jne %l5" : "+S"(out1), "+D"(out2) : "r"(out1) :: label_true, loop);
   else
-asm volatile goto("jne %l5" : "+S"(out1), "+D"(out2) : "r"(out1), "r"(out2) :: label_true, loop);
-  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${5:l}", "={si},={di},r,r,i,i,0,1
+asm volatile goto("jne %l7" : "+S"(out1), "+D"(out2) : "r"(out1), "r"(out2) :: label_true, loop);
+  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${7:l}", "={si},={di},r,r,0,1,i,i
   // CHECK: to label %asm.fallthrough2 [label %label_true, label %loop]
   // CHECK-LABEL: asm.fallthrough2:
   return out1 + out2;
@@ -74,7 +74,7 @@
 
 int test5(int addr, int size, int limit) {
   // CHECK-LABEL: define{{.*}} i32 @test5(
-  // CHECK: callbr i32 asm "add $1,$0 ; jc ${3:l} ; cmp $2,$0 ; ja ${3:l} ; ", "=r,imr,imr,i,0
+  // CHECK: callbr i32 asm "add $1,$0 ; jc ${4:l} ; cmp $2,$0 ; ja ${4:l} ; ", "=r,imr,imr,0,i
   // CHECK: to label %asm.fallthrough [label %t_err]
   // CHECK-LABEL: asm.fallthrough:
   asm goto(
@@ -92,14 +92,40 @@
 
 int test6(int out1) {
   // CHECK-LABEL: define{{.*}} i32 @test6(
-  // CHECK: callbr i32 asm sideeffect "testl $0, $0; testl $1, $1; jne ${2:l}", "={si},r,i,i,0,{{.*}} i8* blockaddress(@test6, %label_true), i8* blockaddress(@test6, %landing)
+  // CHECK: callbr i32 asm sideeffect "testl $0, $0; testl $1, $1; jne ${3:l}", "={si},r,0,i,i,{{.*}} i8* blockaddress(@test6, %label_true), i8* blockaddress(@test6, %landing)
   // CHECK: to label %asm.fallthrough [label %label_true, label %landing]
   // CHECK-LABEL: asm.fallthrough:
   // CHECK-LABEL: landing:
   int out2 = 42;
-  asm volatile goto("testl %0, %0; testl %1, %1; jne %l2" : "+S"(out2) : "r"(out1) :: label_true, landing);
+  asm volatile goto("testl %0, %0; testl %1, %1; jne %l3" : "+S"(out2) : "r"(out1) :: label_true, landing);
 landing:
   return out1 + out2;
 label_true:
   return -2;
 }
+
+// test7 - For the output templates in the asm string (%0, %l2), GCC places
+// hidden inputs tied to outputs ("+r" constraint) BEFORE labels. Test that foo
+// is $2 (or rather ${2:l} because of the l output template) in the emitted asm
+// string, not $1.
+void *test7(void) {
+  // CHECK-LABEL: define{{.*}} i8* @test7(
+  // CHECK: %1 = callbr i8* asm "# $0\0A\09# ${2:l}", "=r,0,i,~{dirflag},~{fpsr},~{flags}"(i8* %0, i8* blockaddress(@test7, %foo))
+  // CHECK-NEXT: to label %asm.fallthrough [label %foo]
+  void *p = &&foo;
+  asm goto ("# %0\n\t# %l2":"+r"(p):::foo);
+foo:
+  return p;
+}
+
+// test8 - the same as test7, but this time we use symbolic names rather than
+// numbered outputs.
+void *test8(void) {
+  // CHECK-LABEL: define{{.*}} i8* @test8(
+  // CHECK: %1 = callbr i8* asm "# $0\0A\09# ${2:l}", "=r,0,i,~{dirflag},~{fpsr},~{flags}"(i8* %0, i8* blockaddress(@test8, %foo))
+  // CHECK-NEXT: to label %asm.fallthrough [label %foo]
+  void *p = &&foo;
+  asm goto ("# %0\n\t# %l[foo]":"+r"(p):::foo);
+foo:
+  return p;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib

[PATCH] D113237: [RISCV] Support I extension version 2.1

2021-12-09 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

There is several issue around the default extension version stuffs.

- Should we add `-misa-spec=` option to Clang/LLVM?
- Behavior for `zifencei` and `zicsr` with `i` 2.0?
- How to encode the extension version in LLVM? by attribute or module flags?

---

Should we add `-misa-spec=` option to Clang/LLVM?
-

Here is a long discussion[1] at 2019, at that moment I think we all agree 
-misa-spec is a good solution,

However it's kind of awkward for this scheme is ISA spec changing the version 
scheme again after `20191213` release,
it's become NO formal release for long time, just bunch of draft release.

That's means NO `-misa-spec` version can cover vector, crypto and bit 
manipulation.

So we might consider different scheme on controlling default version,
or change the semantic of `-misa-spec` to make it no longer just reference 
version of RISC-V ISA manual,
maybe we could reference RISC-V profile[2], but the spec still under discussion.

For GNU toolchain land, `-misa-spec=` already implemented in GNU toolchain 
about ~ 2yrs,
so I prefer change the semantic to reference version other than version of 
RISC-V ISA manual
rather than adding new command line option to control that.

[1] 
https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/aZhMG7NIVTk/m/PTZEaTWiAwAJ
[2] https://github.com/riscv/riscv-profiles

---

Behavior for `zifencei` and `zicsr` with `i` 2.0?
-

I would suggest still accept `i` 2.0 with `zifencei` and `zicsr` for 
compatibility,
but NO effect and NO ELF attribute for those two extensions if `I` is `2.0`,
however I don't have strong opinion on this issue.

---

How to encode the extension version in LLVM? by attribute or module flags?
--

It's kind of LLVM specific implementation issue, RISC-V LLVM use target 
attribute to
enable/disable specific extension, but we didn't encode version info in target 
attribute or module flags yet,
there is not too much problem on clang side during parsing arch string, but 
that cause some problem on ELF
attribute emission, `+a` means `2.0` or `2.1`? `+f` means `2.0`, `2.1` or 
`2.2`? and what the version of `i`?

`i` has major change between `2.0` and `2.1`, so we might consider adding new 
target attribute (e.g `+i2p1`?) to identify the version of `i`.

But `f` and `d` is clarification on the NaN behavior, which is related minor 
for toolchain, so adding new target attribute to that is kind of ... weird?

`f`/`d` 2.0

  FMIN.S and FMAX.S write, respectively, the smaller or larger of rs1 and
  rs2 to rd. 

`f`/`d` 2.2

  Floating-point minimum-number and maximum-number instructions FMIN.S and 
FMAX.S write,
  respectively, the smaller or larger of rs1 and rs2 to rd. For the purposes of 
these instructions only,
  the value −0.0 is considered to be less than the value +0.0. If both inputs 
are NaNs, the result is
  the canonical NaN. If only one operand is a NaN, the result is the non-NaN 
operand. Signaling
  NaN inputs set the invalid operation exception flag, even when the result is 
not NaN.

Anyway, I think here is two possible solution, but I didn't have strong opinion 
here:

- Add new target attribute for each version.
- Encode whole arch string with explicit version into module flag.

Note: Ext. versions in RISC-V ISA spec 20191213: `I` 2.1, `M` 2.0, `A` 2.1, `F` 
2.2, `D` 2.2, `C` 2.0, `E` 1.9, `Zicsr` 2.0, `Zifencei` 2.1


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113237/new/

https://reviews.llvm.org/D113237

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


[PATCH] D115374: [NFC][clang] Return std::strings built from raw_string_ostreams more efficiently

2021-12-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

In D115374#3183776 , @logan-5 wrote:

> Removed `.flush()`es. Seems like this might be able to land without 
> https://reviews.llvm.org/D115421?

Yup! LGTM if you remove the cleanups that are no longer related to this patch, 
and/or split them into separate follow-up NFC commits. Might be nice to split 
even the main commit into a few pieces (e.g., by functional area) to push 
separately, just in case something needs to be reverted due to a call to 
`SetBuffered()` in an unexpected place.

Please make sure the commit message points at 
65b13610a5226b84889b923bae884ba395ad084d 
, which 
made this correct.




Comment at: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h:70
 std::string Str;
-llvm::raw_string_ostream OS(Str);
-OS << "concrete memory address '" << I << "'";
-return OS.str();
+llvm::raw_string_ostream(Str) << "concrete memory address '" << I << "'";
+return Str;

Given there's no scope change needed, these cleanups are no longer related to 
the patch and are adding noise to the diff. I suggest committing them 
separately (or not at all).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115374/new/

https://reviews.llvm.org/D115374

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


[PATCH] D114483: [SYCL] Add support for sycl_special_class attribute

2021-12-09 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 393278.
zahiraam marked an inline comment as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114483/new/

https://reviews.llvm.org/D114483

Files:
  clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaSYCL/special-class-attribute-on-non-sycl.cpp
  clang/test/SemaSYCL/special-class-attribute.cpp

Index: clang/test/SemaSYCL/special-class-attribute.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/special-class-attribute.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+
+// No diagnostics
+class [[clang::sycl_special_class]] class1 {
+  void __init() {};
+};
+class __attribute__((sycl_special_class)) class2 {
+  void __init() {};
+};
+
+class class3;
+class [[clang::sycl_special_class]] class3 {
+  void __init() {};
+};
+
+class class4;
+class __attribute__((sycl_special_class)) class4 {
+  void __init() {};
+};
+
+class [[clang::sycl_special_class]] struct1 {
+  void __init() {};
+};
+struct __attribute__((sycl_special_class)) struct2 {
+  void __init() {};
+};
+
+class [[clang::sycl_special_class]] class5 {
+  void __init() {};
+};
+class special5 {};
+
+class __attribute__((sycl_special_class)) class6;
+class class6 {
+  void __init() {};
+};
+
+
+// Must have __init method defined
+class __attribute__((sycl_special_class)) class7 { // expected-error {{types with 'sycl_special_class' attribute must have an '__init' method defined}}
+  class7() {}
+};
+class [[clang::sycl_special_class]] class8 { // expected-error {{types with 'sycl_special_class' attribute must have an '__init' method defined}}
+  void __init();
+};
+
+struct __attribute__((sycl_special_class)) struct3;
+struct struct3 {}; // expected-error {{types with 'sycl_special_class' attribute must have an '__init' method defined}}
+
+
+// Only classes
+[[clang::sycl_special_class]] int var1 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+__attribute__((sycl_special_class)) int var2 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+
+[[clang::sycl_special_class]] void foo1(); // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+__attribute__((sycl_special_class)) void foo2(); // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+
+// Attribute takes no arguments
+class [[clang::sycl_special_class(1)]] class9 {}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
+class __attribute__((sycl_special_class(1))) class10 {}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
Index: clang/test/SemaSYCL/special-class-attribute-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/special-class-attribute-on-non-sycl.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+
+#ifndef __SYCL_DEVICE_ONLY__
+// expected-warning@+5 {{'sycl_special_class' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+class __attribute__((sycl_special_class)) special_class {
+  void __init() {};
+};
+
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -154,6 +154,7 @@
 // CHECK-NEXT: ReturnTypestate (SubjectMatchRule_function, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
+// CHECK-NEXT: SYCLSpecialClass (SubjectMatchRule_record)
 // CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7757,6 +7757,13 @@
   handleSimpleAttribute(S, D, AL);
 }
 
+static void handleSYCLSpecialClassAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // The 'sycl_special_class' attribute applies only to records.
+  const auto *RD = cast(D);
+  assert(RD && "Record type is expected");
+  handleSimpleAttribute(S, D

[clang] bc9c4d7 - [OpenMP][FIX] Pass the num_threads value directly to parallel_51

2021-12-09 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2021-12-09T16:30:29-05:00
New Revision: bc9c4d7216a5bcdeec8543834fe1451db2c46e5c

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

LOG: [OpenMP][FIX] Pass the num_threads value directly to parallel_51

The problem with the old scheme is that we would need to keep track of
the "next region" and reset the num_threads value after it. The new RT
doesn't do it and an assertion is triggered. The old RT doesn't do it
either, I haven't tested it but I assume a num_threads clause might
impact multiple parallel regions "accidentally". Further, in SPMD mode
num_threads was simply ignored, for some reason beyond me.

In any case, parallel_51 is designed to take the clause value directly,
so let's do that instead.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D113623

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
clang/test/OpenMP/nvptx_target_codegen.cpp
clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
openmp/libomptarget/DeviceRTL/include/Interface.h
openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
openmp/libomptarget/deviceRTLs/common/omptarget.h
openmp/libomptarget/deviceRTLs/common/omptargeti.h
openmp/libomptarget/deviceRTLs/common/src/parallel.cu
openmp/libomptarget/deviceRTLs/interface.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index c3a01448389b3..280cf853ab77c 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2085,7 +2085,8 @@ void CGOpenMPRuntime::emitIfClause(CodeGenFunction &CGF, 
const Expr *Cond,
 void CGOpenMPRuntime::emitParallelCall(CodeGenFunction &CGF, SourceLocation 
Loc,
llvm::Function *OutlinedFn,
ArrayRef CapturedVars,
-   const Expr *IfCond) {
+   const Expr *IfCond,
+   llvm::Value *NumThreads) {
   if (!CGF.HaveInsertPoint())
 return;
   llvm::Value *RTLoc = emitUpdateLocation(CGF, Loc);
@@ -12890,7 +12891,8 @@ void 
CGOpenMPSIMDRuntime::emitParallelCall(CodeGenFunction &CGF,
SourceLocation Loc,
llvm::Function *OutlinedFn,
ArrayRef 
CapturedVars,
-   const Expr *IfCond) {
+   const Expr *IfCond,
+   llvm::Value *NumThreads) {
   llvm_unreachable("Not supported in SIMD-only mode");
 }
 

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h 
b/clang/lib/CodeGen/CGOpenMPRuntime.h
index 527a23a8af6a8..95704226f9b20 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -1015,11 +1015,13 @@ class CGOpenMPRuntime {
   /// variables used in \a OutlinedFn function.
   /// \param IfCond Condition in the associated 'if' clause, if it was
   /// specified, nullptr otherwise.
+  /// \param NumThreads The value corresponding to the num_threads clause, if
+  /// any, or nullptr.
   ///
   virtual void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
 llvm::Function *OutlinedFn,
 ArrayRef CapturedVars,
-const Expr *IfCond);
+const Expr *IfCond, llvm::Value *NumThreads);
 
   /// Emits a critical region.
   /// \param CriticalName Name of the critical region.
@@ -1991,11 +1993,13 @@ class CGOpenMPSIMDRuntime final : public 
CGOpenMPRuntime {
   /// variables used in \a OutlinedFn function.
   /// \param IfCond Condition in the associated 'if' clause, if it was
   /// specified, nullptr otherwise.
+  /// \param NumThreads The value corresponding to the num_threads clause, if
+  /// any, or nullptr.
   ///
   void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
 llvm::Function *OutlinedFn,
 ArrayRef CapturedVars,
-const Expr *IfCond) override;
+const Expr *IfCond, llvm::Value *NumThreads) override;
 
   /// Emits a critical region.
   /// \param CriticalName Name of the critical region.

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index dcb224f331561..fb4061b7ce9e9 10

[PATCH] D113623: [OpenMP][FIX] Pass the num_threads value directly to parallel_51

2021-12-09 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc9c4d7216a5: [OpenMP][FIX] Pass the num_threads value 
directly to parallel_51 (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113623/new/

https://reviews.llvm.org/D113623

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  openmp/libomptarget/DeviceRTL/include/Interface.h
  openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
  openmp/libomptarget/deviceRTLs/common/omptarget.h
  openmp/libomptarget/deviceRTLs/common/omptargeti.h
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/interface.h

Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -220,8 +220,6 @@
 
 // parallel
 EXTERN int32_t __kmpc_global_thread_num(kmp_Ident *loc);
-EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t global_tid,
-int32_t num_threads);
 NOINLINE EXTERN uint8_t __kmpc_parallel_level();
 
 // proc bind
@@ -445,7 +443,8 @@
   bool RequiresFullRuntime);
 EXTERN void __kmpc_target_deinit(ident_t *Ident, int8_t Mode,
  bool RequiresFullRuntime);
-EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn);
+EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn,
+   int32_t NumThreadsClause);
 EXTERN bool __kmpc_kernel_parallel(void **WorkFn);
 EXTERN void __kmpc_kernel_end_parallel();
 
Index: openmp/libomptarget/deviceRTLs/common/src/parallel.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/parallel.cu
+++ openmp/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -73,7 +73,8 @@
 }
 
 // This routine is always called by the team master..
-EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn) {
+EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn,
+   kmp_int32 NumThreadsClause) {
   PRINT0(LD_IO, "call to __kmpc_kernel_prepare_parallel\n");
 
   omptarget_nvptx_workFn = WorkFn;
@@ -92,9 +93,6 @@
 return;
   }
 
-  uint16_t &NumThreadsClause =
-  omptarget_nvptx_threadPrivateContext->NumThreadsForNextParallel(threadId);
-
   uint16_t NumThreads =
   determineNumberOfThreads(NumThreadsClause, nThreads, threadLimit);
 
@@ -255,16 +253,6 @@
 // push params
 
 
-EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t tid,
-int32_t num_threads) {
-  PRINT(LD_IO, "call kmpc_push_num_threads %d\n", num_threads);
-  ASSERT0(LT_FUSSY, isRuntimeInitialized(),
-  "Runtime must be initialized.");
-  tid = GetLogicalThreadIdInBlock();
-  omptarget_nvptx_threadPrivateContext->NumThreadsForNextParallel(tid) =
-  num_threads;
-}
-
 // Do nothing. The host guarantees we started the requested number of
 // teams and we only need inspection of gridDim.
 
@@ -304,11 +292,7 @@
 return;
   }
 
-  // Handle the num_threads clause.
-  if (num_threads != -1)
-__kmpc_push_num_threads(ident, global_tid, num_threads);
-
-  __kmpc_kernel_prepare_parallel((void *)wrapper_fn);
+  __kmpc_kernel_prepare_parallel((void *)wrapper_fn, num_threads);
 
   if (nargs) {
 void **GlobalArgs;
Index: openmp/libomptarget/deviceRTLs/common/omptargeti.h
===
--- openmp/libomptarget/deviceRTLs/common/omptargeti.h
+++ openmp/libomptarget/deviceRTLs/common/omptargeti.h
@@ -158,8 +158,6 @@
   // levelOneTaskDescr is init when starting the parallel region
   // top task descr is NULL (team master version will be fixed separately)
   topTaskDescr[tid] = NULL;
-  // no num threads value has been pushed
-  nextRegion.tnum[tid] = 0;
   // the following don't need to be init here; they are init when using dyn
   // sched
   // current_Event, events_Number, chunk, num_Iterations, schedule
Index: openmp/libomptarget/deviceRTLs/common/omptarget.h
===
--- openmp/libomptarget/deviceRTLs/common/omptarget.h
+++ openmp/libomptarget/deviceRTLs/common/omptarget.h
@@ -181,10 +181,6 @@
 topTaskDescr[tid] = taskICV;
   }
   INLINE omptarget_nvptx_TaskDescr *GetTopLevelTaskDescr(int tid) const;
-  // parallel
-  INLINE uint16_t &NumThreadsForNextParallel(int tid) {
-return nextRegion.tnum

[PATCH] D115440: Provide __builtin_alloca*_uninitialized variants

2021-12-09 Thread Marco Elver via Phabricator via cfe-commits
melver abandoned this revision.
melver added a comment.

GCC devs say that initializing explicit alloca() is a bug, because they aren't 
"automatic storage": 
https://lkml.kernel.org/r/20211209201616.gu...@gate.crashing.org
.. which is also the reason why GCC's behaviour differs here at the moment.

I actually agree with that, and alloca auto-init behaviour needs a new -mllvm 
param.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115440/new/

https://reviews.llvm.org/D115440

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


[PATCH] D115374: [NFC][clang] Return std::strings built from raw_string_ostreams more efficiently

2021-12-09 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 393262.
logan-5 added a comment.

Removed `.flush()`es. Seems like this might be able to land without 
https://reviews.llvm.org/D115421?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115374/new/

https://reviews.llvm.org/D115374

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/Testing/TestClangConfig.h
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/AttrImpl.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclarationName.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/Basic/Version.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/TestModuleFileExtension.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/Analysis/MacroExpansionContextTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -203,7 +203,7 @@
 
 OS << "]";
 
-return OS.str();
+return Storage;
   }
 
   std::string dumpNodes(ArrayRef Nodes) {
@@ -218,7 +218,7 @@
 
 OS << "]";
 
-return OS.str();
+return Storage;
   }
 };
 
Index: clang/unittests/Analysis/MacroExpansionContextTest.cpp
===
--- clang/unittests/Analysis/MacroExpansionContextTest.cpp
+++ clang/unittests/Analysis/MacroExpansionContextTest.cpp
@@ -95,14 +95,14 @@
 std::string Buf;
 llvm::raw_string_ostream OS{Buf};
 Ctx.dumpExpandedTextsToStream(OS);
-return OS.str();
+return Buf;
   }
 
   static std::string dumpExpansionRanges(const MacroExpansionContext &Ctx) {
 std::string Buf;
 llvm::raw_string_ostream OS{Buf};
 Ctx.dumpExpansionRangesToStream(OS);
-return OS.str();
+return Buf;
   }
 };
 
Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -111,7 +111,7 @@
 
   Dumper.Visit(std::forward(N)...);
 
-  return OS.str();
+  return Buffer;
 }
 
 template 
@@ -126,7 +126,7 @@
 
   Dumper.Visit(std::forward(N)...);
 
-  return OS.str();
+  return Buffer;
 }
 
 const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -139,7 +139,7 @@
 
   Passes.run(*M);
 
-  return OS.str();
+  return outString;
 }
 
 // Takes a function and runs it on a set of inputs
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -263,7 +263,7 @@
   OS << " ";
 }
   });
-  return OS.str();
+  return Storage;
 }
 
 void syntax::Node::assertInvariants() const {
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -927,5 +927,5 @@
   M.EndExpanded);
 }
   }
-  return OS.str();
+  return Dump;
 }
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -444,7 +444,7 @@
   std::string s;
   llvm::raw_string_ostream os(s);
   dumpToStream(os);
-  return os.str();
+  return s;
 }
 
 void MemRegion::dumpToStream(raw_ostream &os) const {
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -437,7 +437,7 @@
   for (auto BI : *Buf)
 os << BI;
 
-  return os.str();
+  return file;
 }
 
 void HTMLDiagnostics::dumpCoverageData(
@@ -534,7 +534,7 @@
 
 )<<<";
 
-  return os.str();
+  return s;
 }
 
 void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
@@ -1200,9 +1200,9 @@
 
 std::string getSpanBeginForControl(const char *ClassName, unsigned Index) {
   std::string Res

[PATCH] D115283: [AMDGPU] Set "amdgpu_hostcall" module flag if an AMDGPU function has calls to device lib functions that use hostcalls.

2021-12-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D115283#3183034 , @JonChesterfield 
wrote:

> In D115283#3182879 , @yaxunl wrote:
>
>> In D115283#3181128 , 
>> @JonChesterfield wrote:
>>
>>> Not exactly that. The weak symbol isn't the function name, as that gets 
>>> renamed or inlined.
>>
>> We discussed this before. As code object ABI use runtime metadata to 
>> represent hostcall_buffer, we need to check whether hostcall is needed by IR.
>>
>> This approach will require checking asm instructions inside a function to 
>> determine whether this function requires hostcall. It is hacky for IR 
>> representation.
>
> There are two approaches here:
> 1/ Tag the function using inline asm and totally ignore it in the compiler. 
> HSA/etc tests per-code-object if the symbol is present
> 2/ Tag the function (in source or in compiler), propagate information to llc, 
> embed it in msgpack data, HSA/etc tests per-function if the field is present
>
> 2/ is somewhat useful if we elide the 8 byte slot of kernarg memory for 
> functions that don't use it, otherwise it just increases work done by the 
> runtime. Instead of checking for presence of one symbol (a hashtable lookup), 
> it's a linear scan through msgpack data. We don't currently elide those 8 
> bytes, so right now this is making the compiler more complicated in exchange 
> for making the runtime slower.
>
> 1/ has the benefit of being dead simple and totally compiler agnostic, and 
> the cost of passing the 8 byte hostcall thing to every function in a code 
> object that asked for it.

Option 1 needs code object ABI change that does not work with old ROCm runtime. 
We need to maintain certain stability and backward compatibility with old ROCm 
as we have customers who use trunk clang/llvm with older ROCm runtime.

We could discuss option 1 for the next version of code object format. However, 
before that happens, we still need to fix the bug within the current ABI.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115283/new/

https://reviews.llvm.org/D115283

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


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:2590
+  llvm::Regex RawStringRegex(
+  "R\"([A-Za-z0-9_{}#<>%:;.?*+/^&\\$|~!=,'\\-]*)\\(");
+  SmallVector RawStringMatches;

MyDeveloperDay wrote:
> curdeius wrote:
> > I'm picky but you missed `[` and `]`, no?
> I couldn't get them to work, even if I escaped them.. let me go look at the 
> Regex unit tests
You can try putting`]` at the beginning (just after the opening`[`). It 
*should* work.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115168/new/

https://reviews.llvm.org/D115168

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


[PATCH] D115374: [NFC][clang] Return std::strings built from raw_string_ostreams more efficiently

2021-12-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Returning from https://reviews.llvm.org/D115421, it looks like that 
`raw_string_ostream` has unbuffered by default since 
65b13610a5226b84889b923bae884ba395ad084d 
. Seems 
like all the new `flush()`s in this patch are no-ops. You can simplify this 
patch to just mechanically converting `return OS.str()` to `return S`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115374/new/

https://reviews.llvm.org/D115374

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


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:2590
+  llvm::Regex RawStringRegex(
+  "R\"([A-Za-z0-9_{}#<>%:;.?*+/^&\\$|~!=,'\\-]*)\\(");
+  SmallVector RawStringMatches;

curdeius wrote:
> I'm picky but you missed `[` and `]`, no?
I couldn't get them to work, even if I escaped them.. let me go look at the 
Regex unit tests


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115168/new/

https://reviews.llvm.org/D115168

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


[PATCH] D115379: ASTMatchers: Avoid using SmallVector::set_size()

2021-12-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115379/new/

https://reviews.llvm.org/D115379

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


[PATCH] D115456: Implement on-demand TLS initialization for Microsoft CXX ABI

2021-12-09 Thread Maurice Heumann via Phabricator via cfe-commits
momo5502 updated this revision to Diff 393247.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115456/new/

https://reviews.llvm.org/D115456

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/ms-thread_local.cpp

Index: clang/test/CodeGenCXX/ms-thread_local.cpp
===
--- clang/test/CodeGenCXX/ms-thread_local.cpp
+++ clang/test/CodeGenCXX/ms-thread_local.cpp
@@ -17,10 +17,20 @@
 
 // CHECK-DAG: @"?b@@3UA@@A" = dso_local thread_local global %struct.A zeroinitializer, align 1
 // CHECK-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-DAG: @__tls_guard = external dso_local thread_local global i8
 // CHECK-LD-DAG: @"?b@@3UA@@A" = dso_local thread_local(localdynamic) global %struct.A zeroinitializer, align 1
 // CHECK-LD-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-LD-DAG: @__tls_guard = external dso_local thread_local global i8
 thread_local A b;
 
+// CHECK-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+
+// CHECK-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK: call void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK-LD: call void @__dyn_tls_on_demand_init()
+
 // CHECK-LABEL: define internal void @__tls_init()
 // CHECK: call void @"??__Eb@@YAXXZ"
 // CHECK-LD-LABEL: define internal void @__tls_init()
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -401,7 +401,7 @@
   ArrayRef CXXThreadLocalInitVars) override;
 
   bool usesThreadWrapperFunction(const VarDecl *VD) const override {
-return false;
+return true;
   }
   LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD,
   QualType LValType) override;
@@ -2397,11 +2397,83 @@
   }
 }
 
+static llvm::GlobalValue *getTlsGuardVar(CodeGenModule &CGM) {
+  llvm::Type *VTy = llvm::Type::getInt8Ty(CGM.getLLVMContext());
+  llvm::Constant *TlsGuardConstant =
+  CGM.CreateRuntimeVariable(VTy, "__tls_guard");
+  llvm::GlobalValue *TlsGuard = cast(TlsGuardConstant);
+
+  TlsGuard->setThreadLocal(true);
+
+  return TlsGuard;
+}
+
+static llvm::FunctionCallee getDynTlsOnDemandInitFn(CodeGenModule &CGM) {
+  llvm::FunctionType *FTy =
+  llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), {},
+  /*isVarArg=*/false);
+  return CGM.CreateRuntimeFunction(
+  FTy, "__dyn_tls_on_demand_init",
+  llvm::AttributeList::get(CGM.getLLVMContext(),
+   llvm::AttributeList::FunctionIndex,
+   llvm::Attribute::NoUnwind),
+  /*Local=*/true);
+}
+
+static void emitTlsGuardCheck(CodeGenFunction &CGF, llvm::GlobalValue *TlsGuard,
+  llvm::BasicBlock *DynInitBB,
+  llvm::BasicBlock *ContinueBB) {
+  llvm::LoadInst *TlsGuardValue =
+  CGF.Builder.CreateLoad(Address(TlsGuard, CharUnits::One()));
+  llvm::Value *CmpResult =
+  CGF.Builder.CreateICmpEQ(TlsGuardValue, CGF.Builder.getInt8(0));
+  CGF.Builder.CreateCondBr(CmpResult, DynInitBB, ContinueBB);
+}
+
+static void emitDynamicTlsInitialization(CodeGenFunction &CGF,
+ llvm::GlobalValue *TlsGuard,
+ llvm::BasicBlock *ContinueBB) {
+  CGF.Builder.CreateStore(CGF.Builder.getInt8(1),
+  Address(TlsGuard, CharUnits::One()));
+
+  llvm::FunctionCallee Initializer = getDynTlsOnDemandInitFn(CGF.CGM);
+  llvm::Function *InitializerFunction =
+  cast(Initializer.getCallee());
+  llvm::CallInst *CallVal = CGF.Builder.CreateCall(InitializerFunction);
+  CallVal->setCallingConv(InitializerFunction->getCallingConv());
+
+  CGF.Builder.CreateBr(ContinueBB);
+}
+
 LValue MicrosoftCXXABI::EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF,
  const VarDecl *VD,
  QualType LValType) {
-  CGF.CGM.ErrorUnsupported(VD, "thread wrappers");
-  return LValue();
+  llvm::BasicBlock *DynInitBB =
+  CGF.createBasicBlock("dyntls.dyn_init", CGF.CurFn);
+  llvm::BasicBlock *ContinueBB =
+  CGF.createBasicBlock("dyntls.continue", CGF.CurFn);
+
+  llvm::GlobalValue *TlsGuard = getTlsGuardVar(CGF.CGM);
+
+  emitTlsGuardCheck(CGF, TlsGuard, DynInitBB, ContinueBB);
+  CGF.Builder.SetInsertPoint(DynInitBB);
+  emitDynamicTlsInitialization(CGF, TlsGuard, ContinueBB);
+  CGF.Builder.SetInsertPoint(ContinueBB);
+
+  l

[PATCH] D115283: [AMDGPU] Set "amdgpu_hostcall" module flag if an AMDGPU function has calls to device lib functions that use hostcalls.

2021-12-09 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov added inline comments.



Comment at: clang/test/CodeGenHIP/amdgpu_hostcall.cpp:2-6
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm 
-fcuda-is-device -DFN_HOSTCALL \
+// RUN:   -o - %s | FileCheck --enable-var-scope %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm 
-fcuda-is-device -DFN_PRINTF \
+// RUN:   -o - %s | FileCheck --enable-var-scope %s

kpyzhov wrote:
> dfukalov wrote:
> > Am I right we don't actually need two runs here, the test may be executed 
> > with one run, removed `#ifdefs` and, possible, multiplied `CHECK:` lines?
> > I would suggest to use the llvm/utils/update_cc_test_checks.py script in 
> > such tests.
> Well, it may be executed with one run, but in that case we won't be able to 
> catch an error if one of the functions is broken, because the 2nd one will 
> set the module flag.
> Why do you think I should use the script for this test?
Oh, I see, that indeed should be run with two separate checks.

Regarding the script - it generates CHECK-NEXT sequences so we can be assured 
that substring "amdgpu_hostcall" is not caught from any other place. Of course, 
you can make the test stronger with hand-written `-NEXT` checks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115283/new/

https://reviews.llvm.org/D115283

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


[PATCH] D107450: [clang-tidy] Fix wrong FixIt in performance-move-const-arg

2021-12-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:145
+  if ((!ReceivingCallExpr ||
+   ReceivingCallExpr->getDirectCallee()->isTemplateInstantiation()) &&
+  (!ReceivingConstructExpr ||

Not all `CallExpr` objects have a direct callee, so this will crash (such as 
calls through a function pointer rather than a direct function call). It may be 
worth adding test coverage for this.



Comment at: 
clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:149-153
+  std::string FunctionName;
+  if (ReceivingCallExpr)
+FunctionName = ReceivingCallExpr->getDirectCallee()->getNameAsString();
+  else
+FunctionName = 
ReceivingConstructExpr->getConstructor()->getNameAsString();

Rather than doing this, you should be able to just pass the `NamedDecl *` in to 
the call to `Diag` below and it will be properly formatted and quoted.



Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:154
+FunctionName = 
ReceivingConstructExpr->getConstructor()->getNameAsString();
+  auto NoRefType = InvocationParm->getType()->getPointeeType();
+  PrintingPolicy PolicyWithSupressedTag(getLangOpts());

Please spell the type out in the declaration.



Comment at: 
clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:171-173
   } else if (ReceivingExpr) {
+if (InvocationParm->getOriginalType()->isRValueReferenceType())
+  return;





Comment at: clang-tools-extra/docs/ReleaseNotes.rst:118
+
+  Removed wrong FixIt for trivially-copyable objects wrapped by 
``std::move()`` and passed to an rvalue reference parameter. Removal of 
``std::move()`` would break the code.
+

Can you re-flow this to 80 cols too?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:262-263
+  int a = 10;
+  forwardToShowInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect
+}

whisperity wrote:
> whisperity wrote:
> > Quuxplusone wrote:
> > > Sockke wrote:
> > > > Quuxplusone wrote:
> > > > > ```
> > > > >   forwardToShowInt(std::move(a));
> > > > >   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the 
> > > > > variable 'a' of the trivially-copyable type 'int' has no effect
> > > > > ```
> > > > > I continue to want-not-to-block this PR, since I think it's improving 
> > > > > the situation. However, FWIW...
> > > > > It's good that this message doesn't contain a fixit, since there's 
> > > > > nothing the programmer can really do to "fix" this call. But then, 
> > > > > should this message be emitted at all? If this were `clang -Wall`, 
> > > > > then we definitely would //not// want to emit a "noisy" warning where 
> > > > > there's basically nothing the programmer can do about it. Does 
> > > > > clang-tidy have a similar philosophy? Or is it okay for clang-tidy to 
> > > > > say "This code looks wonky" even when there's no obvious way to fix 
> > > > > it?
> > > > > ```
> > > > >   forwardToShowInt(std::move(a));
> > > > >   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the 
> > > > > variable 'a' of the trivially-copyable type 'int' has no effect
> > > > > ```
> > > > > I continue to want-not-to-block this PR, since I think it's improving 
> > > > > the situation. However, FWIW...
> > > > > It's good that this message doesn't contain a fixit, since there's 
> > > > > nothing the programmer can really do to "fix" this call. But then, 
> > > > > should this message be emitted at all? If this were `clang -Wall`, 
> > > > > then we definitely would //not// want to emit a "noisy" warning where 
> > > > > there's basically nothing the programmer can do about it. Does 
> > > > > clang-tidy have a similar philosophy? Or is it okay for clang-tidy to 
> > > > > say "This code looks wonky" even when there's no obvious way to fix 
> > > > > it?
> > > > 
> > > > Yes, I agree with you. I did not remove warning to maintain the 
> > > > original behavior, which will make the current patch clearer. In any 
> > > > case, it is easy for me to make this modification if you want. 
> > > I'll defer on this subject to whomever you get to review the code change 
> > > in `MoveConstArgCheck.cpp`. (@whisperity perhaps?)
> > (Negative, it would be @aaron.ballman or @alexfh or the other maintainers. 
> > I'm just trying to give back to the community after taking away //a lot// 
> > of reviewer effort with a humongous check that I just recently pushed in 
> > after //years// of (re-)development.)
> >>! In D107450#2958900, @Quuxplusone wrote:
> > It's good that this message doesn't contain a fixit, since there's nothing 
> > the programmer can really do to "fix" this call

[PATCH] D115393: [InstrProf][NFC] Refactor Profile kind into a bitset enum.

2021-12-09 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish added a comment.

@xur Could you please take a look with a focus on ensuring that this change 
retains the semantics that you expect? Previously there were different enum 
values which indicated CS+IR vs IR only. Now the IR bit is set for both cases 
(to be consistent with the version mask). I believe this was the original 
intent. The only change I had to make was reorder the print in the text format 
writer.




Comment at: llvm/include/llvm/ProfileData/InstrProfWriter.h:48
 public:
-  InstrProfWriter(bool Sparse = false, bool InstrEntryBBEnabled = false);
   ~InstrProfWriter();

tejohnson wrote:
> Was the InstrEntryBBEnabled parameter just never used? I didn't see any 
> changes to callsites.
I didn't find any uses in llvm and I don't see it being used in the original 
commit: https://git.io/JDt8k. There is a chance that it could be used by a 
downstream user but it's unlikely? I'll wait for @xur to chime in.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115393/new/

https://reviews.llvm.org/D115393

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


[PATCH] D114564: Fix the use of -fno-approx-func along with -Ofast or -ffast-math

2021-12-09 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2760
 case options::OPT_fno_honor_nans:   HonorNaNs = false;break;
 case options::OPT_fapprox_func: ApproxFunc = true;break;
 case options::OPT_fno_approx_func:  ApproxFunc = false;   break;

masoud.ataei wrote:
> andrew.w.kaylor wrote:
> > Should this also imply "MathErrno = false"?
> I don't think setting ApproxFunc to true should imply "MathErrno = false". 
> 
> Let say someone have a math library that compute approximate result for none 
> special input/output but returns NaN, INF and errno correctly otherwise. That 
> is actually can be fairly common, because performance in the none special 
> cases are much more important that the special ones. So returning errno in 
> the special outputs theoretically should not effect the performance on the 
> main path. Therefore, I think compiler should not assume anything about 
> MathErrno value based on ApproxFunc value.
I am not sure what I was suggesting in my last comment is correct or not. Can 
one of the more experienced reviewers confirm?
The question is: Should "ApproxFunc=ture" implies "MathErrno=false"?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114564/new/

https://reviews.llvm.org/D114564

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


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:2590
+  llvm::Regex RawStringRegex(
+  "R\"([A-Za-z0-9_{}#<>%:;.?*+/^&\\$|~!=,'\\-]*)\\(");
+  SmallVector RawStringMatches;

I'm picky but you missed `[` and `]`, no?



Comment at: clang/lib/Format/Format.cpp:2604
+// Skip past until we think we are at the rawstring literal close.
+if (RawStringRegex.match(Trimmed, &RawStringMatches)) {
+  std::string CharSequence = RawStringMatches[1].str();

Will this match the first or the last occurrence? If it's the last then it's 
ok. Otherwise, we should change it. Also, please test something along the lines 
of:
```
R"x(...)x" ... on the same line R"y(
#include "..."
)y"
```



Comment at: clang/unittests/Format/SortIncludesTest.cpp:1150
+
+  // Missing |`
+#define X "AMZ029amz{}+!%*=_:;',.<>/?#~-$"

Can't `|` be tested? Same for `[` and `]`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115168/new/

https://reviews.llvm.org/D115168

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


[PATCH] D115386: AST: Avoid using SmallVector::set_size() in UnresolvedSet

2021-12-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good.




Comment at: clang/lib/Sema/SemaLookup.cpp:623
 
-  Decls.set_size(N);
+  Decls.truncate(N);
 

dexonsmith wrote:
> Two things to confirm here.
> 
> First is that the destructors are trivial. From 
> clang/include/clang/AST/DeclAccessPair.h:
> ```
> lang=c++
> class DeclAccessPair {
>   uintptr_t Ptr; // we'd use llvm::PointerUnion, but it isn't trivial
> ```
> (If they hadn't been trivial, then hypothetically there could been other code 
> somewhere that ran the destructors later...)
> 
> Second is that `set_size()` was only used for truncation. I confirmed that 
> that three ways:
> - Looking backward, `N` starts as `Decls.size()` and the only changes are 
> decrement operatoers.
> - Looking forward, there's no code that would initialize / assign to the new 
> member (so if it increased size, it would likely have led to problems 
> elsewhere).
> - Tests pass.
Thanks for the details!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115386/new/

https://reviews.llvm.org/D115386

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


[PATCH] D112024: [clang] diagnose_as attribute for Fortify diagnosing like builtins.

2021-12-09 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield updated this revision to Diff 393226.
mbenfield added a comment.

Remove late parsing.

Switch dyn_cast to cast.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112024/new/

https://reviews.llvm.org/D112024

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-diagnose-as-builtin.c

Index: clang/test/Sema/attr-diagnose-as-builtin.c
===
--- /dev/null
+++ clang/test/Sema/attr-diagnose-as-builtin.c
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -Wfortify-source -triple x86_64-apple-macosx10.14.0 %s -verify
+// RUN: %clang_cc1 -Wfortify-source -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify
+
+typedef unsigned long size_t;
+
+__attribute__((diagnose_as_builtin(__builtin_memcpy, 3, 1, 2))) int x; // expected-warning {{'diagnose_as_builtin' attribute only applies to functions}}
+
+void *test_memcpy(const void *src, size_t c, void *dst) __attribute__((diagnose_as_builtin(__builtin_memcpy, 3, 1, 2))) {
+  return __builtin_memcpy(dst, src, c);
+}
+
+void call_test_memcpy() {
+  char bufferA[10];
+  char bufferB[11];
+  test_memcpy(bufferB, 10, bufferA);
+  test_memcpy(bufferB, 11, bufferA); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+void failure_function_doesnt_exist() __attribute__((diagnose_as_builtin(__function_that_doesnt_exist))) {} // expected-error {{use of undeclared identifier '__function_that_doesnt_exist'}}
+
+void not_a_builtin() {}
+
+void failure_not_a_builtin() __attribute__((diagnose_as_builtin(not_a_builtin))) {} // expected-error {{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+
+void failure_too_many_parameters(void *dst, const void *src, size_t count, size_t nothing) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3, 4))) {} // expected-error {{'diagnose_as_builtin' attribute references function '__builtin_memcpy', which takes exactly 3 arguments}}
+
+void failure_too_few_parameters(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2))) {} // expected-error{{'diagnose_as_builtin' attribute references function '__builtin_memcpy', which takes exactly 3 arguments}}
+
+void failure_not_an_integer(void *dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, "abc", 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 2 to be an integer constant}}
+
+void failure_not_a_builtin2() __attribute__((diagnose_as_builtin("abc"))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+
+void failure_parameter_index_bounds(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute references parameter 3, but the function 'failure_parameter_index_bounds' has only 2 parameters}}
+
+void failure_parameter_types(double dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute parameter types do not match: parameter 1 of function 'failure_parameter_types' has type 'double', but parameter 1 of function '__builtin_memcpy' has type 'void *'}}
+
+void to_redeclare(void *dst, const void *src, size_t count);
+
+void use_to_redeclare() {
+  char src[10];
+  char dst[9];
+  // We shouldn't get an error yet.
+  to_redeclare(dst, src, 10);
+}
+
+void to_redeclare(void *dst, const void *src, size_t count) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
+
+void error_to_redeclare() {
+  char src[10];
+  char dst[9];
+  // Now we get an error.
+  to_redeclare(dst, src, 10); // expected-warning {{'memcpy' will always overflow; destination buffer has size 9, but size argument is 10}}
+}
+
+// Make sure this works even with extra qualifiers and the pass_object_size attribute.
+void *memcpy2(void *const dst __attribute__((pass_object_size(0))), const void *src, size_t copy_amount) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
+
+void call_memcpy2() {
+  char buf1[10];
+  char buf2[11];
+  memcpy2(buf1, buf2, 11); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+// We require the types to be identical, modulo canonicalization and qualifiers.
+// Maybe this could be relaxed if it proves too restrictive.
+void failure_type(void *dest, char val, size_t n) __attribute__((diagnose_as_builtin(__builtin_memset, 1, 2, 3))) {} // expected-error {{'diagnose_as_builtin' attribute parameter types do not match: parameter 2 of function 'failure_type' has type 'char', but parameter 2 of func

[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2021-12-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

> I still don't see a need for them to be updated in lock step, especially for 
> Visual Studio which tends to be quite different from other toolchains, but I 
> can see the use of the bumps occurring within the same release version of 
> llvm if its feasible.

It's better to be in separate patches.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114639/new/

https://reviews.llvm.org/D114639

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


[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115341/new/

https://reviews.llvm.org/D115341

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


[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 393221.
ymandel marked 2 inline comments as done.
ymandel added a comment.

rebasing onto latest version of parent patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115341/new/

https://reviews.llvm.org/D115341

Files:
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -0,0 +1,174 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace dataflow;
+
+namespace {
+
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::isDefinition;
+using ::testing::_;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext &Context)
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice &E, Environment &Env) {
+return {};
+  }
+};
+
+template 
+const FunctionDecl *findTargetFunc(ASTContext &Context, T FunctionMatcher) {
+  auto TargetMatcher =
+  functionDecl(FunctionMatcher, isDefinition()).bind("target");
+  for (const auto &Node : ast_matchers::match(TargetMatcher, Context)) {
+const auto *Func = Node.template getNodeAs("target");
+if (Func == nullptr)
+  continue;
+if (Func->isTemplated())
+  continue;
+return Func;
+  }
+  return nullptr;
+}
+
+class BuildStatementToAnnotationMappingTest : public ::testing::Test {
+public:
+  void
+  runTest(llvm::StringRef Code, llvm::StringRef TargetName,
+  std::function &)>
+  RunChecks) {
+llvm::Annotations AnnotatedCode(Code);
+auto Unit = tooling::buildASTFromCodeWithArgs(
+AnnotatedCode.code(), {"-fsyntax-only", "-std=c++17"});
+auto &Context = Unit->getASTContext();
+const FunctionDecl *Func = findTargetFunc(Context, hasName(TargetName));
+ASSERT_NE(Func, nullptr);
+
+llvm::Expected> Mapping =
+clang::dataflow::testing::buildStatementToAnnotationMapping(
+Func, AnnotatedCode);
+ASSERT_TRUE(static_cast(Mapping));
+
+RunChecks(Mapping.get());
+  }
+};
+
+TEST_F(BuildStatementToAnnotationMappingTest, ReturnStmt) {
+  runTest(R"(
+int target() {
+  return 42;
+  /*[[ok]]*/
+}
+  )",
+  "target",
+  [](const llvm::DenseMap &Annotations) {
+ASSERT_EQ(Annotations.size(), static_cast(1));
+EXPECT_TRUE(isa(Annotations.begin()->first));
+EXPECT_EQ(Annotations.begin()->second, "ok");
+  });
+}
+
+void checkDataflow(
+llvm::StringRef Code, llvm::StringRef Target,
+std::function>>,
+   ASTContext &)>
+Expectations) {
+  clang::dataflow::testing::checkDataflow(
+  Code, Target,
+  [](ASTContext &Context, Environment &) { return NoopAnalysis(Context); },
+  std::move(Expectations), {"-fsyntax-only", "-std=c++17"});
+}
+
+TEST(ProgramPointAnnotations, NoAnnotations) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void target() {}", "target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, NoAnnotationsDifferentTarget) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void fun() {}", "fun", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, WithCodepoint) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations,
+  Call(UnorderedElementsAre(Pair("program-point", _)), _))
+  .Times(1);
+
+  checkDataflow(R"cc(void target() {
+ int n;
+ // [[program-point]]
+   })cc",
+"target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, MultipleCodepoints) {
+ 

[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added a comment.

Thanks for the great comments and the fast response time!




Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:134
+
+transferBlock(
+BlockStates, *Block, Env, Analysis,

I've inlined `buildAnnotationToOutputStateMapping`, since it is only intended 
for use here anyhow and factoring it out didn't save anything because we still 
need to translate to typed state.



Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:48
+  << std::declval())>
+std::ostream &operator<<(std::ostream &OS,
+ const DataflowAnalysisState &S) {

xazax.hun wrote:
> This would also be useful for debugging. I wonder whether utilities not 
> strictly related to testing should be closer to the actual code, so someone 
> wanting to use this for debugging does not need to include the header that is 
> dedicated to the tests.
Agreed. Added a FIXME.



Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:77
+// the files provided in `VirtualMappedFiles`.
+bool runOnCode(llvm::StringRef Code,
+   const std::function &Operation,

xazax.hun wrote:
> I feel like some of our tests keep recreating lightweight versions of the 
> LibTooling. Not really an action item for this PR, just a rant :) I hope we 
> will have some more centralized stuff at some point. 
No, I agree! I missed this -- there's no good reason for runOnCode to exist. 
I've removed it and like the result a lot more. :)



Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:94
+template 
+void runDataflow(
+llvm::StringRef Code,

xazax.hun wrote:
> Since this function is actually matching the dataflow results against 
> expectations, I wonder if something like `checkDataflow` would better 
> describe its function. But feel free to keep the current name.
Agreed.



Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:137
+TypeErasedBlockStates =
+runTypeErasedDataflowAnalysis(*cfg, Analysis, Env);
+

xazax.hun wrote:
> Wouldn't users end up calling the template (not the type erased) version of 
> this function? I wonder if we should mimic how users would interact with the 
> framework in the tests.
I see your point and tried to move in that direction. However, it makes this 
code a lot messier because of the need to iterate again over each block with 
`transferBlock` to recoved statement level state. Since `transferBlock` is part 
of the type-erased engine, interacting with it would require mapping all of the 
state to untyped before using it, which somewhat defeats the whole purpose of 
using the typed version.

We should consider reporting statement level information from our 
`run...DataflowAnalysis` functions, which would make this iteration 
unnecessary, at which point moving to the typed version would make a lot of 
sense.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115341/new/

https://reviews.llvm.org/D115341

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


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-09 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/SortIncludesTest.cpp:1162
+ "test.cxx", 0));
+}
+

You should add a `#undef X`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115168/new/

https://reviews.llvm.org/D115168

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


[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 393218.
ymandel added a comment.

responding to review comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115341/new/

https://reviews.llvm.org/D115341

Files:
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -0,0 +1,174 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace dataflow;
+
+namespace {
+
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::isDefinition;
+using ::testing::_;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext &Context)
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice &E, Environment &Env) {
+return {};
+  }
+};
+
+template 
+const FunctionDecl *findTargetFunc(ASTContext &Context, T FunctionMatcher) {
+  auto TargetMatcher =
+  functionDecl(FunctionMatcher, isDefinition()).bind("target");
+  for (const auto &Node : ast_matchers::match(TargetMatcher, Context)) {
+const auto *Func = Node.template getNodeAs("target");
+if (Func == nullptr)
+  continue;
+if (Func->isTemplated())
+  continue;
+return Func;
+  }
+  return nullptr;
+}
+
+class BuildStatementToAnnotationMappingTest : public ::testing::Test {
+public:
+  void
+  runTest(llvm::StringRef Code, llvm::StringRef TargetName,
+  std::function &)>
+  RunChecks) {
+llvm::Annotations AnnotatedCode(Code);
+auto Unit = tooling::buildASTFromCodeWithArgs(
+AnnotatedCode.code(), {"-fsyntax-only", "-std=c++17"});
+auto &Context = Unit->getASTContext();
+const FunctionDecl *Func = findTargetFunc(Context, hasName(TargetName));
+ASSERT_NE(Func, nullptr);
+
+llvm::Expected> Mapping =
+clang::dataflow::testing::buildStatementToAnnotationMapping(
+Func, AnnotatedCode);
+ASSERT_TRUE(static_cast(Mapping));
+
+RunChecks(Mapping.get());
+  }
+};
+
+TEST_F(BuildStatementToAnnotationMappingTest, ReturnStmt) {
+  runTest(R"(
+int target() {
+  return 42;
+  /*[[ok]]*/
+}
+  )",
+  "target",
+  [](const llvm::DenseMap &Annotations) {
+ASSERT_EQ(Annotations.size(), static_cast(1));
+EXPECT_TRUE(isa(Annotations.begin()->first));
+EXPECT_EQ(Annotations.begin()->second, "ok");
+  });
+}
+
+void checkDataflow(
+llvm::StringRef Code, llvm::StringRef Target,
+std::function>>,
+   ASTContext &)>
+Expectations) {
+  clang::dataflow::testing::checkDataflow(
+  Code, Target,
+  [](ASTContext &Context, Environment &) { return NoopAnalysis(Context); },
+  std::move(Expectations), {"-fsyntax-only", "-std=c++17"});
+}
+
+TEST(ProgramPointAnnotations, NoAnnotations) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void target() {}", "target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, NoAnnotationsDifferentTarget) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void fun() {}", "fun", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, WithCodepoint) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations,
+  Call(UnorderedElementsAre(Pair("program-point", _)), _))
+  .Times(1);
+
+  checkDataflow(R"cc(void target() {
+ int n;
+ // [[program-point]]
+   })cc",
+"target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, MultipleCodepoints) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  

[PATCH] D115456: Implement on-demand TLS initialization for Microsoft CXX ABI

2021-12-09 Thread Maurice Heumann via Phabricator via cfe-commits
momo5502 created this revision.
momo5502 added reviewers: rnk, eugenis.
momo5502 added a project: clang.
momo5502 requested review of this revision.
Herald added a subscriber: cfe-commits.

TLS initializers, for example constructors of thread-local variables, don't 
necessarily get called. If for example a thread was created before a module is 
loaded, the module's TLS initializers are not executed for this particular 
thread.

This is why Microsoft added support for dynamic TLS initialization. Before 
every use of thread-local variables, a check is added that runs the module's 
TLS initializers on-demand.

To do this, the method `__dyn_tls_on_demand_init` gets called. Internally, it 
simply calls `__dyn_tls_init`.
To prevent calling initializers again, a guard variable called `__tls_guard` is 
checked and set before executing the call.

No additional TLS initializer that sets the guard needs to be emitted, as the 
guard always gets set by `__dyn_tls_init`.
The guard is also checked again within `__dyn_tls_init`. This makes our check 
redundant, however, as Microsoft's compiler also emits this check, the 
behaviour is adopted here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115456

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/ms-thread_local.cpp

Index: clang/test/CodeGenCXX/ms-thread_local.cpp
===
--- clang/test/CodeGenCXX/ms-thread_local.cpp
+++ clang/test/CodeGenCXX/ms-thread_local.cpp
@@ -17,10 +17,20 @@
 
 // CHECK-DAG: @"?b@@3UA@@A" = dso_local thread_local global %struct.A zeroinitializer, align 1
 // CHECK-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-DAG: @__tls_guard = external dso_local thread_local global i8
 // CHECK-LD-DAG: @"?b@@3UA@@A" = dso_local thread_local(localdynamic) global %struct.A zeroinitializer, align 1
 // CHECK-LD-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-LD-DAG: @__tls_guard = external dso_local thread_local global i8
 thread_local A b;
 
+// CHECK-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+
+// CHECK-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK: call void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK-LD: call void @__dyn_tls_on_demand_init()
+
 // CHECK-LABEL: define internal void @__tls_init()
 // CHECK: call void @"??__Eb@@YAXXZ"
 // CHECK-LD-LABEL: define internal void @__tls_init()
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -401,7 +401,7 @@
   ArrayRef CXXThreadLocalInitVars) override;
 
   bool usesThreadWrapperFunction(const VarDecl *VD) const override {
-return false;
+return true;
   }
   LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD,
   QualType LValType) override;
@@ -2397,11 +2397,87 @@
   }
 }
 
+static llvm::GlobalValue *getTlsGuardVar(CodeGenModule &CGM) {
+  llvm::Type *VTy = llvm::Type::getInt8Ty(CGM.getLLVMContext());
+  llvm::Constant *TlsGuardConstant =
+  CGM.CreateRuntimeVariable(VTy, "__tls_guard");
+  llvm::GlobalValue *TlsGuard = cast(TlsGuardConstant);
+
+  TlsGuard->setThreadLocal(true);
+
+  return TlsGuard;
+}
+
+static llvm::FunctionCallee getDynTlsOnDemandInitFn(CodeGenModule &CGM) {
+  llvm::FunctionType *FTy =
+  llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), {},
+  /*isVarArg=*/false);
+  return CGM.CreateRuntimeFunction(
+  FTy, "__dyn_tls_on_demand_init",
+  llvm::AttributeList::get(CGM.getLLVMContext(),
+   llvm::AttributeList::FunctionIndex,
+   llvm::Attribute::NoUnwind),
+  /*Local=*/true);
+}
+
+static void emitTlsGuardCheck(CodeGenFunction &CGF, llvm::GlobalValue *TlsGuard,
+  llvm::BasicBlock *DynInitBB,
+  llvm::BasicBlock *ContinueBB) {
+  llvm::LoadInst *TlsGuardValue =
+  CGF.Builder.CreateLoad(Address(TlsGuard, CharUnits::One()));
+  llvm::Value *CmpResult =
+  CGF.Builder.CreateICmpEQ(TlsGuardValue, CGF.Builder.getInt8(0));
+  CGF.Builder.CreateCondBr(CmpResult, DynInitBB, ContinueBB);
+}
+
+static void emitDynamicTlsInitialization(CodeGenFunction &CGF,
+ llvm::GlobalValue *TlsGuard,
+ llvm::BasicBlock *ContinueBB) {
+  CGF.Builder.CreateStore(CGF.Builder.getInt8(1),
+  Address(TlsGuard, CharUnits::One()));
+
+  llvm::Funct

[clang] 4c7de4f - Thread safety analysis: Remove unused variable. NFC.

2021-12-09 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2021-12-09T18:57:43+01:00
New Revision: 4c7de4fbda03f38514c4aebed34dc2bbfb7e62a5

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

LOG: Thread safety analysis: Remove unused variable. NFC.

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index b196ffa73cbfb..9cc990bd35a3f 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -418,7 +418,6 @@ class LocalVariableMap {
 private:
   Context::Factory ContextFactory;
   std::vector VarDefinitions;
-  std::vector CtxIndices;
   std::vector> SavedContexts;
 
 public:
@@ -731,8 +730,6 @@ void LocalVariableMap::traverseCFG(CFG *CFGraph,
std::vector &BlockInfo) {
   PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
 
-  CtxIndices.resize(CFGraph->getNumBlockIDs());
-
   for (const auto *CurrBlock : *SortedGraph) {
 unsigned CurrBlockID = CurrBlock->getBlockID();
 CFGBlockInfo *CurrBlockInfo = &BlockInfo[CurrBlockID];



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


[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2021-12-09 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

ping?

@erichkeane Since you are pushing for upgrade the gcc/clang requirement as 
well, would you take care of that?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114639/new/

https://reviews.llvm.org/D114639

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


[PATCH] D114995: clang-tidy: improve the 'modernize-use-default-member-init'

2021-12-09 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In D114995#3180475 , @aaron.ballman 
wrote:

> was there a reason we didn't cover that case originally or was it an 
> oversight/left for future work?

It was left for future work - by only considering the initializer list of the 
default constructor, clang-tidy did not have to work out what to do when the 
constructors don't agree on what value the member init should have.
The next step towards the full solution is to handle classes with only one 
non-special constructor.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114995/new/

https://reviews.llvm.org/D114995

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


[PATCH] D115452: Prevent abseil-cleanup-ctad check from stomping on surrounding context

2021-12-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1968d5341d7: Prevent abseil-cleanup-ctad check from 
stomping on surrounding context (authored by CJ-Johnson, committed by ymandel).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115452/new/

https://reviews.llvm.org/D115452

Files:
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
@@ -81,35 +81,25 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup's class 
template argument deduction pattern in C++17 and higher
   // CHECK-FIXES: {{^}}  absl::Cleanup a = [] {};{{$}}
 
-  // Removes extra parens
-  auto b = absl::MakeCleanup(([] {}));
+  auto b = absl::MakeCleanup(std::function([] {}));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup b = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  absl::Cleanup b = std::function([] {});{{$}}
 
-  auto c = absl::MakeCleanup(std::function([] {}));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup c = std::function([] {});{{$}}
-
-  // Removes extra parens
-  auto d = absl::MakeCleanup((std::function([] {})));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup d = std::function([] {});{{$}}
-
-  const auto e = absl::MakeCleanup([] {});
+  const auto c = absl::MakeCleanup([] {});
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup e = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  const absl::Cleanup c = [] {};{{$}}
 
-  // Removes extra parens
-  const auto f = absl::MakeCleanup(([] {}));
+  const auto d = absl::MakeCleanup(std::function([] {}));
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup f = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  const absl::Cleanup d = std::function([] 
{});{{$}}
 
-  const auto g = absl::MakeCleanup(std::function([] {}));
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup g = std::function([] 
{});{{$}}
+  // Preserves extra parens
+  auto e = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup e = ([] {});{{$}}
 
-  // Removes extra parens
-  const auto h = absl::MakeCleanup((std::function([] {})));
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup h = std::function([] 
{});{{$}}
+  // Preserves comments
+  auto f = /* a */ absl::MakeCleanup(/* b */ [] { /* c */ } /* d */) /* e */;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup f = /* a */ /* b */ [] { /* c */ } /* d 
*/ /* e */;{{$}}
 }
Index: clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
@@ -28,16 +28,14 @@
  "deduction pattern in C++17 and higher");
 
   return makeRule(
-  declStmt(has(varDecl(
+  declStmt(hasSingleDecl(varDecl(
   hasType(autoType()), hasTypeLoc(typeLoc().bind("auto_type_loc")),
-  hasInitializer(traverse(
-  clang::TK_IgnoreUnlessSpelledInSource,
+  hasInitializer(hasDescendant(
   callExpr(callee(functionDecl(hasName("absl::MakeCleanup"))),
-   argumentCountIs(1),
-   hasArgument(0, expr().bind("make_cleanup_argument")))
+   argumentCountIs(1))
   .bind("make_cleanup_call")),
   {changeTo(node("auto_type_loc"), cat("absl::Cleanup")),
-   changeTo(node("make_cleanup_call"), 
cat(node("make_cleanup_argument")))},
+   changeTo(node("make_cleanup_call"), 
cat(callArgs("make_cleanup_call")))},
   warning_message);
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-cle

[clang-tools-extra] a1968d5 - Prevent abseil-cleanup-ctad check from stomping on surrounding context

2021-12-09 Thread Yitzhak Mandelbaum via cfe-commits

Author: CJ Johnson
Date: 2021-12-09T17:41:12Z
New Revision: a1968d5341d7b1ec7889955f230d0375548d165b

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

LOG: Prevent abseil-cleanup-ctad check from stomping on surrounding context

This change applies two fixes to the abseil-cleanup-ctad check. It uses 
hasSingleDecl() to ensure only declStmt()s with one varDecl() are matched 
(leaving compount declStmt()s unchanged). It also addresses a bug in the 
handling of comments that surround the absl::MakeCleanup() calls by switching 
to the callArgs() combinator from Clang Transformer.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D115452

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
index bc152f1dafa7..bbf860342fee 100644
--- a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
@@ -28,16 +28,14 @@ RewriteRule CleanupCtadCheckImpl() {
  "deduction pattern in C++17 and higher");
 
   return makeRule(
-  declStmt(has(varDecl(
+  declStmt(hasSingleDecl(varDecl(
   hasType(autoType()), hasTypeLoc(typeLoc().bind("auto_type_loc")),
-  hasInitializer(traverse(
-  clang::TK_IgnoreUnlessSpelledInSource,
+  hasInitializer(hasDescendant(
   callExpr(callee(functionDecl(hasName("absl::MakeCleanup"))),
-   argumentCountIs(1),
-   hasArgument(0, expr().bind("make_cleanup_argument")))
+   argumentCountIs(1))
   .bind("make_cleanup_call")),
   {changeTo(node("auto_type_loc"), cat("absl::Cleanup")),
-   changeTo(node("make_cleanup_call"), 
cat(node("make_cleanup_argument")))},
+   changeTo(node("make_cleanup_call"), 
cat(callArgs("make_cleanup_call")))},
   warning_message);
 }
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
index c023521bb261..c2b5e4df985d 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
@@ -81,35 +81,25 @@ void test() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup's class 
template argument deduction pattern in C++17 and higher
   // CHECK-FIXES: {{^}}  absl::Cleanup a = [] {};{{$}}
 
-  // Removes extra parens
-  auto b = absl::MakeCleanup(([] {}));
+  auto b = absl::MakeCleanup(std::function([] {}));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup b = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  absl::Cleanup b = std::function([] {});{{$}}
 
-  auto c = absl::MakeCleanup(std::function([] {}));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup c = std::function([] {});{{$}}
-
-  // Removes extra parens
-  auto d = absl::MakeCleanup((std::function([] {})));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup d = std::function([] {});{{$}}
-
-  const auto e = absl::MakeCleanup([] {});
+  const auto c = absl::MakeCleanup([] {});
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup e = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  const absl::Cleanup c = [] {};{{$}}
 
-  // Removes extra parens
-  const auto f = absl::MakeCleanup(([] {}));
+  const auto d = absl::MakeCleanup(std::function([] {}));
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup f = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  const absl::Cleanup d = std::function([] 
{});{{$}}
 
-  const auto g = absl::MakeCleanup(std::function([] {}));
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup g = std::function([] 
{});{{$}}
+  // Preserves extra parens
+  auto e = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup e = ([] {});{{$}}
 
-  // Removes extra parens
-  const auto h = absl::MakeCleanup((std::function([] {})));
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher

[PATCH] D115438: [lldb] Remove unused lldb.cpp

2021-12-09 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115438/new/

https://reviews.llvm.org/D115438

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


[PATCH] D115452: Prevent abseil-cleanup-ctad check from stomping on surrounding context

2021-12-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115452/new/

https://reviews.llvm.org/D115452

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


[PATCH] D115452: Prevent abseil-cleanup-ctad check from stomping on surrounding context

2021-12-09 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson created this revision.
CJ-Johnson added a reviewer: ymandel.
Herald added a subscriber: carlosgalvezp.
CJ-Johnson requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This change applies two fixes to the abseil-cleanup-ctad check. It uses 
hasSingleDecl() to ensure only declStmt()s with one varDecl() are matched 
(leaving compount declStmt()s unchanged). It also addresses a bug in the 
handling of comments that surround the absl::MakeCleanup() calls by switching 
to the callArgs() combinator from Clang Transformer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115452

Files:
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
@@ -81,35 +81,25 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup's class 
template argument deduction pattern in C++17 and higher
   // CHECK-FIXES: {{^}}  absl::Cleanup a = [] {};{{$}}
 
-  // Removes extra parens
-  auto b = absl::MakeCleanup(([] {}));
+  auto b = absl::MakeCleanup(std::function([] {}));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup b = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  absl::Cleanup b = std::function([] {});{{$}}
 
-  auto c = absl::MakeCleanup(std::function([] {}));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup c = std::function([] {});{{$}}
-
-  // Removes extra parens
-  auto d = absl::MakeCleanup((std::function([] {})));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  absl::Cleanup d = std::function([] {});{{$}}
-
-  const auto e = absl::MakeCleanup([] {});
+  const auto c = absl::MakeCleanup([] {});
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup e = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  const absl::Cleanup c = [] {};{{$}}
 
-  // Removes extra parens
-  const auto f = absl::MakeCleanup(([] {}));
+  const auto d = absl::MakeCleanup(std::function([] {}));
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup f = [] {};{{$}}
+  // CHECK-FIXES: {{^}}  const absl::Cleanup d = std::function([] 
{});{{$}}
 
-  const auto g = absl::MakeCleanup(std::function([] {}));
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup g = std::function([] 
{});{{$}}
+  // Preserves extra parens
+  auto e = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup e = ([] {});{{$}}
 
-  // Removes extra parens
-  const auto h = absl::MakeCleanup((std::function([] {})));
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
-  // CHECK-FIXES: {{^}}  const absl::Cleanup h = std::function([] 
{});{{$}}
+  // Preserves comments
+  auto f = /* a */ absl::MakeCleanup(/* b */ [] { /* c */ } /* d */) /* e */;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 
and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup f = /* a */ /* b */ [] { /* c */ } /* d 
*/ /* e */;{{$}}
 }
Index: clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
@@ -28,16 +28,14 @@
  "deduction pattern in C++17 and higher");
 
   return makeRule(
-  declStmt(has(varDecl(
+  declStmt(hasSingleDecl(varDecl(
   hasType(autoType()), hasTypeLoc(typeLoc().bind("auto_type_loc")),
-  hasInitializer(traverse(
-  clang::TK_IgnoreUnlessSpelledInSource,
+  hasInitializer(hasDescendant(
   callExpr(callee(functionDecl(hasName("absl::MakeCleanup"))),
-   argumentCountIs(1),
-   hasArgument(0, expr().bind("make_cleanup_argument")))
+   argumentCountIs(1))
   .bind("make_cleanup_call")),
   {changeTo(node("auto_type_loc"), cat("absl::Cleanup")),
-   changeTo(node("make_cleanup_call"), 
cat(node("make_cleanup_argument")))},
+   changeTo(node("make_cleanup_call"), 
cat(callArgs("make_cleanup_call")))},
   warning_message);
 }
 


Index: clang-tools-ex

[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 393188.
MyDeveloperDay added a comment.

Add a suitable amount of C++ madness, (to the limit of what I could coax the 
regex to accept)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115168/new/

https://reviews.llvm.org/D115168

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -1045,6 +1045,122 @@
   EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
 }
 
+TEST_F(SortIncludesTest, DisableRawStringLiteralSorting) {
+
+  EXPECT_EQ("const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";",
+sort("const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";",
+ "test.cxx", 0));
+  EXPECT_EQ("const char *t = R\"x(\n"
+"#include \n"
+"#include \n"
+")x\";",
+sort("const char *t = R\"x(\n"
+ "#include \n"
+ "#include \n"
+ ")x\";",
+ "test.cxx", 0));
+  EXPECT_EQ("const char *t = R\"xyz(\n"
+"#include \n"
+"#include \n"
+")xyz\";",
+sort("const char *t = R\"xyz(\n"
+ "#include \n"
+ "#include \n"
+ ")xyz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";\n"
+"#include \n"
+"#include \n"
+"const char *t = R\"x(\n"
+"#include \n"
+"#include \n"
+")x\";\n"
+"#include \n"
+"#include \n"
+"const char *t = R\"xyz(\n"
+"#include \n"
+"#include \n"
+")xyz\";\n"
+"#include \n"
+"#include ",
+sort("#include \n"
+ "#include \n"
+ "const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";\n"
+ "#include \n"
+ "#include \n"
+ "const char *t = R\"x(\n"
+ "#include \n"
+ "#include \n"
+ ")x\";\n"
+ "#include \n"
+ "#include \n"
+ "const char *t = R\"xyz(\n"
+ "#include \n"
+ "#include \n"
+ ")xyz\";\n"
+ "#include \n"
+ "#include ",
+ "test.cc", 4));
+
+  EXPECT_EQ("const char *t = R\"AMZ029amz(\n"
+"#include \n"
+"#include \n"
+")AMZ029amz\";",
+sort("const char *t = R\"AMZ029amz(\n"
+ "#include \n"
+ "#include \n"
+ ")AMZ029amz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"-AMZ029amz(\n"
+"#include \n"
+"#include \n"
+")-AMZ029amz\";",
+sort("const char *t = R\"-AMZ029amz(\n"
+ "#include \n"
+ "#include \n"
+ ")-AMZ029amz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"AMZ029amz-(\n"
+"#include \n"
+"#include \n"
+")AMZ029amz-\";",
+sort("const char *t = R\"AMZ029amz-(\n"
+ "#include \n"
+ "#include \n"
+ ")AMZ029amz-\";",
+ "test.cxx", 0));
+
+  // Missing |`
+#define X "AMZ029amz{}+!%*=_:;',.<>/?#~-$"
+
+  EXPECT_EQ("const char *t = R\"" X "(\n"
+"#include \n"
+"#include \n"
+")" X "\";",
+sort("const char *t = R\"" X "(\n"
+ "#include \n"
+ "#include \n"
+ ")" X "\";",
+ "test.cxx", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2586,12 +2586,31 @@
   bool MainIncludeFound = false;
   bool FormattingOff = false;
 
+  llvm::Regex RawStringRegex(
+  "R\"([A-Za-z0-9_{}#<>%:;.?*+/^&\\$|~!=,'\\-]*)\\(");
+  SmallVector RawStringMatches;
+  std::string RawStringTermination = ")\"";
+
   for (;;) {
 auto Pos = Code.find('\n', SearchFrom);
 StringRef Line =
 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
 
 StringRef Trimmed = Line.trim();
+
+// #includes inside raw string literals need to be ignored.
+// or we will sort the contents 

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-12-09 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Release build:
Before this patch:

 text data bssdec hex
  115471733   7987112  443760 123902605   7629a8d ./bin/clang

After this patch:

 text data bssdec hex
  117568981   7996376  443760 126009117   782bf1d ./bin/clang  (+1.7%)

Debug build:
Before this patch:

 text data bssdec hex
  265437945   9544132  494152 275476229   106b6f05./bin/clang

After this patch:

 text data bssdec hex
  272133359   9553380  494152 282180891   10d1bd1b./bin/clang. 
(+2.4%)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111617/new/

https://reviews.llvm.org/D111617

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


[PATCH] D115442: [clangd] Provide documentation as MarkupContent in signaturehelp

2021-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

MarkupContent was introduced in 3.12 in 2018.
We could continue to support older clients by rendering plaintext as string 
instead of the MarkupContent struct but it doesn't seem worth it.




Comment at: clang-tools-extra/clangd/Protocol.h:495
+  /// textDocument.signatureHelp.signatureInformation.documentationFormat
+  MarkupKind SignatureHelpDocumentationFormat = MarkupKind::PlainText;
 };

move next to other sighelp caps?



Comment at: clang-tools-extra/clangd/test/signature-help.test:1
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 # Start a session.

I definitely don't think we need three copies of this test.

I'd personally probably only keep one, and have it specify markdown explicitly 
(plaintext is the default).
Keeping a test for both plain and markdown is more coverage, copied tests are a 
maintenance hazard, up to you.
Keeping both plain-explicitly-specified and plain-by-default seems gratuitous.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115442/new/

https://reviews.llvm.org/D115442

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


[PATCH] D114421: [asan] Add support for disable_sanitizer_instrumentation attribute

2021-12-09 Thread Alexander Potapenko via Phabricator via cfe-commits
glider updated this revision to Diff 393187.
glider added a comment.

Fix a windows test failure: 
https://buildkite.com/llvm-project/premerge-checks/builds/69318#0b873cc6-bf07-482a-ac37-e960566ac8a3


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114421/new/

https://reviews.llvm.org/D114421

Files:
  clang/docs/AddressSanitizer.rst
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/asan-globals.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  
llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll

Index: llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll
@@ -0,0 +1,47 @@
+; This test checks that we are not instrumenting sanitizer code.
+; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function with sanitize_address is instrumented.
+; Function Attrs: nounwind uwtable
+define void @instr_sa(i32* %a) sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @instr_sa
+; CHECK: call void @__asan_report_load
+
+
+; Function with disable_sanitizer_instrumentation is not instrumented.
+; Function Attrs: nounwind uwtable
+define void @noinstr_dsi(i32* %a) disable_sanitizer_instrumentation {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @noinstr_dsi
+; CHECK-NOT: call void @__asan_report_load
+
+
+; disable_sanitizer_instrumentation takes precedence over sanitize_address.
+; Function Attrs: nounwind uwtable
+define void @noinstr_dsi_sa(i32* %a) disable_sanitizer_instrumentation sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @noinstr_dsi_sa
+; CHECK-NOT: call void @__asan_report_load
+
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2890,6 +2890,9 @@
   // Leave if the function doesn't need instrumentation.
   if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return FunctionModified;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return FunctionModified;
+
   LLVM_DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
 
   initializeCallbacks(*F.getParent());
Index: clang/test/CodeGen/asan-globals.cpp
===
--- clang/test/CodeGen/asan-globals.cpp
+++ clang/test/CodeGen/asan-globals.cpp
@@ -10,6 +10,7 @@
 int global;
 int dyn_init_global = global;
 int __attribute__((no_sanitize("address"))) attributed_global;
+int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
 int ignorelisted_global;
 
 int __attribute__((section("__DATA, __common"))) sectioned_global; // KASAN - ignore globals in a section
@@ -50,31 +51,33 @@
 // UWTABLE: attributes #[[#ATTR]] = { nounwind uwtable }
 // UWTABLE: ![[#]] = !{i32 7, !"uwtable", i32 1}
 
-// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false}
 // CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 10, i32 5}
 // CHECK: ![[DYN_INIT_GLOBAL]] = !{{{.*}} ![[DYN_INIT_LOC:[0-9]+]], !"dyn_init_global", i1 true, i1 false}
 // CHECK: ![[DYN_INIT_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 11, i32 5}
-// CHECK: ![[ATTR_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
-// CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
+// CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
+// CHECK: ![

[PATCH] D115438: [lldb] Remove unused lldb.cpp

2021-12-09 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeaf4f60507fd: [lldb] Remove unused lldb.cpp (authored by 
hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115438/new/

https://reviews.llvm.org/D115438

Files:
  lldb/source/lldb.cpp


Index: lldb/source/lldb.cpp
===
--- lldb/source/lldb.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//===-- lldb.cpp 
--===//
-//
-// 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
-//
-//===--===//
-
-#include "VCSVersion.inc"
-#include "lldb/lldb-private.h"
-#include "clang/Basic/Version.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// LLDB_VERSION_STRING is set through a define so unlike the other defines
-// expanded with CMake, it lacks the double quotes.
-#define QUOTE(str) #str
-#define EXPAND_AND_QUOTE(str) QUOTE(str)
-
-static const char *GetLLDBVersion() {
-#ifdef LLDB_VERSION_STRING
-  return EXPAND_AND_QUOTE(LLDB_VERSION_STRING);
-#else
-  return "lldb version " CLANG_VERSION_STRING;
-#endif
-}
-
-static const char *GetLLDBRevision() {
-#ifdef LLDB_REVISION
-  return LLDB_REVISION;
-#else
-  return NULL;
-#endif
-}
-
-static const char *GetLLDBRepository() {
-#ifdef LLDB_REPOSITORY
-  return LLDB_REPOSITORY;
-#else
-  return NULL;
-#endif
-}
-
-const char *lldb_private::GetVersion() {
-  static std::string g_version_str;
-  if (g_version_str.empty()) {
-const char *lldb_version = GetLLDBVersion();
-const char *lldb_repo = GetLLDBRepository();
-const char *lldb_rev = GetLLDBRevision();
-g_version_str += lldb_version;
-if (lldb_repo || lldb_rev) {
-  g_version_str += " (";
-  if (lldb_repo)
-g_version_str += lldb_repo;
-  if (lldb_repo && lldb_rev)
-g_version_str += " ";
-  if (lldb_rev) {
-g_version_str += "revision ";
-g_version_str += lldb_rev;
-  }
-  g_version_str += ")";
-}
-
-std::string clang_rev(clang::getClangRevision());
-if (clang_rev.length() > 0) {
-  g_version_str += "\n  clang revision ";
-  g_version_str += clang_rev;
-}
-std::string llvm_rev(clang::getLLVMRevision());
-if (llvm_rev.length() > 0) {
-  g_version_str += "\n  llvm revision ";
-  g_version_str += llvm_rev;
-}
-  }
-  return g_version_str.c_str();
-}


Index: lldb/source/lldb.cpp
===
--- lldb/source/lldb.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//===-- lldb.cpp --===//
-//
-// 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
-//
-//===--===//
-
-#include "VCSVersion.inc"
-#include "lldb/lldb-private.h"
-#include "clang/Basic/Version.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// LLDB_VERSION_STRING is set through a define so unlike the other defines
-// expanded with CMake, it lacks the double quotes.
-#define QUOTE(str) #str
-#define EXPAND_AND_QUOTE(str) QUOTE(str)
-
-static const char *GetLLDBVersion() {
-#ifdef LLDB_VERSION_STRING
-  return EXPAND_AND_QUOTE(LLDB_VERSION_STRING);
-#else
-  return "lldb version " CLANG_VERSION_STRING;
-#endif
-}
-
-static const char *GetLLDBRevision() {
-#ifdef LLDB_REVISION
-  return LLDB_REVISION;
-#else
-  return NULL;
-#endif
-}
-
-static const char *GetLLDBRepository() {
-#ifdef LLDB_REPOSITORY
-  return LLDB_REPOSITORY;
-#else
-  return NULL;
-#endif
-}
-
-const char *lldb_private::GetVersion() {
-  static std::string g_version_str;
-  if (g_version_str.empty()) {
-const char *lldb_version = GetLLDBVersion();
-const char *lldb_repo = GetLLDBRepository();
-const char *lldb_rev = GetLLDBRevision();
-g_version_str += lldb_version;
-if (lldb_repo || lldb_rev) {
-  g_version_str += " (";
-  if (lldb_repo)
-g_version_str += lldb_repo;
-  if (lldb_repo && lldb_rev)
-g_version_str += " ";
-  if (lldb_rev) {
-g_version_str += "revision ";
-g_version_str += lldb_rev;
-  }
-  g_version_str += ")";
-}
-
-std::string clang_rev(clang::getClangRevision());
-if (clang_rev.length() > 0) {
-  g_version_str += "\n  clang revision ";
-  g_version_str += clang_rev;
-}
-std::string llvm_rev(clang::getLLVMRevision());
-if (llvm_rev.length() > 0) {
-  g_version_str += "\n  llvm revision ";
-  g_version_str += llvm_rev;
-}
-  }
-  return g_version_str.c_

[PATCH] D108694: [RISCV] Add the zvl extension according to the v1.0 spec

2021-12-09 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 393185.
eopXD added a comment.

Rebase now since the preceeding patches are accepted.
This patch is ready for review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108694/new/

https://reviews.llvm.org/D108694

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVSubtarget.cpp
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -36,7 +36,7 @@
 ## Experimental extensions require version string to be explicitly specified
 
 .attribute arch, "rv32iv0p10"
-# CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl128b0p10_zvl32b0p10_zvl64b0p10_zvlsseg0p10"
 
 .attribute arch, "rv32izba1p0"
 # CHECK: attribute  5, "rv32i2p0_zba1p0"
@@ -75,4 +75,40 @@
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1_zfhmin0p1"
 
 .attribute arch, "rv32iv0p10zvamo0p10_zvlsseg0p10"
-# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvl128b0p10_zvl32b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl32b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl128b0p10_zvl32b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl64b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl128b0p10_zvl32b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl128b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl128b0p10_zvl32b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl256b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl128b0p10_zvl256b0p10_zvl32b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl512b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl128b0p10_zvl256b0p10_zvl32b0p10_zvl512b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl1024b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl1024b0p10_zvl128b0p10_zvl256b0p10_zvl32b0p10_zvl512b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl2048b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl1024b0p10_zvl128b0p10_zvl2048b0p10_zvl256b0p10_zvl32b0p10_zvl512b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl4096b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl1024b0p10_zvl128b0p10_zvl2048b0p10_zvl256b0p10_zvl32b0p10_zvl4096b0p10_zvl512b0p10_zvl64b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl8192b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl1024b0p10_zvl128b0p10_zvl2048b0p10_zvl256b0p10_zvl32b0p10_zvl4096b0p10_zvl512b0p10_zvl64b0p10_zvl8192b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl16384b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl1024b0p10_zvl128b0p10_zvl16384b0p10_zvl2048b0p10_zvl256b0p10_zvl32b0p10_zvl4096b0p10_zvl512b0p10_zvl64b0p10_zvl8192b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl32768b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl1024b0p10_zvl128b0p10_zvl16384b0p10_zvl2048b0p10_zvl256b0p10_zvl32768b0p10_zvl32b0p10_zvl4096b0p10_zvl512b0p10_zvl64b0p10_zvl8192b0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p10zvl65536b0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvl1024b0p10_zvl128b0p10_zvl16384b0p10_zvl2048b0p10_zvl256b0p10_zvl32768b0p10_zvl32b0p10_zvl4096b0p10_zvl512b0p10_zvl64b0p10_zvl65536b0p10_zvl8192b0p10_zvlsseg0p10"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -18,7 +18,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbr %s -o - | FileCheck --check-prefix=RV32ZBR %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbs %s -o - | FileCheck --check-prefix=RV32ZBS %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbt %s -o - | FileCheck --check-prefix=RV32ZBT %s
-; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbb,+experimental-zfh,+experimental-zvamo,+experimental-v,+f,+experimental-zvlsseg %s -o - | FileCheck --check-prefix=RV32COMBINED %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbb,+experimental-zfh,+experimental-zvamo,+experimental-v,+experimental-zvlsseg %s -o - | FileCheck --check-prefix=RV32COMBINED %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefix=RV64M %s
 ; RUN: llc -mtriple=riscv64 -mattr=+a %s -o - | FileCheck --check-prefix=RV64A %s
 ; RUN: llc -mtriple=riscv64 -mattr=+f %s -o - | FileCheck --check-prefix=RV64F %s
@@ -37,14 +37,14 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbr %s -o - | FileCheck --check-prefix=RV64ZBR %s
 

[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-12-09 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 393181.
eopXD added a comment.

One last rebase before landing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112359/new/

https://reviews.llvm.org/D112359

Files:
  clang/test/CodeGen/RISCV/riscv-metadata.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c
  clang/test/CodeGen/riscv32-ilp32d-abi.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/attribute-arch-invalid.s
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -33,47 +33,46 @@
 .attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
-.attribute arch, "rv32iv"
+## Experimental extensions require version string to be explicitly specified
+
+.attribute arch, "rv32iv0p10"
 # CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
 
-.attribute arch, "rv32izba"
+.attribute arch, "rv32izba1p0"
 # CHECK: attribute  5, "rv32i2p0_zba1p0"
 
-.attribute arch, "rv32izbb"
+.attribute arch, "rv32izbb1p0"
 # CHECK: attribute  5, "rv32i2p0_zbb1p0"
 
-.attribute arch, "rv32izbc"
+.attribute arch, "rv32izbc1p0"
 # CHECK: attribute  5, "rv32i2p0_zbc1p0"
 
-.attribute arch, "rv32izbe"
+.attribute arch, "rv32izbe0p93"
 # CHECK: attribute  5, "rv32i2p0_zbe0p93"
 
-.attribute arch, "rv32izbf"
+.attribute arch, "rv32izbf0p93"
 # CHECK: attribute  5, "rv32i2p0_zbf0p93"
 
-.attribute arch, "rv32izbm"
+.attribute arch, "rv32izbm0p93"
 # CHECK: attribute  5, "rv32i2p0_zbm0p93"
 
-.attribute arch, "rv32izbp"
+.attribute arch, "rv32izbp0p93"
 # CHECK: attribute  5, "rv32i2p0_zbp0p93"
 
-.attribute arch, "rv32izbr"
+.attribute arch, "rv32izbr0p93"
 # CHECK: attribute  5, "rv32i2p0_zbr0p93"
 
-.attribute arch, "rv32izbs"
+.attribute arch, "rv32izbs1p0"
 # CHECK: attribute  5, "rv32i2p0_zbs1p0"
 
-.attribute arch, "rv32izbt"
+.attribute arch, "rv32izbt0p93"
 # CHECK: attribute  5, "rv32i2p0_zbt0p93"
 
-.attribute arch, "rv32ifzfhmin"
+.attribute arch, "rv32ifzfhmin0p1"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfhmin0p1"
 
-.attribute arch, "rv32ifzfh"
+.attribute arch, "rv32ifzfh0p1"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1_zfhmin0p1"
 
-.attribute arch, "rv32ivzvamo_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
-
-.attribute arch, "rv32iv_zvamo0p10_zvlsseg"
+.attribute arch, "rv32iv0p10zvamo0p10_zvlsseg0p10"
 # CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
Index: llvm/test/MC/RISCV/attribute-arch-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/attribute-arch-invalid.s
@@ -0,0 +1,48 @@
+## Invalid arch string
+
+# RUN: not llvm-mc -triple riscv32 < %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -triple riscv64 < %s 2>&1 | FileCheck %s
+
+## Version strings are required for experimental extensions
+
+.attribute arch, "rv32iv"
+# CHECK: error: invalid arch name 'rv32iv', experimental extension requires explicit version number `v`
+
+.attribute arch, "rv32izba"
+# CHECK: error: invalid arch name 'rv32izba', experimental extension requires explicit version number `zba`
+
+.attribute arch, "rv32izbb"
+# CHECK: error: invalid arch name 'rv32izbb', experimental extension requires explicit version number `zbb`
+
+.attribute arch, "rv32izbc"
+# CHECK: error: invalid arch name 'rv32izbc', experimental extension requires explicit version number `zbc`
+
+.attribute arch, "rv32izbe"
+# CHECK:  error: invalid arch name 'rv32izbe', experimental extension requires explicit version number `zbe`
+
+.attribute arch, "rv32izbf"
+# CHECK: error: invalid arch name 'rv32izbf', experimental extension requires explicit version number `zbf`
+
+.attribute arch, "rv32izbm"
+# CHECK: error: invalid arch name 'rv32izbm', experimental extension requires explicit version number `zbm`
+
+.attribute arch, "rv32izbp"
+# CHECK: error: invalid arch name 'rv32izbp', experimental extension requires explicit version number `zbp`
+
+.attribute arch, "rv32izbr"
+# CHECK: error: invalid arch name 'rv32izbr', experimental extension requires explicit version number `zbr`
+
+.attribute arch, "rv32izbs"
+# CHECK: error: invalid arch name 'rv32izbs', experimental extension requires explicit version number `zbs`
+
+.attribute arch, "rv32izbt"
+# CHECK: error: invalid arch name 'rv32izbt', experimental extension requires explicit version number `zbt`
+
+.attribute arch, "rv32ifzfhmin"
+# CHECK:

[PATCH] D115283: [AMDGPU] Set "amdgpu_hostcall" module flag if an AMDGPU function has calls to device lib functions that use hostcalls.

2021-12-09 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D115283#3182879 , @yaxunl wrote:

> In D115283#3181128 , 
> @JonChesterfield wrote:
>
>> Not exactly that. The weak symbol isn't the function name, as that gets 
>> renamed or inlined.
>
> We discussed this before. As code object ABI use runtime metadata to 
> represent hostcall_buffer, we need to check whether hostcall is needed by IR.
>
> This approach will require checking asm instructions inside a function to 
> determine whether this function requires hostcall. It is hacky for IR 
> representation.

There are two approaches here:
1/ Tag the function using inline asm and totally ignore it in the compiler. 
HSA/etc tests per-code-object if the symbol is present
2/ Tag the function (in source or in compiler), propagate information to llc, 
embed it in msgpack data, HSA/etc tests per-function if the field is present

2/ is somewhat useful if we elide the 8 byte slot of kernarg memory for 
functions that don't use it, otherwise it just increases work done by the 
runtime. Instead of checking for presence of one symbol (a hashtable lookup), 
it's a linear scan through msgpack data. We don't currently elide those 8 
bytes, so right now this is making the compiler more complicated in exchange 
for making the runtime slower.

1/ has the benefit of being dead simple and totally compiler agnostic, and the 
cost of passing the 8 byte hostcall thing to every function in a code object 
that asked for it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115283/new/

https://reviews.llvm.org/D115283

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


[PATCH] D109215: [RISCV] Fix arch string parsing for multi-character extensions

2021-12-09 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 393174.
eopXD added a comment.

One last rebase before landing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109215/new/

https://reviews.llvm.org/D109215

Files:
  clang/test/Driver/riscv-arch.c
  llvm/lib/Support/RISCVISAInfo.cpp


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -72,6 +72,28 @@
   return Ext.consume_front("experimental-");
 }
 
+// This function finds the first character that doesn't belong to a version
+// (e.g. zbe0p93 is extension 'zbe' of version '0p93'). So the function will
+// consume [0-9]*p[0-9]* starting from the backward. An extension name will not
+// end with a digit or the letter 'p', so this function will parse correctly.
+// NOTE: This function is NOT able to take empty strings or strings that only
+// have version numbers and no extension name. It assumes the extension name
+// will be at least more than one character.
+static size_t findFirstNonVersionCharacter(const StringRef &Ext) {
+  if (Ext.size() == 0)
+llvm_unreachable("Already guarded by if-statement in ::parseArchString");
+
+  int Pos = Ext.size() - 1;
+  while (Pos > 0 && isDigit(Ext[Pos]))
+Pos--;
+  if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) {
+Pos--;
+while (Pos > 0 && isDigit(Ext[Pos]))
+  Pos--;
+  }
+  return Pos;
+}
+
 struct FindByName {
   FindByName(StringRef Ext) : Ext(Ext){};
   StringRef Ext;
@@ -638,7 +660,7 @@
 
 StringRef Type = getExtensionType(Ext);
 StringRef Desc = getExtensionTypeDesc(Ext);
-auto Pos = Ext.find_if(isDigit);
+size_t Pos = findFirstNonVersionCharacter(Ext) + 1;
 StringRef Name(Ext.substr(0, Pos));
 StringRef Vers(Ext.substr(Pos));
 
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -392,7 +392,7 @@
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izbb1p0zbp0p93 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE %s
-// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb1p0zbp0p93', multi-character extensions must be separated by 
underscores
+// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 
'rv32izbb1p0zbp0p93', unsupported version number 0.93 for extension 'zbb1p0zbp'
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izba1p0 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBA %s


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -72,6 +72,28 @@
   return Ext.consume_front("experimental-");
 }
 
+// This function finds the first character that doesn't belong to a version
+// (e.g. zbe0p93 is extension 'zbe' of version '0p93'). So the function will
+// consume [0-9]*p[0-9]* starting from the backward. An extension name will not
+// end with a digit or the letter 'p', so this function will parse correctly.
+// NOTE: This function is NOT able to take empty strings or strings that only
+// have version numbers and no extension name. It assumes the extension name
+// will be at least more than one character.
+static size_t findFirstNonVersionCharacter(const StringRef &Ext) {
+  if (Ext.size() == 0)
+llvm_unreachable("Already guarded by if-statement in ::parseArchString");
+
+  int Pos = Ext.size() - 1;
+  while (Pos > 0 && isDigit(Ext[Pos]))
+Pos--;
+  if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) {
+Pos--;
+while (Pos > 0 && isDigit(Ext[Pos]))
+  Pos--;
+  }
+  return Pos;
+}
+
 struct FindByName {
   FindByName(StringRef Ext) : Ext(Ext){};
   StringRef Ext;
@@ -638,7 +660,7 @@
 
 StringRef Type = getExtensionType(Ext);
 StringRef Desc = getExtensionTypeDesc(Ext);
-auto Pos = Ext.find_if(isDigit);
+size_t Pos = findFirstNonVersionCharacter(Ext) + 1;
 StringRef Name(Ext.substr(0, Pos));
 StringRef Vers(Ext.substr(Pos));
 
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -392,7 +392,7 @@
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izbb1p0zbp0p93 -menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE %s
-// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 'rv32izbb1p0zbp0p93', multi-character extensions must be separated by underscores
+// RV32-EXPERIMENTAL-ZBB-ZBP-UNDERSCORE: error: invalid arch name 'rv32izbb1p0zbp0p93', unsupported version number 0

[PATCH] D115441: [X86][MS] Add 80bit long double support for Windows

2021-12-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Doesn’t icc also emit code into main to change the FPCW precision control 
field? Is making long double 80 bits useful if you don’t increase the precision 
in hardware?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115441/new/

https://reviews.llvm.org/D115441

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


[PATCH] D114421: [asan] Add support for disable_sanitizer_instrumentation attribute

2021-12-09 Thread Alexander Potapenko via Phabricator via cfe-commits
glider updated this revision to Diff 393168.
glider added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114421/new/

https://reviews.llvm.org/D114421

Files:
  clang/docs/AddressSanitizer.rst
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/asan-globals.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  
llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll

Index: llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll
@@ -0,0 +1,47 @@
+; This test checks that we are not instrumenting sanitizer code.
+; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function with sanitize_address is instrumented.
+; Function Attrs: nounwind uwtable
+define void @instr_sa(i32* %a) sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @instr_sa
+; CHECK: call void @__asan_report_load
+
+
+; Function with disable_sanitizer_instrumentation is not instrumented.
+; Function Attrs: nounwind uwtable
+define void @noinstr_dsi(i32* %a) disable_sanitizer_instrumentation {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @noinstr_dsi
+; CHECK-NOT: call void @__asan_report_load
+
+
+; disable_sanitizer_instrumentation takes precedence over sanitize_address.
+; Function Attrs: nounwind uwtable
+define void @noinstr_dsi_sa(i32* %a) disable_sanitizer_instrumentation sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @noinstr_dsi_sa
+; CHECK-NOT: call void @__asan_report_load
+
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2890,6 +2890,9 @@
   // Leave if the function doesn't need instrumentation.
   if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return FunctionModified;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return FunctionModified;
+
   LLVM_DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
 
   initializeCallbacks(*F.getParent());
Index: clang/test/CodeGen/asan-globals.cpp
===
--- clang/test/CodeGen/asan-globals.cpp
+++ clang/test/CodeGen/asan-globals.cpp
@@ -10,6 +10,7 @@
 int global;
 int dyn_init_global = global;
 int __attribute__((no_sanitize("address"))) attributed_global;
+int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
 int ignorelisted_global;
 
 int __attribute__((section("__DATA, __common"))) sectioned_global; // KASAN - ignore globals in a section
@@ -50,31 +51,33 @@
 // UWTABLE: attributes #[[#ATTR]] = { nounwind uwtable }
 // UWTABLE: ![[#]] = !{i32 7, !"uwtable", i32 1}
 
-// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false}
 // CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 10, i32 5}
 // CHECK: ![[DYN_INIT_GLOBAL]] = !{{{.*}} ![[DYN_INIT_LOC:[0-9]+]], !"dyn_init_global", i1 true, i1 false}
 // CHECK: ![[DYN_INIT_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 11, i32 5}
-// CHECK: ![[ATTR_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
-// CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
+// CHECK: ![[ATTR_GLOBAL]] = !{{{.*@attributed_global.*}}, null, null, i1 false, i1 true}
+// CHECK: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*@disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
+// CHECK: ![[IGNOREL

[PATCH] D115346: [clang][deps] Squash caches for original and minimized files

2021-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 marked 3 inline comments as done.
jansvoboda11 added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:50-51
+
+  /// Minimize contents of the file.
+  static void minimize(CachedFileSystemEntry &Entry);
 

dexonsmith wrote:
> Might be more natural as a non-static:
> ```
> lang=c++
> void minimize();
> ```
> 
Agreed. I originally wanted to minimize diff of the implementation (by being 
able to refer to `Result` as before), but I'm happy making this an instance 
method.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:69-75
+  llvm::ErrorOr getContents(bool Minimized) const {
+assert(isValid() && "not initialized");
 if (!MaybeStat)
   return MaybeStat.getError();
 assert(!MaybeStat->isDirectory() && "not a file");
-assert(isValid() && "not initialized");
-return Contents->getBuffer();
+return (Minimized ? MinimizedContents : OriginalContents)->getBuffer();
   }

dexonsmith wrote:
> I *think* this is thread-safe -- since `Minimized` should be the same as when 
> the local cache entry was created -- but it's a bit subtle.
> 
> The problematic case I am worried about:
> - First use in local cache is non-minimized.
> - Creates shared cache entry that's not minimized.
> - Some other local cache wants it to be minimized.
> - Later use in local cache is minimized.
> - Accessing `Minimized` pointer races with the other thread setting it.
> 
> If the local cache is guaranteed to always pass the same value for 
> `Minimized` as when it fist accessed it, then there shouldn't be a problem...
> 
> I wonder if there's a way to make it less subtle?
I extracted the logic into `EntryRef` which now gets returned from the main 
function. It carries the `bool Minimized` bit and makes reasoning about this 
more local. WDYT?



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:106-108
+  std::unique_ptr OriginalContents;
+  std::unique_ptr MinimizedContents;
   PreprocessorSkippedRangeMapping PPSkippedRangeMapping;

dexonsmith wrote:
> I'm finding it a bit subtle detecting if there are races on access / setting 
> of these, but I think it's correct.
> - I think I verified that they are "set once".
> - All the setters are guarded by locks.
> - The first getter per "local" cache is guarded by a lock.
> - Subsequent getters are not.
> 
> The key question: are the subsequent getters ONLY used when the first getter 
> was successful?
> 
> One way to make it more obvious:
> ```
> lang=c++
>   struct ContentWithPPRanges {
> std::unique_ptr Content;
> PreprocessorSkippedRangeMapping PPSkippedRangeMapping;
>   };
> 
> private:
>   // Always accessed,mutated under a lock. Not mutated after they escape.
>   std::unique_ptr Original;
>   std::unique_ptr Minimized;
>   PreprocessorSkippedRangeMapping PPSkippedRangeMapping;
> 
>   // Used in getters. Pointed-at memory immutable after these are set.
>   std::atomic OriginalAccess;
>   std::atomic MinimizedAccess;
>   std::atomic PPRangesAccess;
> ```
> I don't think this is the only approach though.
> 
I think there are no races on the original contents. The pointer is 
unconditionally set on creation of `CachedFileSystemEntry` under a lock that no 
threads get past without having set the pointer (or failing and never accessing 
the pointer).

For minimized contents, the latest revision adds check at the beginning of the 
main function (`needsMinimization`) outside the critical section. There are 
three paths I can think of:
* The check returns `true` in thread A (pointer is `null`), thread A enters 
critical section, minimizes the contents and initializes the pointer.
* The check returns `true` in thread A, but thread B entered the critical 
section, minimized contents and initialized the pointer. When thread A enters 
the critical section, it performs the check again, figures that out and skips 
minimization.
* The check returns `false` and the local cache entry is returned.

So there definitely is a race here, but I believe it's benign. Do you agree? Do 
you think it's worth addressing?



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp:253
+  if (Entry.isMinimized()) {
+if (!Entry.getPPSkippedRangeMapping().empty() && PPSkipMappings)
+  (*PPSkipMappings)[Result->Buffer->getBufferStart()] =

Maybe the `isMinimized()` check should be performed internally in `EntryRef` 
when accessing `getPPSkippedRangeMapping()` to make the race avoidance more 
local...



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp:189-191
+if (ShouldBeMinimized && CacheEntry.hasOriginalContents() &&
+!CacheEntry.hasMinimizedContents())
+  CachedFileSystemEntry::minimize(CacheEntry);
-

[PATCH] D115153: clang/AMDGPU: Don't set implicit arg attribute to default size

2021-12-09 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Great, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115153/new/

https://reviews.llvm.org/D115153

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-12-09 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D111617#3175167 , @craig.topper 
wrote:

> In D111617#3060377 , @HsiangKai 
> wrote:
>
>> Although it reduces the header size, this patch will increase the binary 
>> size of clang.
>>
>> Debug build:
>> Before this patch:
>>
>>   textdatabss dec hex
>>  filename
>>   263892591   10838284500232  275231107   1067b183   
>>  clang-14
>>
>> After this patch:
>>
>>   textdatabss dec hex
>>  filename
>>   263909721   12085116500232  276495069   107afadd   
>>  clang-14
>>
>> Release build:
>> Before this patch;
>>
>>   textdatabss dec hex
>>  filename
>>   382952171   8802976410264736481246671   1caf3dcf   
>>  clang-14
>>
>> After this patch:
>>
>>   textdatabss dec hex
>>  filename
>>   387629483   9465258210264736492546801   1d5baaf1   
>>  clang-14
>
> These number indicate the release build is larger than debug. That seems 
> wrong. Am I misreading these numbers?

Indeed, it is strange. The data is got from the first draft version. I have no 
such environment now. I could collect the clang size using the latest 
implementation.
After removing the global static constructor, there is no build time problem 
now.
So, in the latest implementation, we can get the better compile time, smaller 
clang size and acceptable build time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111617/new/

https://reviews.llvm.org/D111617

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


[PATCH] D115442: [clangd] Provide documentation as MarkupContent in signaturehelp

2021-12-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Also some related discussions in https://github.com/clangd/clangd/issues/945


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115442/new/

https://reviews.llvm.org/D115442

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


[PATCH] D107275: [Sema] a[x] has type T when a has type T* or T[], even when T is dependent

2021-12-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Sorry for leaving this without any replies, I think the summary you have is 
already of our offline discussion. Let me raise my final concerns, if you think 
we're covered for those and others don't chime in this week I suppose we can 
consider this as good to go.

---

I think 2nd case is fine, as we're unlikely to regress anything by handling 
just LHS. The rare case just won't get the benefits.

---

I am more worried about creating "incorrect" nodes in some cases. I think it 
isn't valid in C/C++ for both LHS && RHS to be pointers/arrays in a subscript 
expression, but I've got no idea about when it's diagnosed in clang and what is 
put into the AST.

If that detection happens before creating any SubscriptExprs (i.e. hitting 
changes in this patch), I guess we're all fine (i.e. we won't generate a node 
with an incorrect `ResultType`).
If it happens after creating these exprs though, now we'll have a bunch of 
expressions with erroneous `ResultType` info which might trip over some things. 
(Worst case scenario, detection completely fails and some code that should've 
been diagnosed as being broken will miscompile instead.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107275/new/

https://reviews.llvm.org/D107275

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


[PATCH] D115283: [AMDGPU] Set "amdgpu_hostcall" module flag if an AMDGPU function has calls to device lib functions that use hostcalls.

2021-12-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D115283#3181109 , @kpyzhov wrote:

> In D115283#3180836 , @yaxunl wrote:
>
>> If we only need to check whether `__ockl_hostcall_internal` exists in the 
>> final module in LLVM codegen to determine whether we need the hostcall 
>> metadata, probably we don't even need a function attribute or even module 
>> flag.
>
> Right, we used to do exactly that (just check at the CodeGen phase if 
> 'ockl_hostcall_internal()' is present in the module), but then it turned out 
> that it does not work with -fgpu-rdc since IPO may rename the 
> 'ockl_hostcall_internal()'.

Sorry I forgot that.

Then I agree that a function attribute seems a better way to represent hostcall 
requirement in IR. It is needed in both source and IR. This avoids checking 
hostcall requirements by function names. It works for all frontends as long as 
they use device libs or mark their own hostcall function with the attribute. It 
also can result in more efficient code object if useless hostcall functions are 
removed by optimizers. Overall it will result in a cleaner IR representation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115283/new/

https://reviews.llvm.org/D115283

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


[PATCH] D115346: [clang][deps] Squash caches for original and minimized files

2021-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D115346#3181198 , @dexonsmith 
wrote:

> This looks really nice.
>
> One problem is that it's subtle to confirm whether it's thread-safe. The 
> local cache access parts of CachedFileSystemEntry lock-free, but the 
> CachedFileSystemEntry might get changed later (i.e., filled in with minimized 
> content). Are accessed fields guaranteed by context not to be the ones that 
> mutate later?

I believe the latest revision is thread-safe (albeit with benign data-races on 
`needsMinimization`). Once a `CachedFileSystemEntry` has been created, only the 
`MinimizedContents` and `PPSkippedRangeMapping` members can be modified (at 
most once, under a lock). Access to those fields only happens in "minimizing" 
contexts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115346/new/

https://reviews.llvm.org/D115346

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


[clang] ab28cb1 - Revert "[xray] add support for hexagon"

2021-12-09 Thread Brian Cain via cfe-commits

Author: Brian Cain
Date: 2021-12-09T07:30:40-08:00
New Revision: ab28cb1c5c4dc7181fae3d47f0601982996739db

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

LOG: Revert "[xray] add support for hexagon"

This reverts commit 543a9ad7c460bb8d641b1b7c67bbc032c9bfdb45.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Driver/XRayArgs.cpp
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
compiler-rt/lib/xray/CMakeLists.txt
compiler-rt/lib/xray/xray_interface.cpp
compiler-rt/lib/xray/xray_tsc.h
llvm/lib/CodeGen/XRayInstrumentation.cpp
llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp
llvm/lib/Target/Hexagon/HexagonAsmPrinter.h
llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
llvm/lib/Target/Hexagon/HexagonInstrInfo.h
llvm/lib/Target/Hexagon/HexagonMCInstLower.cpp
llvm/lib/Target/Hexagon/HexagonSubtarget.h
llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp

Removed: 
compiler-rt/lib/xray/xray_hexagon.cpp
compiler-rt/lib/xray/xray_trampoline_hexagon.S
llvm/test/CodeGen/Hexagon/xray-pred-ret.ll
llvm/test/CodeGen/Hexagon/xray.ll



diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 2ce7904ecc40d..18270818d1589 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -226,7 +226,6 @@ constructHexagonLinkArgs(Compilation &C, const JobAction 
&JA,
   StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(HTC, Args, CmdArgs);
-  bool NeedsXRayDeps = addXRayRuntime(HTC, Args, CmdArgs);
 
   
//
   // Silence warnings for various options
@@ -298,8 +297,6 @@ constructHexagonLinkArgs(Compilation &C, const JobAction 
&JA,
 
 CmdArgs.push_back("-lunwind");
   }
-  if (NeedsXRayDeps)
-linkXRayRuntimeDeps(HTC, CmdArgs);
 
   CmdArgs.push_back("-lclang_rt.builtins-hexagon");
   CmdArgs.push_back("-lc");

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 63b575178bd12..b44509ad3b881 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -40,7 +40,6 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
 case llvm::Triple::x86_64:
 case llvm::Triple::arm:
 case llvm::Triple::aarch64:
-case llvm::Triple::hexagon:
 case llvm::Triple::ppc64le:
 case llvm::Triple::mips:
 case llvm::Triple::mipsel:

diff  --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 3e86cf63c789b..45226b4158d74 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -73,8 +73,7 @@ set(ALL_SCUDO_STANDALONE_SUPPORTED_ARCH ${X86} ${X86_64} 
${ARM32} ${ARM64}
 if(APPLE)
 set(ALL_XRAY_SUPPORTED_ARCH ${X86_64})
 else()
-set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64}
-   powerpc64le ${HEXAGON})
+set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} 
powerpc64le)
 endif()
 set(ALL_SHADOWCALLSTACK_SUPPORTED_ARCH ${ARM64})
 

diff  --git a/compiler-rt/lib/xray/CMakeLists.txt 
b/compiler-rt/lib/xray/CMakeLists.txt
index ca9389747a5ee..204e5b17c7970 100644
--- a/compiler-rt/lib/xray/CMakeLists.txt
+++ b/compiler-rt/lib/xray/CMakeLists.txt
@@ -73,11 +73,6 @@ set(powerpc64le_SOURCES
   xray_trampoline_powerpc64_asm.S
   )
 
-set(hexagon_SOURCES
-  xray_hexagon.cpp
-  xray_trampoline_hexagon.S
-  )
-
 set(XRAY_IMPL_HEADERS
   xray_allocator.h
   xray_basic_flags.h
@@ -116,7 +111,6 @@ set(XRAY_ALL_SOURCE_FILES
   ${x86_64_SOURCES}
   ${arm_SOURCES}
   ${armhf_SOURCES}
-  ${hexagon_SOURCES}
   ${mips_SOURCES}
   ${mipsel_SOURCES}
   ${mips64_SOURCES}

diff  --git a/compiler-rt/lib/xray/xray_hexagon.cpp 
b/compiler-rt/lib/xray/xray_hexagon.cpp
deleted file mode 100644
index 7f127b2b499cd..0
--- a/compiler-rt/lib/xray/xray_hexagon.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-//===-- xray_hexagon.cpp --*- C++ 
---*-===//
-//
-// 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
-//
-//===--===//
-//
-// This file is a part of XRay, a dynamic runtime instrumentation system.
-//
-// Implementation of hexagon-specific routines (32-bit).
-//
-//===--===//
-#include "sanitizer_common/saniti

[PATCH] D115346: [clang][deps] Squash caches for original and minimized files

2021-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 393162.
jansvoboda11 added a comment.

Prevent potential data races by wrapping access to 
`Entry.getPPSkippedRangeMapping()` in `if (Entry.isMinimized())`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115346/new/

https://reviews.llvm.org/D115346

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp

Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -75,6 +75,12 @@
 : Name(Name.str()), UID(UID), MTime(MTime), User(User), Group(Group),
   Size(Size), Type(Type), Perms(Perms) {}
 
+Status Status::copyWithNewSize(const Status &In, uint64_t NewSize) {
+  return Status(In.getName(), In.getUniqueID(), In.getLastModificationTime(),
+In.getUser(), In.getGroup(), NewSize, In.getType(),
+In.getPermissions());
+}
+
 Status Status::copyWithNewName(const Status &In, const Twine &NewName) {
   return Status(NewName, In.getUniqueID(), In.getLastModificationTime(),
 In.getUser(), In.getGroup(), In.getSize(), In.getType(),
Index: llvm/include/llvm/Support/VirtualFileSystem.h
===
--- llvm/include/llvm/Support/VirtualFileSystem.h
+++ llvm/include/llvm/Support/VirtualFileSystem.h
@@ -64,6 +64,8 @@
  uint64_t Size, llvm::sys::fs::file_type Type,
  llvm::sys::fs::perms Perms);
 
+  /// Get a copy of a Status with a different size.
+  static Status copyWithNewSize(const Status &In, uint64_t NewSize);
   /// Get a copy of a Status with a different name.
   static Status copyWithNewName(const Status &In, const Twine &NewName);
   static Status copyWithNewName(const llvm::sys::fs::file_status &In,
Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -205,32 +205,46 @@
 }
 
 namespace dependencies {
-TEST(DependencyScanningFilesystem, IgnoredFilesHaveSeparateCache) {
+TEST(DependencyScanningFilesystem, IgnoredFilesAreCachedSeparately1) {
   auto VFS = llvm::makeIntrusiveRefCnt();
-  VFS->addFile("/mod.h", 0, llvm::MemoryBuffer::getMemBuffer("// hi there!\n"));
+  VFS->addFile("/mod.h", 0,
+   llvm::MemoryBuffer::getMemBuffer("#include \n"
+"// hi there!\n"));
 
   DependencyScanningFilesystemSharedCache SharedCache;
   auto Mappings = std::make_unique();
   DependencyScanningWorkerFilesystem DepFS(SharedCache, VFS, Mappings.get());
 
+  DepFS.enableMinimizationOfAllFiles(); // Let's be explicit for clarity.
   auto StatusMinimized0 = DepFS.status("/mod.h");
   DepFS.disableMinimization("/mod.h");
   auto StatusFull1 = DepFS.status("/mod.h");
-  DepFS.enableMinimizationOfAllFiles();
-
-  auto StatusMinimized2 = DepFS.status("/mod.h");
-  DepFS.disableMinimization("/mod.h");
-  auto StatusFull3 = DepFS.status("/mod.h");
 
   EXPECT_TRUE(StatusMinimized0);
-  EXPECT_EQ(StatusMinimized0->getSize(), 0u);
   EXPECT_TRUE(StatusFull1);
-  EXPECT_EQ(StatusFull1->getSize(), 13u);
+  EXPECT_EQ(StatusMinimized0->getSize(), 17u);
+  EXPECT_EQ(StatusFull1->getSize(), 30u);
+}
+
+TEST(DependencyScanningFilesystem, IgnoredFilesAreCachedSeparately2) {
+  auto VFS = llvm::makeIntrusiveRefCnt();
+  VFS->addFile("/mod.h", 0,
+   llvm::MemoryBuffer::getMemBuffer("#include \n"
+"// hi there!\n"));
+
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto Mappings = std::make_unique();
+  DependencyScanningWorkerFilesystem DepFS(SharedCache, VFS, Mappings.get());
+
+  DepFS.disableMinimization("/mod.h");
+  auto StatusFull0 = DepFS.status("/mod.h");
+  DepFS.enableMinimizationOfAllFiles();
+  auto StatusMinimized1 = DepFS.status("/mod.h");
 
-  EXPECT_TRUE(StatusMinimized2);
-  EXPECT_EQ(StatusMinimized2->getSize(), 0u);
-  EXPECT_TRUE(StatusFull3);
-  EXPECT_EQ(StatusFull3->getSize(), 13u);
+  EXPECT_TRUE(StatusFull0);
+  EXPECT_TRUE(StatusMinimized1);
+  EXPECT_EQ(StatusFull0->getSize(), 30u);
+  EXPECT_EQ(StatusMinimized1->getSize(), 17u);
 }
 
 } // end namespace dependencies
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -16,8 +16,9 @@
 using namespace tooling;
 using namespace depen

[PATCH] D115283: [AMDGPU] Set "amdgpu_hostcall" module flag if an AMDGPU function has calls to device lib functions that use hostcalls.

2021-12-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D115283#3181128 , @JonChesterfield 
wrote:

> Not exactly that. The weak symbol isn't the function name, as that gets 
> renamed or inlined.

We discussed this before. As code object ABI use runtime metadata to represent 
hostcall_buffer, we need to check whether hostcall is needed by IR.

This approach will require checking asm instructions inside a function to 
determine whether this function requires hostcall. It is hacking for IR 
representation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115283/new/

https://reviews.llvm.org/D115283

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


[PATCH] D115346: [clang][deps] Squash caches for original and minimized files

2021-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 393159.
jansvoboda11 added a comment.

Introduce `EntryRef`, handle delayed minimization.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115346/new/

https://reviews.llvm.org/D115346

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp

Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -75,6 +75,12 @@
 : Name(Name.str()), UID(UID), MTime(MTime), User(User), Group(Group),
   Size(Size), Type(Type), Perms(Perms) {}
 
+Status Status::copyWithNewSize(const Status &In, uint64_t NewSize) {
+  return Status(In.getName(), In.getUniqueID(), In.getLastModificationTime(),
+In.getUser(), In.getGroup(), NewSize, In.getType(),
+In.getPermissions());
+}
+
 Status Status::copyWithNewName(const Status &In, const Twine &NewName) {
   return Status(NewName, In.getUniqueID(), In.getLastModificationTime(),
 In.getUser(), In.getGroup(), In.getSize(), In.getType(),
Index: llvm/include/llvm/Support/VirtualFileSystem.h
===
--- llvm/include/llvm/Support/VirtualFileSystem.h
+++ llvm/include/llvm/Support/VirtualFileSystem.h
@@ -64,6 +64,8 @@
  uint64_t Size, llvm::sys::fs::file_type Type,
  llvm::sys::fs::perms Perms);
 
+  /// Get a copy of a Status with a different size.
+  static Status copyWithNewSize(const Status &In, uint64_t NewSize);
   /// Get a copy of a Status with a different name.
   static Status copyWithNewName(const Status &In, const Twine &NewName);
   static Status copyWithNewName(const llvm::sys::fs::file_status &In,
Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -205,32 +205,46 @@
 }
 
 namespace dependencies {
-TEST(DependencyScanningFilesystem, IgnoredFilesHaveSeparateCache) {
+TEST(DependencyScanningFilesystem, IgnoredFilesAreCachedSeparately1) {
   auto VFS = llvm::makeIntrusiveRefCnt();
-  VFS->addFile("/mod.h", 0, llvm::MemoryBuffer::getMemBuffer("// hi there!\n"));
+  VFS->addFile("/mod.h", 0,
+   llvm::MemoryBuffer::getMemBuffer("#include \n"
+"// hi there!\n"));
 
   DependencyScanningFilesystemSharedCache SharedCache;
   auto Mappings = std::make_unique();
   DependencyScanningWorkerFilesystem DepFS(SharedCache, VFS, Mappings.get());
 
+  DepFS.enableMinimizationOfAllFiles(); // Let's be explicit for clarity.
   auto StatusMinimized0 = DepFS.status("/mod.h");
   DepFS.disableMinimization("/mod.h");
   auto StatusFull1 = DepFS.status("/mod.h");
-  DepFS.enableMinimizationOfAllFiles();
-
-  auto StatusMinimized2 = DepFS.status("/mod.h");
-  DepFS.disableMinimization("/mod.h");
-  auto StatusFull3 = DepFS.status("/mod.h");
 
   EXPECT_TRUE(StatusMinimized0);
-  EXPECT_EQ(StatusMinimized0->getSize(), 0u);
   EXPECT_TRUE(StatusFull1);
-  EXPECT_EQ(StatusFull1->getSize(), 13u);
+  EXPECT_EQ(StatusMinimized0->getSize(), 17u);
+  EXPECT_EQ(StatusFull1->getSize(), 30u);
+}
+
+TEST(DependencyScanningFilesystem, IgnoredFilesAreCachedSeparately2) {
+  auto VFS = llvm::makeIntrusiveRefCnt();
+  VFS->addFile("/mod.h", 0,
+   llvm::MemoryBuffer::getMemBuffer("#include \n"
+"// hi there!\n"));
+
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto Mappings = std::make_unique();
+  DependencyScanningWorkerFilesystem DepFS(SharedCache, VFS, Mappings.get());
+
+  DepFS.disableMinimization("/mod.h");
+  auto StatusFull0 = DepFS.status("/mod.h");
+  DepFS.enableMinimizationOfAllFiles();
+  auto StatusMinimized1 = DepFS.status("/mod.h");
 
-  EXPECT_TRUE(StatusMinimized2);
-  EXPECT_EQ(StatusMinimized2->getSize(), 0u);
-  EXPECT_TRUE(StatusFull3);
-  EXPECT_EQ(StatusFull3->getSize(), 13u);
+  EXPECT_TRUE(StatusFull0);
+  EXPECT_TRUE(StatusMinimized1);
+  EXPECT_EQ(StatusFull0->getSize(), 30u);
+  EXPECT_EQ(StatusMinimized1->getSize(), 17u);
 }
 
 } // end namespace dependencies
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -16,8 +16,9 @@
 using namespace tooling;
 using namespace dependencies;
 
-CachedFileSystemEntry CachedFileSystemEntry::createFile

  1   2   >