[PATCH] D97916: [Driver][RISCV] Support parsing multi-lib config from GCC.

2021-03-03 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 328040.
kito-cheng added a comment.

Minor clean up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97916

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/bin/riscv32-unknown-elf-gcc
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32iac/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32iac/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32imafc/ilp32f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32imafc/ilp32f/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv64imafdc/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv64imafdc/lp64d/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/rv32iac/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/rv32imafc/ilp32f/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/rv64imac/lp64/crt0.o
  clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/bin/riscv64-unknown-elf-gcc
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imafdc/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imafdc/lp64d/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/rv32iac/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/rv32imafc/ilp32f/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/rv64imac/lp64/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk_bad/bin/riscv64-unknown-elf-gcc
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -153,6 +153,24 @@
 // C-RV64-RTLIB-COMPILERRT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "{{.*}}libclang_rt.builtins-riscv64.a"
 // C-RV64-RTLIB-COMPILERRT-LP64: "{{.*}}clang_rt.crtend-riscv64.o"
 
+// Test for multi-lib config from GCC.
+// RUN: %clang %s \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv64_elf_sdk \
+// RUN:   --print-multi-lib \
+// RUN:   | FileCheck -check-prefix=C-RV64-GCC-MULTI-LIB %s
+// C-RV64-GCC-MULTI-LIB: rv32iac/ilp32;@march=rv32iac@mabi=ilp32
+// C-RV64-GCC-MULTI-LIB-NEXT: rv32imafc/ilp32f;@march=rv32iac@mabi=ilp32f
+// C-RV64-GCC-MULTI-LIB-NEXT: rv64imafdc/lp64d;@march=rv64imafdc@mabi=lp64d
+// C-RV64-GCC-MULTI-LIB-NOT:  {{^.+$}}
+
+// RUN: %clang %s \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv64_elf_sdk_bad \
+// RUN:   --print-multi-lib 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-GCC-MULTI-LIB-BAD %s
+// C-RV64-GCC-MULTI-LIB-BAD: warning: xxx option unrecognized in multi-lib configuration when parsing config from GCC, falling back to built-in multi-lib configuration. [-Wmultilib-fallback]
+
 // RUN: %clang -target riscv64 %s -emit-llvm -S -o - | FileCheck %s
 
 typedef __builtin_va_list va_list;
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -197,6 +197,17 @@
 // 

[PATCH] D97916: [Driver][RISCV] Support parsing multi-lib config from GCC.

2021-03-03 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng created this revision.
Herald added subscribers: vkmr, frasercrmck, evandro, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
niosHD, sabuasal, simoncook, johnrusso, rbar, asb, emaste.
kito-cheng requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

RISC-V is highly configurable architecture, so it's hard to list all
possible multi-lib here, in order to deal with that issue , GCC has support
a flexible way to configure the multi-lib[1] for bare-matel toolchain.

So I think it would be great to just leverage that from GCC, the
simplest way is asking the multi-lib configuration from GCC.

[1] 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c1e6691245ca2f1f329549f323f67afe32bcb97a


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97916

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/bin/riscv32-unknown-elf-gcc
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32iac/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32iac/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32imafc/ilp32f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv32imafc/ilp32f/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv64imafdc/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/lib/gcc/riscv32-unknown-elf/8.2.0/rv64imafdc/lp64d/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/rv32iac/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/rv32imafc/ilp32f/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv32_elf_sdk/riscv32-unknown-elf/lib/rv64imac/lp64/crt0.o
  clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/bin/riscv64-unknown-elf-gcc
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imafdc/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imafdc/lp64d/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/rv32iac/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/rv32imafc/ilp32f/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk/riscv64-unknown-elf/lib/rv64imac/lp64/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv64_elf_sdk_bad/bin/riscv64-unknown-elf-gcc
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -153,6 +153,24 @@
 // C-RV64-RTLIB-COMPILERRT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "{{.*}}libclang_rt.builtins-riscv64.a"
 // C-RV64-RTLIB-COMPILERRT-LP64: "{{.*}}clang_rt.crtend-riscv64.o"
 
+// Test for multi-lib config from GCC.
+// RUN: %clang %s \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv64_elf_sdk \
+// RUN:   --print-multi-lib \
+// RUN:   | FileCheck -check-prefix=C-RV64-GCC-MULTI-LIB %s
+// C-RV64-GCC-MULTI-LIB: rv32iac/ilp32;@march=rv32iac@mabi=ilp32
+// C-RV64-GCC-MULTI-LIB-NEXT: rv32imafc/ilp32f;@march=rv32iac@mabi=ilp32f
+// C-RV64-GCC-MULTI-LIB-NEXT: rv64imafdc/lp64d;@march=rv64imafdc@mabi=lp64d
+// C-RV64-GCC-MULTI-LIB-NOT:  {{^.+$}}
+
+// RUN: %clang 

[PATCH] D97912: [doc] Document that __fp16 will apply default argument promotion rule.

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

Update SUMMARY, first version I just incorrectly said ACLE didn't clarify the 
default argument promotion rule, but I found that in ABI spec later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97912

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


[PATCH] D92815: [PowerPC] [Clang] Enable float128 feature on VSX targets

2021-03-03 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang accepted this revision.
steven.zhang added a comment.

LGTM now. But please hold on for at least one week to see if @nemanjai has 
concern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92815

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


[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

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

I didn't add any new tests. Instead, added checks for the new code sequence: 1. 
check that `llvm.assume` is there to make sure the adjusted address is 
correctly aligned. 2. check that `llvm.coro.align` and the associated 
instructions are there to over-allocate heap memory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97915

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


[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-03-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 328036.
ychen added a comment.
Herald added a subscriber: jdoerfert.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97915

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-builtins.c
  clang/test/CodeGenCoroutines/coro-gro.cpp
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Coroutines/CoroInstr.h
  llvm/lib/Transforms/Coroutines/CoroInternal.h
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/Coroutines/Coroutines.cpp

Index: llvm/lib/Transforms/Coroutines/Coroutines.cpp
===
--- llvm/lib/Transforms/Coroutines/Coroutines.cpp
+++ llvm/lib/Transforms/Coroutines/Coroutines.cpp
@@ -234,6 +234,7 @@
   Shape.CoroBegin = nullptr;
   Shape.CoroEnds.clear();
   Shape.CoroSizes.clear();
+  Shape.CoroAligns.clear();
   Shape.CoroSuspends.clear();
 
   Shape.FrameTy = nullptr;
@@ -268,6 +269,9 @@
   case Intrinsic::coro_size:
 CoroSizes.push_back(cast(II));
 break;
+  case Intrinsic::coro_align:
+CoroAligns.push_back(cast(II));
+break;
   case Intrinsic::coro_frame:
 CoroFrames.push_back(cast(II));
 break;
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -997,23 +997,33 @@
   Shape.AsyncLowering.AsyncFuncPointer->setInitializer(NewFuncPtrStruct);
 }
 
-static void replaceFrameSize(coro::Shape ) {
+static void replaceFrameSizeAndAlign(coro::Shape ) {
   if (Shape.ABI == coro::ABI::Async)
 updateAsyncFuncPointerContextSize(Shape);
 
-  if (Shape.CoroSizes.empty())
-return;
+  if (!Shape.CoroSizes.empty()) {
+// In the same function all coro.sizes should have the same result type.
+auto *SizeIntrin = Shape.CoroSizes.back();
+Module *M = SizeIntrin->getModule();
+const DataLayout  = M->getDataLayout();
+auto Size = DL.getTypeAllocSize(Shape.FrameTy);
+auto *SizeConstant = ConstantInt::get(SizeIntrin->getType(), Size);
+
+for (CoroSizeInst *CS : Shape.CoroSizes) {
+  CS->replaceAllUsesWith(SizeConstant);
+  CS->eraseFromParent();
+}
+  }
 
-  // In the same function all coro.sizes should have the same result type.
-  auto *SizeIntrin = Shape.CoroSizes.back();
-  Module *M = SizeIntrin->getModule();
-  const DataLayout  = M->getDataLayout();
-  auto Size = DL.getTypeAllocSize(Shape.FrameTy);
-  auto *SizeConstant = ConstantInt::get(SizeIntrin->getType(), Size);
+  if (!Shape.CoroAligns.empty()) {
+auto *Intrin = Shape.CoroAligns.back();
+auto *AlignConstant =
+ConstantInt::get(Intrin->getType(), Shape.FrameAlign.value());
 
-  for (CoroSizeInst *CS : Shape.CoroSizes) {
-CS->replaceAllUsesWith(SizeConstant);
-CS->eraseFromParent();
+for (CoroAlignInst *CS : Shape.CoroAligns) {
+  CS->replaceAllUsesWith(AlignConstant);
+  CS->eraseFromParent();
+}
   }
 }
 
@@ -1748,7 +1758,7 @@
 
   simplifySuspendPoints(Shape);
   buildCoroutineFrame(F, Shape);
-  replaceFrameSize(Shape);
+  replaceFrameSizeAndAlign(Shape);
 
   // If there are no suspend points, no split required, just remove
   // the allocation and deallocation blocks, they are not needed.
Index: llvm/lib/Transforms/Coroutines/CoroInternal.h
===
--- llvm/lib/Transforms/Coroutines/CoroInternal.h
+++ llvm/lib/Transforms/Coroutines/CoroInternal.h
@@ -99,6 +99,7 @@
   CoroBeginInst *CoroBegin;
   SmallVector CoroEnds;
   SmallVector CoroSizes;
+  SmallVector CoroAligns;
   SmallVector CoroSuspends;
   SmallVector SwiftErrorOps;
 
Index: llvm/lib/Transforms/Coroutines/CoroInstr.h
===
--- llvm/lib/Transforms/Coroutines/CoroInstr.h
+++ llvm/lib/Transforms/Coroutines/CoroInstr.h
@@ -599,6 +599,18 @@
   }
 };
 
+/// This represents the llvm.coro.align instruction.
+class LLVM_LIBRARY_VISIBILITY CoroAlignInst : public IntrinsicInst {
+public:
+  // Methods to support type inquiry through isa, cast, and dyn_cast:
+  static bool classof(const IntrinsicInst *I) {
+return I->getIntrinsicID() == Intrinsic::coro_align;
+  }
+  static bool classof(const Value *V) {
+return isa(V) && classof(cast(V));
+  }
+};
+
 class LLVM_LIBRARY_VISIBILITY AnyCoroEndInst : public IntrinsicInst {
   enum { FrameArg, UnwindArg };
 
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -1237,6 +1237,7 @@
 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], 

[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-03-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: rjmccall, lxfind, GorNishanov.
Herald added a subscriber: hiraditya.
ychen requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

by over-allocating and emitting `alignTo` code to adjust the frame start 
address.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97915

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-builtins.c
  clang/test/CodeGenCoroutines/coro-gro.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1004,14 +1004,10 @@
   if (!Shape.CoroSizes.empty()) {
 // In the same function all coro.sizes should have the same result type.
 auto *SizeIntrin = Shape.CoroSizes.back();
-auto *SizeConstant =
-ConstantInt::get(SizeIntrin->getType(), Shape.FrameSize);
-assert(
-Shape.FrameSize ==
-alignTo(SizeIntrin->getModule()->getDataLayout().getTypeStoreSize(
-Shape.FrameTy),
-Align(Shape.FrameAlign)) &&
-"FrameSize should already be aligned up to FrameAlign");
+Module *M = SizeIntrin->getModule();
+const DataLayout  = M->getDataLayout();
+auto Size = DL.getTypeAllocSize(Shape.FrameTy);
+auto *SizeConstant = ConstantInt::get(SizeIntrin->getType(), Size);
 
 for (CoroSizeInst *CS : Shape.CoroSizes) {
   CS->replaceAllUsesWith(SizeConstant);
Index: clang/test/CodeGenCoroutines/coro-gro.cpp
===
--- clang/test/CodeGenCoroutines/coro-gro.cpp
+++ clang/test/CodeGenCoroutines/coro-gro.cpp
@@ -49,7 +49,8 @@
   // CHECK: %[[GroActive:.+]] = alloca i1
 
   // CHECK: %[[Size:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: call noalias nonnull i8* @_Znwm(i64 %[[Size]])
+  // CHECK: %[[NewSize:.+]] = add i64 %[[Size]], %{{.+}}
+  // CHECK: call noalias nonnull i8* @_Znwm(i64 %[[NewSize]])
   // CHECK: store i1 false, i1* %[[GroActive]]
   // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJiEE12promise_typeC1Ev(
   // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJiEE12promise_type17get_return_objectEv(
Index: clang/test/CodeGenCoroutines/coro-builtins.c
===
--- clang/test/CodeGenCoroutines/coro-builtins.c
+++ clang/test/CodeGenCoroutines/coro-builtins.c
@@ -21,7 +21,12 @@
   __builtin_coro_noop();
 
   // CHECK-NEXT: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK-NEXT: %[[MEM:.+]] = call i8* @myAlloc(i64 %[[SIZE]])
+  // CHECK-NEXT: %[[ALIGN:.+]] = call i64 @llvm.coro.align.i64()
+  // CHECK-NEXT: %[[DIFF:.+]] = sub nsw i64 %[[ALIGN]], 16
+  // CHECK-NEXT: %[[CMP:.+]] = icmp sgt i64 %[[DIFF]], 0
+  // CHECK-NEXT: %[[SEL:.+]] = select i1 %[[CMP]], i64 %[[DIFF]], i64 0
+  // CHECK-NEXT: %[[NEWSIZE:.+]] = add i64 %[[SIZE]], %[[SEL]]
+  // CHECK-NEXT: %[[MEM:.+]] = call i8* @myAlloc(i64 %[[NEWSIZE]])
   // CHECK-NEXT: %[[FRAME:.+]] = call i8* @llvm.coro.begin(token %[[COROID]], i8* %[[MEM]])
   __builtin_coro_begin(myAlloc(__builtin_coro_size()));
 
Index: clang/test/CodeGenCoroutines/coro-alloc.cpp
===
--- clang/test/CodeGenCoroutines/coro-alloc.cpp
+++ clang/test/CodeGenCoroutines/coro-alloc.cpp
@@ -60,9 +60,14 @@
   // CHECK: br i1 %[[NeedAlloc]], label %[[AllocBB:.+]], label %[[InitBB:.+]]
 
   // CHECK: [[AllocBB]]:
-  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: %[[MEM:.+]] = call noalias nonnull i8* @_Znwm(i64 %[[SIZE]])
-  // CHECK: br label %[[AlignAllocBB:.+]]
+  // CHECK-NEXT: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK-NEXT: %[[ALIGN:.+]] = call i64 @llvm.coro.align.i64()
+  // CHECK-NEXT: %[[DIFF:.+]] = sub nsw i64 %[[ALIGN]], 16
+  // CHECK-NEXT: %[[CMP:.+]] = icmp sgt i64 %[[DIFF]], 0
+  // CHECK-NEXT: %[[SEL:.+]] = select i1 %[[CMP]], i64 %[[DIFF]], i64 0
+  // CHECK-NEXT: %[[NEWSIZE:.+]] = add i64 %[[SIZE]], %[[SEL]]
+  // CHECK-NEXT: %[[MEM:.+]] = call noalias nonnull i8* @_Znwm(i64 %[[NEWSIZE]])
+  // CHECK-NEXT: br label %[[AlignAllocBB:.+]]
 
   // CHECK: [[AlignAllocBB]]:
   // CHECK: %[[ALIGN:.+]] = call i64 @llvm.coro.align.i64()
@@ -104,7 +109,8 @@
 extern "C" void f1(promise_new_tag ) {
   // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
   // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
-  // CHECK: call i8* @_ZNSt12experimental16coroutine_traitsIJv15promise_new_tagEE12promise_typenwEm(i64 %[[SIZE]])
+  // CHECK: %[[NEWSIZE:.+]] = add i64 %[[SIZE]], %{{.+}}
+  // CHECK: call i8* 

[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2021-03-03 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous added a comment.

Ping @rsmith @dblaikie @MaskRay @Xiangling_L @lebedev.ri


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90448

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


[PATCH] D97912: [doc] Document that __fp16 will apply default argument promotion rule.

2021-03-03 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng created this revision.
kito-cheng requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

ACLE didn't specify the default argument promotion rule on __fp16, but
the current implementation both on GCC and clang are applied default
argument promotion rule on __fp16, so I think it should document that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97912

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -569,12 +569,13 @@
 ``3.14f16``.
 
 Because default argument promotion only applies to the standard floating-point
-types, ``_Float16`` values are not promoted to ``double`` when passed as 
variadic
-or untyped arguments.  As a consequence, some caution must be taken when using
-certain library facilities with ``_Float16``; for example, there is no 
``printf`` format
-specifier for ``_Float16``, and (unlike ``float``) it will not be implicitly 
promoted to
-``double`` when passed to ``printf``, so the programmer must explicitly cast 
it to
-``double`` before using it with an ``%f`` or similar specifier.
+types and ``__fp16``, ``_Float16`` values are not promoted to ``double`` when
+passed as variadic or untyped arguments.  As a consequence, some caution must
+be taken when using certain library facilities with ``_Float16``; for example,
+there is no ``printf`` format specifier for ``_Float16``, and (unlike 
``float``)
+it will not be implicitly promoted to ``double`` when passed to ``printf``, so
+the programmer must explicitly cast it to ``double`` before using it with an
+``%f`` or similar specifier.
 
 Messages on ``deprecated`` and ``unavailable`` Attributes
 =


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -569,12 +569,13 @@
 ``3.14f16``.
 
 Because default argument promotion only applies to the standard floating-point
-types, ``_Float16`` values are not promoted to ``double`` when passed as variadic
-or untyped arguments.  As a consequence, some caution must be taken when using
-certain library facilities with ``_Float16``; for example, there is no ``printf`` format
-specifier for ``_Float16``, and (unlike ``float``) it will not be implicitly promoted to
-``double`` when passed to ``printf``, so the programmer must explicitly cast it to
-``double`` before using it with an ``%f`` or similar specifier.
+types and ``__fp16``, ``_Float16`` values are not promoted to ``double`` when
+passed as variadic or untyped arguments.  As a consequence, some caution must
+be taken when using certain library facilities with ``_Float16``; for example,
+there is no ``printf`` format specifier for ``_Float16``, and (unlike ``float``)
+it will not be implicitly promoted to ``double`` when passed to ``printf``, so
+the programmer must explicitly cast it to ``double`` before using it with an
+``%f`` or similar specifier.
 
 Messages on ``deprecated`` and ``unavailable`` Attributes
 =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-03-03 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:2245
+  case tok::kw___ibm128:
+DS.SetTypeSpecType(DeclSpec::TST_ibm128, Loc, PrevSpec, DiagID, Policy);
+break;

hubert.reinterpretcast wrote:
> qiucf wrote:
> > hubert.reinterpretcast wrote:
> > > Not sure what the best method is to implement this, but `long double` and 
> > > `__ibm128` are the same type for GCC when `-mabi=ibmlongdouble` is in 
> > > effect.
> > Seems clang is also different from GCC under `-mabi=ieeelongdouble`? I saw 
> > `__float128` and `long double` are the same for GCC but not for clang.
> Have you checked whether the new libstdc++ for which this support is being 
> added needs the GCC behaviour to work properly?
> 
> The GCC behaviour allows the following to be compiled without introducing 
> novel overload resolution tiebreakers:
> ```
> void f(__float128);
> void f(__ibm128);
> void f(int);
> 
> long double ld;
> 
> int main() { f(ld); }
> ```
As I saw both GCC and clang have error for ambiguous `operator<<` for:

```
std::cout << "long double:\n";
std::cout << std::numeric_limits::max() << std::endl;
std::cout << std::numeric_limits::min() << std::endl;

std::cout << "__float128:\n";
std::cout << std::numeric_limits<__float128>::max() << std::endl;
std::cout << std::numeric_limits<__float128>::min() << std::endl;

std::cout << "__ibm128:\n";
std::cout << std::numeric_limits<__ibm128>::max() << std::endl;
std::cout << std::numeric_limits<__ibm128>::min() << std::endl;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

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


[PATCH] D97759: [doc] Fix description of _Float16

2021-03-03 Thread 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 rGb46a1b129f68: [doc] Fix description of _Float16 (authored by 
Kito Cheng kito.ch...@sifive.com).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D97759?vs=327387=328023#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97759

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -542,7 +542,7 @@
 Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``, not the 
ARM
 alternative format.
 
-``_Float16`` is an extended floating-point type.  This means that, just like 
arithmetic on
+``_Float16`` is an interchange floating-point type.  This means that, just 
like arithmetic on
 ``float`` or ``double``, arithmetic on ``_Float16`` operands is formally 
performed in the
 ``_Float16`` type, so that e.g. the result of adding two ``_Float16`` values 
has type
 ``_Float16``.  The behavior of ``_Float16`` is specified by ISO/IEC TS 
18661-3:2015


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -542,7 +542,7 @@
 Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``, not the ARM
 alternative format.
 
-``_Float16`` is an extended floating-point type.  This means that, just like arithmetic on
+``_Float16`` is an interchange floating-point type.  This means that, just like arithmetic on
 ``float`` or ``double``, arithmetic on ``_Float16`` operands is formally performed in the
 ``_Float16`` type, so that e.g. the result of adding two ``_Float16`` values has type
 ``_Float16``.  The behavior of ``_Float16`` is specified by ISO/IEC TS 18661-3:2015
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b46a1b1 - [doc] Fix description of _Float16

2021-03-03 Thread Kito Cheng via cfe-commits

Author: Kito Cheng
Date: 2021-03-04T14:17:54+08:00
New Revision: b46a1b129f684a230dd680341d198d8b11731812

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

LOG: [doc] Fix description of _Float16

According to ISO/IEC TS 18661-3:2015 _FloatN is interchange floating
point type, extended floating-point type is _FloatNx.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2342.pdf

Reviewed By: SjoerdMeijer

Differential revision: https://reviews.llvm.org/D97759

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 4b82b8a6dbbc..4e25abca656a 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -542,7 +542,7 @@ The behavior of ``__fp16`` is specified by the ARM C 
Language Extensions (`ACLE
 Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``, not the 
ARM
 alternative format.
 
-``_Float16`` is an extended floating-point type.  This means that, just like 
arithmetic on
+``_Float16`` is an interchange floating-point type.  This means that, just 
like arithmetic on
 ``float`` or ``double``, arithmetic on ``_Float16`` operands is formally 
performed in the
 ``_Float16`` type, so that e.g. the result of adding two ``_Float16`` values 
has type
 ``_Float16``.  The behavior of ``_Float16`` is specified by ISO/IEC TS 
18661-3:2015



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


[PATCH] D97555: [clangd] Add diagnostic augmentation hook to Modules

2021-03-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Module.h:97
 
+  /// Called by auxilary threads as diagnostics encountered to generate fixes.
+  /// So this can be called concurrently from multiple threads. If a module

This seems too specialized to me - maybe we want to observe diagnostics only, 
or mutate some other property of them.

Consider just passing in the (mutable) clangd::Diag, and returning void? Maybe 
call it `handleDiagnostic` or so

Maybe also the clang::Diagnostic if you really need it.



Comment at: clang-tools-extra/clangd/Module.h:98
+  /// Called by auxilary threads as diagnostics encountered to generate fixes.
+  /// So this can be called concurrently from multiple threads. If a module
+  /// provides a code action with a custom, it should also register itself as

random thoughts about how this gets called... (definitely not for now though!)

There are other things we might want to do while building ASTs.
e.g. *generate* diagnostics (maybe IWYU or clang-tidy can be modules)
At that point maybe we want something like
```
virtual unique_ptr Module::parseAST() { return nullptr; } // 
threadsafe
class ParseASTHooks { // implementations need not be threadsafe
  virtual void sawDiagnostic(clangd::Diag );
  virtual void finish(ParsedAST&);
};
```
That way it's easier to reason about call sequences. (and it eliminates the 
problem of calling an empty virtual method on each module for each diagnostic)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97555

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


[PATCH] D96245: [clangd] Propagate CodeActions in addition to Fixes for diagnostics

2021-03-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Will the fixes/actions this enables really be available synchronously?

AFAIK the only reasons we attach fixes to diagnostics are:

- because clang fixes are generated at parse time and need to be stored 
somewhere
- for the benefit of embedders that need the fix content synchronously with the 
diagnostic
- to trigger the "fix available" text

The first two points don't apply if the fix content is too slow to compute 
synchronously. (And the third can be more simply solved with a boolean flag 
instead)

The alternative is just to discover these fixes through the code action flow 
(and allow modules to contribute code actions, which we should do anyway)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96245

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


[PATCH] D97535: [clangd] Use URIs instead of paths in the index file list

2021-03-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks (both for the patch and bearing with me :D), LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97535

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


[PATCH] D97548: [clangd] Introduce client state invalidation

2021-03-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/ClangdServer.h:78
+
+/// Called when server triggers a state change without client requesting 
it.
+/// For example a preamble build, which might happen on its own,

I think "state change", "client information" and "requesting it" might be a bit 
too vague.
Some ideas to take or leave...

"onSemanticsMaybeChanged"

Called when the meaning of a source code may have changed without an edit.
Usually clients assume that responses to requests are valid until they next
edit the file. If they're invalidated at other times, we should tell the client.
In particular, when an asynchronous preamble build finishes, we can provide
more accurate semantic tokens, so we should tell the client to refresh.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97548

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


[libclc] 21427b8 - libclc: Add clspv target to libclc

2021-03-03 Thread Jan Vesely via cfe-commits

Author: Alan Baker
Date: 2021-03-04T00:19:10-05:00
New Revision: 21427b8eb8e773789bdb4cd8911bee6631910a37

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

LOG: libclc: Add clspv target to libclc

Add clspv as a new target for libclc. clspv is an open-source compiler that 
compiles OpenCL C to Vulkan SPIR-V. Compiles for the spir target.

The clspv target differs from the the spirv target in the following ways:
* fma is modified to use uint2 instead of ulong for mantissas. This results in 
lower performance fma, but provides a implementation that can be used on more 
Vulkan devices where 64-bit integer support is less common.
* Use of a software implementation of nextafter because the generic 
implementation depends on nextafter being a defined builtin function for which 
clspv has no definition.
* Full optimization of the library (-O3) and no conversion to SPIR-V

This library is close to what would be produced by running opt -O3 < 
builtins.opt.spirv-mesa3d-.bc > builtins.opt.clspv--.bc and continuing the 
build from that point.

Reviewer: jvesely

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

Added: 
libclc/clspv/lib/SOURCES
libclc/clspv/lib/math/fma.cl
libclc/clspv/lib/math/nextafter.cl
libclc/clspv/lib/math/nextafter.inc
libclc/clspv/lib/subnormal_config.cl

Modified: 
libclc/CMakeLists.txt

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index b8b5ceff086c..7f8d81e9036a 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -7,6 +7,7 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
   amdgcn/lib/SOURCES;
   amdgcn-mesa3d/lib/SOURCES;
   amdgpu/lib/SOURCES;
+  clspv/lib/SOURCES;
   generic/lib/SOURCES;
   ptx/lib/SOURCES;
   ptx-nvidiacl/lib/SOURCES;
@@ -19,6 +20,7 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
 set( LIBCLC_TARGETS_ALL
   amdgcn--
   amdgcn--amdhsa
+  clspv--
   r600--
   nvptx--
   nvptx64--
@@ -145,6 +147,7 @@ set( r600--_devices cedar cypress barts cayman )
 set( amdgcn--_devices tahiti )
 set( amdgcn-mesa-mesa3d_devices ${amdgcn--_devices} )
 set( amdgcn--amdhsa_devices none )
+set( clspv--_devices none )
 set( nvptx--_devices none )
 set( nvptx64--_devices none )
 set( nvptx--nvidiacl_devices none )
@@ -203,7 +206,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
set( dirs )
 
-   if ( NOT ${ARCH} STREQUAL spirv AND NOT ${ARCH} STREQUAL spirv64 )
+   if ( NOT ${ARCH} STREQUAL spirv AND NOT ${ARCH} STREQUAL spirv64 AND 
NOT ${ARCH} STREQUAL clspv )
LIST( APPEND dirs generic )
endif()
 
@@ -234,7 +237,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
# Add the generated convert.cl here to prevent adding
# the one listed in SOURCES
-   if( NOT ${ARCH} STREQUAL "spirv" AND NOT ${ARCH} STREQUAL "spirv64" )
+   if( NOT ${ARCH} STREQUAL "spirv" AND NOT ${ARCH} STREQUAL "spirv64" AND 
NOT ${ARCH} STREQUAL "clspv" )
set( rel_files convert.cl )
set( objects convert.cl )
if( NOT ENABLE_RUNTIME_SUBNORMAL )
@@ -284,6 +287,10 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
set( build_flags -O0 -finline-hint-functions )
set( opt_flags )
set( spvflags --spirv-max-version=1.1 )
+   elseif( ${ARCH} STREQUAL "clspv" )
+   set( t "spir--" )
+   set( build_flags )
+   set( opt_flags -O3 )
else()
set( build_flags )
set( opt_flags -O3 )

diff  --git a/libclc/clspv/lib/SOURCES b/libclc/clspv/lib/SOURCES
new file mode 100644
index ..0466345cee02
--- /dev/null
+++ b/libclc/clspv/lib/SOURCES
@@ -0,0 +1,48 @@
+subnormal_config.cl
+../../generic/lib/geometric/distance.cl
+../../generic/lib/geometric/length.cl
+math/fma.cl
+math/nextafter.cl
+../../generic/lib/math/acosh.cl
+../../generic/lib/math/asinh.cl
+../../generic/lib/math/atan.cl
+../../generic/lib/math/atan2.cl
+../../generic/lib/math/atan2pi.cl
+../../generic/lib/math/atanh.cl
+../../generic/lib/math/atanpi.cl
+../../generic/lib/math/cbrt.cl
+../../generic/lib/math/clc_fmod.cl
+../../generic/lib/math/clc_hypot.cl
+../../generic/lib/math/clc_ldexp.cl
+../../generic/lib/math/clc_nextafter.cl
+../../generic/lib/math/clc_remainder.cl
+../../generic/lib/math/clc_remquo.cl
+../../generic/lib/math/clc_rootn.cl
+../../generic/lib/math/clc_sqrt.cl
+../../generic/lib/math/clc_tan.cl
+../../generic/lib/math/erf.cl
+../../generic/lib/math/erfc.cl
+../../generic/lib/math/fmod.cl
+../../generic/lib/math/fract.cl
+../../generic/lib/math/frexp.cl
+../../generic/lib/math/half_divide.cl
+../../generic/lib/math/half_recip.cl

[PATCH] D97548: [clangd] Introduce client state invalidation

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

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97548

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


[PATCH] D97555: [clangd] Add diagnostic augmentation hook to Modules

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

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97555

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


[PATCH] D96245: [clangd] Propagate CodeActions in addition to Fixes for diagnostics

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

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96245

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


[PATCH] D96709: Add Windows ehcont section support (/guard:ehcont).

2021-03-03 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7e67c930ae5: Add Windows ehcont section support 
(/guard:ehcont). (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96709

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/CodeGen/cfguardtable.c
  clang/test/Driver/cl-options.c
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -51,6 +51,9 @@
 
Makes programs 10x faster by doing Special New Thing.
 
+* Windows Control-flow Enforcement Technology: the ``-ehcontguard`` option now
+  emits valid unwind entrypoints which are validated when the context is being
+  set during exception handling.
 
 Changes to the LLVM IR
 --
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -614,6 +614,13 @@
 // RUN: %clang_cl /guard:nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDNOCHECKSINVALID %s
 // CFGUARDNOCHECKSINVALID: invalid value 'nochecks' in '/guard:'
 
+// RUN: %clang_cl  -### -- %s 2>&1 | FileCheck -check-prefix=NOEHCONTGUARD %s
+// RUN: %clang_cl /guard:ehcont- -### -- %s 2>&1 | FileCheck -check-prefix=NOEHCONTGUARD %s
+// NOEHCONTGUARD-NOT: -ehcontguard
+
+// RUN: %clang_cl /guard:ehcont -### -- %s 2>&1 | FileCheck -check-prefix=EHCONTGUARD %s
+// EHCONTGUARD: -ehcontguard
+
 // RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
 // CFGUARDINVALID: invalid value 'foo' in '/guard:'
 
Index: clang/test/CodeGen/cfguardtable.c
===
--- clang/test/CodeGen/cfguardtable.c
+++ clang/test/CodeGen/cfguardtable.c
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -cfguard-no-checks -emit-llvm %s -o - | FileCheck %s -check-prefix=CFGUARDNOCHECKS
-// RUN: %clang_cc1 -cfguard -emit-llvm %s -o - | FileCheck %s -check-prefix=CFGUARD
-
-void f() {}
-
-// Check that the cfguard metadata flag gets correctly set on the module.
-// CFGUARDNOCHECKS: !"cfguard", i32 1}
-// CFGUARD: !"cfguard", i32 2}
+// RUN: %clang_cc1 -cfguard-no-checks -emit-llvm %s -o - | FileCheck %s -check-prefix=CFGUARDNOCHECKS
+// RUN: %clang_cc1 -cfguard -emit-llvm %s -o - | FileCheck %s -check-prefix=CFGUARD
+// RUN: %clang_cc1 -ehcontguard -emit-llvm %s -o - | FileCheck %s -check-prefix=EHCONTGUARD
+
+void f() {}
+
+// Check that the cfguard metadata flag gets correctly set on the module.
+// CFGUARDNOCHECKS: !"cfguard", i32 1}
+// CFGUARD: !"cfguard", i32 2}
+// EHCONTGUARD: !"ehcontguard", i32 1}
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -509,6 +509,10 @@
   CmdArgs.push_back("-guard:cf");
 } else if (GuardArgs.equals_lower("cf-")) {
   CmdArgs.push_back("-guard:cf-");
+} else if (GuardArgs.equals_lower("ehcont")) {
+  CmdArgs.push_back("-guard:ehcont");
+} else if (GuardArgs.equals_lower("ehcont-")) {
+  CmdArgs.push_back("-guard:ehcont-");
 }
   }
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7076,14 +7076,19 @@
 
   if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
-// The only valid options are "cf", "cf,nochecks", and "cf-".
+// The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
+// "ehcont-".
 if (GuardArgs.equals_lower("cf")) {
   // Emit CFG instrumentation and the table of address-taken functions.
   CmdArgs.push_back("-cfguard");
 } else if (GuardArgs.equals_lower("cf,nochecks")) {
   // Emit only the table of address-taken functions.
   CmdArgs.push_back("-cfguard-no-checks");
-} else if (GuardArgs.equals_lower("cf-")) {
+} else if (GuardArgs.equals_lower("ehcont")) {
+  // Emit EH continuation table.
+  CmdArgs.push_back("-ehcontguard");
+} else if (GuardArgs.equals_lower("cf-") ||
+   GuardArgs.equals_lower("ehcont-")) {
   // Do nothing, but we might want to emit a security warning in future.
 } else {
   D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << GuardArgs;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ 

[clang] e7e67c9 - Add Windows ehcont section support (/guard:ehcont).

2021-03-03 Thread via cfe-commits

Author: Wang, Pengfei
Date: 2021-03-04T11:47:29+08:00
New Revision: e7e67c930ae59151affcd57bd49d650e4dac3468

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

LOG: Add Windows ehcont section support (/guard:ehcont).

Add option /guard:ehcont

Reviewed By: rnk

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

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/CodeGen/cfguardtable.c
clang/test/Driver/cl-options.c
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index b762bf9a542b..c668645aaeca 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3523,7 +3523,8 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   /Gs Use stack probes (default)
   /Gs  Set stack probe size (default 4096)
   /guard:  Enable Control Flow Guard with /guard:cf,
-  or only the table with /guard:cf,nochecks
+  or only the table with /guard:cf,nochecks.
+  Enable EH Continuation Guard with /guard:ehcont
   /Gv Set __vectorcall as a default calling convention
   /Gw-Don't put each data item in its own section
   /Gw Put each data item in its own section

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 832f7fad3551..50503dbe4f84 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -42,6 +42,7 @@ CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
 CODEGENOPT(IgnoreXCOFFVisibility , 1, 0) ///< -mignore-xcoff-visibility
 CODEGENOPT(ControlFlowGuardNoChecks  , 1, 0) ///< -cfguard-no-checks
 CODEGENOPT(ControlFlowGuard  , 1, 0) ///< -cfguard
+CODEGENOPT(EHContGuard   , 1, 0) ///< -ehcontguard
 CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling 
destructors.
 CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or 
__cxa_atexit to register global destructors.
 CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 72213ed51ce2..2f57895d4c23 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4859,6 +4859,9 @@ def cfguard_no_checks : Flag<["-"], "cfguard-no-checks">,
 def cfguard : Flag<["-"], "cfguard">,
 HelpText<"Emit Windows Control Flow Guard tables and checks">,
 MarshallingInfoFlag>;
+def ehcontguard : Flag<["-"], "ehcontguard">,
+HelpText<"Emit Windows EH Continuation Guard tables">,
+MarshallingInfoFlag>;
 
 def fdenormal_fp_math_f32_EQ : Joined<["-"], "fdenormal-fp-math-f32=">,
Group;
@@ -5857,7 +5860,8 @@ def _SLASH_Fo : CLCompileJoined<"Fo">,
   HelpText<"Set output object file (with /c)">,
   MetaVarName<"">;
 def _SLASH_guard : CLJoined<"guard:">,
-  HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with 
/guard:cf,nochecks">;
+  HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with 
/guard:cf,nochecks. "
+   "Enable EH Continuation Guard with /guard:ehcont">;
 def _SLASH_GX : CLFlag<"GX">,
   HelpText<"Deprecated; use /EHsc">;
 def _SLASH_GX_ : CLFlag<"GX-">,

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 802a13fb41fc..b23d995683bf 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -552,6 +552,10 @@ void CodeGenModule::Release() {
 // Function ID tables for Control Flow Guard (cfguard=1).
 getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1);
   }
+  if (CodeGenOpts.EHContGuard) {
+// Function ID tables for EH Continuation Guard.
+getModule().addModuleFlag(llvm::Module::Warning, "ehcontguard", 1);
+  }
   if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
 // We don't support LTO with 2 with 
diff erent StrictVTablePointers
 // FIXME: we could support it by stripping all the information introduced

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index df2b20702efc..eb09d722d304 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7076,14 +7076,19 @@ void Clang::AddClangCLArgs(const ArgList , 
types::ID InputType,
 
   

[PATCH] D97878: [DirectoryWatcher] Increase timeout to make test less flaky

2021-03-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

@jkorous thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97878

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


[PATCH] D97878: [DirectoryWatcher] Increase timeout to make test less flaky

2021-03-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi accepted this revision.
plotfi added a comment.
This revision is now accepted and ready to land.

This makes sense to me. I approve. Can we move the 3/60 seconds number to a 
const int value set somewhere higher up in the file as a global with a comment 
explaining this as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97878

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


[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths

2021-03-03 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

Although the bug can be avoided via "-I /usr/lib/avr/include" in clang's 
command line option, I expect clang to have the save behaviour as avr-gcc.

And for avr-gcc, `avr-gcc a.c -mmcu=xxx` will automatically include avr-libc's 
header files and link avr-libc's lib.a .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97669

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


[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

So, like, I think it's a start. You introduced a single source of truth for 
casting `SVal`s and it's good. But i'm worried about our API surface.




Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:539
 
-SVal SValBuilder::evalCast(SVal V, QualType CastTy, QualType OriginalTy) {
-  CastTy = Context.getCanonicalType(CastTy);
-  OriginalTy = Context.getCanonicalType(OriginalTy);
-  if (CastTy == OriginalTy)
+// In case when `OriginalTy.isNull() == true` we cast `V` less accurately.
+SVal SValBuilder::evalCast(SVal V, QualType CastTy,

NoQ wrote:
> This is one of the most important APIs of `SValBuilder`, alongside 
> `evalBinOp()`. The newly added behavior is definitely obscure and needs 
> explaining. So i think you should move this comment into the header, turn it 
> into a doxygen comment, and elaborate what "less accurately" actually means 
> here.
Like, are you sure that the new behavior makes sense at all for call sites that 
aren't ex-`CastRetrievedVal`? When, and why, would a regular user use this 
functionality?

Maybe instead of obfuscating this functionality as a null pointer we should add 
an explicit flag and give it an understandable name? Even if it's `bool 
CastRetrievedValBackdoorHackDoNotUse = false` it's still much better than "umm 
we kind of expect it to work if you pass null here but we don't really know 
how".



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:564
   switch (V.getBaseKind()) {
+  default:
+llvm_unreachable("Unknown SVal kind");

No, don't add `default:`. All possible cases are currently handled. It breaks 
compiler warning about not all cases handled in the switch when new enum cases 
are added. Compile-time warnings are better than run-time warnings.


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

https://reviews.llvm.org/D96090

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


[PATCH] D97902: [Driver] Clarify --gcc-toolchain

2021-03-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a subscriber: aaron.ballman.
MaskRay added a comment.

This is motivated by Linux kernel folks' confusion on `--gcc-toolchain` 
https://lore.kernel.org/linux-kbuild/20210303230708.l6pbk5o5nc2qa...@google.com/
(it confused me, even if I had stared at this piece code a few times before!)

The command line option documentation is currently a bit messy, and lacks much 
information.
We probably need something similar to `include/clang/Basic/AttrDocs.td` by 
@aaron.ballman

I choose to add it inline before the infrastructure is available.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97902

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


[PATCH] D97902: [Driver] Clarify --gcc-toolchain

2021-03-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: nathanchance, nickdesaulniers.
Herald added subscribers: jansvoboda11, dang.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

And add tests: when both --prefix(-B) and --gcc-toolchain are specified, the GCC
installation with the largest version wins. This just documents the
current behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97902

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/test/Driver/gcc-toolchain.cpp


Index: clang/test/Driver/gcc-toolchain.cpp
===
--- clang/test/Driver/gcc-toolchain.cpp
+++ clang/test/Driver/gcc-toolchain.cpp
@@ -29,3 +29,23 @@
 // CHECK: 
"{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5{{/|}}crtbegin.o"
 // CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
 // CHECK: 
"-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
+//
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: --target=x86_64-linux-gnu -stdlib=libstdc++ \
+// RUN: --gcc-toolchain=%S/Inputs/ubuntu_13.04_multiarch_tree/usr \
+// RUN: --sysroot= | FileCheck %s --check-prefix=UBUNTU13
+
+/// If both --prefix and --gcc-toolchain are specified, the GCC installation 
with a larger version wins.
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
+// RUN: --prefix=%S/Inputs/ubuntu_13.04_multiarch_tree/usr \
+// RUN: --gcc-toolchain=%S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: --sysroot= | FileCheck %s --check-prefix=UBUNTU13
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
+// RUN: --prefix=%S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: --gcc-toolchain=%S/Inputs/ubuntu_13.04_multiarch_tree/usr \
+// RUN: --sysroot= | FileCheck %s --check-prefix=UBUNTU13
+
+// UBUNTU13: 
{{.*}}/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -599,8 +599,12 @@
 def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
 Flags<[NoXarchOption, CoreOption]>;
 def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>, 
Group;
-def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"">,
-HelpText<"Add  to search path for binaries and object files used 
implicitly">;
+def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"">,
+HelpText<"Search $prefix/$triple-$file and $prefix$file for executables, 
libraries, includes and data files used by the compiler. "
+"If $prefix is a directory, the directory is used to search for GCC 
installation on targets which commonly use GCC. "
+"The directory usually contains 'include' and 'lib'. "
+"If $prefix is not a directory, the GCC installation detection is skipped 
but $prefix can still be used to "
+"find executables, typically for -nostdinc -nostdlib compiles">;
 def CC : Flag<["-"], "CC">, Flags<[CC1Option]>, Group,
 HelpText<"Include comments from within macros in preprocessed output">,
 MarshallingInfoFlag>;
@@ -3667,7 +3671,9 @@
 def mcpu_EQ_QUESTION : Flag<["-"], "mcpu=?">, Alias;
 def mtune_EQ_QUESTION : Flag<["-"], "mtune=?">, Alias;
 def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
-  HelpText<"Use the gcc toolchain at the given directory">;
+  HelpText<"Search for GCC installation in the specified directory, similar to 
-B."
+  "The directory usually contains 'lib' and 'include'."
+  "If specified, sysroot is not skipped for GCC detection">;
 def time : Flag<["-"], "time">,
   HelpText<"Time individual commands">;
 def traditional_cpp : Flag<["-", "--"], "traditional-cpp">, Flags<[CC1Option]>,
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -18,9 +18,9 @@
 
 
 .. program:: clang
-.. option:: -B, --prefix , --prefix=
+.. option:: -B, --prefix , --prefix=
 
-Add  to search path for binaries and object files used implicitly
+Search $prefix/$triple-$file and $prefix$file for executables, libraries, 
includes and data files used by the compiler. If $prefix is a directory, the 
directory is used to search for GCC installation on targets which commonly use 
GCC. The directory usually contains 'include' and 'lib'. If $prefix is not a 
directory, the GCC installation detection is skipped but $prefix can still be 
used to find executables, typically for -nostdinc -nostdlib compiles
 
 .. option:: -F
 
@@ -256,7 +256,7 @@
 
 .. option:: --gcc-toolchain=, 

[PATCH] D97901: [SystemZ] Test for infinity in testFPKind().

2021-03-03 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7229
+  case Builtin::BI__builtin_isfinite:
+Invert = true;
+LLVM_FALLTHROUGH;

What are these variants all about...?



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

https://reviews.llvm.org/D97901

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


[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:539
 
-SVal SValBuilder::evalCast(SVal V, QualType CastTy, QualType OriginalTy) {
-  CastTy = Context.getCanonicalType(CastTy);
-  OriginalTy = Context.getCanonicalType(OriginalTy);
-  if (CastTy == OriginalTy)
+// In case when `OriginalTy.isNull() == true` we cast `V` less accurately.
+SVal SValBuilder::evalCast(SVal V, QualType CastTy,

This is one of the most important APIs of `SValBuilder`, alongside 
`evalBinOp()`. The newly added behavior is definitely obscure and needs 
explaining. So i think you should move this comment into the header, turn it 
into a doxygen comment, and elaborate what "less accurately" actually means 
here.


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

https://reviews.llvm.org/D96090

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


[PATCH] D97901: [SystemZ] Test for infinity in testFPKind().

2021-03-03 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa created this revision.
jonpa added reviewers: uweigand, thopre.
jonpa requested review of this revision.

Recognize __builtin_isinf and BI__builtin_isfinite (and a few other builtin 
opcodes for finite checks) in testFPKind().

TDC can check for infinity, and for finite with an inversion of the result.

'finite', '__finite', ... seemed to always work as double with 
extension/trunction from float/long double. I would guess it is expected to 
handle those as well with TDC, or?


https://reviews.llvm.org/D97901

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/SystemZ/strictfp_builtins.c

Index: clang/test/CodeGen/SystemZ/strictfp_builtins.c
===
--- clang/test/CodeGen/SystemZ/strictfp_builtins.c
+++ clang/test/CodeGen/SystemZ/strictfp_builtins.c
@@ -41,3 +41,80 @@
   return __builtin_isnan(ld);
 }
 
+// CHECK-LABEL: @test_isinf_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 48) [[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_float(float f) {
+  return __builtin_isinf(f);
+}
+
+// CHECK-LABEL: @test_isinf_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 48) [[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_double(double d) {
+  return __builtin_isinf(d);
+}
+
+// CHECK-LABEL: @test_isinf_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 48) [[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+int test_isinf_long_double(long double ld) {
+  return __builtin_isinf(ld);
+}
+
+// CHECK-LABEL: @test_isfinite_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 48) [[ATTR2]]
+// CHECK-NEXT:[[TMP2:%.*]] = xor i32 [[TMP1]], 1
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+int test_isfinite_float(float f) {
+  return __builtin_isfinite(f);
+}
+
+// CHECK-LABEL: @test_isfinite_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 48) [[ATTR2]]
+// CHECK-NEXT:[[TMP2:%.*]] = xor i32 [[TMP1]], 1
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+int test_isfinite_double(double d) {
+  return __builtin_isfinite(d);
+}
+
+// CHECK-LABEL: @test_isfinite_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 48) [[ATTR2]]
+// CHECK-NEXT:[[TMP3:%.*]] = xor i32 [[TMP2]], 1
+// CHECK-NEXT:ret i32 [[TMP3]]
+//
+int test_isfinite_long_double(long double ld) {
+  return __builtin_isfinite(ld);
+}
+
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7214,17 +7214,32 @@
   llvm::Function *TDCFunc =
   llvm::Intrinsic::getDeclaration(, llvm::Intrinsic::s390_tdc, Ty);
   unsigned TDCBits = 0;
+  bool Invert = false;
   switch (BuiltinID) {
   case Builtin::BI__builtin_isnan:
 TDCBits = 0xf;
 break;
+  case Builtin::BIfinite:
+  case Builtin::BI__finite:
+  case Builtin::BIfinitef:
+  case Builtin::BI__finitef:
+  case Builtin::BIfinitel:
+  case Builtin::BI__finitel:
+  case Builtin::BI__builtin_isfinite:
+Invert = true;
+LLVM_FALLTHROUGH;
+  case Builtin::BI__builtin_isinf:
+TDCBits = 0x30;
+break;
   default:
 break;
   }
-  if (TDCBits)
-

[PATCH] D95799: [analyzer] Symbolicate float values with integral casting

2021-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> tiny patch

IIUC this is roughly the first time ever when `SValBuilder` starts emitting 
symbols of float type. This is a huge change with an almost unlimited scope of 
unexpected side effects and very rigorous testing is required to understand the 
actual effect of this patch on programs that use floats. I think that generally 
some symbols are always better than no symbols, even if the constraint manager 
is completely unable to handle them. But we have to make sure that the entirety 
of `SValBuilder` and the entirety of `RegionStore` (and possibly the entirety 
of `ExprEngine`) are ready to deal with completely new kinds of values that 
they've never seen before.




Comment at: clang/test/Analysis/svalbuilder-float-cast.c:11
   *p += 1;
-  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
-  // FIXME: Ideally, this should be $x + 1.

You silently ignored and removed this comment. The author of the original code 
was pretty certain that your solution is incorrect and most likely added this 
comment there specifically to make sure your solution doesn't get implemented.

If you see potential problems with your patch, please don't try to sweep them 
under the rug. If you're sure your solution is correct, please explain why. If 
not, please ask about it in the summary or in the comments.

Generally, every commit should be obvious. If there are obvious questions that 
remain unanswered then the commit is not obvious and needs improvement.


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

https://reviews.llvm.org/D95799

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


[PATCH] D96586: [analyzer][CTU][NFC] Add an extra regression test

2021-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

> `-analyzer-opt-analyze-headers`

I'm actually shocked that we provide such option at all. And that it's the 
first option in the list in `scan-build --help`. And that I haven't noticed it 
until now despite that. How did you discover the crash? Are people actually 
using it?

The test is obviously nice to have.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96586

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


[PATCH] D97896: [Clang][RISCV][RFC] Add byval parameter attribute?

2021-03-03 Thread Luís Marques via Phabricator via cfe-commits
luismarques created this revision.
luismarques added reviewers: asb, mundaym.
Herald added subscribers: vkmr, frasercrmck, evandro, apazos, sameer.abuasal, 
s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar.
luismarques requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Should we add the `byval` parameter attribute to struct parameters?

Pros:

- Improves optimizations;
- Used by MSan instrumentation pass (without it a test will fail).

Cons:

- ?

An example of an optimization without `byval` and with `byval`:

  $ cat test.c
  struct S { char c[32]; };
  void foo(struct S s) {
  s.c[0] = 42;
  }
  $ clang --target=riscv64-linux -O2 -S -o- test.c

Without `byval`:

  foo:
  addia1, zero, 42
  sb  a1, 0(a0)
  ret

With `byval`:

  foo:
  ret

I'm not sure what the impact would be of also adding the attribute to vector 
parameters, so this patch doesn't do so.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97896

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.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-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

Index: clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
===
--- clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
+++ clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
@@ -240,7 +240,7 @@
 
 struct int_double_int_s { int a; double b; int c; };
 
-// CHECK: define{{.*}} void @f_int_double_int_s_arg(%struct.int_double_int_s* %a)
+// CHECK: define{{.*}} void @f_int_double_int_s_arg(%struct.int_double_int_s* byval(%struct.int_double_int_s) align 8 %a)
 void f_int_double_int_s_arg(struct int_double_int_s a) {}
 
 // CHECK: define{{.*}} void @f_ret_int_double_int_s(%struct.int_double_int_s* noalias sret(%struct.int_double_int_s) align 8 %agg.result)
Index: clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
===
--- clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
+++ clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
@@ -159,7 +159,7 @@
   int64_t a, b, c, d;
 };
 
-// CHECK-LABEL: define{{.*}} void @f_agg_large(%struct.large* %x)
+// CHECK-LABEL: define{{.*}} void @f_agg_large(%struct.large* byval(%struct.large) align 8 %x)
 void f_agg_large(struct large x) {
   x.a = x.b + x.c + x.d;
 }
@@ -186,7 +186,7 @@
 // Scalars passed on the stack should not have signext/zeroext attributes
 // (they are anyext).
 
-// CHECK-LABEL: define{{.*}} signext i32 @f_scalar_stack_1(i64 %a.coerce, [2 x i64] %b.coerce, i128 %c.coerce, %struct.large* %d, i8 zeroext %e, i8 signext %f, i8 %g, i8 %h)
+// CHECK-LABEL: define{{.*}} signext i32 @f_scalar_stack_1(i64 %a.coerce, [2 x i64] %b.coerce, i128 %c.coerce, %struct.large* byval(%struct.large) align 8 %d, i8 zeroext %e, i8 signext %f, i8 %g, i8 %h)
 int f_scalar_stack_1(struct tiny a, struct small b, struct small_aligned c,
  struct large d, uint8_t e, int8_t f, uint8_t g, int8_t h) {
   return g + h;
@@ -217,7 +217,7 @@
 
 // CHECK-LABEL: define{{.*}} void @f_va_caller()
 void f_va_caller() {
-  // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 signext 1, i32 signext 2, i64 3, double 4.00e+00, double 5.00e+00, i64 {{%.*}}, [2 x i64] {{%.*}}, i128 {{%.*}}, %struct.large* {{%.*}})
+  // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 signext 1, i32 signext 2, i64 3, double 4.00e+00, double 5.00e+00, i64 {{%.*}}, [2 x i64] {{%.*}}, i128 {{%.*}}, %struct.large* byval(%struct.large) align 8 {{%.*}})
   f_va_callee(1, 2, 3LL, 4.0f, 5.0, (struct tiny){6, 7, 8, 9},
   (struct small){10, NULL}, (struct small_aligned){11},
   (struct large){12, 13, 14, 15});
Index: clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
===
--- clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
+++ clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
@@ -109,7 +109,7 @@
   return (struct float_int32_s){1.0, 2};
 }
 
-// CHECK: define{{.*}} void @f_float_int64_s_arg(%struct.float_int64_s* %a)
+// CHECK: define{{.*}} void @f_float_int64_s_arg(%struct.float_int64_s* byval(%struct.float_int64_s) align 8 %a)
 void f_float_int64_s_arg(struct float_int64_s a) {}
 
 // CHECK: define{{.*}} void @f_ret_float_int64_s(%struct.float_int64_s* noalias sret(%struct.float_int64_s) align 8 %agg.result)
@@ -233,7 +233,7 @@
 
 struct 

[PATCH] D97699: [analyzer] Add InvalidPtrChecker

2021-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

CERT rules are typically very vague and don't map nicely into specific static 
analysis algorithms. A lot of CERT rules flag valid code as well as bugs. I 
want you to explain what *exactly* does the checker checks (say, in the form of 
a state machine, i.e. what //sequences of events in the program// does it find) 
and whether flagged code is expected to be always invalid.

> `// warnOnDeadSymbol reports 'envp' dead here`

If it reports the symbol as dead after the warning would have been emitted then 
the problem must be elsewhere. There must be other differences in the analysis 
*before* the buggy statement. Nothing that happens after the buggy statement 
should ever matter.

Also the behavior of `checkDeadSymbols` looks correct here, I don't see any 
problems from your description. The symbol is reported dead when there's a 
guarantee that it won't be encountered anymore during analysis. If the 
parameter variable and the aliasing variable aren't used anymore and the symbol 
isn't stored anywhere else then the symbol is correctly marked as dead.

Why are you even tracking `reg_$0`? It's obvious from the structure of 
the symbol that it's an environment pointer, there's no need to keep it in maps.




Comment at: clang/docs/analyzer/checkers.rst:2103-2104
+puts(envp[i]);
+// envp may no longer point to the current environment
+// this program has unanticipated behavior.
+  }

It's very important to explain whether the "unanticipated behavior" is an 
entirely psychological concept ("most people don't understand how this works 
but this can occasionally also be a valid solution if you know what you're 
doing") or a 100% clear indication of a bug ("such code can never be correct", 
eg. it instantly causes undefined behavior, or the written value can never be 
read later so there's absolutely no point in writing it, or something like 
that).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97699

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


[PATCH] D97826: [RISCV] Make use of the required features in BuiltinInfo to store that V extension builtins require 'experimental-v'.

2021-03-03 Thread Craig Topper 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 rG201ebf211f97: [RISCV] Make use of the required features in 
BuiltinInfo to store that V… (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D97826?vs=327645=327965#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97826

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Sema/SemaChecking.cpp


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3392,16 +3392,13 @@
 bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo ,
  unsigned BuiltinID,
  CallExpr *TheCall) {
-  switch (BuiltinID) {
-  default:
-break;
-#define RISCVV_BUILTIN(ID, TYPE, ATTRS) case RISCV::BI##ID:
-#include "clang/Basic/BuiltinsRISCV.def"
-if (!TI.hasFeature("experimental-v"))
-  return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
- << TheCall->getSourceRange();
-break;
-  }
+  // CodeGenFunction can also detect this, but this gives a better error
+  // message.
+  StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
+  if (Features.find("experimental-v") != StringRef::npos &&
+  !TI.hasFeature("experimental-v"))
+return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
+   << TheCall->getSourceRange();
 
   return false;
 }
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -201,6 +201,8 @@
 const Builtin::Info RISCVTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   
\
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   
\
+{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #include "clang/Basic/BuiltinsRISCV.def"
 };
 
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -11,8 +11,12 @@
 //
 
//===--===//
 
-#if defined(BUILTIN) && !defined(RISCVV_BUILTIN)
-#define RISCVV_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+#if defined(TARGET_BUILTIN) && !defined(RISCVV_BUILTIN)
+#define RISCVV_BUILTIN(ID, TYPE, ATTRS) TARGET_BUILTIN(ID, TYPE, ATTRS, 
"experimental-v")
 #endif
 
 RISCVV_BUILTIN(__builtin_rvv_vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3392,16 +3392,13 @@
 bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo ,
  unsigned BuiltinID,
  CallExpr *TheCall) {
-  switch (BuiltinID) {
-  default:
-break;
-#define RISCVV_BUILTIN(ID, TYPE, ATTRS) case RISCV::BI##ID:
-#include "clang/Basic/BuiltinsRISCV.def"
-if (!TI.hasFeature("experimental-v"))
-  return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
- << TheCall->getSourceRange();
-break;
-  }
+  // CodeGenFunction can also detect this, but this gives a better error
+  // message.
+  StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
+  if (Features.find("experimental-v") != StringRef::npos &&
+  !TI.hasFeature("experimental-v"))
+return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
+   << TheCall->getSourceRange();
 
   return false;
 }
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -201,6 +201,8 @@
 const Builtin::Info RISCVTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #include "clang/Basic/BuiltinsRISCV.def"
 };
 
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- 

[clang] 201ebf2 - [RISCV] Make use of the required features in BuiltinInfo to store that V extension builtins require 'experimental-v'.

2021-03-03 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-03-03T16:24:08-08:00
New Revision: 201ebf211f9772ef19abac82170b9b06fe2ccf2b

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

LOG: [RISCV] Make use of the required features in BuiltinInfo to store that V 
extension builtins require 'experimental-v'.

Use that to print the diagnostic in SemaChecking instead of
listing all of the builtins in a switch.

With the required features, IR generation will also be able
to error on this. Checking this here allows us to have a RISCV
focused error message.

Reviewed By: HsiangKai

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 4f4ed74a11d2..9fbfa9369507 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -11,8 +11,12 @@
 //
 
//===--===//
 
-#if defined(BUILTIN) && !defined(RISCVV_BUILTIN)
-#define RISCVV_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+#if defined(TARGET_BUILTIN) && !defined(RISCVV_BUILTIN)
+#define RISCVV_BUILTIN(ID, TYPE, ATTRS) TARGET_BUILTIN(ID, TYPE, ATTRS, 
"experimental-v")
 #endif
 
 RISCVV_BUILTIN(__builtin_rvv_vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")

diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index f3e29af93d81..aee5aba97fd3 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -201,6 +201,8 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
,
 const Builtin::Info RISCVTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   
\
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   
\
+{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #include "clang/Basic/BuiltinsRISCV.def"
 };
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 779bc23a6fcd..7e6dd354caac 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3392,16 +3392,13 @@ bool Sema::CheckAMDGCNBuiltinFunctionCall(unsigned 
BuiltinID,
 bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo ,
  unsigned BuiltinID,
  CallExpr *TheCall) {
-  switch (BuiltinID) {
-  default:
-break;
-#define RISCVV_BUILTIN(ID, TYPE, ATTRS) case RISCV::BI##ID:
-#include "clang/Basic/BuiltinsRISCV.def"
-if (!TI.hasFeature("experimental-v"))
-  return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
- << TheCall->getSourceRange();
-break;
-  }
+  // CodeGenFunction can also detect this, but this gives a better error
+  // message.
+  StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
+  if (Features.find("experimental-v") != StringRef::npos &&
+  !TI.hasFeature("experimental-v"))
+return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
+   << TheCall->getSourceRange();
 
   return false;
 }



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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Thanks. This looks just looks me untested and likely uneeded logic.

My notes about --gcc-toolchain= and --prefix (-B)

https://lore.kernel.org/linux-kbuild/20210303230708.l6pbk5o5nc2qa...@google.com/

In the presence of --gcc-toolchain= (even if it equals `$prefix/usr`), the 
magic detection should be avoided.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-03 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks @MaskRay for this clean up. I can't speak for all of Gentoo but please 
give me a couple of days to at least test this on Chrome OS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97755: [IRSymTab] Set FB_used on llvm.compiler.used symbols

2021-03-03 Thread Fangrui Song 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 rG584cb67d2df3: [IRSymTab] Set FB_used on llvm.compiler.used 
symbols (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D97755?vs=327958=327960#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97755

Files:
  clang/test/CodeGen/thinlto-inline-asm2.c
  llvm/lib/LTO/LTO.cpp
  llvm/lib/Object/IRSymtab.cpp
  llvm/test/ThinLTO/X86/asm.ll
  llvm/test/tools/gold/X86/emit-llvm.ll

Index: llvm/test/tools/gold/X86/emit-llvm.ll
===
--- llvm/test/tools/gold/X86/emit-llvm.ll
+++ llvm/test/tools/gold/X86/emit-llvm.ll
@@ -54,6 +54,7 @@
   ret void
 }
 
+;; f2 is not internalized because it is in the llvm.used list.
 ; CHECK-DAG: define hidden void @f2()
 ; OPT-DAG: define hidden void @f2()
 define hidden void @f2() {
@@ -97,6 +98,15 @@
   ret i32* @g8
 }
 
+;; f9 is not internalized because it is in the llvm.compiler.used list.
+; CHECK-DAG: define hidden void @f9()
+; OPT-DAG: define hidden void @f9()
+define hidden void @f9() {
+  ret void
+}
+
+@llvm.compiler.used = appending global [1 x i8*] [ i8* bitcast (void ()* @f9 to i8*)]
+
 ; RES: .o,f1,pl{{$}}
 ; RES: .o,f2,pl{{$}}
 ; RES: .o,f3,px{{$}}
@@ -105,6 +115,7 @@
 ; RES: .o,f6,p{{$}}
 ; RES: .o,f7,px{{$}}
 ; RES: .o,f8,px{{$}}
+; RES: .o,f9,pl{{$}}
 ; RES: .o,g1,px{{$}}
 ; RES: .o,g2,p{{$}}
 ; RES: .o,g3,p{{$}}
Index: llvm/test/ThinLTO/X86/asm.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/asm.ll
@@ -0,0 +1,34 @@
+; RUN: split-file %s %t
+; RUN: opt -module-summary %t/a.s -o %t/a.bc
+; RUN: opt -module-summary %t/b.s -o %t/b.bc
+; RUN: llvm-nm %t/a.bc | FileCheck %s --check-prefix=NM
+
+; RUN: llvm-lto2 run %t/a.bc %t/b.bc -o %t/out -save-temps -r=%t/a.bc,ref,plx -r=%t/b.bc,ff_h264_cabac_tables,pl
+; RUN: llvm-dis < %t/out.2.2.internalize.bc | FileCheck %s
+
+;--- a.s
+;; IR symtab does not track inline asm symbols, so we don't know
+;; ff_h264_cabac_tables is undefined.
+; NM-NOT: {{.}}
+; NM:  T ref
+; NM-NOT: {{.}}
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i8* @ref() {
+entry:
+  %0 = tail call i8* asm sideeffect "lea ff_h264_cabac_tables(%rip), $0", "=,~{dirflag},~{fpsr},~{flags}"()
+  ret i8* %0
+}
+
+;--- b.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+;; ff_h264_cabac_tables has __attribute__((used)) in the source code, which means
+;; its definition must be retained because there can be references the compiler
+;; cannot see (inline asm reference). Test we don't internalize it.
+; CHECK: @ff_h264_cabac_tables = dso_local constant [1 x i8] c"\09"
+@ff_h264_cabac_tables = dso_local constant [1 x i8] c"\09"
+
+@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast ([1 x i8]* @ff_h264_cabac_tables to i8*)], section "llvm.metadata"
Index: llvm/lib/Object/IRSymtab.cpp
===
--- llvm/lib/Object/IRSymtab.cpp
+++ llvm/lib/Object/IRSymtab.cpp
@@ -119,8 +119,20 @@
 return make_error("input module has no datalayout",
inconvertibleErrorCode());
 
+  // Symbols in the llvm.used list will get the FB_Used bit and will not be
+  // internalized. We do this for llvm.compiler.used as well:
+  //
+  // IR symbol table tracks module-level asm symbol references but not inline
+  // asm. A symbol only referenced by inline asm is not in the IR symbol table,
+  // so we may not know that the definition (in another translation unit) is
+  // referenced. That definition may have __attribute__((used)) (which lowers to
+  // llvm.compiler.used on ELF targets) to communicate to the compiler that it
+  // may be used by inline asm. The usage is perfectly fine, so we treat
+  // llvm.compiler.used conservatively as llvm.used to work around our own
+  // limitation.
   SmallVector UsedV;
   collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/false);
+  collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/true);
   SmallPtrSet Used(UsedV.begin(), UsedV.end());
 
   ModuleSymbolTable Msymtab;
Index: llvm/lib/LTO/LTO.cpp
===
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -563,8 +563,8 @@
 
 // Set the partition to external if we know it is re-defined by the linker
 // with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
-// regular object, is referenced from llvm.compiler_used, or was already
-// recorded as being referenced from a different partition.
+// regular object, is 

[clang] 584cb67 - [IRSymTab] Set FB_used on llvm.compiler.used symbols

2021-03-03 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-03T16:22:30-08:00
New Revision: 584cb67d2df32163efe61cfa58b3c798ee5b6b5c

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

LOG: [IRSymTab] Set FB_used on llvm.compiler.used symbols

IR symbol table does not parse inline asm. A symbol only referenced by inline
asm is not in the IR symbol table, so LTO does not know that the definition (in
another translation unit) is referenced and may internalize it, even if that
definition has `__attribute__((used))` (which lowers to `llvm.compiler.used` on
ELF targets since D97446).

```
// cabac.c
__attribute__((used)) const uint8_t ff_h264_cabac_tables[...] = {...};

// h264_cabac.c
  asm("lea ff_h264_cabac_tables(%rip), %0" : ...);
```

`__attribute__((used))` is the recommended way to tell the compiler there may
be inline asm references, so the usage is perfectly fine. This patch
conservatively sets the `FB_used` bit on `llvm.compiler.used` symbols to work
around the IR symbol table limitation. Note: before D97446, Clang never emitted
symbols in the `llvm.compiler.used` list, so this change does not punish any
Clang emitted global object.

Without the patch, `ff_h264_cabac_tables` may be assigned to a non-external
partition and get internalized. Then we will get a linker error because the
`cabac.c` definition is not exposed.

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

Added: 
clang/test/CodeGen/thinlto-inline-asm2.c
llvm/test/ThinLTO/X86/asm.ll

Modified: 
llvm/lib/LTO/LTO.cpp
llvm/lib/Object/IRSymtab.cpp
llvm/test/tools/gold/X86/emit-llvm.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-inline-asm2.c 
b/clang/test/CodeGen/thinlto-inline-asm2.c
new file mode 100644
index ..30d8bfb04c5b
--- /dev/null
+++ b/clang/test/CodeGen/thinlto-inline-asm2.c
@@ -0,0 +1,29 @@
+// REQUIRES: x86-registered-target
+
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -flto=thin -emit-llvm-bc 
%t/a.c -o %t/a.bc
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -flto=thin -emit-llvm-bc 
%t/b.c -o %t/b.bc
+// RUN: llvm-nm %t/a.bc | FileCheck %s --check-prefix=NM
+
+// RUN: llvm-lto2 run %t/a.bc %t/b.bc -o %t/out -save-temps -r=%t/a.bc,ref,plx 
-r=%t/b.bc,ff_h264_cabac_tables,pl
+// RUN: llvm-dis < %t/out.2.2.internalize.bc | FileCheck %s
+
+//--- a.c
+/// IR symtab does not track inline asm symbols, so we don't know
+/// ff_h264_cabac_tables is undefined.
+// NM-NOT: {{.}}
+// NM:  T ref
+// NM-NOT: {{.}}
+const char *ref() {
+  const char *ret;
+  asm("lea ff_h264_cabac_tables(%%rip), %0" : "=r"(ret));
+  return ret;
+}
+
+//--- b.c
+/// ff_h264_cabac_tables has __attribute__((used)) in the source code, which 
means
+/// its definition must be retained because there can be references the 
compiler
+/// cannot see (inline asm reference). Test we don't internalize it.
+// CHECK: @ff_h264_cabac_tables = dso_local constant [1 x i8] c"\09"
+__attribute__((used))
+const char ff_h264_cabac_tables[1] = "\x09";

diff  --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index ea576269ec84..8bcb1600925d 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -563,8 +563,8 @@ void LTO::addModuleToGlobalRes(ArrayRef 
Syms,
 
 // Set the partition to external if we know it is re-defined by the linker
 // with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
-// regular object, is referenced from llvm.compiler_used, or was already
-// recorded as being referenced from a 
diff erent partition.
+// regular object, is referenced from llvm.compiler.used/llvm.used, or was
+// already recorded as being referenced from a 
diff erent partition.
 if (Res.LinkerRedefined || Res.VisibleToRegularObj || Sym.isUsed() ||
 (GlobalRes.Partition != GlobalResolution::Unknown &&
  GlobalRes.Partition != Partition)) {

diff  --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp
index 16c6433a2061..4ff73f9356cb 100644
--- a/llvm/lib/Object/IRSymtab.cpp
+++ b/llvm/lib/Object/IRSymtab.cpp
@@ -119,8 +119,20 @@ Error Builder::addModule(Module *M) {
 return make_error("input module has no datalayout",
inconvertibleErrorCode());
 
+  // Symbols in the llvm.used list will get the FB_Used bit and will not be
+  // internalized. We do this for llvm.compiler.used as well:
+  //
+  // IR symbol table tracks module-level asm symbol references but not inline
+  // asm. A symbol only referenced by inline asm is not in the IR symbol table,
+  // so we may not know that the definition (in another translation unit) is
+  // referenced. That definition may have __attribute__((used)) (which lowers 
to
+  // llvm.compiler.used on ELF targets) to communicate to 

[PATCH] D97755: [IRSymTab] Set FB_used on llvm.compiler.used symbols

2021-03-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 327958.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Add llvm-nm checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97755

Files:
  clang/test/CodeGen/thinlto-inline-asm2.c
  llvm/lib/LTO/LTO.cpp
  llvm/lib/Object/IRSymtab.cpp
  llvm/test/ThinLTO/X86/asm.ll
  llvm/test/tools/gold/X86/emit-llvm.ll

Index: llvm/test/tools/gold/X86/emit-llvm.ll
===
--- llvm/test/tools/gold/X86/emit-llvm.ll
+++ llvm/test/tools/gold/X86/emit-llvm.ll
@@ -54,6 +54,7 @@
   ret void
 }
 
+;; f2 is not internalized because it is in the llvm.used list.
 ; CHECK-DAG: define hidden void @f2()
 ; OPT-DAG: define hidden void @f2()
 define hidden void @f2() {
@@ -97,6 +98,15 @@
   ret i32* @g8
 }
 
+;; f9 is not internalized because it is in the llvm.compiler.used list.
+; CHECK-DAG: define hidden void @f9()
+; OPT-DAG: define hidden void @f9()
+define hidden void @f9() {
+  ret void
+}
+
+@llvm.compiler.used = appending global [1 x i8*] [ i8* bitcast (void ()* @f9 to i8*)]
+
 ; RES: .o,f1,pl{{$}}
 ; RES: .o,f2,pl{{$}}
 ; RES: .o,f3,px{{$}}
@@ -105,6 +115,7 @@
 ; RES: .o,f6,p{{$}}
 ; RES: .o,f7,px{{$}}
 ; RES: .o,f8,px{{$}}
+; RES: .o,f9,pl{{$}}
 ; RES: .o,g1,px{{$}}
 ; RES: .o,g2,p{{$}}
 ; RES: .o,g3,p{{$}}
Index: llvm/test/ThinLTO/X86/asm.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/asm.ll
@@ -0,0 +1,34 @@
+; RUN: split-file %s %t
+; RUN: opt -module-summary %t/a.s -o %t/a.bc
+; RUN: opt -module-summary %t/b.s -o %t/b.bc
+; RUN: llvm-nm %t/a.bc | FileCheck %s --check-prefix=NM
+
+; RUN: llvm-lto2 run %t/a.bc %t/b.bc -o %t/out -save-temps -r=%t/a.bc,ref,plx -r=%t/b.bc,ff_h264_cabac_tables,pl
+; RUN: llvm-dis < %t/out.2.2.internalize.bc | FileCheck %s
+
+;--- a.s
+;; IR symtab does not track inline asm symbols, so we don't know
+;; ff_h264_cabac_tables is undefined.
+; NM-NOT: {{.}}
+; NM:  T ref
+; NM-NOT: {{.}}
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i8* @ref() {
+entry:
+  %0 = tail call i8* asm sideeffect "lea ff_h264_cabac_tables(%rip), $0", "=,~{dirflag},~{fpsr},~{flags}"()
+  ret i8* %0
+}
+
+;--- b.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+;; ff_h264_cabac_tables has __attribute__((used)) in the source code, which means
+;; its definition must be retained because there can be references the compiler
+;; cannot see (inline asm reference). Test we don't internalize it.
+; CHECK: @ff_h264_cabac_tables = dso_local constant [1 x i8] c"\09"
+@ff_h264_cabac_tables = dso_local constant [1 x i8] c"\09"
+
+@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast ([1 x i8]* @ff_h264_cabac_tables to i8*)], section "llvm.metadata"
Index: llvm/lib/Object/IRSymtab.cpp
===
--- llvm/lib/Object/IRSymtab.cpp
+++ llvm/lib/Object/IRSymtab.cpp
@@ -119,8 +119,19 @@
 return make_error("input module has no datalayout",
inconvertibleErrorCode());
 
+  // Symbols in the llvm.used list will get the FB_Used bit and will not be
+  // internalized. We do this for llvm.compiler.used as well:
+  //
+  // IR symbol table tracks module-level asm symbol references but not inline
+  // asm, so we may not know that a symbol defined in another translation unit
+  // is referenced. That definition may have __attribute__((used)) (which lowers
+  // to llvm.compiler.used on ELF targets) to communicate to the compiler that
+  // it may be used by inline asm. The usage is perfectly fine, so we treat
+  // llvm.compiler.used conservatively as llvm.used to work around our own
+  // limitation.
   SmallVector UsedV;
   collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/false);
+  collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/true);
   SmallPtrSet Used(UsedV.begin(), UsedV.end());
 
   ModuleSymbolTable Msymtab;
Index: llvm/lib/LTO/LTO.cpp
===
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -563,8 +563,8 @@
 
 // Set the partition to external if we know it is re-defined by the linker
 // with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
-// regular object, is referenced from llvm.compiler_used, or was already
-// recorded as being referenced from a different partition.
+// regular object, is referenced from llvm.compiler.used/llvm.used, or was
+// already recorded as being referenced from a different partition.
 if (Res.LinkerRedefined || Res.VisibleToRegularObj || Sym.isUsed() ||
 (GlobalRes.Partition != GlobalResolution::Unknown 

[PATCH] D97823: [AIX] Update default arch on AIX

2021-03-03 Thread Steven Wan 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 rG0b274ed49960: [AIX] Update default arch on AIX (authored by 
stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else 

[PATCH] D97755: [IRSymTab] Set FB_used on llvm.compiler.used symbols

2021-03-03 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm with change suggested below. Thanks!




Comment at: clang/test/CodeGen/thinlto-inline-asm2.c:10
+
+//--- a.c
+const char *ref() {

MaskRay wrote:
> tejohnson wrote:
> > Is this other file needed for the test?
> This is test the limitation.
> 
> If we fix the tracking for inline asm references (this traverses instructions 
> and I don't know whether it should be fixed):
> 
> without the reference, the `ff_h264_cabac_tables` will be internalized if we 
> don't have a reference. The test ensures that such improvement can be 
> detected.
> 
> `llvm.compiler.used` means the references are seen by the linker, and do not 
> need to suppress internalization if the linker has full knowledge.
Ok, that makes sense. But then please add the same llvm-nm check with comment 
here as in the other test, so that it fails if that gets changed - I don't 
think as is this test will fail if that improvement is made.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97755

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


[clang] 0b274ed - [AIX] Update default arch on AIX

2021-03-03 Thread Steven Wan via cfe-commits

Author: Steven Wan
Date: 2021-03-03T19:07:43-05:00
New Revision: 0b274ed499603d30694c0b995252ab014609acf9

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

LOG: [AIX] Update default arch on AIX

On AIX, the default arch level should match the minimum supported arch level of 
the OS version.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/aix-mcpu-default.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 9471639350af..46a0fc67ced0 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@ std::string tools::getCPUName(const ArgList , const 
llvm::Triple ,
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";

diff  --git a/clang/test/Driver/aix-mcpu-default.c 
b/clang/test/Driver/aix-mcpu-default.c
index 10636abad304..7b55839a8066 100644
--- a/clang/test/Driver/aix-mcpu-default.c
+++ b/clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \



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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: mgorny, manojgupta.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97894

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1932,13 +1932,10 @@
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1932,13 +1932,10 @@
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

2021-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

That's definitely an improvement for our API surface. I think this is good but 
like @steakhal said I recommend running on a large codebase looking for 
potential regressions because this code is (still) very much spaghetti and hard 
to reason about.


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

https://reviews.llvm.org/D97388

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


[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

2021-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:877-879
+  std::tie(IsZero, IsNotZero) =
+  
getStateManager().getConstraintManager().isSymValWithinOrOutsideRange(
+  State, SE, Zero, Zero);

What was wrong with `State->assume(V)`? Why make a new function? Is this for 
optimization only?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97874

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


[PATCH] D97826: [RISCV] Make use of the required features in BuiltinInfo to store that V extension builtins require 'experimental-v'.

2021-03-03 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai accepted this revision.
HsiangKai added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97826

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


[PATCH] D97755: [IRSymTab] Set FB_used on llvm.compiler.used symbols

2021-03-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/thinlto-inline-asm2.c:10
+
+//--- a.c
+const char *ref() {

tejohnson wrote:
> Is this other file needed for the test?
This is test the limitation.

If we fix the tracking for inline asm references (this traverses instructions 
and I don't know whether it should be fixed):

without the reference, the `ff_h264_cabac_tables` will be internalized if we 
don't have a reference. The test ensures that such improvement can be detected.

`llvm.compiler.used` means the references are seen by the linker, and do not 
need to suppress internalization if the linker has full knowledge.



Comment at: llvm/test/ThinLTO/X86/asm.ll:11
+; NM-NOT: {{.}}
+; NM:  T ref
+; NM-NOT: {{.}}

tejohnson wrote:
> MaskRay wrote:
> > tejohnson wrote:
> > > What is the behavior here without this patch?
> > This is not changed. `ff_h264_cabac_tables` is not in the IR symbol table.
> Same question here - is this file needed to test the handling of the 
> llvm.compiler.used in the other file?
See my answer above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97755

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


[PATCH] D97457: [flang][driver] Add `-fdebug-dump-parsing-log`

2021-03-03 Thread Asher Mancinelli via Phabricator via cfe-commits
ashermancinelli added a comment.

It //is// unintuitive to me that we are mixing feature and action flags, 
however I don't have a better suggestion. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97457

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


[PATCH] D97512: [clang] removes check against integral-to-pointer conversion...

2021-03-03 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:10326
+  !isa(
+  Cast->getSubExpr()->IgnoreImplicitAsWritten()->IgnoreParens()))
+return;

thakis wrote:
> cjdb wrote:
> > cjdb wrote:
> > > aaron.ballman wrote:
> > > > I'm not 100% certain, but would `IgnoreParenImpCasts()` be sufficient 
> > > > here? (`IgnoreImplicitAsWritten() seems to be a bit special -- the only 
> > > > use of it I can find in tree is for rewritten binary operator 
> > > > expressions.)
> > > @rsmith would you mind weighing in here please? My original use-case for 
> > > `IgnoreImplicitAsWritten` might be different to here and I don't have an 
> > > answer for @aaron.ballman.
> > I've tried out `IgnoreParenImpCasts` and it seems to work, but I'd 
> > appreciate an answer here for future patches please.
> Can you rephrase your question? I'm not sure what exactly you want to know.
Richard suggested I use `IgnoreImplicitAsWritten` in D94640, but it's 
apparently unnecessary in D97512. I'd like to better understand when to use 
`IgnoreImplicitAsWritten`. (BTW this is non-blocking, so if there are no other 
comments that need addressing, I'd like to press forward please.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97512

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


[PATCH] D97755: [IRSymTab] Set FB_used on llvm.compiler.used symbols

2021-03-03 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/test/CodeGen/thinlto-inline-asm2.c:10
+
+//--- a.c
+const char *ref() {

Is this other file needed for the test?



Comment at: llvm/test/ThinLTO/X86/asm.ll:11
+; NM-NOT: {{.}}
+; NM:  T ref
+; NM-NOT: {{.}}

MaskRay wrote:
> tejohnson wrote:
> > What is the behavior here without this patch?
> This is not changed. `ff_h264_cabac_tables` is not in the IR symbol table.
Same question here - is this file needed to test the handling of the 
llvm.compiler.used in the other file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97755

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


[PATCH] D97889: [clang-tidy] Fix assert in modernize-loop-convert

2021-03-03 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: aaron.ballman.
Herald added subscribers: usaxena95, kadircet, xazax.hun.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

I'm unable to figure out a reproduction of this bug as it emerged when using 
clangd(On a ReleaseWithAssertions build) making it very hard to figure out the 
exact code that caught it.
However this is a pretty obvious check to include.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97889

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp


Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -313,6 +313,8 @@
   const auto *Member = dyn_cast(TheCall->getCallee());
   if (!Member)
 return nullptr;
+  if (!Member->getMemberDecl()->getDeclName().isIdentifier())
+return nullptr;
   StringRef Name = Member->getMemberDecl()->getName();
   if (!Name.consume_back(IsBegin ? "begin" : "end"))
 return nullptr;
@@ -544,6 +546,7 @@
   std::vector FixIts;
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
+assert(AliasVar->getDeclName().isIdentifier());
 VarName = AliasVar->getName().str();
 
 // Use the type of the alias if it's not the same


Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -313,6 +313,8 @@
   const auto *Member = dyn_cast(TheCall->getCallee());
   if (!Member)
 return nullptr;
+  if (!Member->getMemberDecl()->getDeclName().isIdentifier())
+return nullptr;
   StringRef Name = Member->getMemberDecl()->getName();
   if (!Name.consume_back(IsBegin ? "begin" : "end"))
 return nullptr;
@@ -544,6 +546,7 @@
   std::vector FixIts;
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
+assert(AliasVar->getDeclName().isIdentifier());
 VarName = AliasVar->getName().str();
 
 // Use the type of the alias if it's not the same
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94973: [clang][OpenMP] Use OpenMPIRBuilder for workshare loops.

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

In D94973#2591493 , @jdenny wrote:

>> I even think that representing semantic information alongside of syntax is 
>> one of the principles of Clang's AST.
>
> Interesting.  Is that documented somewhere?

https://clang.llvm.org/docs/InternalsManual.html#faithfulness

> Some AST nodes (for example, ParenExpr) represent only syntax, and others 
> (for example, ImplicitCastExpr) represent only semantics,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94973

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


[PATCH] D97417: [clangd] use a compatible preamble for the first AST built

2021-03-03 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 327923.
qchateau added a comment.

fix bad arc diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97417

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h

Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -312,6 +312,8 @@
   class ASTCache;
   /// Tracks headers included by open files, to get known-good compile commands.
   class HeaderIncluderCache;
+  /// Store all known preambles
+  class PreambleStore;
 
   // The file being built/processed in the current thread. This is a hack in
   // order to get the file name into the index implementations. Do not depend on
@@ -335,6 +337,7 @@
   llvm::StringMap> Files;
   std::unique_ptr IdleASTs;
   std::unique_ptr HeaderIncluders;
+  std::unique_ptr Preambles;
   // None when running tasks synchronously and non-None when running tasks
   // asynchronously.
   llvm::Optional PreambleTasks;
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -96,6 +96,62 @@
 
 namespace {
 class ASTWorker;
+
+bool compileCommandsAreSimilar(const tooling::CompileCommand ,
+   const tooling::CompileCommand ) {
+  auto LIt = LHS.CommandLine.begin();
+  auto RIt = RHS.CommandLine.begin();
+
+  auto SkipSpecificArg = [](auto It, auto End, const std::string ) {
+while (It != End) {
+  if (*It == "-o" || *It == "-x") {
+// Erase -o and its argument
+// Erase -x and its argument: it would prevent using header file
+// preamble for a source file
+It = std::min(It + 2, End);
+  } else if (*It == "-c" || It->find("-W") == 0 || *It == "-pedantic") {
+// We don't care about those flags
+It++;
+  } else if (It->find(Filename) != std::string::npos) {
+// The file we're compiling appears in this argument, drop it to make it
+// generic
+It++;
+  } else {
+break;
+  }
+}
+return It;
+  };
+
+  // Iterate the command line, skipping arguments that are specific to the
+  // file being compiled and that would not influence the premable
+  // compatiblity. Stop when one iterate reach the or when an argument differs
+  auto LEnd = LHS.CommandLine.end();
+  auto REnd = RHS.CommandLine.end();
+  while (true) {
+LIt = SkipSpecificArg(LIt, LEnd, LHS.Filename);
+RIt = SkipSpecificArg(RIt, REnd, RHS.Filename);
+
+if (LIt == LEnd || RIt == REnd) {
+  break;
+}
+
+if (*LIt != *RIt) {
+  break;
+}
+
+LIt++;
+RIt++;
+  }
+
+  // If both iterator get to the end at the same time, the CL are compatible
+  bool Compatible = LIt == LEnd && RIt == REnd;
+  if (Compatible) {
+vlog("{0} and {1} are compatible", LHS.Filename, RHS.Filename);
+  }
+  return Compatible;
+}
+
 } // namespace
 
 static clang::clangd::Key kFileBeingProcessed;
@@ -301,6 +357,59 @@
   }
 };
 
+class TUScheduler::PreambleStore {
+public:
+  struct Entry {
+std::shared_ptr Preamble;
+size_t Score;
+Path FileName;
+
+bool operator>(const Entry ) const { return Score > Other.Score; }
+  };
+
+  auto getAll() {
+std::unique_lock Lock(Mut);
+return Store;
+  }
+
+  void push(PathRef FileName, std::shared_ptr Preamble) {
+std::unique_lock Lock(Mut);
+auto It = llvm::find_if(
+Store, [&](const auto ) { return Item.FileName == FileName; });
+if (It == Store.end()) {
+  Store.push_back(Entry{std::move(Preamble), 0, FileName.str()});
+  popWorstPreambles();
+}
+vlog("Store contains {0} preambles", Store.size());
+  }
+
+  void hit(PathRef FileName) {
+std::unique_lock Lock(Mut);
+auto It = llvm::find_if(
+Store, [&](const auto ) { return Item.FileName == FileName; });
+if (It == Store.end()) {
+  return;
+}
+It->Score++;
+  }
+
+private:
+  void popWorstPreambles() {
+constexpr int ClosedPreamblesToKeep = 5;
+auto Begin = llvm::partition(
+Store, [](const auto ) { return Item.Preamble.use_count() > 1; });
+if (std::distance(Begin, Store.end()) <= ClosedPreamblesToKeep) {
+  return;
+}
+auto Nth = Begin + ClosedPreamblesToKeep;
+std::nth_element(Begin, Nth, Store.end(), std::greater());
+Store.erase(Nth, Store.end());
+  }
+
+  std::mutex Mut;
+  std::vector Store;
+};
+
 namespace {
 
 bool isReliable(const tooling::CompileCommand ) {
@@ -500,7 +609,8 @@
   ASTWorker(PathRef FileName, const GlobalCompilationDatabase ,
 TUScheduler::ASTCache ,
 TUScheduler::HeaderIncluderCache ,
-Semaphore , bool 

[PATCH] D97417: [clangd] use a compatible preamble for the first AST built

2021-03-03 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 327922.
qchateau added a comment.

rebase on main, fix formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97417

Files:
  clang-tools-extra/clangd/TUScheduler.cpp


Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -609,8 +609,8 @@
   ASTWorker(PathRef FileName, const GlobalCompilationDatabase ,
 TUScheduler::ASTCache ,
 TUScheduler::HeaderIncluderCache ,
-TUScheduler::PreambleStore ,
-Semaphore , bool RunSync, const TUScheduler::Options ,
+TUScheduler::PreambleStore , Semaphore ,
+bool RunSync, const TUScheduler::Options ,
 ParsingCallbacks );
 
 public:
@@ -623,9 +623,9 @@
   create(PathRef FileName, const GlobalCompilationDatabase ,
  TUScheduler::ASTCache ,
  TUScheduler::HeaderIncluderCache ,
- TUScheduler::PreambleStore ,
- AsyncTaskRunner *Tasks, Semaphore ,
- const TUScheduler::Options , ParsingCallbacks );
+ TUScheduler::PreambleStore , AsyncTaskRunner *Tasks,
+ Semaphore , const TUScheduler::Options ,
+ ParsingCallbacks );
   ~ASTWorker();
 
   void update(ParseInputs Inputs, WantDiagnostics, bool ContentChanged);
@@ -844,11 +844,11 @@
 ASTWorker::ASTWorker(PathRef FileName, const GlobalCompilationDatabase ,
  TUScheduler::ASTCache ,
  TUScheduler::HeaderIncluderCache ,
-TUScheduler::PreambleStore ,
- Semaphore , bool RunSync,
- const TUScheduler::Options ,
+ TUScheduler::PreambleStore , Semaphore ,
+ bool RunSync, const TUScheduler::Options ,
  ParsingCallbacks )
-: IdleASTs(LRUCache), HeaderIncluders(HeaderIncluders), 
Preambles(Preambles), RunSync(RunSync),
+: IdleASTs(LRUCache), HeaderIncluders(HeaderIncluders),
+  Preambles(Preambles), RunSync(RunSync),
   UpdateDebounce(Opts.UpdateDebounce), FileName(FileName),
   ContextProvider(Opts.ContextProvider), CDB(CDB), Callbacks(Callbacks),
   Barrier(Barrier), Done(false), Status(FileName, Callbacks),


Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -609,8 +609,8 @@
   ASTWorker(PathRef FileName, const GlobalCompilationDatabase ,
 TUScheduler::ASTCache ,
 TUScheduler::HeaderIncluderCache ,
-TUScheduler::PreambleStore ,
-Semaphore , bool RunSync, const TUScheduler::Options ,
+TUScheduler::PreambleStore , Semaphore ,
+bool RunSync, const TUScheduler::Options ,
 ParsingCallbacks );
 
 public:
@@ -623,9 +623,9 @@
   create(PathRef FileName, const GlobalCompilationDatabase ,
  TUScheduler::ASTCache ,
  TUScheduler::HeaderIncluderCache ,
- TUScheduler::PreambleStore ,
- AsyncTaskRunner *Tasks, Semaphore ,
- const TUScheduler::Options , ParsingCallbacks );
+ TUScheduler::PreambleStore , AsyncTaskRunner *Tasks,
+ Semaphore , const TUScheduler::Options ,
+ ParsingCallbacks );
   ~ASTWorker();
 
   void update(ParseInputs Inputs, WantDiagnostics, bool ContentChanged);
@@ -844,11 +844,11 @@
 ASTWorker::ASTWorker(PathRef FileName, const GlobalCompilationDatabase ,
  TUScheduler::ASTCache ,
  TUScheduler::HeaderIncluderCache ,
-TUScheduler::PreambleStore ,
- Semaphore , bool RunSync,
- const TUScheduler::Options ,
+ TUScheduler::PreambleStore , Semaphore ,
+ bool RunSync, const TUScheduler::Options ,
  ParsingCallbacks )
-: IdleASTs(LRUCache), HeaderIncluders(HeaderIncluders), Preambles(Preambles), RunSync(RunSync),
+: IdleASTs(LRUCache), HeaderIncluders(HeaderIncluders),
+  Preambles(Preambles), RunSync(RunSync),
   UpdateDebounce(Opts.UpdateDebounce), FileName(FileName),
   ContextProvider(Opts.ContextProvider), CDB(CDB), Callbacks(Callbacks),
   Barrier(Barrier), Done(false), Status(FileName, Callbacks),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97805: [clang-query] Add option to enable only displaying main file matches

2021-03-03 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 327921.
njames93 added a comment.

Change default match mode to include all files.
Update so the prompt to switch match mode is only displayed once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97805

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/QueryParser.h
  clang-tools-extra/clang-query/QuerySession.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-query/Inputs/foo.h
  clang-tools-extra/test/clang-query/headers.cpp

Index: clang-tools-extra/test/clang-query/headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-query/headers.cpp
@@ -0,0 +1,55 @@
+// RUN: clang-query -c "set match-scope include-headers" -c "match functionDecl(hasName('foo'))" %s -- | FileCheck %s --check-prefix=CHECK-ALL-FOO
+// RUN: clang-query -c "set match-scope main-file-only" -c "match functionDecl(hasName('foo'))" %s -- | FileCheck %s --check-prefix=CHECK-MAIN-FOO
+// RUN: clang-query -c "set match-scope include-headers" -c "match functionDecl(hasName('bar'))" %s -- | FileCheck %s --check-prefix=CHECK-ALL-BAR
+// RUN: clang-query -c "set match-scope main-file-only" -c "match functionDecl(hasName('bar'))" %s -- | FileCheck %s --check-prefix=CHECK-MAIN-BAR
+// RUN: clang-query -c "set match-scope include-headers" -c "match functionDecl()" %s -- | FileCheck %s --check-prefix=CHECK-ALL-ANY
+// RUN: clang-query -c "set match-scope main-file-only" -c "match functionDecl()" %s -- | FileCheck %s --check-prefix=CHECK-MAIN-ANY
+
+// Test to ensure default behavious only includes main file matches.
+// RUN: clang-query -c "match functionDecl()" %s -- | FileCheck %s --check-prefix=CHECK-ALL-ANY
+
+// Test to ensure the warnings about selecting match-scope is only shown once
+// RUN: clang-query -c "set match-scope include-headers" -c "match functionDecl()" -c "match functionDecl()" %s | FileCheck %s --check-prefix=CHECK-SINGLE-WARN-ALL
+// RUN: clang-query -c "set match-scope main-file-only" -c "match functionDecl()" -c "match functionDecl()" %s | FileCheck %s --check-prefix=CHECK-SINGLE-WARN-MAIN
+
+#include "Inputs/foo.h"
+
+void foo() {}
+
+// CHECK-ALL-FOO: /Inputs/foo.h:4:1: note: "root" binds here
+// CHECK-ALL-FOO: /headers.cpp:17:1: note: "root" binds here
+// CHECK-ALL-FOO: 2 matches.
+// CHECK-ALL-FOO-NEXT: Included 1 match from header files
+// CHECK-ALL-FOO-NEXT: Use 'set match-mode main-file-only' to hide them.
+
+// CHECK-MAIN-FOO: /headers.cpp:17:1: note: "root" binds here
+// CHECK-MAIN-FOO: 1 match.
+// CHECK-MAIN-FOO-Next: Skipped 1 match from header files.
+// CHECK-MAIN-FOO-Next: Use 'set match-mode include-headers' to display them.
+
+// CHECK-ALL-BAR: /Inputs/foo.h:5:1: note: "root" binds here
+// CHECK-ALL-BAR: 1 match.
+// CHECK-ALL-BAR-NEXT: Included 1 match from header files
+// CHECK-ALL-BAR-NEXT: Use 'set match-mode main-file-only' to hide them.
+
+// CHECK-MAIN-BAR: 0 matches.
+// CHECK-MAIN-BAR-Next: Skipped 1 match from header files.
+// CHECK-MAIN-BAR-Next: Use 'set match-mode include-headers' to display them.
+
+// CHECK-ALL-ANY: /Inputs/foo.h:4:1: note: "root" binds here
+// CHECK-ALL-ANY: /Inputs/foo.h:5:1: note: "root" binds here
+// CHECK-ALL-ANY: /headers.cpp:17:1: note: "root" binds here
+// CHECK-ALL-ANY: 3 matches.
+// CHECK-ALL-ANY-NEXT: Included 2 matches from header files
+// CHECK-ALL-ANY-NEXT: Use 'set match-mode main-file-only' to hide them.
+
+// CHECK-MAIN-ANY: /headers.cpp:17:1: note: "root" binds here
+// CHECK-MAIN-ANY: 1 match.
+// CHECK-MAIN-ANY-Next: Skipped 2 matches from header files.
+// CHECK-MAIN-ANY-Next: Use 'set match-mode include-headers' to display them.
+
+// CHECK-SINGLE-WARN-ALL: Use 'set match-mode main-file-only' to hide them.
+// CHECK-SINGLE-WARN-ALL-NOT: Use 'set match-mode main-file-only' to hide them.
+
+// CHECK-SINGLE-WARN-MAIN: Use 'set match-mode include-headers' to display them.
+// CHECK-SINGLE-WARN-MAIN-NOT: Use 'set match-mode include-headers' to display them.
Index: clang-tools-extra/test/clang-query/Inputs/foo.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-query/Inputs/foo.h
@@ -0,0 +1,7 @@
+#ifndef INPUTS_FOO_HH
+#define INPUTS_FOO_HH
+
+void foo();
+void bar();
+
+#endif // INPUTS_FOO_HH
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -57,7 +57,8 @@
 Improvements to clang-query
 ---
 
-The improvements are...
+ - Added a option `set match-scope` to control displaying matches that occur 
+   in header files.
 
 Improvements to clang-rename
 
Index: 

[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-03-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D96771#2574638 , @awarzynski wrote:

> In D96771#2571855 , @Anastasia wrote:
>
>> This is only the initial patch and for the moment the primary goal is to 
>> remove the need for the flag at least from the clang perspective.
>
> Shorter compiler invocation is always nice! Does OpenCL (will) require a flag 
> to specify the C++ standard used in the kernel? Or is that going to be 
> controlled with `-cl-std={cl2.1|cl2.2|cl2.3`? This would be very weird 
> `-cl-std=clc++ -cl-std=cl2.1`, so I see why you would want to remove  
> `-cl-std=clc++`.

Thanks a lot for all the feedback! Just to clarify I am not removing the flag I 
am just removing the need for it to be passed. FYI I have modified the driver 
test slightly to indicate that the flag is still available. The reason for it 
is backward compatibility. OpenCL (not only C++ for OpenCL) has always used 
this flag to override the default settings per file extensions. Some IDEs and 
other toolchains started relying on this feature. For example, they would 
compile `.c` extension file with `-cl-std=cl`. Not sure why it was set up this 
way but it is not something that would be easy to change without introducing 
backward compatibility issue.

>> I just dislike the fact that moving files in the repo complicates the commit 
>> history lookup so I was not sure if the renaming was good or bad thing. Do 
>> you have any suggestions?
>
> Have you tried it? Git is very clever in this respect and will track the file 
> changes very accurately anyway. IMHO this wouldn't be disruptive in terms of 
> browsing the history at all. If you are making this change to remove the need 
> for `-cl-std=clc++` and to simplify things, you could as well organize tests 
> per kernel language (i.e. OpenCL C vs OpenCL C++). Also, `-cl-std=clc++` in 
> tests will look very confusing (i.e., why keep OpenCL C++ tests in OpenCL C 
> tests and force the standard with `-cl-std=clc++`)? Lastly, such change would 
> be a very through verification of your changes :)

Yes, I agree. I have renamed the tests. The only drawback is that `git log` 
would need an extra option to see the full history but it should be acceptable 
and I am up for consistency. Also if we are ever to rename those tests now is 
better than later.

> By scanning your patch I get the impression that you don't need `TY_CLCXX` 
> just yet. The language for the kernel is set in 
> `clang/lib/Frontend/CompilerInvocation.cpp`:
>
>   .Case("clcpp", Language::OpenCLCXX)
>
> In Types.cpp this should be sufficient for now:
>
>   .Case("clcpp", TY_CLCXX)
>
> Basically, you could limit your changes to the frontend driver and the 
> changes in the compiler driver keep to a tiny minimum. I think! :)

Yes, I have removed most of the redundant code. It was mainly related to the 
headers btw. It looks a lot cleaner now. :)


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

https://reviews.llvm.org/D96771

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


[PATCH] D97687: [SEH] Fix capture of this in lambda functions

2021-03-03 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97687

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


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-03-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D92808#2600245 , @hans wrote:

> Reverted in 
> https://github.com/llvm/llvm-project/commit/0a5dd067181dac2a8882a139ea3bd19bdea5fa44
>  until this can be fixed.

Thanks! I pushed a fix for the issue in 75805dce5ff8 
. @Hans, 
would it be possible to check if D92808  + 
75805dce5ff8 
 fixes the 
issue or should we just recommit D92808 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-03-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 327915.
Anastasia added a comment.
Herald added subscribers: kbarton, nemanjai.

- Renamed extensions to `cppcl` as it was more popular in RFC
- Minimized number of changes in driver setup
- Changed file extension in all C++ for OpenCL tests


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

https://reviews.llvm.org/D96771

Files:
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/FrontendOptions.cpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.cppcl
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.cl
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
  clang/test/CodeGenOpenCLCXX/addrspace-operators.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-references.cl
  clang/test/CodeGenOpenCLCXX/addrspace-references.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.cl
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace_cast.cl
  clang/test/CodeGenOpenCLCXX/addrspace_cast.cppcl
  clang/test/CodeGenOpenCLCXX/atexit.cl
  clang/test/CodeGenOpenCLCXX/atexit.cppcl
  clang/test/CodeGenOpenCLCXX/constexpr.cl
  clang/test/CodeGenOpenCLCXX/constexpr.cppcl
  clang/test/CodeGenOpenCLCXX/global_init.cl
  clang/test/CodeGenOpenCLCXX/global_init.cppcl
  clang/test/CodeGenOpenCLCXX/local_addrspace_init.cl
  clang/test/CodeGenOpenCLCXX/local_addrspace_init.cppcl
  clang/test/CodeGenOpenCLCXX/method-overload-address-space.cl
  clang/test/CodeGenOpenCLCXX/method-overload-address-space.cppcl
  clang/test/CodeGenOpenCLCXX/template-address-spaces.cl
  clang/test/CodeGenOpenCLCXX/template-address-spaces.cppcl
  clang/test/Driver/cxx_for_opencl.cppcl
  clang/test/Driver/lit.local.cfg
  clang/test/SemaOpenCLCXX/address-space-castoperators.cl
  clang/test/SemaOpenCLCXX/address-space-castoperators.cppcl
  clang/test/SemaOpenCLCXX/address-space-cond.cl
  clang/test/SemaOpenCLCXX/address-space-cond.cppcl
  clang/test/SemaOpenCLCXX/address-space-deduction.cl
  clang/test/SemaOpenCLCXX/address-space-deduction.cppcl
  clang/test/SemaOpenCLCXX/address-space-lambda.cl
  clang/test/SemaOpenCLCXX/address-space-lambda.cppcl
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cppcl
  clang/test/SemaOpenCLCXX/address-space-of-this.cl
  clang/test/SemaOpenCLCXX/address-space-of-this.cppcl
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaOpenCLCXX/address-space-references.cppcl
  clang/test/SemaOpenCLCXX/address-space-templates.cl
  clang/test/SemaOpenCLCXX/address-space-templates.cppcl
  clang/test/SemaOpenCLCXX/address_space_overloading.cl
  clang/test/SemaOpenCLCXX/address_space_overloading.cppcl
  clang/test/SemaOpenCLCXX/addrspace-auto.cl
  clang/test/SemaOpenCLCXX/addrspace-auto.cppcl
  clang/test/SemaOpenCLCXX/addrspace_cast.cl
  clang/test/SemaOpenCLCXX/addrspace_cast.cppcl
  clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.cl
  clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.cppcl
  clang/test/SemaOpenCLCXX/invalid-kernel.cl
  clang/test/SemaOpenCLCXX/invalid-kernel.cppcl
  clang/test/SemaOpenCLCXX/members.cl
  clang/test/SemaOpenCLCXX/members.cppcl
  clang/test/SemaOpenCLCXX/method-overload-address-space.cl
  clang/test/SemaOpenCLCXX/method-overload-address-space.cppcl
  clang/test/SemaOpenCLCXX/newdelete.cl
  clang/test/SemaOpenCLCXX/newdelete.cppcl
  clang/test/SemaOpenCLCXX/references.cl
  clang/test/SemaOpenCLCXX/references.cppcl
  clang/test/SemaOpenCLCXX/restricted.cl
  clang/test/SemaOpenCLCXX/restricted.cppcl
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -26,7 +26,7 @@
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu',
-   '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
+   '.ll', '.cl', '.cppcl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: 

[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-03-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/Interpreter/execute.c:1
+// RUN: cat %s | clang-repl | FileCheck %s
+

Presumably here (and in all the interpreter tests) we will need to check that 
we configured Clang and LLVM so that they can actually JIT code for the host 
machine, and disable the test if not.


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

https://reviews.llvm.org/D96033

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


[PATCH] D97755: [IRSymTab] Set FB_used on llvm.compiler.used symbols

2021-03-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 327909.
MaskRay added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add a clang/test/CodeGen/ test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97755

Files:
  clang/test/CodeGen/thinlto-inline-asm2.c
  llvm/lib/LTO/LTO.cpp
  llvm/lib/Object/IRSymtab.cpp
  llvm/test/ThinLTO/X86/asm.ll
  llvm/test/tools/gold/X86/emit-llvm.ll

Index: llvm/test/tools/gold/X86/emit-llvm.ll
===
--- llvm/test/tools/gold/X86/emit-llvm.ll
+++ llvm/test/tools/gold/X86/emit-llvm.ll
@@ -54,6 +54,7 @@
   ret void
 }
 
+;; f2 is not internalized because it is in the llvm.used list.
 ; CHECK-DAG: define hidden void @f2()
 ; OPT-DAG: define hidden void @f2()
 define hidden void @f2() {
@@ -97,6 +98,15 @@
   ret i32* @g8
 }
 
+;; f9 is not internalized because it is in the llvm.compiler.used list.
+; CHECK-DAG: define hidden void @f9()
+; OPT-DAG: define hidden void @f9()
+define hidden void @f9() {
+  ret void
+}
+
+@llvm.compiler.used = appending global [1 x i8*] [ i8* bitcast (void ()* @f9 to i8*)]
+
 ; RES: .o,f1,pl{{$}}
 ; RES: .o,f2,pl{{$}}
 ; RES: .o,f3,px{{$}}
@@ -105,6 +115,7 @@
 ; RES: .o,f6,p{{$}}
 ; RES: .o,f7,px{{$}}
 ; RES: .o,f8,px{{$}}
+; RES: .o,f9,pl{{$}}
 ; RES: .o,g1,px{{$}}
 ; RES: .o,g2,p{{$}}
 ; RES: .o,g3,p{{$}}
Index: llvm/test/ThinLTO/X86/asm.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/asm.ll
@@ -0,0 +1,35 @@
+; RUN: split-file %s %t
+; RUN: opt -module-summary %t/a.s -o %t/a.bc
+; RUN: opt -module-summary %t/b.s -o %t/b.bc
+; RUN: llvm-nm %t/a.bc | FileCheck %s --check-prefix=NM
+
+; RUN: llvm-lto2 run %t/a.bc %t/b.bc -o %t/out -save-temps -r=%t/a.bc,ref,plx -r=%t/b.bc,ff_h264_cabac_tables,pl
+; RUN: llvm-dis < %t/out.2.2.internalize.bc | FileCheck %s
+
+;; IR symtab does not track inline asm symbols, so we don't know
+;; ff_h264_cabac_tables is undefined.
+; NM-NOT: {{.}}
+; NM:  T ref
+; NM-NOT: {{.}}
+
+;--- a.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i8* @ref() {
+entry:
+  %0 = tail call i8* asm sideeffect "lea ff_h264_cabac_tables(%rip), $0", "=,~{dirflag},~{fpsr},~{flags}"()
+  ret i8* %0
+}
+
+;--- b.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+;; ff_h264_cabac_tables has __attribute__((used)) in the source code, which means
+;; its definition must be retained because there can be references the compiler
+;; cannot see (inline asm reference). Test we don't internalize it.
+; CHECK: @ff_h264_cabac_tables = dso_local constant [1 x i8] c"\09"
+@ff_h264_cabac_tables = dso_local constant [1 x i8] c"\09"
+
+@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast ([1 x i8]* @ff_h264_cabac_tables to i8*)], section "llvm.metadata"
Index: llvm/lib/Object/IRSymtab.cpp
===
--- llvm/lib/Object/IRSymtab.cpp
+++ llvm/lib/Object/IRSymtab.cpp
@@ -119,8 +119,19 @@
 return make_error("input module has no datalayout",
inconvertibleErrorCode());
 
+  // Symbols in the llvm.used list will get the FB_Used bit and will not be
+  // internalized. We do this for llvm.compiler.used as well:
+  //
+  // IR symbol table tracks module-level asm symbol references but not inline
+  // asm, so we may not know that a symbol defined in another translation unit
+  // is referenced. That definition may have __attribute__((used)) (which lowers
+  // to llvm.compiler.used on ELF targets) to communicate to the compiler that
+  // it may be used by inline asm. The usage is perfectly fine, so we treat
+  // llvm.compiler.used conservatively as llvm.used to work around our own
+  // limitation.
   SmallVector UsedV;
   collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/false);
+  collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/true);
   SmallPtrSet Used(UsedV.begin(), UsedV.end());
 
   ModuleSymbolTable Msymtab;
Index: llvm/lib/LTO/LTO.cpp
===
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -563,8 +563,8 @@
 
 // Set the partition to external if we know it is re-defined by the linker
 // with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
-// regular object, is referenced from llvm.compiler_used, or was already
-// recorded as being referenced from a different partition.
+// regular object, is referenced from llvm.compiler.used/llvm.used, or was
+// already recorded as being referenced from a different partition.
 if (Res.LinkerRedefined || Res.VisibleToRegularObj || Sym.isUsed() ||
 

[clang] eec7f8f - [WebAssembly] Add missing default cases in switch statements

2021-03-03 Thread Thomas Lively via cfe-commits

Author: Soumi Manna
Date: 2021-03-03T13:15:23-08:00
New Revision: eec7f8f7b1226be422a76542cb403d02538f453a

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

LOG: [WebAssembly] Add missing default cases in switch statements

unsigned variable 'IntNo' has been declared but not been defined inside function
EmitWebAssemblyBuiltinExpr().

static code analysis tool complains about uninitialized variable "IntNo" since
this enters to default branch without setting any intrinsics and calls Function
*Callee = CGM.getIntrinsic(IntNo).

This patch fixes the problem by adding default cases in switch statements.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1a5dfdedc037..6b3d385c411e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17365,6 +17365,8 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 case WebAssembly::BI__builtin_wasm_widen_high_u_i32x4_i64x2:
   IntNo = Intrinsic::wasm_widen_high_unsigned;
   break;
+default:
+  llvm_unreachable("unexpected builtin ID");
 }
 Function *Callee = CGM.getIntrinsic(IntNo);
 return Builder.CreateCall(Callee, Vec);
@@ -17383,6 +17385,8 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 case WebAssembly::BI__builtin_wasm_widen_u_i8x16_i32x4:
   IntNo = Intrinsic::wasm_widen_unsigned;
   break;
+default:
+  llvm_unreachable("unexpected builtin ID");
 }
 Function *Callee = CGM.getIntrinsic(IntNo);
 return Builder.CreateCall(Callee, {Vec, SubVec});
@@ -17398,6 +17402,8 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 case WebAssembly::BI__builtin_wasm_convert_low_u_i32x4_f64x2:
   IntNo = Intrinsic::wasm_convert_low_unsigned;
   break;
+default:
+  llvm_unreachable("unexpected builtin ID");
 }
 Function *Callee = CGM.getIntrinsic(IntNo);
 return Builder.CreateCall(Callee, Vec);
@@ -17413,6 +17419,8 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 case WebAssembly::BI__builtin_wasm_trunc_saturate_zero_u_f64x2_i32x4:
   IntNo = Intrinsic::wasm_trunc_saturate_zero_unsigned;
   break;
+default:
+  llvm_unreachable("unexpected builtin ID");
 }
 Function *Callee = CGM.getIntrinsic(IntNo);
 return Builder.CreateCall(Callee, Vec);



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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-03 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 327898.
DiggerLin added a comment.

modify a test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Index: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large \
+// RUN:-fvisibility-inlines-hidden -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility -emit-llvm \
+// RUN:-fvisibility-inlines-hidden -fvisibility default -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+int x = 66;
+__attribute__((__noinline__)) inline void f() {
+  x = 55;
+}
+
+#pragma GCC visibility push(hidden)
+__attribute__((__noinline__)) inline void foo() {
+  x = 55;
+}
+#pragma GCC visibility pop
+
+int bar() {
+  f();
+  foo();
+  return x;
+}
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z1fv()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z1fv()
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z3foov()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z3foov()
Index: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
===
--- clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -1,24 +1,8 @@
-// REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -o - -x c++ -S  %s  |\
-// RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
@@ -70,28 +54,11 @@
 // VISIBILITY-IR:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* {{[^,]*}} %this)
 // VISIBILITY-IR:define hidden void @_Z7prambarv()
 
-// VISIBILITY-ASM: .globl  _Z5foo_hPi[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z5foo_hPi,hidden
-// VISIBILITY-ASM: .globl  _Z3barv[DS],protected
-// VISIBILITY-ASM: .globl  ._Z3barv,protected
-// VISIBILITY-ASM: .weak   _ZNK9TestClass5valueEv[DS],hidden
-// VISIBILITY-ASM: .weak   ._ZNK9TestClass5valueEv,hidden
-// VISIBILITY-ASM: .weak   _ZN5basicIiE7getdataEv[DS],protected
-// VISIBILITY-ASM: .weak   ._ZN5basicIiE7getdataEv,protected
-// VISIBILITY-ASM: .globl  _Z7prambarv[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z7prambarv,hidden
-// VISIBILITY-ASM: .globl  b,protected
-// VISIBILITY-ASM: .globl  pramb,hidden
-
-// IGNOREVISIBILITY-ASM: .globl  _Z5foo_hPi[DS]
-// IGNOREVISIBILITY-ASM: .globl  ._Z5foo_hPi
-// IGNOREVISIBILITY-ASM: .globl  _Z3barv[DS]
-// IGNOREVISIBILITY-ASM: .globl  ._Z3barv
-// IGNOREVISIBILITY-ASM: .weak   _ZNK9TestClass5valueEv[DS]
-// IGNOREVISIBILITY-ASM: .weak   ._ZNK9TestClass5valueEv
-// IGNOREVISIBILITY-ASM: .weak   _ZN5basicIiE7getdataEv[DS]
-// 

[PATCH] D96709: Add Windows ehcont section support (/guard:ehcont).

2021-03-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:499
   CmdArgs.push_back("-guard:cf-");
+} else if (GuardArgs.equals_lower("ehcont")) {
+  CmdArgs.push_back("/guard:ehcont");

pengfei wrote:
> rnk wrote:
> > This is gone now, btw
> Sorry, I don't understand by the mean "gone"? The check for cf is still there 
> after I rebased, I think we should do for ehcont too.
Oh, I misspoke. I assumed this was code for doing fall back to cl.exe, which 
was removed recently. Nevermind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96709

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


[PATCH] D97824: [ObjC][ARC] Don't add operand bundle `clang.arc.attachedcall` to a call if the call already has the operand bundle

2021-03-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 327888.
ahatanak added a comment.

Emit a call to `@llvm.objc.retain` instead of a call to 
`@llvm.objc.retainAutoreleasedReturnValue`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97824

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjCXX/arc-rv-attr.mm


Index: clang/test/CodeGenObjCXX/arc-rv-attr.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/arc-rv-attr.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc 
-std=c++11 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK
+
+id foo(void);
+
+// CHECK-LABEL: define{{.*}} void @_Z14test_list_initv(
+// CHECK: %[[CALL1:.*]] = call i8* @_Z3foov() [ "clang.arc.attachedcall"(i64 
0) ]
+// CHECK: call i8* @llvm.objc.retain(i8* %[[CALL1]])
+
+void test_list_init() {
+  auto t = id{foo()};
+}
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -2341,11 +2341,19 @@
   // FIXME: Do this when the target isn't aarch64.
   if (CGF.CGM.getCodeGenOpts().OptimizationLevel > 0 &&
   CGF.CGM.getTarget().getTriple().isAArch64()) {
+auto *oldCall = cast(value);
+
+// The operand bundle cannot be added if the call already has the operand
+// bundle.
+if (llvm::objcarc::hasAttachedCallOpBundle(oldCall))
+  // If the runtime function being called is retainRV, emit a call to
+  // @objc_retain. Do nothing if it is claimRV.
+  return IsRetainRV ? CGF.EmitARCRetainNonBlock(value) : value;
+
 llvm::Value *bundleArgs[] = {llvm::ConstantInt::get(
 CGF.Int64Ty,
 llvm::objcarc::getAttachedCallOperandBundleEnum(IsRetainRV))};
 llvm::OperandBundleDef OB("clang.arc.attachedcall", bundleArgs);
-auto *oldCall = cast(value);
 llvm::CallBase *newCall = llvm::CallBase::addOperandBundle(
 oldCall, llvm::LLVMContext::OB_clang_arc_attachedcall, OB, oldCall);
 newCall->copyMetadata(*oldCall);


Index: clang/test/CodeGenObjCXX/arc-rv-attr.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/arc-rv-attr.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -std=c++11 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+
+id foo(void);
+
+// CHECK-LABEL: define{{.*}} void @_Z14test_list_initv(
+// CHECK: %[[CALL1:.*]] = call i8* @_Z3foov() [ "clang.arc.attachedcall"(i64 0) ]
+// CHECK: call i8* @llvm.objc.retain(i8* %[[CALL1]])
+
+void test_list_init() {
+  auto t = id{foo()};
+}
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -2341,11 +2341,19 @@
   // FIXME: Do this when the target isn't aarch64.
   if (CGF.CGM.getCodeGenOpts().OptimizationLevel > 0 &&
   CGF.CGM.getTarget().getTriple().isAArch64()) {
+auto *oldCall = cast(value);
+
+// The operand bundle cannot be added if the call already has the operand
+// bundle.
+if (llvm::objcarc::hasAttachedCallOpBundle(oldCall))
+  // If the runtime function being called is retainRV, emit a call to
+  // @objc_retain. Do nothing if it is claimRV.
+  return IsRetainRV ? CGF.EmitARCRetainNonBlock(value) : value;
+
 llvm::Value *bundleArgs[] = {llvm::ConstantInt::get(
 CGF.Int64Ty,
 llvm::objcarc::getAttachedCallOperandBundleEnum(IsRetainRV))};
 llvm::OperandBundleDef OB("clang.arc.attachedcall", bundleArgs);
-auto *oldCall = cast(value);
 llvm::CallBase *newCall = llvm::CallBase::addOperandBundle(
 oldCall, llvm::LLVMContext::OB_clang_arc_attachedcall, OB, oldCall);
 newCall->copyMetadata(*oldCall);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97878: [DirectoryWatcher] Increase timeout to make test less flaky

2021-03-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: jkorous, arphaman, akyrtzi, gribozavr.
smeenai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We've observed this test being significantly flaky on our Mac CI
machines when we're running the full check-clang suite. It fails because
the wait_for condition isn't met within 3 seconds. We believe it's
because our CI machines are somewhat underpowered and pretty heavily
loaded when we're running the full check-clang suite.

I ran some experiments on increasing the timeout. I ran the full
check-clang suite 100 times with each timeout value and recorded how
many flaky failures we encountered in these tests. The results are:

3 second timeout (baseline): 20 failures
10 second timeout: 14 failures
20 second timeout: 4 failures
30 second timeout: 2 failures
40 second timeout: 1 failure
50 second timeout: 0 failures
60 second timeout: 0 failures

I ran another set of 100 tests for the 50 second timeout and observed
one flaky failure. By contrast, I ended up running check-clang 500 times
for the 60 second timeout and didn't observe a single flaky failure.
That's how the 60 second timeout value used in this patch was derived.

While a 60 second timeout might seem high, keep in mind that:

- This is a timeout, not a sleep; the test should require much less time the 
vast majority of instances, especially on more powerful machines.
- The long timeout is most likely to occur when other tests are also running at 
the same time, so the latency of the timeout will also be masked by the latency 
of the other tests.

See https://reviews.llvm.org/D58418?id=200123#inline-554211 for where
this timeout was originally introduced and the possibility of raising it
if it wasn't enough was discussed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97878

Files:
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp


Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -243,7 +243,7 @@
   std::thread worker(std::move(task));
   worker.detach();
 
-  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
+  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(60)) ==
   std::future_status::ready)
   << "The expected result state wasn't reached before the time-out.";
   std::unique_lock L(TestConsumer.Mtx);


Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -243,7 +243,7 @@
   std::thread worker(std::move(task));
   worker.detach();
 
-  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
+  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(60)) ==
   std::future_status::ready)
   << "The expected result state wasn't reached before the time-out.";
   std::unique_lock L(TestConsumer.Mtx);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97834: [WebAssembly] Disable uses of __clang_call_terminate

2021-03-03 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added a comment.

I agree this is a good approach, and I also like that it's smaller and simpler. 
In the future we can revisit whether following this particular Itanium 
convention buys us anything useful or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97834

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


[PATCH] D97824: [ObjC][ARC] Don't add operand bundle `clang.arc.attachedcall` to a call if the call already has the operand bundle

2021-03-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak planned changes to this revision.
ahatanak added a comment.

On second thought, I think we should emit a call to `@llvm.objc.retain` instead 
of a call to `@llvm.objc.retainAutoreleasedReturnValue`. I think we might want 
to remove ARC optimizer's code that converts calls to 
`@llvm.objc.retainAutoreleasedReturnValue` to calls to `@llvm.objc.retain` 
since it sometimes does the transformation when it shouldn't and we won't need 
that transformation once we switch to using the `clang.arc.attachedcall` 
operand bundle.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97824

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


[PATCH] D97101: [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Zequan Wu 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 rG2d7374a0c680: [Coverage] Emit gap region between statements 
if first statements contains… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/terminate-statements.cpp
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c

Index: compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
===
--- compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
+++ compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
@@ -21,9 +21,9 @@
 
 // CHECK-COVERAGE: Filename RegionsMissed Regions Cover   Functions  Missed Functions  Executed   Lines  Missed Lines Cover
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 180.00%
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 180.00%
 
 extern int __llvm_profile_is_continuous_mode_enabled(void);
 
Index: clang/test/CoverageMapping/unreachable-macro.c
===
--- clang/test/CoverageMapping/unreachable-macro.c
+++ clang/test/CoverageMapping/unreachable-macro.c
@@ -6,6 +6,7 @@
 void counters_in_macro_following_unreachable() {
   // CHECK-NEXT: File 0, [[@LINE-1]]:48 -> {{[0-9]+}}:2 = #0
   return;
+  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:10 -> [[@LINE+3]]:3 = 0
   // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:3 -> [[@LINE+2]]:8 = 0
   // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+2]]:2 = 0
   WHILE
Index: clang/test/CoverageMapping/trycatch.cpp
===
--- clang/test/CoverageMapping/trycatch.cpp
+++ clang/test/CoverageMapping/trycatch.cpp
@@ -13,7 +13,7 @@
 void func(int i) {// CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0
   // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:11 = #0
   if(i % 2) { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+4]]:4 = #1
-throw Error();
+throw Error();// CHECK-NEXT: Gap,File 0, [[@LINE]]:19 -> [[@LINE+1]]:5 = 0
 int j = 0;// CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:4 = 0
   // CHECK: File 0, [[@LINE+1]]:10 -> [[@LINE+2]]:27 = (#0 - #1)
   } else if(i == 8)   // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE]]:19 = (#0 - #1)
Index: clang/test/CoverageMapping/terminate-statements.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/terminate-statements.cpp
@@ -0,0 +1,343 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fexceptions -fcxx-exceptions -emit-llvm-only -triple %itanium_abi_triple -main-file-name terminate-statements.cpp -I %S/Inputs %s | FileCheck %s
+
+int f1() {
+  return 0;
+  return 0; // CHECK: Gap,File 0, [[@LINE-1]]:12 -> [[@LINE]]:3 = 0
+}
+
+int f2(int i) {
+  if (i)
+return 0;
+  else
+;   // CHECK: Gap,File 0, [[@LINE]]:6 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 1; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f3() {
+  for (int a = 1; a < 9; a--)
+return a; // CHECK: Gap,File 0, [[@LINE]]:14 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 0;   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f4(int i) {
+  while (i > 0) {
+i++;
+return i;
+  } // CHECK: File 0, [[@LINE]]:4 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 0; // 

[clang] 2d7374a - [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2021-03-03T11:25:49-08:00
New Revision: 2d7374a0c680f96bdcdb3d05034a93bf145d140f

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

LOG: [Coverage] Emit gap region between statements if first statements contains 
terminate statements.

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

Added: 
clang/test/CoverageMapping/terminate-statements.cpp

Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/break.c
clang/test/CoverageMapping/classtemplate.cpp
clang/test/CoverageMapping/continue.c
clang/test/CoverageMapping/coroutine.cpp
clang/test/CoverageMapping/label.cpp
clang/test/CoverageMapping/return.c
clang/test/CoverageMapping/switch.cpp
clang/test/CoverageMapping/switchmacro.c
clang/test/CoverageMapping/trycatch.cpp
clang/test/CoverageMapping/unreachable-macro.c
compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c

Removed: 
clang/test/CoverageMapping/deferred-region.cpp



diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 4a008b4ef632..8a11da600e4a 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -104,26 +104,21 @@ class SourceMappingRegion {
   /// The region's ending location.
   Optional LocEnd;
 
-  /// Whether this region should be emitted after its parent is emitted.
-  bool DeferRegion;
-
   /// Whether this region is a gap region. The count from a gap region is set
   /// as the line execution count if there are no other regions on the line.
   bool GapRegion;
 
 public:
   SourceMappingRegion(Counter Count, Optional LocStart,
-  Optional LocEnd, bool DeferRegion = 
false,
-  bool GapRegion = false)
-  : Count(Count), LocStart(LocStart), LocEnd(LocEnd),
-DeferRegion(DeferRegion), GapRegion(GapRegion) {}
+  Optional LocEnd, bool GapRegion = false)
+  : Count(Count), LocStart(LocStart), LocEnd(LocEnd), GapRegion(GapRegion) 
{
+  }
 
   SourceMappingRegion(Counter Count, Optional FalseCount,
   Optional LocStart,
-  Optional LocEnd, bool DeferRegion = 
false,
-  bool GapRegion = false)
+  Optional LocEnd, bool GapRegion = false)
   : Count(Count), FalseCount(FalseCount), LocStart(LocStart),
-LocEnd(LocEnd), DeferRegion(DeferRegion), GapRegion(GapRegion) {}
+LocEnd(LocEnd), GapRegion(GapRegion) {}
 
   const Counter () const { return Count; }
 
@@ -155,10 +150,6 @@ class SourceMappingRegion {
 return *LocEnd;
   }
 
-  bool isDeferred() const { return DeferRegion; }
-
-  void setDeferred(bool Deferred) { DeferRegion = Deferred; }
-
   bool isGap() const { return GapRegion; }
 
   void setGap(bool Gap) { GapRegion = Gap; }
@@ -544,10 +535,6 @@ struct CounterCoverageMappingBuilder
   /// A stack of currently live regions.
   std::vector RegionStack;
 
-  /// The currently deferred region: its end location and count can be set once
-  /// its parent has been popped from the region stack.
-  Optional DeferredRegion;
-
   CounterExpressionBuilder Builder;
 
   /// A location in the most recently visited file or macro.
@@ -556,8 +543,11 @@ struct CounterCoverageMappingBuilder
   /// expressions cross file or macro boundaries.
   SourceLocation MostRecentLocation;
 
-  /// Location of the last terminated region.
-  Optional> LastTerminatedRegion;
+  /// Whether the visitor at a terminate statement.
+  bool HasTerminateStmt = false;
+
+  /// Gap region counter after terminate statement.
+  Counter GapRegionCounter;
 
   /// Return a counter for the subtraction of \c RHS from \c LHS
   Counter subtractCounters(Counter LHS, Counter RHS) {
@@ -590,77 +580,13 @@ struct CounterCoverageMappingBuilder
 
 if (StartLoc && !FalseCount.hasValue()) {
   MostRecentLocation = *StartLoc;
-  completeDeferred(Count, MostRecentLocation);
 }
 
-RegionStack.emplace_back(Count, FalseCount, StartLoc, EndLoc,
- FalseCount.hasValue());
+RegionStack.emplace_back(Count, FalseCount, StartLoc, EndLoc);
 
 return RegionStack.size() - 1;
   }
 
-  /// Complete any pending deferred region by setting its end location and
-  /// count, and then pushing it onto the region stack.
-  size_t completeDeferred(Counter Count, SourceLocation DeferredEndLoc) {
-size_t Index = RegionStack.size();
-if (!DeferredRegion)
-  return Index;
-
-// Consume the pending region.
-SourceMappingRegion DR = DeferredRegion.getValue();
-DeferredRegion = None;
-
-// If the region ends in an expansion, find the expansion site.
-FileID StartFile = 

[PATCH] D97617: [clangd] ObjC fixes for semantic highlighting and xref highlights

2021-03-03 Thread Sam McCall 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 rG7d2fba8ddb90: [clangd] ObjC fixes for semantic highlighting 
and xref highlights (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97617

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -115,10 +115,23 @@
   f.[[^~]]Foo();
 }
   )cpp",
+  R"cpp(// ObjC methods with split selectors.
+@interface Foo
+  +(void) [[x]]:(int)a [[y]]:(int)b;
+@end
+@implementation Foo
+  +(void) [[x]]:(int)a [[y]]:(int)b {}
+@end
+void go() {
+  [Foo [[x]]:2 [[^y]]:4];
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = TestTU::withCode(T.code()).build();
+auto TU = TestTU::withCode(T.code());
+TU.ExtraArgs.push_back("-xobjective-c++");
+auto AST = TU.build();
 EXPECT_THAT(findDocumentHighlights(AST, T.point()), HighlightsFrom(T))
 << Test;
   }
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -75,6 +75,7 @@
   TU.Code = std::string(Test.code());
 
   TU.ExtraArgs.push_back("-std=c++20");
+  TU.ExtraArgs.push_back("-xobjective-c++");
 
   for (auto File : AdditionalFiles)
 TU.AdditionalFiles.insert({File.first, std::string(File.second)});
@@ -645,6 +646,48 @@
   R"cpp(
   <:[deprecated]:> int $Variable_decl_deprecated[[x]];
   )cpp",
+  R"cpp(
+// ObjC: Classes and methods
+@class $Class_decl[[Forward]];
+
+@interface $Class_decl[[Foo]]
+@end
+@interface $Class_decl[[Bar]] : $Class[[Foo]]
+-($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]];
++(void) $StaticMethod_decl_static[[explode]];
+@end
+@implementation $Class_decl[[Bar]]
+-($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]] {
+  return self;
+}
++(void) $StaticMethod_decl_static[[explode]] {}
+@end
+
+void $Function_decl[[m]]($Class[[Bar]] *$Parameter_decl[[b]]) {
+  [$Parameter[[b]] $Method[[x]]:1 $Method[[y]]:2];
+  [$Class[[Bar]] $StaticMethod_static[[explode]]];
+}
+  )cpp",
+  R"cpp(
+// ObjC: Protocols
+@protocol $Interface_decl[[Protocol]]
+@end
+@protocol $Interface_decl[[Protocol2]] <$Interface[[Protocol]]>
+@end
+@interface $Class_decl[[Klass]] <$Interface[[Protocol]]>
+@end
+// FIXME: protocol list in ObjCObjectType should be highlighted.
+id $Variable_decl[[x]];
+  )cpp",
+  R"cpp(
+// ObjC: Categories
+@interface $Class_decl[[Foo]]
+@end
+@interface $Class[[Foo]]($Namespace_decl[[Bar]])
+@end
+@implementation $Class[[Foo]]($Namespace_decl[[Bar]])
+@end
+  )cpp",
   };
   for (const auto  : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1593,6 +1593,35 @@
   "0: targets = {f}\n"
   "1: targets = {I::x}\n"
   "2: targets = {I::setY:}\n"},
+  {
+  // Objective-C: methods
+  R"cpp(
+@interface I
+  -(void) a:(int)x b:(int)y;
+@end
+void foo(I *i) {
+  [$0^i $1^a:1 b:2];
+}
+  )cpp",
+  "0: targets = {i}\n"
+  "1: targets = {I::a:b:}\n"
+  },
+  {
+  // Objective-C: protocols
+  R"cpp(
+@interface I
+@end
+@protocol P
+@end
+void foo() {
+  // FIXME: should reference P
+  $0^I *$1^x;
+}
+  

[clang-tools-extra] 7d2fba8 - [clangd] ObjC fixes for semantic highlighting and xref highlights

2021-03-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-03T20:16:08+01:00
New Revision: 7d2fba8ddb90cf018d9cfc852b68e4584b15678e

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

LOG: [clangd] ObjC fixes for semantic highlighting and xref highlights

- highlight references to protocols in class/protocol/extension decls
- support multi-token selector highlights in semantic + xref highlights
  (method calls and declarations only)
- In `@interface I(C)`, I now references the interface and C the category
- highlight uses of interfaces as types
- added semantic highlightings of protocol names (as "interface") and
  category names (as "namespace").
  These are both standard kinds, maybe "extension" will be standardized...
- highlight `auto` as "class" when it resolves to an ObjC pointer
- don't highlight `self` as a variable even though the AST models it as one

Not fixed: uses of protocols in type names (needs some refactoring of
unrelated code first)

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 64053797867d..16433151d902 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -12,6 +12,7 @@
 #include "support/Logger.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclVisitor.h"
@@ -633,6 +634,61 @@ llvm::SmallVector refInDecl(const Decl *D,
   /*IsDecl=*/false,
   {DG->getDeducedTemplate()}});
 }
+
+void VisitObjCMethodDecl(const ObjCMethodDecl *OMD) {
+  // The name may have several tokens, we can only report the first.
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OMD->getSelectorStartLoc(),
+  /*IsDecl=*/true,
+  {OMD}});
+}
+
+void visitProtocolList(
+llvm::iterator_range Protocols,
+llvm::iterator_range Locations) {
+  for (const auto  : llvm::zip(Protocols, Locations)) {
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+std::get<1>(P),
+/*IsDecl=*/false,
+{std::get<0>(P)}});
+  }
+}
+
+void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *OID) {
+  if (OID->isThisDeclarationADefinition())
+visitProtocolList(OID->protocols(), OID->protocol_locs());
+  Base::VisitObjCInterfaceDecl(OID); // Visit the interface's name.
+}
+
+void VisitObjCCategoryDecl(const ObjCCategoryDecl *OCD) {
+  visitProtocolList(OCD->protocols(), OCD->protocol_locs());
+  // getLocation is the extended class's location, not the category's.
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCD->getLocation(),
+  /*IsDecl=*/false,
+  {OCD->getClassInterface()}});
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCD->getCategoryNameLoc(),
+  /*IsDecl=*/true,
+  {OCD}});
+}
+
+void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *OCID) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCID->getLocation(),
+  /*IsDecl=*/false,
+  {OCID->getClassInterface()}});
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OCID->getCategoryNameLoc(),
+  /*IsDecl=*/true,
+  {OCID->getCategoryDecl()}});
+}
+
+void VisitObjCProtocolDecl(const ObjCProtocolDecl *OPD) {
+  if (OPD->isThisDeclarationADefinition())
+visitProtocolList(OPD->protocols(), OPD->protocol_locs());
+  Base::VisitObjCProtocolDecl(OPD); // Visit the protocol's name.
+}
   };
 
   Visitor V{Resolver};
@@ -711,6 +767,14 @@ llvm::SmallVector refInStmt(const Stmt *S,
   explicitReferenceTargets(DynTypedNode::create(*E), {}, 

[PATCH] D97101: [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

Thanks for reviewing.




Comment at: clang/test/CoverageMapping/switch.cpp:62
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> 
[[@LINE-1]]:10 = #4, (#0 - #4)
+  }

vsk wrote:
> zequanwu wrote:
> > vsk wrote:
> > > The blank space after `default: break;` and before the closing '}' should 
> > > have the same count as the switch condition, I thought (this goes for all 
> > > of the unreachable code within a switch body)? The idea is to prevent 
> > > 'not-executed' regions from appearing after the `break` stmt.
> > Yes, they are unreachable. So, shouldn't they always have zero count 
> > instead of same count as switch condition?
> I see, you're right. We use a gap region with zero count to cover the area 
> after break. That's actually documented here: 
> https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#switch-statements. 
> One interesting point is that there's only one gap region that covers the 
> whole body; in this example, that would be `Gap,File 0, [[@LINE]]:13 -> 
> [[@LINE+8]]:10 = 0`. So, perhaps the new gaps emitted in switches are 
> redundant, but getting rid of them is just a performance optimization.
Yes, they are redundant. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

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


[PATCH] D97101: [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 327859.
zequanwu added a comment.

use itanium abi in terminate-statements.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/terminate-statements.cpp
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c

Index: compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
===
--- compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
+++ compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
@@ -21,9 +21,9 @@
 
 // CHECK-COVERAGE: Filename RegionsMissed Regions Cover   Functions  Missed Functions  Executed   Lines  Missed Lines Cover
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 180.00%
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 180.00%
 
 extern int __llvm_profile_is_continuous_mode_enabled(void);
 
Index: clang/test/CoverageMapping/unreachable-macro.c
===
--- clang/test/CoverageMapping/unreachable-macro.c
+++ clang/test/CoverageMapping/unreachable-macro.c
@@ -6,6 +6,7 @@
 void counters_in_macro_following_unreachable() {
   // CHECK-NEXT: File 0, [[@LINE-1]]:48 -> {{[0-9]+}}:2 = #0
   return;
+  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:10 -> [[@LINE+3]]:3 = 0
   // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:3 -> [[@LINE+2]]:8 = 0
   // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+2]]:2 = 0
   WHILE
Index: clang/test/CoverageMapping/trycatch.cpp
===
--- clang/test/CoverageMapping/trycatch.cpp
+++ clang/test/CoverageMapping/trycatch.cpp
@@ -13,7 +13,7 @@
 void func(int i) {// CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0
   // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:11 = #0
   if(i % 2) { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+4]]:4 = #1
-throw Error();
+throw Error();// CHECK-NEXT: Gap,File 0, [[@LINE]]:19 -> [[@LINE+1]]:5 = 0
 int j = 0;// CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:4 = 0
   // CHECK: File 0, [[@LINE+1]]:10 -> [[@LINE+2]]:27 = (#0 - #1)
   } else if(i == 8)   // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE]]:19 = (#0 - #1)
Index: clang/test/CoverageMapping/terminate-statements.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/terminate-statements.cpp
@@ -0,0 +1,343 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fexceptions -fcxx-exceptions -emit-llvm-only -triple %itanium_abi_triple -main-file-name terminate-statements.cpp -I %S/Inputs %s | FileCheck %s
+
+int f1() {
+  return 0;
+  return 0; // CHECK: Gap,File 0, [[@LINE-1]]:12 -> [[@LINE]]:3 = 0
+}
+
+int f2(int i) {
+  if (i)
+return 0;
+  else
+;   // CHECK: Gap,File 0, [[@LINE]]:6 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 1; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f3() {
+  for (int a = 1; a < 9; a--)
+return a; // CHECK: Gap,File 0, [[@LINE]]:14 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 0;   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f4(int i) {
+  while (i > 0) {
+i++;
+return i;
+  } // CHECK: File 0, [[@LINE]]:4 -> [[@LINE+1]]:3 = (#0 - #1)
+  return 0; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = (#0 - #1)
+}
+
+int f5(int i) {
+  do {
+return i;
+  } while (i > 0); // CHECK: Gap,File 0, 

[PATCH] D97819: [CMake] Enable Polly for Fuchsia toolchain build

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

As a contributor to Polly, this makes me happy to see ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97819

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


[PATCH] D97535: [clangd] Use URIs instead of paths in the index file list

2021-03-03 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 327853.
ArcsinX added a comment.

- use URIs as keys
- create the file list from the keys


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97535

Files:
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/test/memory_tree.test
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp

Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -229,7 +229,7 @@
   RefSlab Refs;
   auto Size = Symbols.bytes() + Refs.bytes();
   auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
-  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  llvm::StringSet<> Files = {"unittest:///foo.cc", "unittest:///bar.cc"};
   MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
  std::move(Files), IndexContents::All, std::move(Data), Size);
   auto ContainsFile = I.indexedFiles();
@@ -506,7 +506,7 @@
   RefSlab DynRefs;
   auto DynSize = DynSymbols.bytes() + DynRefs.bytes();
   auto DynData = std::make_pair(std::move(DynSymbols), std::move(DynRefs));
-  llvm::StringSet<> DynFiles = {testPath("foo.cc")};
+  llvm::StringSet<> DynFiles = {"unittest:///foo.cc"};
   MemIndex DynIndex(std::move(DynData.first), std::move(DynData.second),
 RelationSlab(), std::move(DynFiles), IndexContents::Symbols,
 std::move(DynData), DynSize);
@@ -514,7 +514,7 @@
   RefSlab StaticRefs;
   auto StaticData =
   std::make_pair(std::move(StaticSymbols), std::move(StaticRefs));
-  llvm::StringSet<> StaticFiles = {testPath("foo.cc"), testPath("bar.cc")};
+  llvm::StringSet<> StaticFiles = {"unittest:///foo.cc", "unittest:///bar.cc"};
   MemIndex StaticIndex(
   std::move(StaticData.first), std::move(StaticData.second), RelationSlab(),
   std::move(StaticFiles), IndexContents::References, std::move(StaticData),
Index: clang-tools-extra/clangd/unittests/DexTests.cpp
===
--- clang-tools-extra/clangd/unittests/DexTests.cpp
+++ clang-tools-extra/clangd/unittests/DexTests.cpp
@@ -737,7 +737,7 @@
   RefSlab Refs;
   auto Size = Symbols.bytes() + Refs.bytes();
   auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
-  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  llvm::StringSet<> Files = {"unittest:///foo.cc", "unittest:///bar.cc"};
   Dex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
 std::move(Files), IndexContents::All, std::move(Data), Size);
   auto ContainsFile = I.indexedFiles();
Index: clang-tools-extra/clangd/test/memory_tree.test
===
--- clang-tools-extra/clangd/test/memory_tree.test
+++ clang-tools-extra/clangd/test/memory_tree.test
@@ -23,7 +23,9 @@
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
 # CHECK-NEXT:   "slabs": {
-# CHECK-NEXT: "{{.*}}main.cpp": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}},
+# CHECK-NEXT: "test:///main.cpp": {
 # CHECK-NEXT:   "_self": {{[0-9]+}},
 # CHECK-NEXT:   "_total": {{[0-9]+}},
 # CHECK-NEXT:   "references": {
@@ -38,9 +40,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   }
-# CHECK-NEXT: },
-# CHECK-NEXT: "_self": {{[0-9]+}},
-# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT: }
 # CHECK-NEXT:   }
 # CHECK-NEXT: },
 # CHECK-NEXT: "preamble": {
Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -316,14 +316,7 @@
 llvm::unique_function
 Dex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-if (Files.empty())
-  return IndexContents::None;
-auto Path = URI::resolve(FileURI, Files.begin()->first());
-if (!Path) {
-  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
-  return IndexContents::None;
-}
-return Files.contains(*Path) ? IdxContents : IndexContents::None;
+return Files.contains(FileURI) ? IdxContents : IndexContents::None;
   };
 }
 
Index: clang-tools-extra/clangd/index/MemIndex.cpp
===
--- 

[PATCH] D97834: [WebAssembly] Disable uses of __clang_call_terminate

2021-03-03 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.
This revision is now accepted and ready to land.

Nice, this actually looks like a good simplification in addition to fixing the 
specific problem.




Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4650
+  // Itanium ABI calls __clang_call_terminate(), which __cxa_begin_catch() on
+  // the violating exception to mark it handled, but it is currently hard to dl
+  // with wasm EH instruction structure with catch/catch_all, we just call




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97834

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


[PATCH] D89490: Introduce __attribute__((darwin_abi))

2021-03-03 Thread Adrien Guinet via Phabricator via cfe-commits
aguinet added a comment.

So, what could be the futur of that patch? Would that be okay to merge with a 
`target_abi` Clang attribute?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89490

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

I don't think we have any tests that explicitly use valgrind and testing with 
valgrind enabled is an optional thing. I would be fine landing this as-is 
without a test case if it turns out that testing this is too involved, so I'm 
accepting the review. However, if it turns out there is a way to test it that 
others can think of, I would appreciate adding the test coverage (even if it's 
post-commit).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Just a few minor nits from me, but I'm mostly wondering: where are we at with 
this and are there still substantive changes required? (I looked through the 
comments, but there's a lot of back-and-forth since Oct and I'm not certain 
what's holding the patch back currently.)




Comment at: clang/include/clang/AST/Type.h:492
+(isPtrSizeAddressSpace(B) || B == LangAS::Default)) ||
+   // Default is a superset of SYCL address spaces
+   (A == LangAS::Default &&





Comment at: clang/lib/AST/ItaniumMangle.cpp:2379
   unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
-  if (TargetAS != 0)
+  if (TargetAS != 0 || 
(Context.getASTContext().getLangOpts().SYCLIsDevice))
 ASString = "AS" + llvm::utostr(TargetAS);





Comment at: clang/lib/Basic/Targets/SPIR.h:71-75
+if (Triple.getEnvironment() == llvm::Triple::SYCLDevice) {
+  AddrSpaceMap = 
+} else {
+  AddrSpaceMap = 
+}





Comment at: clang/lib/CodeGen/TargetInfo.cpp:9997
+if (auto ConstAS = CGM.getTarget().getConstantAddressSpace())
+  return ConstAS.getValue();
+  }

I called it out because it wasn't clear to me what the type actually was, but I 
see now that it's an `Optional`. I think it's useful to know that we're 
dealing with an optional, but it's not crucial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D97849#2600300 , @teemperor wrote:

> We can (and do) run LIT tests under valgrind, so if you have a test that 
> triggers this valgrind error then that seems like the way to go. I don't 
> think the test has to deterministically fail outside valgrind to be a valid 
> test.

Do you mean to use lit with `--vg` or should we explicitly call valgrind in a 
lit test? If the latter, could you please show an example how to do that 
properly (I could not find any explicit valgrind call, not even in lldb) ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D97849: [AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

2021-03-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D97849#2600220 , @steakhal wrote:

> In D97849#2600201 , @aaron.ballman 
> wrote:
>
>> This looks reasonable to me (good catch!), but is there a way for us to add 
>> a regression test for it?
>
> I'm not sure if it's possible to write a test for deterministically 
> demonstrating the bug - which is a non-deterministic crash.
> So, even if we would have a test case, that would not catch the regression 
> deterministically.
> We could include the minimal reproducer for CTU analysis - the way we 
> observed and tracked down this crash.
>
> AFAIK, it did not reproduce with memory sanitizers.

Address and ubsan could not catch it (LLVM_USE_SANITIZER: Address;Undefined). 
And I had trouble with the Memory and MemoryWithOrigins setup because ninja 
could not generate the .inc files since clang-tblgen failed always with 
uninited errors. Fortunately, vlagrind could catch the error consistently all 
the time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97849

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


[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

2021-03-03 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: steakhal, NoQ, xazax.hun, vsavchenko, 
Eugene.Zelenko.
ASDenysPetrov added a project: clang.
Herald added subscribers: martong, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Improve `SValBuilder::evalCast` function in a part of **integer **to **bool 
**cast. Сonvert known `SymbolVal` `RangeSet` to `ConcreteInt` if possible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97874

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/cast_symbolic_ints_to_bool.cpp

Index: clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
===
--- /dev/null
+++ clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+template 
+void clang_analyzer_dump(T);
+
+void test_int_to_bool(bool b, int x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x < 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_char_to_bool(char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+  if (x < 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(bool b, unsigned x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(unsigned char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+  if (x < 42) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+if (x) {
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+} else {
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -870,11 +870,18 @@
   // Symbol to bool.
   if (!OriginalTy.isNull() && CastTy->isBooleanType()) {
 // Non-float to bool.
-if (Loc::isLocType(OriginalTy) ||
-OriginalTy->isIntegralOrEnumerationType() ||
-OriginalTy->isMemberPointerType()) {
+if (OriginalTy->isIntegralOrEnumerationType()) {
   BasicValueFactory  = getBasicValueFactory();
-  return makeNonLoc(SE, BO_NE, BVF.getValue(0, SE->getType()), CastTy);
+  const llvm::APSInt  = BVF.getValue(0, OriginalTy);
+  bool IsZero, IsNotZero;
+  std::tie(IsZero, IsNotZero) =
+  getStateManager().getConstraintManager().isSymValWithinOrOutsideRange(
+  State, SE, Zero, Zero);
+  // Symbolic pointer, integer to bool.
+  if (IsZero || IsNotZero)
+return makeTruthVal(IsNotZero, CastTy);
+  // Symbolic integer to bool.
+  return V;
 }
   } else {
 // Symbol to integer.
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1278,6 +1278,9 @@
 
   const llvm::APSInt *getSymVal(ProgramStateRef State,
 SymbolRef Sym) const override;
+  std::pair
+  isSymValWithinOrOutsideRange(ProgramStateRef State, SymbolRef Sym,
+   llvm::APSInt lower, llvm::APSInt upper) override;
 
   ProgramStateRef removeDeadBindings(ProgramStateRef State,
  SymbolReaper ) override;
@@ -1875,6 +1878,15 @@
   return T ? T->getConcreteValue() : nullptr;
 }
 
+std::pair RangeConstraintManager::isSymValWithinOrOutsideRange(
+ProgramStateRef St, SymbolRef Sym, llvm::APSInt lower, llvm::APSInt upper) {
+  if (const RangeSet *T = getConstraint(St, Sym)) {
+RangeSet 

[PATCH] D97872: [clang] Don't assert in EmitAggregateCopy on trivial_abi types

2021-03-03 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes PR42961.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97872

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp


Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -262,3 +262,6 @@
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
+
+// PR42961
+Small (*fp)() = []() -> Small {};
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -2056,7 +2056,7 @@
   Record->hasTrivialCopyAssignment() ||
   Record->hasTrivialMoveConstructor() ||
   Record->hasTrivialMoveAssignment() ||
-  Record->isUnion()) &&
+  Record->hasAttr() || Record->isUnion()) &&
  "Trying to aggregate-copy a type without a trivial copy/move "
  "constructor or assignment operator");
   // Ignore empty classes in C++.


Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -262,3 +262,6 @@
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
+
+// PR42961
+Small (*fp)() = []() -> Small {};
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -2056,7 +2056,7 @@
   Record->hasTrivialCopyAssignment() ||
   Record->hasTrivialMoveConstructor() ||
   Record->hasTrivialMoveAssignment() ||
-  Record->isUnion()) &&
+  Record->hasAttr() || Record->isUnion()) &&
  "Trying to aggregate-copy a type without a trivial copy/move "
  "constructor or assignment operator");
   // Ignore empty classes in C++.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94627: [PowerPC][PC Rel] Implement option to omit Power10 instructions from stubs

2021-03-03 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 327839.
Conanap added a comment.

Updated 2 test cases and some nits


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

https://reviews.llvm.org/D94627

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/Thunks.cpp
  lld/ELF/Thunks.h
  lld/test/ELF/ppc64-call-reach.s
  lld/test/ELF/ppc64-long-branch-localentry-offset.s
  lld/test/ELF/ppc64-long-branch-pi.s
  lld/test/ELF/ppc64-long-branch-rel14.s
  lld/test/ELF/ppc64-long-branch.s
  lld/test/ELF/ppc64-pcrel-call-to-extern.s
  lld/test/ELF/ppc64-pcrel-call-to-toc.s
  lld/test/ELF/ppc64-plt-stub-compatible.s
  lld/test/ELF/ppc64-tls-pcrel-gd.s
  lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
  lld/test/ELF/ppc64-toc-call-to-pcrel.s
  llvm/include/llvm/Object/ELF.h

Index: llvm/include/llvm/Object/ELF.h
===
--- llvm/include/llvm/Object/ELF.h
+++ llvm/include/llvm/Object/ELF.h
@@ -87,6 +87,9 @@
 
 enum PPCInstrMasks : uint64_t {
   PADDI_R12_NO_DISP = 0x06103980,
+  ADDIS_R12_TO_R2_NO_DISP = 0x3D82,
+  ADDI_R12_TO_R2_NO_DISP = 0x3982,
+  ADDI_R12_TO_R12_NO_DISP = 0x398C,
   PLD_R12_NO_DISP = 0x0410E580,
   MTCTR_R12 = 0x7D8903A6,
   BCTR = 0x4E800420,
Index: lld/test/ELF/ppc64-toc-call-to-pcrel.s
===
--- lld/test/ELF/ppc64-toc-call-to-pcrel.s
+++ lld/test/ELF/ppc64-toc-call-to-pcrel.s
@@ -14,6 +14,12 @@
 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t | FileCheck %s
 
+# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
+# RUN: ld.lld -T %t.script %t.o -o %t --no-power10-stubs
+# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
+# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t \
+# RUN: | FileCheck %s
+
 # The point of this test is to make sure that when a function with TOC access
 # a local function with st_other=1, a TOC save stub is inserted.
 
Index: lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
===
--- lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
+++ lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
@@ -11,15 +11,20 @@
 # RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_be | FileCheck %s
 # RUN: llvm-readelf -s %t_be | FileCheck %s --check-prefix=SYM
 
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
+# RUN: ld.lld -T %t/lts %t.o -o %t_le --no-power10-stubs
+# RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_le | FileCheck %s --check-prefix=NoP10
+# RUN: llvm-readelf -s %t_le | FileCheck %s --check-prefix=SYM
+
 # SYM:  Symbol table '.symtab' contains 9 entries:
 # SYM:  1: 1001 0 NOTYPE  LOCAL  DEFAULT []   1 callee
 # SYM-NEXT: 2: 10020008 0 NOTYPE  LOCAL  DEFAULT  2 caller_close
 # SYM-NEXT: 3: 20020008 0 NOTYPE  LOCAL  DEFAULT []   3 caller
 # SYM-NEXT: 4: 000520020008 0 NOTYPE  LOCAL  DEFAULT  4 caller_far
-# SYM-NEXT: 5: 000520028038 0 NOTYPE  LOCAL  HIDDEN   6 .TOC.
+# SYM-NEXT: 5: 000520028040 0 NOTYPE  LOCAL  HIDDEN   6 .TOC.
 # SYM-NEXT: 6: 10020020 8 FUNCLOCAL  DEFAULT  2 __toc_save_callee
-# SYM-NEXT: 7: 2002002020 FUNCLOCAL  DEFAULT  3 __toc_save_callee
-# SYM-NEXT: 8: 00052002002020 FUNCLOCAL  DEFAULT  4 __toc_save_callee
+# SYM-NEXT: 7: 2002002032 FUNCLOCAL  DEFAULT  3 __toc_save_callee
+# SYM-NEXT: 8: 00052002002032 FUNCLOCAL  DEFAULT  4 __toc_save_callee
 
 #--- lts
 PHDRS {
@@ -72,6 +77,17 @@
 # CHECK-NEXT:paddi 12, 0, -268501028, 1
 # CHECK-NEXT:mtctr 12
 # CHECK-NEXT:bctr
+
+# NoP10-LABEL: :
+# NoP10: bl 0x20020020
+# NoP10-NEXT:ld 2, 24(1)
+# NoP10-NEXT:blr
+# NoP10-LABEL: <__toc_save_callee>:
+# NoP10-NEXT: std 2, 24(1)
+# NoP10-NEXT:addis 12, 2, -4098
+# NoP10-NEXT:addi 12, 12, 32704
+# NoP10-NEXT:mtctr 12
+# NoP10-NEXT:bctr
 .section .text_caller, "ax", %progbits
 .Lfunc_toc2:
   .quad .TOC.-.Lfunc_gep2
Index: lld/test/ELF/ppc64-tls-pcrel-gd.s
===
--- lld/test/ELF/ppc64-tls-pcrel-gd.s
+++ lld/test/ELF/ppc64-tls-pcrel-gd.s
@@ -42,10 +42,10 @@
 #--- asm
 
 # GD-RELOC: Relocation section '.rela.dyn' at offset 0x100b8 contains 4 entries:
-# GD-RELOC: 01001160  00010044 R_PPC64_DTPMOD64    x + 0
-# GD-RELOC: 01001168  0001004e R_PPC64_DTPREL64    x + 0
-# GD-RELOC: 01001170  00030044 R_PPC64_DTPMOD64    y + 0
-# GD-RELOC: 01001178  0003004e R_PPC64_DTPREL64    y + 

[PATCH] D97871: Update diagnostic groups for pre-compat warnings

2021-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall.
aaron.ballman requested review of this revision.
Herald added a project: clang.

As a follow-up to D95691 , add new diagnostic 
groups named `pre-c++N-compat` to replace the old diagnostic groups with the 
standards listed out explicitly. The old group names are retained for backwards 
compatibility.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97871

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/Parser/static_assert.c
  clang/test/SemaCXX/cxx98-compat-pedantic.cpp
  clang/test/SemaCXX/inline.cpp


Index: clang/test/SemaCXX/inline.cpp
===
--- clang/test/SemaCXX/inline.cpp
+++ clang/test/SemaCXX/inline.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s 
-Wc++98-c++11-c++14-compat
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s -Wpre-c++17-compat
 
 // Check that we don't allow illegal uses of inline
 // (checking C++-only constructs here)
Index: clang/test/SemaCXX/cxx98-compat-pedantic.cpp
===
--- clang/test/SemaCXX/cxx98-compat-pedantic.cpp
+++ clang/test/SemaCXX/cxx98-compat-pedantic.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98
 
-// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s 
-Wno-c++98-c++11-compat-pedantic -DCXX1Y2
+// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s 
-Wno-pre-c++14-compat-pedantic -DCXX1Y2
 
 // -Wc++98-compat-pedantic warns on C++11 features which we accept without a
 // warning in C++98 mode.
Index: clang/test/Parser/static_assert.c
===
--- clang/test/Parser/static_assert.c
+++ clang/test/Parser/static_assert.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify=cxx17-pedantic 
-x c++ %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify=cxx98 -x c++ %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -pedantic -verify=cxx98-pedantic 
-x c++ %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-c++11-c++14-compat 
-verify=cxx17-compat -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wpre-c++17-compat 
-verify=cxx17-compat -x c++ %s
 
 // cxx17-no-diagnostics
 
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -253,22 +253,30 @@
 // Name of this warning in GCC.
 def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>;
 
-// Warnings for C2x code which is not compatible with prior C standards.
+// Warnings for C code which is not compatible with previous C standards.
 def CPre2xCompat : DiagGroup<"pre-c2x-compat">;
 def CPre2xCompatPedantic : DiagGroup<"pre-c2x-compat-pedantic",
  [CPre2xCompat]>;
 
-// Warnings for C++1y code which is not compatible with prior C++ standards.
-def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">;
-def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic",
+// Warnings for C++ code which is not compatible with previous C++ standards.
+def CXXPre14Compat : DiagGroup<"pre-c++14-compat">;
+def : DiagGroup<"c++98-c++11-compat", [CXXPre14Compat]>;
+def CXXPre14CompatPedantic : DiagGroup<"pre-c++14-compat-pedantic",
[CXXPre14Compat,
 CXXPre14CompatBinaryLiteral]>;
-def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">;
-def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
+def : DiagGroup<"c++98-c++11-compat-pedantic", [CXXPre14CompatPedantic]>;
+def CXXPre17Compat : DiagGroup<"pre-c++17-compat">;
+def : DiagGroup<"c++98-c++11-c++14-compat", [CXXPre17Compat]>;
+def CXXPre17CompatPedantic : DiagGroup<"pre-c++17-compat-pedantic",
[CXXPre17Compat]>;
-def CXXPre20Compat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
-def CXXPre20CompatPedantic : 
DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
+def : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
+[CXXPre17CompatPedantic]>;
+def CXXPre20Compat : DiagGroup<"pre-c++20-compat">;
+def : DiagGroup<"c++98-c++11-c++14-c++17-compat", [CXXPre20Compat]>;
+def CXXPre20CompatPedantic : DiagGroup<"pre-c++20-compat-pedantic",
[CXXPre20Compat]>;
+def : DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
+[CXXPre20CompatPedantic]>;
 def CXXPre2bCompat : DiagGroup<"pre-c++2b-compat">;
 def 

[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-03-03 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

I tested this with `FLANG_BUILD_NEW_DRIVER` set to`On` and `Off` - all works 
fine. It's been a tricky patch @arnamoy10 , thank you for all the effort!

I believe that you've addressed all of @tskeith comments too. In my opinion 
this is ready to be merged (though I'd wait 1 day just in case).


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

https://reviews.llvm.org/D96344

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


[PATCH] D97101: [Coverage] Emit gap region between statements if first statements contains terminate statements.

2021-03-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, this looks great.




Comment at: clang/test/CoverageMapping/switch.cpp:62
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> 
[[@LINE-1]]:10 = #4, (#0 - #4)
+  }

zequanwu wrote:
> vsk wrote:
> > The blank space after `default: break;` and before the closing '}' should 
> > have the same count as the switch condition, I thought (this goes for all 
> > of the unreachable code within a switch body)? The idea is to prevent 
> > 'not-executed' regions from appearing after the `break` stmt.
> Yes, they are unreachable. So, shouldn't they always have zero count instead 
> of same count as switch condition?
I see, you're right. We use a gap region with zero count to cover the area 
after break. That's actually documented here: 
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#switch-statements. One 
interesting point is that there's only one gap region that covers the whole 
body; in this example, that would be `Gap,File 0, [[@LINE]]:13 -> 
[[@LINE+8]]:10 = 0`. So, perhaps the new gaps emitted in switches are 
redundant, but getting rid of them is just a performance optimization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 327825.
stevewan added a comment.

Reflect varible is unused in its name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";

[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

If possible to add a fragment of what is generated it would be great!


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

https://reviews.llvm.org/D97869

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97058#2600160 , @azabaznov wrote:

> Check 'isEnabled' is now private: it is used only for non-core or 
> non-optional core features;
> creation of implicit type definitions is guarder with extension support 
> check; minor refactoring

Ok, I think we could remove further the differences between extensions and 
features wrt pragmas as suggested in the comments but it is also ok if we do 
separately. This is definitely a step closer to the end goal of simplifying and 
unifying the handling of extensions and features and removing the confusion 
about the pragmas.




Comment at: clang/lib/Sema/Sema.cpp:364
   for (auto  : Atomic64BitTypes)
 setOpenCLExtensionForType(I,
 "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics");

I think this should be lifted into the above if statement? Although since we 
are adding the types conditionally we could even drop this code completely and 
let the developers just use the types as they are already added and made 
available by the frontend.



Comment at: clang/lib/Sema/Sema.cpp:376
+addImplicitTypedef(#ExtType, Context.Id##Ty);  
\
+setOpenCLExtensionForType(Context.Id##Ty, #Ext);   
\
+  }

Since we are guarding by the feature/extension support we could even remove the 
need for pragma in order to use the types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-03 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, azabaznov.
Herald added subscribers: jfb, yaxunl.
svenvh requested review of this revision.

Add a new clang-tblgen flag `-gen-clang-opencl-builtin-tests` that
generates a .cl file containing calls to every builtin function
defined in the .td input.

This patch does not add any use of the new flag, so the only way to
obtain a generated test file is through a manual invocation of
clang-tblgen.


https://reviews.llvm.org/D97869

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -118,6 +118,8 @@
 
 void EmitClangOpenCLBuiltins(llvm::RecordKeeper ,
  llvm::raw_ostream );
+void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper ,
+ llvm::raw_ostream );
 
 void EmitClangDataCollectors(llvm::RecordKeeper ,
  llvm::raw_ostream );
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangCommentCommandInfo,
   GenClangCommentCommandList,
   GenClangOpenCLBuiltins,
+  GenClangOpenCLBuiltinTests,
   GenArmNeon,
   GenArmFP16,
   GenArmBF16,
@@ -191,6 +192,8 @@
"documentation comments"),
 clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
"Generate OpenCL builtin declaration handlers"),
+clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
+   "Generate OpenCL builtin declaration tests"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
 clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
@@ -362,6 +365,9 @@
   case GenClangOpenCLBuiltins:
 EmitClangOpenCLBuiltins(Records, OS);
 break;
+  case GenClangOpenCLBuiltinTests:
+EmitClangOpenCLBuiltinTests(Records, OS);
+break;
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -228,6 +228,64 @@
   // same entry ().
   MapVector SignatureListMap;
 };
+
+// OpenCL builtin test generator.  This class processes the same TableGen input
+// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
+// builtin function described in the .td input.
+class OpenCLBuiltinTestEmitter {
+public:
+  OpenCLBuiltinTestEmitter(RecordKeeper , raw_ostream )
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions for testing all OpenCL builtin
+  // functions.
+  void Emit();
+
+private:
+  struct TypeFlags {
+TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
+bool IsConst : 1;
+bool IsVolatile : 1;
+bool IsPointer : 1;
+StringRef AddrSpace;
+  };
+
+  // Return a string representation of the given type, such that it can be
+  // used as a type in OpenCL C code.
+  std::string getTypeString(const Record *Type, TypeFlags Flags,
+int VectorSize) const;
+
+  // Return the type(s) and vector size(s) for the given type.  For
+  // non-GenericTypes, the resulting vectors will contain 1 element.  For
+  // GenericTypes, the resulting vectors typically contain multiple elements.
+  void getTypeLists(Record *Type, TypeFlags ,
+std::vector ,
+std::vector ) const;
+
+  // Expand the TableGen Records representing a builtin function signature into
+  // one or more function signatures.  Return them as a vector of a vector of
+  // strings, with each string containing an OpenCL C type and optional
+  // qualifiers.
+  //
+  // The Records may contain GenericTypes, which expand into multiple
+  // signatures.  Repeated occurrences of GenericType in a signature expand to
+  // the same types.  For example [char, FGenType, FGenType] expands to:
+  //   [char, float, float]
+  //   [char, float2, float2]
+  //   [char, float3, float3]
+  //   ...
+  void
+  expandTypesInSignature(const std::vector ,
+ SmallVectorImpl> );
+
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper 
+
+  // The output file.
+  raw_ostream 
+};
+
 } // namespace
 
 void BuiltinNameEmitter::Emit() {
@@ -816,7 +874,192 @@
   OS << "\n} 

[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision.
jsji added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:403
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);

stevewan wrote:
> jsji wrote:
> > `micro` unsed.
> Sorry I missed this comment. I agree that the unused `micro` is a bit ugly, 
> do you have a preference on how you'd like it to be improved? We don't have 
> an existing query for only `major` and `minor`, and creating one seems 
> unnecessary IMHO. If you think renaming the variable to `unused_micro` 
> mitigates the problem, I can do that.
That's ok to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

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


[PATCH] D97857: [Matrix] Add support for matrix-by-scalar division.

2021-03-03 Thread Everton Constantino via Phabricator via cfe-commits
everton.constantino added inline comments.



Comment at: clang/test/CodeGen/matrix-type-operators.c:303
 }
 
+// CHECK-LABEL: @divide_double_matrix_scalar_float(

Shouldn't a test for half floating point be added here as well? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97857

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


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:403
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);

jsji wrote:
> `micro` unsed.
Sorry I missed this comment. I agree that the unused `micro` is a bit ugly, do 
you have a preference on how you'd like it to be improved? We don't have an 
existing query for only `major` and `minor`, and creating one seems unnecessary 
IMHO. If you think renaming the variable to `unused_micro` mitigates the 
problem, I can do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97823

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


[PATCH] D95745: Support unwinding from inline assembly

2021-03-03 Thread Paul via Phabricator via cfe-commits
cynecx added a comment.

Weekly ping :)


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

https://reviews.llvm.org/D95745

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


[PATCH] D97854: [RFC][nsan] A Floating-point numerical sanitizer.

2021-03-03 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

When bootstrapping LLVM with nsan, there are only a few issues.

Several of them stem from using `double` to measure elapsed time in seconds: We 
measure start time, end time, and subtract them. The resulting error depends on 
the arbitrary magnitude of the time since epoch, so as time passes the error 
will increase. This is especially visible when we measure short intervals of 
time (e.g. a few microseconds, which are small compared to the time since 
epoch).

For example one test has more than 2% error:

  WARNING: NumericalStabilitySanitizer: inconsistent shadow results while 
checking store to address 0x4b87860
  double   precision  (native): dec: 0.0858306884765625  hex: 
0x1.2000p-17
  __float128   precision  (shadow): dec: 0.08806000  hex: 
0x9.3bd7b64e9fe4fc00p-20
  shadow truncated to double  : dec: 0.08806000  hex: 
0x1.277af6c9d3fca000p-17
  Relative error: 2.53158247040370201937% (2^47 epsilons)
  Absolute error: 0x1.debdb274ff27e000p-23
  (131595325226954 ULPs == 14.1 digits == 46.9 bits)
  #0 0x119db71 in llvm::TimeRecord::operator-=(llvm::TimeRecord const&) 
[...]/llvm/llvm-project/llvm/include/llvm/Support/Timer.h:63:14
  #1 0x119db71 in llvm::Timer::stopTimer() 
[...]/llvm/llvm-project/llvm/lib/Support/Timer.cpp:176:8
  #2 0x108b1d2 in llvm::TimePassesHandler::stopTimer(llvm::StringRef) 
[...]/llvm/llvm-project/llvm/lib/IR/PassTimingInfo.cpp:248:14
  #3 0x108b1d2 in llvm::TimePassesHandler::runAfterPass(llvm::StringRef) 
[...]/llvm/llvm-project/llvm/lib/IR/PassTimingInfo.cpp:267:3
  #4 0x108e159 in 
llvm::TimePassesHandler::registerCallbacks(llvm::PassInstrumentationCallbacks&)::$_2::operator()(llvm::StringRef,
 llvm::Any, llvm::PreservedAnalyses const&) const 
[...]/llvm/llvm-project/llvm/lib/IR/PassTimingInfo.cpp:281:15
  #5 0x108e159 in void llvm::detail::UniqueFunctionBase::CallImpl(void*,
 llvm::StringRef, llvm::Any&, llvm::PreservedAnalyses const&) 
[...]/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:204:12
  #6 0xa4f826 in llvm::unique_function::operator()(llvm::StringRef, llvm::Any, 
llvm::PreservedAnalyses const&) 
[...]/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:366:12
  #7 0xa4f826 in void llvm::PassInstrumentation::runAfterPass((anonymous namespace)::MyPass2 const&, 
llvm::Module const&, llvm::PreservedAnalyses const&) const 
[...]/llvm/llvm-project/llvm/include/llvm/IR/PassInstrumentation.h:227:9
  #8 0xa4f826 in (anonymous 
namespace)::TimePassesTest_CustomOut_Test::TestBody() 
[...]/llvm/llvm-project/llvm/unittests/IR/TimePassesTest.cpp:137:6
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97854

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


  1   2   >