[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-06-29 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 355445.
RedDocMD added a comment.

Fixed bug in enum conversion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -457,3 +457,32 @@
 P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   }
 }
+
+// The following is a silly function,
+// but serves to test if we are picking out
+// standard comparision functions from custom ones.
+template 
+bool operator<(std::unique_ptr , double d);
+
+void uniquePtrComparision(std::unique_ptr unknownPtr) {
+  auto ptr = std::unique_ptr(new int(13));
+  auto nullPtr = std::unique_ptr();
+  auto otherPtr = std::unique_ptr(new int(29));
+
+  clang_analyzer_eval(ptr == ptr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr > ptr);  // expected-warning{{FALSE}}
+  clang_analyzer_eval(ptr <= ptr); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(nullPtr <= unknownPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(unknownPtr >= nullPtr); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(ptr != otherPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr > nullPtr);   // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(ptr != nullptr);// expected-warning{{TRUE}}
+  clang_analyzer_eval(nullPtr != nullptr);// expected-warning{{FALSE}}
+  clang_analyzer_eval(nullptr <= unknownPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(nullptr < unknownPtr);  // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(ptr < 2.0); // expected-warning{{UNKNOWN}}
+}
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -978,6 +978,61 @@
 void swap(unique_ptr , unique_ptr ) noexcept {
   x.swap(y);
 }
+
+template 
+bool operator==(const unique_ptr , const unique_ptr );
+
+template 
+bool operator!=(const unique_ptr , const unique_ptr );
+
+template 
+bool operator<(const unique_ptr , const unique_ptr );
+
+template 
+bool operator>(const unique_ptr , const unique_ptr );
+
+template 
+bool operator<=(const unique_ptr , const unique_ptr );
+
+template 
+bool operator>=(const unique_ptr , const unique_ptr );
+
+template 
+bool operator==(const unique_ptr , nullptr_t y);
+
+template 
+bool operator!=(const unique_ptr , nullptr_t y);
+
+template 
+bool operator<(const unique_ptr , nullptr_t y);
+
+template 
+bool operator>(const unique_ptr , nullptr_t y);
+
+template 
+bool operator<=(const unique_ptr , nullptr_t y);
+
+template 
+bool operator>=(const unique_ptr , nullptr_t y);
+
+template 
+bool operator==(nullptr_t x, const unique_ptr );
+
+template 
+bool operator!=(nullptr_t x, const unique_ptr );
+
+template 
+bool operator>(nullptr_t x, const unique_ptr );
+
+template 
+bool operator<(nullptr_t x, const unique_ptr );
+
+template 
+bool operator>=(nullptr_t x, const unique_ptr );
+
+template 
+bool operator<=(nullptr_t x, const unique_ptr );
+
 } // namespace std
 #endif
 
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -29,7 +29,10 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/ErrorHandling.h"
 #include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -68,6 +71,7 @@
   bool updateMovedSmartPointers(CheckerContext , const MemRegion *ThisRegion,
 const MemRegion *OtherSmartPtrRegion) const;
   void handleBoolConversion(const CallEvent , CheckerContext ) const;
+  bool handleComparisionOp(const CallEvent , CheckerContext ) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent , CheckerContext &) const;
@@ -89,18 +93,24 @@
   const auto *MethodDecl = dyn_cast_or_null(Call.getDecl());
   if (!MethodDecl || !MethodDecl->getParent())
 return false;
+  return isStdSmartPtr(MethodDecl->getParent());
+}
 
-  const auto *RecordDecl = MethodDecl->getParent();
-  if (!RecordDecl || !RecordDecl->getDeclContext()->isStdNamespace())
+bool isStdSmartPtr(const CXXRecordDecl *RD) {
+  if (!RD || 

[PATCH] D105097: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2120
+  } else
+Addr = EmitLValue(E).getAddress(CGF);
   Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy));

junparser wrote:
> junparser wrote:
> > efriedma wrote:
> > > I don't think it's legal to use EmitLValue here at all; the emitted IR 
> > > could have side-effects.
> > > 
> > > Since we have the vector insert/extract intrinsics now, can we just use 
> > > them here instead of going through the load/store dance?
> > > I don't think it's legal to use EmitLValue here at all; the emitted IR 
> > > could have side-effects.
> > > 
> > I agree since we have already visited E. 
> > 
> > > Since we have the vector insert/extract intrinsics now, can we just use 
> > > them here instead of going through the load/store dance?
> > 
> > we have already use insert/extract intrinsics for same element type, we can 
> > only handle predicate cast through memory.
> > One of idea here is always use store + load. what do you think?
> > 
> @efriedma I'm also working on a patch that optimize such store + bitcast + 
> load pattern with constant vector, so maybe it is ok to always use alloca + 
> load
I'd be happy to accept just unconditionally doing the alloca+store+load thing 
for now.

Not sure I understand why predicates are special here.  Even if we can't handle 
predicates directly in insert/extract intrinsics, we can always just 
zero-extend to a bigger integer type, do the cast, then truncate the result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105097

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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to to RISCVArchStringParser.

2021-06-29 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, hiraditya, mgorny.
kito-cheng requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

How many place you need to modify when implementing a new extension for RISC-V?

At least 6 places as I know:

- Add new SubtargetFeature at RISCV.td
- -march parser in RISCV.cpp
- RISCVTargetInfo::initfeature...@riscv.cpp for handling feature vector.
- RISCVTargetInfo::gettargetdefi...@riscv.cpp for pre-define marco.
- Arch string parser for ELF attribute in RISCVAsmParser.cpp
- ELF attribute emittion in RISCVAsmParser.cpp, and make sure it's in canonical 
order...

And now, this patch provide an unified infrastructure for handling (almost)
everything of RISC-V arch string.

After this patch, you only need to update 2 places for implement an extension
for RISC-V:

- Add new SubtargetFeature at RISCV.td, hmmm, it's hard to avoid.
- Add new entry to supportedextensionin...@riscvarchstringparser.cpp.

Most codes are come from existing -march parser, but with few new feature/bug
fixes:

- Accept version for -march, e.g. -march=rv32i2p0.
- Reject version info with `p` but without minor version number liek `rv32i2p`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105168

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/attribute-with-insts.s
  llvm/test/MC/RISCV/invalid-attribute.s

Index: llvm/test/MC/RISCV/invalid-attribute.s
===
--- llvm/test/MC/RISCV/invalid-attribute.s
+++ llvm/test/MC/RISCV/invalid-attribute.s
@@ -7,10 +7,10 @@
 # RUN: not llvm-mc %s -triple=riscv64 -filetype=asm 2>&1 | FileCheck %s
 
 .attribute arch, "foo"
-# CHECK: [[@LINE-1]]:18: error: bad arch string foo
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'foo', string must begin with rv32{i,e,g} or rv64{i,g}
 
 .attribute arch, "rv32i2p0_y2p0"
-# CHECK: [[@LINE-1]]:18: error: bad arch string y2p0
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'rv32i2p0_y2p0', invalid standard user-level extension 'y'
 
 .attribute stack_align, "16"
 # CHECK: [[@LINE-1]]:25: error: expected numeric constant
Index: llvm/test/MC/RISCV/attribute-with-insts.s
===
--- llvm/test/MC/RISCV/attribute-with-insts.s
+++ llvm/test/MC/RISCV/attribute-with-insts.s
@@ -10,7 +10,7 @@
 # RUN:   | llvm-objdump --triple=riscv64 -d -M no-aliases - \
 # RUN:   | FileCheck -check-prefix=CHECK-INST %s
 
-.attribute arch, "rv64i2p0_m2p0_a2p0_d2p0_c2p0"
+.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 # CHECK-INST: lr.w t0, (t1)
 lr.w t0, (t1)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -9,9 +9,6 @@
 .attribute arch, "rv32i2"
 # CHECK: attribute  5, "rv32i2p0"
 
-.attribute arch, "rv32i2p"
-# CHECK: attribute  5, "rv32i2p0"
-
 .attribute arch, "rv32i2p0"
 # CHECK: attribute  5, "rv32i2p0"
 
@@ -33,14 +30,14 @@
 .attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
-.attribute arch, "rv32ima2p_fdc"
+.attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 .attribute arch, "rv32ib"
 # CHECK: attribute  5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
 
 .attribute arch, "rv32iv"
-# CHECK: attribute  5, "rv32i2p0_v0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 
 .attribute arch, "rv32izba"
 # CHECK: attribute  5, "rv32i2p0_zba0p93"
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/RISCVAttributes.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/TargetRegistry.h"
 
 #include 
@@ -50,6 +51,13 @@
 STATISTIC(RISCVNumInstrsCompressed,
   "Number of RISC-V Compressed instructions emitted");
 
+namespace llvm {
+extern const llvm::SubtargetFeatureKV RISCVFeatureKV[];
+}
+
+static 

[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 355431.
lxfind added a comment.

Put the post-split ramp function back to the CGSCC worklist


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

Files:
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
  llvm/test/Transforms/Coroutines/coro-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-alloca-06.ll
  llvm/test/Transforms/Coroutines/coro-alloca-07.ll
  llvm/test/Transforms/Coroutines/coro-alloca-08.ll
  llvm/test/Transforms/Coroutines/coro-async.ll
  llvm/test/Transforms/Coroutines/coro-byval-param.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch.ll
  llvm/test/Transforms/Coroutines/coro-debug.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-arrayalloca.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-frame.ll
  llvm/test/Transforms/Coroutines/coro-materialize.ll
  llvm/test/Transforms/Coroutines/coro-padding.ll
  llvm/test/Transforms/Coroutines/coro-param-copy.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
  llvm/test/Transforms/Coroutines/coro-retcon-frame.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-retcon-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/Coroutines/coro-spill-after-phi.ll
  llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-promise.ll
  llvm/test/Transforms/Coroutines/coro-split-00.ll
  llvm/test/Transforms/Coroutines/coro-split-02.ll
  llvm/test/Transforms/Coroutines/coro-split-alloc.ll
  llvm/test/Transforms/Coroutines/coro-split-dbg.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-00.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-01.ll
  llvm/test/Transforms/Coroutines/coro-split-hidden.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail1.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail2.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail3.ll
  llvm/test/Transforms/Coroutines/coro-split-recursive.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-01.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-02.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-03.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-04.ll
  llvm/test/Transforms/Coroutines/coro-swifterror.ll
  llvm/test/Transforms/Coroutines/coro-zero-alloca.ll
  llvm/test/Transforms/Coroutines/no-suspend.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll
  llvm/test/Transforms/Coroutines/smoketest.ll

Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -10,12 +10,16 @@
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
 ; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -debug-pass-manager \
-; RUN: -passes='function(coro-early),cgscc(coro-split),function(coro-elide,coro-cleanup)' 2>&1 \
+; RUN: -passes='function(coro-early),function(coro-elide),cgscc(coro-split),function(coro-cleanup)' 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 
+; note that we run CoroElidePass before CoroSplitPass. This is because CoroElidePass is part of
+; function simplification pipeline, which runs before 

[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D95807#2849128 , @lxfind wrote:

>> If coroutine ramp function couldn't get inlined, it would disable coroutine 
>> elide optimization. Could you elaborate more on why do you want to do that?
>
> Ramp function will eventually be inlined, but not when you run Inliner on the 
> inlinee.
> Let's say coroutine A calls coroutine B, and eventually we want to inline B 
> into A so that we could perform CoroElide on A.
> After B is split, we don't need to run inliner again on B. When we run 
> inliner on A, A will inline B.

Thanks for clarifying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

> If coroutine ramp function couldn't get inlined, it would disable coroutine 
> elide optimization. Could you elaborate more on why do you want to do that?

Ramp function will eventually be inlined, but not when you run Inliner on the 
inlinee.
Let's say coroutine A calls coroutine B, and eventually we want to inline B 
into A so that we could perform CoroElide on A.
After B is split, we don't need to run inliner again on B. When we run inliner 
on A, A will inline B.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D95807#2849120 , @lxfind wrote:

> In D95807#2849053 , @aeubanks wrote:
>
>> this will run the function simplification pipeline twice on every single 
>> function when coroutines are enabled, I don't think that's the intention
>>
>> I thought the intention was to do all the the re-adding of SCCs inside 
>> CoroSplit.cpp, including the SCC with the function that was split
>
> Good point. I was trying to avoid the second inliner on the coroutine ramp 
> function. But I guess the cost will be bigger than the win.

If coroutine ramp function couldn't get inlined, it would disable coroutine 
elide optimization. Could you elaborate more on why do you want to do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D95807#2849053 , @aeubanks wrote:

> this will run the function simplification pipeline twice on every single 
> function when coroutines are enabled, I don't think that's the intention
>
> I thought the intention was to do all the the re-adding of SCCs inside 
> CoroSplit.cpp, including the SCC with the function that was split

Good point. I was trying to avoid the second inliner on the coroutine ramp 
function. But I guess the cost will be bigger than the win.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D105167: [analyzer] Fix HTML report deduplication.

2021-06-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: vsavchenko, xazax.hun, Szelethus, ASDenysPetrov.
Herald added subscribers: manas, steakhal, martong, dkrupp, donat.nagy, 
arphaman, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
NoQ requested review of this revision.

Folks, I deleted some code.

Some of it was... Perl code.

Not sure if anybody noticed but scan-build didn't deduplicate reports 
correctly. Its algorithm was extremely primitive (basically it hashed each html 
file and deleted files with duplicate hash). This obviously didn't work with 
cross-file reports (i.e., bug path starts in the main file but ends in a 
header) which we intended to deduplicate by the end-of-path location, because 
the main file name is included in the report and therefore affects md5. D42269 
 doesn't help either. Long story short, it 
didn't honor the modern advancements in `IssueHash` at all.

I could make scan-build read the issue hash but I think my solution is even 
more elegant so hear me out. I put the issue hash into the report filename 
instead, replacing the random section. When clang tries to emit a duplicate 
report, it'll simply fail because the file with that name is already present. 
Moreover, as per tradition, I reduce the issue hash to the first 6 characters, 
so bug report filenames look exactly like before (`report-123abc.html`), except 
now they're automatically stable and deterministic! Such truncation is, of 
course, entirely cosmetic and absolutely unnecessary but I think it's pretty 
cool.

The flag `-analyzer-config stable-report-filename=true` now becomes redundant 
because reports are stable anyway (in fact, they weren't actually stable before 
the patch even with the flag, because they depended on the race between clang 
invocations to emit the reports; I changed it to include a snippet of the issue 
hash as well instead of the race-y index). That said, I'm conflicted about 
removing the flag entirely because it also produces more verbose/readable 
filenames that people seem to enjoy. I think we should enable it by default 
instead, as soon as we make sure it doesn't produce extremely long filenames.

`scan-build --generate-index-only` no longer does deduplication, as seen on the 
updated test "`rebuild_index`". If deduplication is desired, it can typically 
be achieved with a simple

  find -name '*.html' -exec mv "{}" . \;


Repository:
  rC Clang

https://reviews.llvm.org/D105167

Files:
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/scan-build/Inputs/deduplication/1.c
  clang/test/Analysis/scan-build/Inputs/deduplication/2.c
  clang/test/Analysis/scan-build/Inputs/deduplication/header.h
  clang/test/Analysis/scan-build/deduplication.test
  clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
  clang/test/Analysis/scan-build/rebuild_index/report-3.html
  clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-3.html
  clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html
  clang/tools/scan-build/bin/scan-build

Index: clang/tools/scan-build/bin/scan-build
===
--- clang/tools/scan-build/bin/scan-build
+++ clang/tools/scan-build/bin/scan-build
@@ -14,7 +14,6 @@
 use strict;
 use warnings;
 use FindBin qw($RealBin);
-use Digest::MD5;
 use File::Basename;
 use File::Find;
 use File::Copy qw(copy);
@@ -268,27 +267,6 @@
   $ENV{'CCC_ANALYZER_HTML'} = $Dir;
 }
 
-####
-# ComputeDigest - Compute a digest of the specified file.
-####
-
-sub ComputeDigest {
-  my $FName = shift;
-  DieDiag("Cannot read $FName to compute Digest.\n") if (! -r $FName);
-
-  # Use Digest::MD5.  We don't have to be cryptographically secure.  We're
-  # just looking for duplicate files that come from a non-malicious source.
-  # We use Digest::MD5 because it is a standard Perl module that should
-  # come bundled on most systems.
-  open(FILE, $FName) or DieDiag("Cannot open $FName when computing Digest.\n");
-  binmode FILE;
-  my $Result = Digest::MD5->new->addfile(*FILE)->hexdigest;
-  close(FILE);
-
-  # Return the digest.
-  return $Result;
-}
-
 ####
 #  UpdatePrefix - Compute the common prefix of files.
 ####
@@ -374,8 +352,6 @@
 # Sometimes a source file is scanned more than once, and thus produces
 # multiple error reports.  We use a cache to solve this problem.
 
-my %AlreadyScanned;
-
 sub ScanFile {
 
   my $Index = shift;
@@ -383,19 +359,6 @@
   my $FName = shift;
   my $Stats = shift;
 
-  # Compute a digest for the report file.  Determine if we have already
-  # scanned a file that looks just like it.
-
-  my $digest = 

[PATCH] D105097: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-29 Thread JunMa via Phabricator via cfe-commits
junparser added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2120
+  } else
+Addr = EmitLValue(E).getAddress(CGF);
   Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy));

junparser wrote:
> efriedma wrote:
> > I don't think it's legal to use EmitLValue here at all; the emitted IR 
> > could have side-effects.
> > 
> > Since we have the vector insert/extract intrinsics now, can we just use 
> > them here instead of going through the load/store dance?
> > I don't think it's legal to use EmitLValue here at all; the emitted IR 
> > could have side-effects.
> > 
> I agree since we have already visited E. 
> 
> > Since we have the vector insert/extract intrinsics now, can we just use 
> > them here instead of going through the load/store dance?
> 
> we have already use insert/extract intrinsics for same element type, we can 
> only handle predicate cast through memory.
> One of idea here is always use store + load. what do you think?
> 
@efriedma I'm also working on a patch that optimize such store + bitcast + load 
pattern with constant vector, so maybe it is ok to always use alloca + load


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105097

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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

this will run the function simplification pipeline twice on every single 
function when coroutines are enabled, I don't think that's the intention

I thought the intention was to do all the the re-adding of SCCs inside 
CoroSplit.cpp, including the SCC with the function that was split


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-06-29 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added inline comments.



Comment at: clang/lib/AST/OSLog.cpp:212
+  } else if (Lit->isUTF16()) {
+std::wstring_convert, char16_t> Convert;
+std::u16string U16 = Lit->getStringAsChar16();

aaron.ballman wrote:
> cor3ntin wrote:
> > I'm not sure I have a better suggestion but `codecvt_utf8_utf16` is 
> > deprecated in C++17
> Good point -- this likely should be lifted into a common interface (as it 
> appears several times in the patch) and make use of the existing LLVM UTF 
> conversion functionality: 
> https://github.com/intel/llvm/blob/sycl/llvm/include/llvm/Support/ConvertUTF.h
The ConvertUTF version you linked contains `convertUTF32toUTF8String` but the 
one in LLVM does not, what's the process for updating this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103426

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


[PATCH] D105097: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-29 Thread JunMa via Phabricator via cfe-commits
junparser added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2120
+  } else
+Addr = EmitLValue(E).getAddress(CGF);
   Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy));

efriedma wrote:
> I don't think it's legal to use EmitLValue here at all; the emitted IR could 
> have side-effects.
> 
> Since we have the vector insert/extract intrinsics now, can we just use them 
> here instead of going through the load/store dance?
> I don't think it's legal to use EmitLValue here at all; the emitted IR could 
> have side-effects.
> 
I agree since we have already visited E. 

> Since we have the vector insert/extract intrinsics now, can we just use them 
> here instead of going through the load/store dance?

we have already use insert/extract intrinsics for same element type, we can 
only handle predicate cast through memory.
One of idea here is always use store + load. what do you think?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105097

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


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

In D95807#2847449 , @lxfind wrote:

> In D95807#2846358 , @ChuanqiXu wrote:
>
>>> note that we don't really need to run Inliner again on the ramp function 
>>> after split
>>
>> This isn't accurate. The inline may run again for ramp function after split 
>> and it's required by coro elide.
>
> If there is an inlining opportunity, it should have happened pre-split, 
> right? Is there any reason it didn't happen pre-split but only post-split?

Since we had prevent inlining coroutine before split, coroutine can't be 
inlined pre-split. After splitting, due to the SCC changes, the inliner would 
run again for ramp.

LGTM. But I am not familiar with the pipeline, please wait for 1~2 days in case 
there are more comments.




Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:2112-2114
 StringRef Value = Attr.getValueAsString();
 LLVM_DEBUG(dbgs() << "CoroSplit: Processing coroutine '" << F.getName()
   << "' state: " << Value << "\n");

These are not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D105092: [PoC][RISCV] Add the tail policy argument to builtins/intrinsics.

2021-06-29 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 355420.
HsiangKai added a comment.

- Use constant value for tail policy argument.
- Rename HasPolicy to HasPolicyOp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105092

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-policy.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/vadd-policy.ll

Index: llvm/test/CodeGen/RISCV/rvv/vadd-policy.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rvv/vadd-policy.ll
@@ -0,0 +1,65 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs \
+; RUN:   --riscv-no-aliases < %s | FileCheck %s
+
+declare  @llvm.riscv.vadd.nxv8i8.nxv8i8(
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vadd_vv_nxv8i8_nxv8i8_nxv8i8( %0,  %1, i64 %2) nounwind {
+; CHECK-LABEL: intrinsic_vadd_vv_nxv8i8_nxv8i8_nxv8i8:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e8, m1, ta, mu
+; CHECK-NEXT:vadd.vv v8, v8, v9
+; CHECK-NEXT:jalr zero, 0(ra)
+entry:
+  %a = call  @llvm.riscv.vadd.nxv8i8.nxv8i8(
+ %0,
+ %1,
+i64 %2)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8(
+  ,
+  ,
+  ,
+  ,
+  i64, i64);
+
+define  @intrinsic_vadd_mask_tu( %0,  %1,  %2,  %3, i64 %4) nounwind {
+; CHECK-LABEL: intrinsic_vadd_mask_tu:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetivli zero, 3, e8, m1, tu, mu
+; CHECK-NEXT:vadd.vv v8, v9, v10, v0.t
+; CHECK-NEXT:jalr zero, 0(ra)
+entry:
+  %a = call  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8(
+ %0,
+ %1,
+ %2,
+ %3,
+i64 %4, i64 0)
+
+  ret  %a
+}
+
+define  @intrinsic_vadd_mask_ta( %0,  %1,  %2,  %3, i64 %4) nounwind {
+; CHECK-LABEL: intrinsic_vadd_mask_ta:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetivli zero, 3, e8, m1, ta, mu
+; CHECK-NEXT:vadd.vv v8, v9, v10, v0.t
+; CHECK-NEXT:jalr zero, 0(ra)
+entry:
+  %a = call  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8(
+ %0,
+ %1,
+ %2,
+ %3,
+i64 %4, i64 1)
+
+  ret  %a
+}
+
Index: llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
@@ -269,6 +269,36 @@
  VMV0:$vm, GPR:$vl, sew)>;
 }
 
+multiclass VPatBinaryVL_VV_WithPolicy {
+  def : Pat<(result_type (vop
+ (op_type op_reg_class:$rs1),
+ (op_type op_reg_class:$rs2),
+ (mask_type true_mask),
+ VLOpFrag)),
+(!cast(instruction_name#"_VV_"# vlmul.MX)
+ op_reg_class:$rs1,
+ op_reg_class:$rs2,
+ GPR:$vl, sew)>;
+  def : Pat<(result_type (vop
+ (op_type op_reg_class:$rs1),
+ (op_type op_reg_class:$rs2),
+ (mask_type VMV0:$vm),
+ VLOpFrag)),
+(!cast(instruction_name#"_VV_"# vlmul.MX#"_MASK")
+ (result_type (IMPLICIT_DEF)),
+ op_reg_class:$rs1,
+ op_reg_class:$rs2,
+ VMV0:$vm, GPR:$vl, sew, 0)>;
+}
+
 multiclass VPatBinaryVL_XI;
 }
 
+multiclass VPatBinaryVL_XI_WithPolicy {
+  def : Pat<(result_type (vop
+ (vop_type vop_reg_class:$rs1),
+ (vop_type (SplatPatKind (XLenVT xop_kind:$rs2))),
+ (mask_type true_mask),
+ VLOpFrag)),
+(!cast(instruction_name#_#suffix#_# vlmul.MX)
+ vop_reg_class:$rs1,
+ xop_kind:$rs2,
+ GPR:$vl, sew)>;
+  def : Pat<(result_type (vop
+ (vop_type vop_reg_class:$rs1),
+ (vop_type (SplatPatKind (XLenVT xop_kind:$rs2))),
+ (mask_type VMV0:$vm),
+ VLOpFrag)),
+(!cast(instruction_name#_#suffix#_# vlmul.MX#"_MASK")
+ (result_type (IMPLICIT_DEF)),
+ vop_reg_class:$rs1,
+ xop_kind:$rs2,
+ VMV0:$vm, GPR:$vl, sew, 0)>;
+}
+
 multiclass VPatBinaryVL_VV_VX {
   foreach vti = AllIntegerVectors in {
 defm : VPatBinaryVL_VV {
+  foreach vti = AllIntegerVectors in {
+defm : VPatBinaryVL_VV_WithPolicy;
+defm : VPatBinaryVL_XI_WithPolicy;
+  }
+}
+
 

[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

OpenMP side looks reasonable.




Comment at: clang/lib/Headers/__clang_hip_cmath.h:96
+__DEVICE__ __CONSTEXPR__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ __CONSTEXPR__ bool isnan(double __x) { return ::__isnan(__x); }
 

^ This is how OpenMP resolves the overload issue wrt. different return types.



Comment at: clang/lib/Headers/__clang_hip_math.h:35
+#ifdef __OPENMP_AMDGCN__
+#define __RETURN_TYPE int
+#else

pdhaliwal wrote:
> jdoerfert wrote:
> > JonChesterfield wrote:
> > > I'd expect openmp to match the cplusplus/c distinction here, as openmp 
> > > works on C source
> > ^ Agreed. Though, we use a different trick because it's unfortunately not 
> > as straight forward always and can be decided based on the C vs C++.
> This is somewhat tricky. Since declaration of `__finite/__isnan /__isinff` is 
> with int return type in standard library (and the corresponding methods in 
> C++ seems to be isfinite, isnan and isinf with bool return type), the 
> compiler fails to resolve these functions when using bool. I don't know how 
> HIP is working.
> 
> __RETURN_TYPE macro is only being used with the following methods:
> 1. __finite
> 2. __isnan
> 3. __isinf
> 4. __signbit
> 
> and with the corresponding float versions.
I marked the code above that actually overloads these functions in OpenMP (or 
better the versions w/o underscores) such that the system can have either 
version and it should work fine.



Comment at: clang/test/Headers/Inputs/include/cstdlib:29
 float fabs(float __x) { return __builtin_fabs(__x); }
+#endif
 

That seems to be fundamentally broken then, but let's see, maybe it will 
somehow work anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D105143: [OPENMP]Fix PR50929: Ignored initializer clause in user-defined reduction.

2021-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105143

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


Re: [PATCH] D104388: [clang-format] PR50727 C# Invoke Lamda Expression indentation incorrect

2021-06-29 Thread Eliza Velasquez via cfe-commits
Sorry, been away from my setup lately. I'll approve once I'm back at my PC
hopefully by EOD.

On Tue, Jun 29, 2021, 1:13 PM Jonathan B Coe via Phabricator <
revi...@reviews.llvm.org> wrote:

> jbcoe accepted this revision.
> jbcoe added a subscriber: krasimir.
> jbcoe added a comment.
>
> Some outstanding nits to address but this looks good to me.
>
> With @krasimir I implemented a good fraction of the C# support and am
> confident that these changes are an improvement.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D104388/new/
>
> https://reviews.llvm.org/D104388
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105127: Implement P1401R5

2021-06-29 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3930
+  ExprResult E = PerformContextuallyConvertToBool(CondExpr);
+  if (!IsConstexpr || CondExpr->isValueDependent())
+return E;

Minor nit: I think it would be a tiny bit clearer if you factored out this 
condition, since you repeat it:
```
bool IsConstexprNonValueDependent = IsConstexpr  && 
!CondExpr->isValueDependent();
if (!LangOpts.CPlusPlus2b && IsConstexprNonValueDependent) {

if (!IsConstexprNonValueDependent)
```



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3935
+  E = VerifyIntegerConstantExpression(
+  E.get(), ,
+  diag::err_constexpr_if_condition_expression_is_not_constant);

The value returned from `PerformContextuallyConvertToBool` can have a possibly 
failed state (We follow this convention for FooResult named types).
But here there is a `get` on it on a path where there could be an error.
Can you handle this, and also add test case to cover it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

___
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-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 355401.
ychen added a comment.

- Add description of `raw frame` in `Coroutines.rst`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97915

Files:
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  llvm/docs/Coroutines.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Coroutines/CoroInstr.h
  llvm/lib/Transforms/Coroutines/CoroInternal.h
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/Coroutines/Coroutines.cpp
  llvm/test/Transforms/Coroutines/coro-frame-overalign.ll

Index: llvm/test/Transforms/Coroutines/coro-frame-overalign.ll
===
--- /dev/null
+++ llvm/test/Transforms/Coroutines/coro-frame-overalign.ll
@@ -0,0 +1,78 @@
+; Check that `llvm.coro.align`, `llvm.coro.raw.frame.ptr.offset` and
+; `@llvm.coro.raw.frame.ptr.alloca` are lowered correctly.
+; RUN: opt < %s -passes=coro-split -S | FileCheck %s
+
+%PackedStruct = type <{ i64 }>
+
+declare void @consume(%PackedStruct*, i32, i32, i8**)
+declare void @consume2(i32, i32)
+
+define i8* @f() "coroutine.presplit"="1" {
+entry:
+  %data = alloca %PackedStruct, align 32
+  %id = call token @llvm.coro.id(i32 16, i8* null, i8* null, i8* null)
+  %size = call i32 @llvm.coro.size.i32()
+  %alloc = call i8* @malloc(i32 %size)
+  %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
+  %align = call i32 @llvm.coro.align.i32()
+  %offset = call i32 @llvm.coro.raw.frame.ptr.offset.i32()
+  %addr = call i8** @llvm.coro.raw.frame.ptr.addr()
+  call void @consume(%PackedStruct* %data, i32 %align, i32 %offset, i8** %addr)
+  %0 = call i8 @llvm.coro.suspend(token none, i1 false)
+  switch i8 %0, label %suspend [i8 0, label %resume
+i8 1, label %cleanup]
+resume:
+  br label %cleanup
+
+cleanup:
+  %align2 = call i32 @llvm.coro.align.i32()
+  %offset2 = call i32 @llvm.coro.raw.frame.ptr.offset.i32()
+  call void @consume2(i32 %align2, i32 %offset2)
+  %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
+  call void @free(i8* %mem)
+  br label %suspend
+suspend:
+  call i1 @llvm.coro.end(i8* %hdl, i1 0)
+  ret i8* %hdl
+}
+
+; See if the raw frame pointer was inserted into the frame.
+; CHECK-LABEL: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i8*, i1, [7 x i8], %PackedStruct }
+
+; See if we used correct index to access frame addr field (field 2).
+; CHECK-LABEL: @f(
+; CHECK: %alloc.frame.ptr = alloca i8*, align 8
+; CHECK: %[[FIELD:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 2
+; CHECK: %[[ADDR:.+]] = load i8*, i8** %alloc.frame.ptr, align 8
+; CHECK: store i8* %[[ADDR]], i8** %[[FIELD]], align 8
+; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 5
+; CHECK: call void @consume(%PackedStruct* %[[DATA]], i32 32, i32 16, i8** %[[FIELD]])
+; CHECK: ret i8*
+
+; See if `llvm.coro.align` and `llvm.coro.raw.frame.ptr.offset` are lowered
+; correctly during deallocation.
+; CHECK-LABEL: @f.destroy(
+; CHECK: call void @consume2(i32 32, i32 16)
+; CHECK: call void @free(i8* %{{.*}})
+
+; CHECK-LABEL: @f.cleanup(
+; CHECK: call void @consume2(i32 32, i32 16)
+; CHECK: call void @free(i8*
+
+declare i8* @llvm.coro.free(token, i8*)
+declare i32 @llvm.coro.size.i32()
+declare i32 @llvm.coro.align.i32()
+declare i32 @llvm.coro.raw.frame.ptr.offset.i32()
+declare i8** @llvm.coro.raw.frame.ptr.addr()
+declare i8  @llvm.coro.suspend(token, i1)
+declare void @llvm.coro.resume(i8*)
+declare void @llvm.coro.destroy(i8*)
+
+declare token @llvm.coro.id(i32, i8*, i8*, i8*)
+declare i1 @llvm.coro.alloc(token)
+declare i8* @llvm.coro.begin(token, i8*)
+declare i1 @llvm.coro.end(i8*, i1)
+
+declare noalias i8* @malloc(i32)
+declare double @print(double)
+declare void @free(i8*)
Index: llvm/lib/Transforms/Coroutines/Coroutines.cpp
===
--- llvm/lib/Transforms/Coroutines/Coroutines.cpp
+++ llvm/lib/Transforms/Coroutines/Coroutines.cpp
@@ -234,6 +234,9 @@
   Shape.CoroBegin = nullptr;
   Shape.CoroEnds.clear();
   Shape.CoroSizes.clear();
+  Shape.CoroAligns.clear();
+  Shape.CoroRawFramePtrOffsets.clear();
+  Shape.CoroRawFramePtrAddrs.clear();
   Shape.CoroSuspends.clear();
 
   Shape.FrameTy = nullptr;
@@ -268,6 +271,15 @@
   case Intrinsic::coro_size:
 CoroSizes.push_back(cast(II));
 break;
+  case Intrinsic::coro_align:
+CoroAligns.push_back(cast(II));
+break;
+  case Intrinsic::coro_raw_frame_ptr_offset:
+CoroRawFramePtrOffsets.push_back(cast(II));
+break;
+  case Intrinsic::coro_raw_frame_ptr_addr:
+CoroRawFramePtrAddrs.push_back(cast(II));
+break;
 

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

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

> Thanks for clarifying. Let's solve the semantics problem first.
> With the introduction about 'raw frame', I think it's necessary to introduce 
> this concept in the section 'Switched-Resume Lowering' or even the section 
> 'Introduction' in the document. Add a section to tell the terminology is 
> satisfied too.

Done.

> Then why we defined both 'llvm.coro.raw.frame.ptr.offset' and 
> 'llvm.coro.raw.frame.ptr.addr' together? It looks like refer to the same 
> value finally. It looks like 'llvm.coro.raw.frame.ptr.offset' are trying to 
> solve the problem about memory leak. But I think we could use 
> llvm.coro.raw.frame.ptr.addr directly instead of traversing the frame (Maybe 
> we need to add an intrinsic `llvm.coro.raw.size`).  Then we can omit a field 
> in the frame to save space.

("llvm.coro.raw.frame.ptr.offset" is an offset from coroutine frame address 
instead of raw frame pointer)

Apologies for the confusion. I've briefly explained it here 
https://reviews.llvm.org/D102145#2752445 I think it is not clear. 
"llvm.coro.raw.frame.ptr.addr" is conceptually "the address of a coroutine 
frame field storing the `raw frame pointer`" only after `insertSpills` in 
CoroFrame.cpp. Before that, "llvm.coro.raw.frame.ptr.addr" is actually an 
alloca storing the `raw frame pointer` (try grepping "alloc.frame.ptr" in this 
review page). Using  "llvm.coro.raw.frame.ptr.offset" instead of  
"llvm.coro.raw.frame.ptr.addr" is doable which looks like below, please check 
line 31. The downside is that the write to coroutine frame is not through an 
alloca but a direct write. It is unusual because all fields in the frame are 
stored as 1. special/header fields 2. alloca 3. splills. Doing the write 
indirectly as Alloca makes me comfortable. The tradeoff is one extra intrinsic 
"llvm.coro.raw.frame.ptr.addr". What do you think?

  19 coro.alloc.align: ; preds = 
%coro.alloc.check.align
  20   %3 = sub nsw i64 64, 16
  21   %4 = add i64 128, %3
  22   %call1 = call noalias nonnull i8* @_Znwm(i64 %4) #13
  23   %mask = sub i64 64, 1
  24   %intptr = ptrtoint i8* %call1 to i64
  25   %over_boundary = add i64 %intptr, %mask
  26   %inverted_mask = xor i64 %mask, -1
  27   %aligned_intptr = and i64 %over_boundary, %inverted_mask
  28   %diff = sub i64 %aligned_intptr, %intptr
  29   %aligned_result = getelementptr inbounds i8, i8* %call1, i64 %diff
  30   call void @llvm.assume(i1 true) [ "align"(i8* %aligned_result, i64 64) ]
  31   store i8* %call1, i8** %alloc.frame.ptr, align 8 
  
   ; Replace line 31 with below, and must makes sure line 46~line 48 is 
skipped.
   ; %poff = call i32 @llvm.coro.raw.frame.ptr.offset.i32()
   ; %addr = getelementptr inbounds i8, i8* %aligned_result, i32 %poff
   ; %addr1 = bitcast i8* %addr to i8**
   ; store i8* %call1, i8** %addr1, align 8
  
  
  32   br label %coro.init.from.coro.alloc.align
  33
  34 coro.init.from.coro.alloc.align:  ; preds = 
%coro.alloc.align
  35   %aligned_result.coro.init = phi i8* [ %aligned_result, %coro.alloc.align 
]
  36   br label %coro.init
  37
  38 coro.init:; preds = 
%coro.init.from.entry, %coro.init.from.coro.alloc.align, %cor
 o.init.from.coro.alloc
  39   %5 = phi i8* [ %.coro.init, %coro.init.from.entry ], [ %call.coro.init, 
%coro.init.from.coro.alloc ], [ %aligned_result
 .coro.init, %coro.init.from.coro.alloc.align ]
  40   %FramePtr = bitcast i8* %5 to %f0.Frame*
  41   %resume.addr = getelementptr inbounds %f0.Frame, %f0.Frame* %FramePtr, 
i32 0, i32 0
  42   store void (%f0.Frame*)* @f0.resume, void (%f0.Frame*)** %resume.addr, 
align 8
  43   %6 = select i1 true, void (%f0.Frame*)* @f0.destroy, void (%f0.Frame*)* 
@f0.cleanup
  44   %destroy.addr = getelementptr inbounds %f0.Frame, %f0.Frame* %FramePtr, 
i32 0, i32 1
  45   store void (%f0.Frame*)* %6, void (%f0.Frame*)** %destroy.addr, align 8
  46   %7 = getelementptr inbounds %f0.Frame, %f0.Frame* %FramePtr, i32 0, i32 2
  47   %8 = load i8*, i8** %alloc.frame.ptr, align 8
  48   store i8* %8, i8** %7, align 8
  49   br label %AllocaSpillBB
  50
  51 AllocaSpillBB:; preds = %coro.init
  52   %.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* %FramePtr, 
i32 0, i32 4
  53   %ref.tmp.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
%FramePtr, i32 0, i32 5
  54   %agg.tmp.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
%FramePtr, i32 0, i32 6
  55   %ref.tmp5.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
%FramePtr, i32 0, i32 7
  56   %agg.tmp8.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
%FramePtr, i32 0, i32 8
  57   %__promise.reload.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
%FramePtr, i32 0, i32 10
  58   br label %PostSpill




> Then I am a little confused for the design again, since we would treat the 
> value for 

[PATCH] D104285: [analyzer] Retrieve value by direct index from list initialization of constant array declaration.

2021-06-29 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx added a comment.

In D104285#2847547 , @ASDenysPetrov 
wrote:

> I don't think we should revert b30521c28a4d 
>  because 
> it corrects symbol representation in CSA and fixes two bugs: 
> https://bugs.llvm.org/show_bug.cgi?id=37503 and 
> https://bugs.llvm.org/show_bug.cgi?id=49007. Another point of non-revert is 
> that your cases were previously hidden in CSA core and that's good to find 
> them. I'm afraid it's a dubious idea to return back old bugs in favor of not 
> seeing new ones.

Valid point.  Thanks for considering the question.  I agree it's better to move 
forward and get this patch working.  :)   I just wish I had the bandwidth to 
help more...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104285

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


[clang-tools-extra] 632e15e - Conditionalize function only used in an assert to address -Wunused-function

2021-06-29 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-06-29T16:39:59-07:00
New Revision: 632e15e766ee625ae367b2e872f3df903e507bfb

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

LOG: Conditionalize function only used in an assert to address -Wunused-function

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 72f5b25e9f66a..8e972298adcec 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -167,10 +167,6 @@ static inline std::string formatMixFlags(MixFlags F) {
   return Str.str().str();
 }
 
-#else
-
-static inline std::string formatMixFlags(MixFlags F);
-
 #endif // NDEBUG
 
 /// The results of the steps of an Implicit Conversion Sequence is saved in

diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 75e551b665185..c29900b2c694d 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -3606,15 +3606,19 @@ LDVSSABlock *LDVSSABlockIterator::operator*() {
   return Updater.getSSALDVBlock(*PredIt);
 }
 
-} // namespace
-
-namespace llvm {
+#ifndef NDEBUG
 
 raw_ostream <<(raw_ostream , const LDVSSAPhi ) {
   out << "SSALDVPHI " << PHI.PHIValNum;
   return out;
 }
 
+#endif
+
+} // namespace
+
+namespace llvm {
+
 /// Template specialization to give SSAUpdater access to CFG and value
 /// information. SSAUpdater calls methods in these traits, passing in the
 /// LDVSSAUpdater object, to learn about blocks and the values they define.



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


[PATCH] D104883: [CodeGen] Add ParmVarDecls to FunctionDecls that are created to generate ObjC property getter/setter functions

2021-06-29 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cda73e3c449: [CodeGen] Add ParmVarDecls to FunctionDecls 
that are created to generate (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104883

Files:
  clang/lib/CodeGen/CGObjC.cpp


Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -3698,12 +3698,18 @@
   FunctionTy, nullptr, SC_Static, false, false);
 
   FunctionArgList args;
-  ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy,
-ImplicitParamDecl::Other);
-  args.push_back();
-  ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy,
-ImplicitParamDecl::Other);
-  args.push_back();
+  ParmVarDecl *Params[2];
+  ParmVarDecl *DstDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy,
+  C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[0] = DstDecl);
+  ParmVarDecl *SrcDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy,
+  C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[1] = SrcDecl);
+  FD->setParams(Params);
 
   const CGFunctionInfo  =
   CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args);
@@ -3719,12 +3725,12 @@
 
   StartFunction(FD, ReturnTy, Fn, FI, args);
 
-  DeclRefExpr DstExpr(C, , false, DestTy, VK_PRValue, 
SourceLocation());
+  DeclRefExpr DstExpr(C, DstDecl, false, DestTy, VK_PRValue, SourceLocation());
   UnaryOperator *DST = UnaryOperator::Create(
   C, , UO_Deref, DestTy->getPointeeType(), VK_LValue, OK_Ordinary,
   SourceLocation(), false, FPOptionsOverride());
 
-  DeclRefExpr SrcExpr(C, , false, SrcTy, VK_PRValue, SourceLocation());
+  DeclRefExpr SrcExpr(C, SrcDecl, false, SrcTy, VK_PRValue, SourceLocation());
   UnaryOperator *SRC = UnaryOperator::Create(
   C, , UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary,
   SourceLocation(), false, FPOptionsOverride());
@@ -3782,12 +3788,18 @@
   FunctionTy, nullptr, SC_Static, false, false);
 
   FunctionArgList args;
-  ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy,
-ImplicitParamDecl::Other);
-  args.push_back();
-  ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy,
-ImplicitParamDecl::Other);
-  args.push_back();
+  ParmVarDecl *Params[2];
+  ParmVarDecl *DstDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy,
+  C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[0] = DstDecl);
+  ParmVarDecl *SrcDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy,
+  C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[1] = SrcDecl);
+  FD->setParams(Params);
 
   const CGFunctionInfo  =
   CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args);
@@ -3802,7 +3814,7 @@
 
   StartFunction(FD, ReturnTy, Fn, FI, args);
 
-  DeclRefExpr SrcExpr(getContext(), , false, SrcTy, VK_PRValue,
+  DeclRefExpr SrcExpr(getContext(), SrcDecl, false, SrcTy, VK_PRValue,
   SourceLocation());
 
   UnaryOperator *SRC = UnaryOperator::Create(
@@ -3829,7 +3841,7 @@
  CXXConstExpr->getConstructionKind(),
  SourceRange());
 
-  DeclRefExpr DstExpr(getContext(), , false, DestTy, VK_PRValue,
+  DeclRefExpr DstExpr(getContext(), DstDecl, false, DestTy, VK_PRValue,
   SourceLocation());
 
   RValue DV = EmitAnyExpr();


Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -3698,12 +3698,18 @@
   FunctionTy, nullptr, SC_Static, false, false);
 
   FunctionArgList args;
-  ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy,
-ImplicitParamDecl::Other);
-  args.push_back();
-  ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy,
-ImplicitParamDecl::Other);
-  args.push_back();
+  ParmVarDecl *Params[2];
+  ParmVarDecl *DstDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy,
+  C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[0] = DstDecl);
+  ParmVarDecl *SrcDecl = ParmVarDecl::Create(
+  

[clang] 6cda73e - [CodeGen] Add ParmVarDecls to FunctionDecls that are created to generate

2021-06-29 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2021-06-29T16:27:24-07:00
New Revision: 6cda73e3c44968eb6fff4b73cb6f1d0ef7d861f4

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

LOG: [CodeGen] Add ParmVarDecls to FunctionDecls that are created to generate
ObjC property getter/setter functions

This is needed to prevent clang from crashing when we make the changes
proposed in https://reviews.llvm.org/D98799.

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

Added: 


Modified: 
clang/lib/CodeGen/CGObjC.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 63429b1d4f65..b865780ffe93 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -3698,12 +3698,18 @@ 
CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction(
   FunctionTy, nullptr, SC_Static, false, false);
 
   FunctionArgList args;
-  ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy,
-ImplicitParamDecl::Other);
-  args.push_back();
-  ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy,
-ImplicitParamDecl::Other);
-  args.push_back();
+  ParmVarDecl *Params[2];
+  ParmVarDecl *DstDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy,
+  C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[0] = DstDecl);
+  ParmVarDecl *SrcDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy,
+  C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[1] = SrcDecl);
+  FD->setParams(Params);
 
   const CGFunctionInfo  =
   CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args);
@@ -3719,12 +3725,12 @@ 
CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction(
 
   StartFunction(FD, ReturnTy, Fn, FI, args);
 
-  DeclRefExpr DstExpr(C, , false, DestTy, VK_PRValue, 
SourceLocation());
+  DeclRefExpr DstExpr(C, DstDecl, false, DestTy, VK_PRValue, SourceLocation());
   UnaryOperator *DST = UnaryOperator::Create(
   C, , UO_Deref, DestTy->getPointeeType(), VK_LValue, OK_Ordinary,
   SourceLocation(), false, FPOptionsOverride());
 
-  DeclRefExpr SrcExpr(C, , false, SrcTy, VK_PRValue, SourceLocation());
+  DeclRefExpr SrcExpr(C, SrcDecl, false, SrcTy, VK_PRValue, SourceLocation());
   UnaryOperator *SRC = UnaryOperator::Create(
   C, , UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary,
   SourceLocation(), false, FPOptionsOverride());
@@ -3782,12 +3788,18 @@ 
CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
   FunctionTy, nullptr, SC_Static, false, false);
 
   FunctionArgList args;
-  ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy,
-ImplicitParamDecl::Other);
-  args.push_back();
-  ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy,
-ImplicitParamDecl::Other);
-  args.push_back();
+  ParmVarDecl *Params[2];
+  ParmVarDecl *DstDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy,
+  C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[0] = DstDecl);
+  ParmVarDecl *SrcDecl = ParmVarDecl::Create(
+  C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy,
+  C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None,
+  /*DefArg=*/nullptr);
+  args.push_back(Params[1] = SrcDecl);
+  FD->setParams(Params);
 
   const CGFunctionInfo  =
   CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args);
@@ -3802,7 +3814,7 @@ 
CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
 
   StartFunction(FD, ReturnTy, Fn, FI, args);
 
-  DeclRefExpr SrcExpr(getContext(), , false, SrcTy, VK_PRValue,
+  DeclRefExpr SrcExpr(getContext(), SrcDecl, false, SrcTy, VK_PRValue,
   SourceLocation());
 
   UnaryOperator *SRC = UnaryOperator::Create(
@@ -3829,7 +3841,7 @@ 
CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
  CXXConstExpr->getConstructionKind(),
  SourceRange());
 
-  DeclRefExpr DstExpr(getContext(), , false, DestTy, VK_PRValue,
+  DeclRefExpr DstExpr(getContext(), DstDecl, false, DestTy, VK_PRValue,
   SourceLocation());
 
   RValue DV = EmitAnyExpr();



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


[PATCH] D100000: [clang] WIP: Implement simpler alternative to two-phase lookup for NRVO

2021-06-29 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 355393.
mizvekov added a comment.

Patch now in workable state. Is Missing a few cleanups in the implementation.

Updates coroutine implicit move tests, as now they can finally match C++20 
behavior and don't need P2266  retroactively 
applied.

There are some test result changes.
These all match current GCC behaviour though: We are now broken in the same way 
as GCC is for these.
TBD what to do about these. The ambiguous overload resolution one might be easy 
to solve,
the other ones have to be studied more carefully.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D10

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaObjCXX/block-capture.mm

Index: clang/test/SemaObjCXX/block-capture.mm
===
--- clang/test/SemaObjCXX/block-capture.mm
+++ clang/test/SemaObjCXX/block-capture.mm
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b,cxx2b %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
-// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98  %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b,cxx2b%s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx98_20,cxx11_2b %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx98_20,cxx11_2b %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98_20,cxx98%s
 
 #define TEST(T) void test_##T() { \
   __block T x;\
@@ -51,31 +51,31 @@
 
 struct ConvertingRVRef {
   ConvertingRVRef();
-  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98-note {{marked deleted here}}
+  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98_20-note {{marked deleted here}}
 
   struct X {};
   ConvertingRVRef(X &&);
   operator X() const & = delete;
   operator X() &&;
 };
-TEST(ConvertingRVRef); // cxx98-error {{call to deleted constructor}}
+TEST(ConvertingRVRef); // cxx98_20-error {{call to deleted constructor}}
 
 struct ConvertingCLVRef {
   ConvertingCLVRef();
   ConvertingCLVRef(ConvertingCLVRef &);
 
   struct X {};
-  ConvertingCLVRef(X &&); // cxx11_2b-note {{passing argument to parameter here}}
+  ConvertingCLVRef(X &&); // cxx2b-note {{passing argument to parameter here}}
   operator X() const &;
-  operator X() && = delete; // cxx11_2b-note {{marked deleted here}}
+  operator X() && = delete; // cxx2b-note {{marked deleted here}}
 };
-TEST(ConvertingCLVRef); // cxx11_2b-error {{invokes a deleted function}}
+TEST(ConvertingCLVRef); // cxx2b-error {{invokes a deleted function}}
 
 struct SubSubMove {};
 struct SubMove : SubSubMove {
   SubMove();
-  SubMove(SubMove &) = delete; // cxx98-note {{marked deleted here}}
+  SubMove(SubMove &) = delete; // cxx98_20-note {{marked deleted here}}
 
   SubMove(SubSubMove &&);
 };
-TEST(SubMove); // cxx98-error {{call to deleted constructor}}
+TEST(SubMove); // cxx98_20-error {{call to deleted constructor}}
Index: clang/test/SemaCXX/coroutine-rvo.cpp
===
--- clang/test/SemaCXX/coroutine-rvo.cpp
+++ clang/test/SemaCXX/coroutine-rvo.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx2b %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected   %s
 
 namespace std::experimental {
 template  struct coroutine_handle {
@@ -56,7 +57,9 @@
 auto final_suspend() noexcept { return suspend_never{}; }
 auto get_return_object() { return task{}; }
 static void unhandled_exception() {}
-void 

[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 355391.
jdoerfert added a comment.
Herald added a subscriber: ormris.

Adjust AAExecutionDomain properly to account for the new target agnostic kernel 
init,
this makes D104911  obsolete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/single_threaded_execution.ll
  openmp/libomptarget/deviceRTLs/common/include/target.h
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -60,7 +60,13 @@
   return Mask;
 }
 
-EXTERN void __kmpc_impl_syncthreads() { __syncthreads(); }
+EXTERN void __kmpc_impl_syncthreads() { 
+  int barrier = 2;
+  asm volatile("barrier.sync %0;"
+   :
+   : "r"(barrier)
+   : "memory");
+}
 
 EXTERN void __kmpc_impl_syncwarp(__kmpc_impl_lanemask_t Mask) {
   __nvvm_bar_warp_sync(Mask);
@@ -75,7 +81,7 @@
   // The named barrier for active parallel threads of a team in an L1 parallel
   // region to synchronize with each other.
   int barrier = 1;
-  asm volatile("bar.sync %0, %1;"
+  asm volatile("barrier.sync %0, %1;"
:
: "r"(barrier), "r"(num_threads)
: "memory");
Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -416,11 +416,11 @@
  int32_t cancelVal);
 
 // non standard
-EXTERN void __kmpc_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime);
-EXTERN void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized);
-EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit,
-int16_t RequiresOMPRuntime);
-EXTERN void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime);
+EXTERN int32_t __kmpc_target_init(ident_t *Ident, bool IsSPMD,
+ bool UseGenericStateMachine,
+   bool RequiresFullRuntime);
+EXTERN void __kmpc_target_deinit(ident_t *Ident, bool IsSPMD,
+   bool RequiresFullRuntime);
 EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn);
 EXTERN bool __kmpc_kernel_parallel(void **WorkFn);
 EXTERN void __kmpc_kernel_end_parallel();
Index: openmp/libomptarget/deviceRTLs/common/src/parallel.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/parallel.cu
+++ openmp/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -331,7 +331,7 @@
 (1 + (IsActiveParallelRegion ? OMP_ACTIVE_PARALLEL_LEVEL : 0));
 
   // Master signals work to activate workers.
-  __kmpc_barrier_simple_spmd(nullptr, 0);
+  __kmpc_barrier_simple_spmd(ident, 0);
 
   // OpenMP [2.5, Parallel Construct, p.49]
   // There is an implied barrier at the end of a parallel region. After the
@@ -339,7 +339,7 @@
   // execution of the enclosing task region.
   //
   // The master waits at this barrier until all workers are done.
-  __kmpc_barrier_simple_spmd(nullptr, 0);
+  __kmpc_barrier_simple_spmd(ident, 0);
 
   // Decrement parallel level for non-SPMD warps.
   for (int I = 0; I < NumWarps; ++I)
Index: openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
+++ openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
@@ -12,6 +12,7 @@
 #pragma omp declare target
 
 #include "common/omptarget.h"
+#include "common/support.h"
 #include "target_impl.h"
 
 
@@ -26,16 +27,18 @@
 // init entry points
 
 
-EXTERN void __kmpc_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime) {
+static void __kmpc_generic_kernel_init() {
   PRINT(LD_IO, "call to __kmpc_kernel_init with version %f\n",
 OMPTARGET_NVPTX_VERSION);
-  ASSERT0(LT_FUSSY, RequiresOMPRuntime,
-  "Generic always requires initialized runtime.");
-  setExecutionParameters(Generic, RuntimeInitialized);
-  for (int I = 0; I < MAX_THREADS_PER_TEAM / 

[PATCH] D104847: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX 6.5 and 7.0 WMMA and MMA instructions

2021-06-29 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3644726a78e3: [Clang][NVPTX] Add NVPTX intrinsics and 
builtins for CUDA PTX 6.5 and 7.0 WMMA… (authored by steffenlarsen, committed 
by tra).

Changed prior to commit:
  https://reviews.llvm.org/D104847?vs=354814=355390#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104847

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx-mma.cu
  clang/test/CodeGen/builtins-nvptx-mma.py
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/lit.local.cfg
  llvm/test/CodeGen/NVPTX/wmma.py

Index: llvm/test/CodeGen/NVPTX/wmma.py
===
--- llvm/test/CodeGen/NVPTX/wmma.py
+++ llvm/test/CodeGen/NVPTX/wmma.py
@@ -6,7 +6,7 @@
 # RUN: FileCheck %t-ptx60-sm_70.ll < %t-ptx60-sm_70.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16
 # RUN: FileCheck %t-ptx60-sm_70.ll < %t-ptx60-sm_70.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOEXTGEOM,NOINT,NOSUBINT,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOEXTGEOM,NOINT,NOSUBINT,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx60-sm_70.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx60 \
 # RUN:   | FileCheck %t-ptx60-sm_70.ll
 
@@ -15,7 +15,7 @@
 # RUN: FileCheck %t-ptx61-sm_70.ll < %t-ptx61-sm_70.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM
 # RUN: FileCheck %t-ptx61-sm_70.ll < %t-ptx61-sm_70.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx61-sm_70.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx61 \
 # RUN:   | FileCheck %t-ptx61-sm_70.ll
 
@@ -24,7 +24,7 @@
 # RUN: FileCheck %t-ptx63-sm_72.ll < %t-ptx63-sm_72.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT
 # RUN: FileCheck %t-ptx63-sm_72.ll < %t-ptx63-sm_72.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOSUBINT,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOSUBINT,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx63-sm_72.ll -march=nvptx64 -mcpu=sm_72 -mattr=+ptx63 \
 # RUN:   | FileCheck %t-ptx63-sm_72.ll
 
@@ -33,7 +33,7 @@
 # RUN: FileCheck %t-ptx63-sm_75.ll < %t-ptx63-sm_75.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT
 # RUN: FileCheck %t-ptx63-sm_75.ll < %t-ptx63-sm_75.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx63-sm_75.ll -march=nvptx64 -mcpu=sm_75 -mattr=+ptx63 \
 # RUN:   | FileCheck %t-ptx63-sm_75.ll
 
@@ -42,10 +42,28 @@
 # RUN: FileCheck %t-ptx64-sm_70.ll < %t-ptx64-sm_70.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,MMA
 # RUN: FileCheck %t-ptx64-sm_70.ll < %t-ptx64-sm_70.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT
+# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx64-sm_70.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx64 \
 # RUN:   | FileCheck %t-ptx64-sm_70.ll
 
+# Check all variants of instructions supported by PTX65 on SM75+
+# RUN: python %s --ptx=65 --gpu-arch=75 > %t-ptx65-sm_75.ll
+# RUN: FileCheck %t-ptx65-sm_75.ll < %t-ptx65-sm_75.ll \
+# RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,PTX65MMA
+# RUN: FileCheck %t-ptx65-sm_75.ll < %t-ptx65-sm_75.ll \
+# RUN:   --check-prefixes=INTRINSICS
+# RUN: llc < %t-ptx65-sm_75.ll -march=nvptx64 -mcpu=sm_75 -mattr=+ptx65 \
+# RUN:   | FileCheck %t-ptx65-sm_75.ll
+
+# Check all variants of instructions supported by PTX70 on SM80+
+# RUN: python %s --ptx=70 --gpu-arch=80 > %t-ptx70-sm_80.ll
+# RUN: FileCheck %t-ptx70-sm_80.ll < %t-ptx70-sm_80.ll \
+# RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX70MMA
+# RUN: FileCheck %t-ptx70-sm_80.ll < %t-ptx70-sm_80.ll \
+# RUN:   --check-prefixes=INTRINSICS
+# RUN: llc < %t-ptx70-sm_80.ll -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 \
+# RUN:   | FileCheck %t-ptx70-sm_80.ll
+
 from __future__ import print_function
 
 import argparse
@@ -56,19 +74,23 @@
   def __init__(self, ptx_type):
 self.ptx_type = ptx_type
 self.llvm_type = {
-"f16" : "<2 x half>",
-"f32" : "float",
-"s32" : "i32",
-"s8"  : "i32",
-"u8"  : "i32",
-"s4"  : "i32",
-"u4"  : "i32",
-"b1"  : "i32",
+"f16"  : "<2 x half>",
+"f32"  : "float",
+"f64"  : "double",
+"s32"  : "i32",
+"s8"   : "i32",
+"u8"   : "i32",
+"s4"   : "i32",
+"u4"   : 

[PATCH] D104056: [clangd][nfc] Show more information in logs when compiler instance prepare fails

2021-06-29 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 355389.
ArcsinX added a comment.

Check ASTDiags.take() for empty instead of ASTDiags.getNumErrors() value check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104056

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -390,8 +390,8 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {1}", FileName,
- Inputs.Version);
+elog("Could not build a preamble for file {0} version {1}: {2}", FileName,
+ Inputs.Version, BuiltPreamble.getError().message());
 return nullptr;
   }
 }
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -289,8 +289,15 @@
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
   ASTDiags);
-  if (!Clang)
+  if (!Clang) {
+// The last diagnostic contains information about the reason of this
+// failure.
+std::vector Diags(ASTDiags.take());
+elog("Failed to prepare a compiler instance: {0}",
+ !Diags.empty() ? static_cast(Diags.back()).Message
+: "unknown error");
 return None;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -390,8 +390,8 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {1}", FileName,
- Inputs.Version);
+elog("Could not build a preamble for file {0} version {1}: {2}", FileName,
+ Inputs.Version, BuiltPreamble.getError().message());
 return nullptr;
   }
 }
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -289,8 +289,15 @@
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
   ASTDiags);
-  if (!Clang)
+  if (!Clang) {
+// The last diagnostic contains information about the reason of this
+// failure.
+std::vector Diags(ASTDiags.take());
+elog("Failed to prepare a compiler instance: {0}",
+ !Diags.empty() ? static_cast(Diags.back()).Message
+: "unknown error");
 return None;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104871: [Docs] use -fprofile-generate for IR PGO and -fprofile-instr-generate for code coverage

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



Comment at: clang/docs/UsersManual.rst:2117-2118
 
-Clang also supports profiling via instrumentation. This requires building a
-special instrumented version of the code and has some runtime
 overhead during the profiling, but it provides more detailed results than a

I like the original paragraph here. The casual reader doesn't need to know 
about the two flavors of instrumentation, that detail can be added at the end 
of this section.



Comment at: clang/docs/UsersManual.rst:2197
 
 4. Build the code again using the ``-fprofile-instr-use`` option to specify the
collected profile data.

This should be `fprofile-use`, correct?



Comment at: clang/docs/UsersManual.rst:2208-2211
 Profile generation using an alternative instrumentation method can be
 controlled by the GCC-compatible flags ``-fprofile-generate`` and
 ``-fprofile-use``. Although these flags are semantically equivalent to
 their GCC counterparts, they *do not* handle GCC-compatible profiles.

This is the right place to mention the `fprofile-instr-generate / use` flags.

It's worth retaining the note that, although Clang and GCC use the same command 
line flags to enable PGO, the profile data format is not compatible.



Comment at: clang/docs/UsersManual.rst:2219
   The ``-fprofile-generate`` and ``-fprofile-generate=`` flags will use
   an alternative instrumentation method for profile generation. When
   given a directory name, it generates the profile file

This probably needs edits too, it's not the alternative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104871

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


[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D105099#2848317 , @curdeius wrote:

> Formatting part and tests look good to me, but I'd rather see this patch 
> merge all related boolean options into one enum.
> Just thinking out loud, but is it doable to merge 
> AllowAllConstructorInitializersOnNextLine, 
> ConstructorInitializerAllOnOneLineOrOnePerLine and this patch's 
> ConstructorInitializerAlwaysOnePerLine into e.g. ConstructorInitializerStyle: 
> AllowNextLine | NonBinPack==AllOnOneLineOrOnePerLine | OnePerLine. And one 
> other enum value for the default case without special handling.
> Of course, we'd need to keep that backward compatible.

If we were to start this all over without the need of backward compatibility 
and the existence of the related unit tests, an enum might be a better option. 
Then I still think the user might have some trouble relating the following to 
the enum.

  If AlwaysOnePerLine:
Put each on its own line.
  Else If AllOnOneLineOrOnePerline:
If they all fit on one line:
  Put all of them on a single line.
Else If AllOnNextLine:
  Put (the rest of) them on the next line.
Else:
  Put each on its own line.
  Else:
...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D104649: Thread safety analysis: Rename parameters of ThreadSafetyAnalyzer::intersectAndWarn (NFC)

2021-06-29 Thread Aaron Puchert 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 rGe0b90771c318: Thread safety analysis: Rename parameters of 
ThreadSafetyAnalyzer… (authored by aaronpuchert).

Changed prior to commit:
  https://reviews.llvm.org/D104649?vs=353380=355374#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104649

Files:
  clang/lib/Analysis/ThreadSafety.cpp


Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1052,13 +1052,13 @@
 
   bool join(const FactEntry , const FactEntry );
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1,
-LockErrorKind LEK2);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind EntryLEK,
+LockErrorKind ExitLEK);
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1) {
-intersectAndWarn(FSet1, FSet2, JoinLoc, LEK1, LEK1);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind LEK) {
+intersectAndWarn(EntrySet, ExitSet, JoinLoc, LEK, LEK);
   }
 
   void runAnalysis(AnalysisDeclContext );
@@ -2219,43 +2219,44 @@
 /// are the same. In the event of a difference, we use the intersection of 
these
 /// two locksets at the start of D.
 ///
-/// \param FSet1 The first lockset.
-/// \param FSet2 The second lockset.
+/// \param EntrySet A lockset for entry into a (possibly new) block.
+/// \param ExitSet The lockset on exiting a preceding block.
 /// \param JoinLoc The location of the join point for error reporting
-/// \param LEK1 The error message to report if a mutex is missing from LSet1
-/// \param LEK2 The error message to report if a mutex is missing from Lset2
-void ThreadSafetyAnalyzer::intersectAndWarn(FactSet ,
-const FactSet ,
+/// \param EntryLEK The warning if a mutex is missing from \p EntrySet.
+/// \param ExitLEK The warning if a mutex is missing from \p ExitSet.
+void ThreadSafetyAnalyzer::intersectAndWarn(FactSet ,
+const FactSet ,
 SourceLocation JoinLoc,
-LockErrorKind LEK1,
-LockErrorKind LEK2) {
-  FactSet FSet1Orig = FSet1;
-
-  // Find locks in FSet2 that conflict or are not in FSet1, and warn.
-  for (const auto  : FSet2) {
-const FactEntry  = FactMan[Fact];
-
-FactSet::iterator Iter1 = FSet1.findLockIter(FactMan, LDat2);
-if (Iter1 != FSet1.end()) {
-  if (join(FactMan[*Iter1], LDat2) && LEK1 == LEK_LockedSomePredecessors)
-*Iter1 = Fact;
-} else if (!LDat2.managed()) {
-  LDat2.handleRemovalFromIntersection(FSet2, FactMan, JoinLoc, LEK1,
-  Handler);
+LockErrorKind EntryLEK,
+LockErrorKind ExitLEK) {
+  FactSet EntrySetOrig = EntrySet;
+
+  // Find locks in ExitSet that conflict or are not in EntrySet, and warn.
+  for (const auto  : ExitSet) {
+const FactEntry  = FactMan[Fact];
+
+FactSet::iterator EntryIt = EntrySet.findLockIter(FactMan, ExitFact);
+if (EntryIt != EntrySet.end()) {
+  if (join(FactMan[*EntryIt], ExitFact) &&
+  EntryLEK == LEK_LockedSomePredecessors)
+*EntryIt = Fact;
+} else if (!ExitFact.managed()) {
+  ExitFact.handleRemovalFromIntersection(ExitSet, FactMan, JoinLoc,
+ EntryLEK, Handler);
 }
   }
 
-  // Find locks in FSet1 that are not in FSet2, and remove them.
-  for (const auto  : FSet1Orig) {
-const FactEntry *LDat1 = [Fact];
-const FactEntry *LDat2 = FSet2.findLock(FactMan, *LDat1);
+  // Find locks in EntrySet that are not in ExitSet, and remove them.
+  for (const auto  : EntrySetOrig) {
+const FactEntry *EntryFact = [Fact];
+const FactEntry *ExitFact = ExitSet.findLock(FactMan, *EntryFact);
 
-if (!LDat2) {
-  if (!LDat1->managed() || LEK2 == LEK_LockedSomeLoopIterations)
-LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
- Handler);
-  if (LEK2 == LEK_LockedSomePredecessors)
-FSet1.removeLock(FactMan, *LDat1);
+if (!ExitFact) {
+  if (!EntryFact->managed() || ExitLEK == LEK_LockedSomeLoopIterations)
+EntryFact->handleRemovalFromIntersection(EntrySetOrig, FactMan, 
JoinLoc,
+ ExitLEK, 

[PATCH] D104261: Thread safety analysis: Always warn when dropping locks on back edges

2021-06-29 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
aaronpuchert marked an inline comment as done.
Closed by commit rGf664e2ec371f: Thread safety analysis: Always warn when 
dropping locks on back edges (authored by aaronpuchert).

Changed prior to commit:
  https://reviews.llvm.org/D104261?vs=351972=355373#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104261

Files:
  clang/lib/Analysis/ThreadSafety.cpp
  clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -636,11 +636,11 @@
 
 void shared_fun_1() {
   sls_mu.ReaderLock(); // \
-// expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
+// expected-note {{the other acquisition of mutex 'sls_mu' is here}}
   do {
 sls_mu.Unlock();
 sls_mu.Lock();  // \
-  // expected-note {{the other acquisition of mutex 'sls_mu' is here}}
+  // expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
   } while (getBool());
   sls_mu.Unlock();
 }
@@ -695,11 +695,11 @@
 
 void shared_bad_0() {
   sls_mu.Lock();  // \
-// expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
+// expected-note {{the other acquisition of mutex 'sls_mu' is here}}
   do {
 sls_mu.Unlock();
 sls_mu.ReaderLock();  // \
-  // expected-note {{the other acquisition of mutex 'sls_mu' is here}}
+  // expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
   } while (getBool());
   sls_mu.Unlock();
 }
@@ -2773,6 +2773,45 @@
   x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
 }
 
+void loopAcquire() {
+  RelockableMutexLock scope(, DeferTraits{});
+  for (unsigned i = 1; i < 10; ++i)
+scope.Lock(); // We could catch this double lock with negative capabilities.
+}
+
+void loopRelease() {
+  RelockableMutexLock scope(, ExclusiveTraits{}); // expected-note {{mutex acquired here}}
+  // We have to warn on this join point despite the lock being managed ...
+  for (unsigned i = 1; i < 10; ++i) { // expected-warning {{expecting mutex 'mu' to be held at start of each loop}}
+x = 1; // ... because we might miss that this doesn't always happen under lock.
+if (i == 5)
+  scope.Unlock();
+  }
+}
+
+void loopAcquireContinue() {
+  RelockableMutexLock scope(, DeferTraits{});
+  for (unsigned i = 1; i < 10; ++i) {
+x = 1; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+if (i == 5) {
+  scope.Lock();
+  continue;
+}
+  }
+}
+
+void loopReleaseContinue() {
+  RelockableMutexLock scope(, ExclusiveTraits{}); // expected-note {{mutex acquired here}}
+  // We have to warn on this join point despite the lock being managed ...
+  for (unsigned i = 1; i < 10; ++i) {
+x = 1; // ... because we might miss that this doesn't always happen under lock.
+if (i == 5) {
+  scope.Unlock();
+  continue; // expected-warning {{expecting mutex 'mu' to be held at start of each loop}}
+}
+  }
+}
+
 void exclusiveSharedJoin() {
   RelockableMutexLock scope(, DeferTraits{});
   if (b)
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -865,7 +865,7 @@
   handleRemovalFromIntersection(const FactSet , FactManager ,
 SourceLocation JoinLoc, LockErrorKind LEK,
 ThreadSafetyHandler ) const override {
-if (!managed() && !asserted() && !negative() && !isUniversal()) {
+if (!asserted() && !negative() && !isUniversal()) {
   Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,
 LEK);
 }
@@ -2239,7 +2239,7 @@
 if (Iter1 != FSet1.end()) {
   if (join(FactMan[*Iter1], LDat2) && LEK1 == LEK_LockedSomePredecessors)
 *Iter1 = Fact;
-} else {
+} else if (!LDat2.managed()) {
   LDat2.handleRemovalFromIntersection(FSet2, FactMan, JoinLoc, LEK1,
   Handler);
 }
@@ -2251,8 +2251,9 @@
 const FactEntry *LDat2 = FSet2.findLock(FactMan, *LDat1);
 
 if (!LDat2) {
-  LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
-   Handler);
+  if (!LDat1->managed() || LEK2 == LEK_LockedSomeLoopIterations)
+LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
+ Handler);
   

[clang] e0b9077 - Thread safety analysis: Rename parameters of ThreadSafetyAnalyzer::intersectAndWarn (NFC)

2021-06-29 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-06-29T23:56:52+02:00
New Revision: e0b90771c318625e51c34c67db3f3dfbbb686df8

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

LOG: Thread safety analysis: Rename parameters of 
ThreadSafetyAnalyzer::intersectAndWarn (NFC)

In D104261 we made the parameters' meaning slightly more specific, this
changes their names accordingly. In all uses we're building a new lock
set by intersecting existing locksets. The first (modifiable) argument
is the new lock set being built, the second (non-modifiable) argument is
the exit set of a preceding block.

Reviewed By: aaron.ballman, delesley

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

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index b09de2bd71f2..5b2c882c4235 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1052,13 +1052,13 @@ class ThreadSafetyAnalyzer {
 
   bool join(const FactEntry , const FactEntry );
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1,
-LockErrorKind LEK2);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind EntryLEK,
+LockErrorKind ExitLEK);
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1) {
-intersectAndWarn(FSet1, FSet2, JoinLoc, LEK1, LEK1);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind LEK) {
+intersectAndWarn(EntrySet, ExitSet, JoinLoc, LEK, LEK);
   }
 
   void runAnalysis(AnalysisDeclContext );
@@ -2219,43 +2219,44 @@ bool ThreadSafetyAnalyzer::join(const FactEntry , 
const FactEntry ) {
 /// are the same. In the event of a 
diff erence, we use the intersection of these
 /// two locksets at the start of D.
 ///
-/// \param FSet1 The first lockset.
-/// \param FSet2 The second lockset.
+/// \param EntrySet A lockset for entry into a (possibly new) block.
+/// \param ExitSet The lockset on exiting a preceding block.
 /// \param JoinLoc The location of the join point for error reporting
-/// \param LEK1 The error message to report if a mutex is missing from LSet1
-/// \param LEK2 The error message to report if a mutex is missing from Lset2
-void ThreadSafetyAnalyzer::intersectAndWarn(FactSet ,
-const FactSet ,
+/// \param EntryLEK The warning if a mutex is missing from \p EntrySet.
+/// \param ExitLEK The warning if a mutex is missing from \p ExitSet.
+void ThreadSafetyAnalyzer::intersectAndWarn(FactSet ,
+const FactSet ,
 SourceLocation JoinLoc,
-LockErrorKind LEK1,
-LockErrorKind LEK2) {
-  FactSet FSet1Orig = FSet1;
-
-  // Find locks in FSet2 that conflict or are not in FSet1, and warn.
-  for (const auto  : FSet2) {
-const FactEntry  = FactMan[Fact];
-
-FactSet::iterator Iter1 = FSet1.findLockIter(FactMan, LDat2);
-if (Iter1 != FSet1.end()) {
-  if (join(FactMan[*Iter1], LDat2) && LEK1 == LEK_LockedSomePredecessors)
-*Iter1 = Fact;
-} else if (!LDat2.managed()) {
-  LDat2.handleRemovalFromIntersection(FSet2, FactMan, JoinLoc, LEK1,
-  Handler);
+LockErrorKind EntryLEK,
+LockErrorKind ExitLEK) {
+  FactSet EntrySetOrig = EntrySet;
+
+  // Find locks in ExitSet that conflict or are not in EntrySet, and warn.
+  for (const auto  : ExitSet) {
+const FactEntry  = FactMan[Fact];
+
+FactSet::iterator EntryIt = EntrySet.findLockIter(FactMan, ExitFact);
+if (EntryIt != EntrySet.end()) {
+  if (join(FactMan[*EntryIt], ExitFact) &&
+  EntryLEK == LEK_LockedSomePredecessors)
+*EntryIt = Fact;
+} else if (!ExitFact.managed()) {
+  ExitFact.handleRemovalFromIntersection(ExitSet, FactMan, JoinLoc,
+ EntryLEK, Handler);
 }
   }
 
-  // Find locks in FSet1 that are not in FSet2, and remove them.
-  for (const auto  : FSet1Orig) {
-const FactEntry *LDat1 = [Fact];
-const FactEntry *LDat2 = FSet2.findLock(FactMan, *LDat1);
+  // Find locks in EntrySet that are not in ExitSet, and remove them.
+  for (const auto  : EntrySetOrig) {
+const FactEntry *EntryFact = [Fact];
+const FactEntry *ExitFact = ExitSet.findLock(FactMan, 

[clang] f664e2e - Thread safety analysis: Always warn when dropping locks on back edges

2021-06-29 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-06-29T23:56:52+02:00
New Revision: f664e2ec371f61b69e11147d7f9e045083335917

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

LOG: Thread safety analysis: Always warn when dropping locks on back edges

We allow branches to join where one holds a managed lock but the other
doesn't, but we can't do so for back edges: because there we can't drop
them from the lockset, as we have already analyzed the loop with the
larger lockset. So we can't allow dropping managed locks on back edges.

We move the managed() check from handleRemovalFromIntersection up to
intersectAndWarn, where we additionally check if we're on a back edge if
we're removing from the first lock set (the entry set of the next block)
but not if we're removing from the second lock set (the exit set of the
previous block). Now that the order of arguments matters, I had to swap
them in one invocation, which also causes some minor differences in the
tests.

Reviewed By: delesley

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

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 3eb1b640e7290..b09de2bd71f24 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -865,7 +865,7 @@ class LockableFactEntry : public FactEntry {
   handleRemovalFromIntersection(const FactSet , FactManager ,
 SourceLocation JoinLoc, LockErrorKind LEK,
 ThreadSafetyHandler ) const override {
-if (!managed() && !asserted() && !negative() && !isUniversal()) {
+if (!asserted() && !negative() && !isUniversal()) {
   Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,
 LEK);
 }
@@ -2239,7 +2239,7 @@ void ThreadSafetyAnalyzer::intersectAndWarn(FactSet 
,
 if (Iter1 != FSet1.end()) {
   if (join(FactMan[*Iter1], LDat2) && LEK1 == LEK_LockedSomePredecessors)
 *Iter1 = Fact;
-} else {
+} else if (!LDat2.managed()) {
   LDat2.handleRemovalFromIntersection(FSet2, FactMan, JoinLoc, LEK1,
   Handler);
 }
@@ -2251,8 +2251,9 @@ void ThreadSafetyAnalyzer::intersectAndWarn(FactSet 
,
 const FactEntry *LDat2 = FSet2.findLock(FactMan, *LDat1);
 
 if (!LDat2) {
-  LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
-   Handler);
+  if (!LDat1->managed() || LEK2 == LEK_LockedSomeLoopIterations)
+LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
+ Handler);
   if (LEK2 == LEK_LockedSomePredecessors)
 FSet1.removeLock(FactMan, *LDat1);
 }
@@ -2528,7 +2529,7 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext ) {
   CFGBlock *FirstLoopBlock = *SI;
   CFGBlockInfo *PreLoop = [FirstLoopBlock->getBlockID()];
   CFGBlockInfo *LoopEnd = [CurrBlockID];
-  intersectAndWarn(LoopEnd->ExitSet, PreLoop->EntrySet, PreLoop->EntryLoc,
+  intersectAndWarn(PreLoop->EntrySet, LoopEnd->ExitSet, PreLoop->EntryLoc,
LEK_LockedSomeLoopIterations);
 }
   }

diff  --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp 
b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
index 8e8bb6f45dde4..e9d41da80517c 100644
--- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -636,11 +636,11 @@ void shared_fun_0() {
 
 void shared_fun_1() {
   sls_mu.ReaderLock(); // \
-// expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in 
the same scope}}
+// expected-note {{the other acquisition of mutex 'sls_mu' is here}}
   do {
 sls_mu.Unlock();
 sls_mu.Lock();  // \
-  // expected-note {{the other acquisition of mutex 'sls_mu' is here}}
+  // expected-warning {{mutex 'sls_mu' is acquired exclusively and shared 
in the same scope}}
   } while (getBool());
   sls_mu.Unlock();
 }
@@ -695,11 +695,11 @@ void shared_fun_11() {
 
 void shared_bad_0() {
   sls_mu.Lock();  // \
-// expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in 
the same scope}}
+// expected-note {{the other acquisition of mutex 'sls_mu' is here}}
   do {
 sls_mu.Unlock();
 sls_mu.ReaderLock();  // \
-  // expected-note {{the other acquisition of mutex 'sls_mu' is here}}
+  // expected-warning {{mutex 'sls_mu' is acquired exclusively and shared 
in the same scope}}
   } while (getBool());
   sls_mu.Unlock();
 }
@@ -2773,6 

[PATCH] D104766: [X86] Zero some outputs of Keylocker intrinsics in error case

2021-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14834
 
+BasicBlock *NoError = createBasicBlock(StrNoErr, this->CurFn);
+BasicBlock *Error = createBasicBlock(StrErr, this->CurFn);

Sorry I'm late here. Instead of having 3 separate strings for each intrinsic 
can you do something like `createBasicBlock(BaseName + "_no_error"...)` here. I 
believe createBasicBlock takes a Twine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104766

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


[PATCH] D104085: [compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia

2021-06-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 355368.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104085

Files:
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp

Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -46,7 +46,12 @@
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
   InitStackAndTls(state);
+#if !SANITIZER_FUCHSIA
+  // Do not initialize the stack ring buffer just yet on Fuchsia. Threads will
+  // be initialized before we enter the thread itself, so we will instead call
+  // this later.
   InitStackRingBuffer(stack_buffer_start, stack_buffer_size);
+#endif
 }
 
 void Thread::InitStackRingBuffer(uptr stack_buffer_start,
Index: compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
===
--- /dev/null
+++ compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -0,0 +1,158 @@
+//===-- hwasan_fuchsia.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file is a part of HWAddressSanitizer and contains Fuchsia-specific
+/// code.
+///
+//===--===//
+
+#include "sanitizer_common/sanitizer_fuchsia.h"
+#if SANITIZER_FUCHSIA
+
+#include "hwasan.h"
+#include "hwasan_interface_internal.h"
+#include "hwasan_report.h"
+#include "hwasan_thread.h"
+#include "hwasan_thread_list.h"
+
+// This TLS variable contains the location of the stack ring buffer and can be
+// used to always find the hwasan thread object associated with the current
+// running thread.
+SANITIZER_INTERFACE_ATTRIBUTE
+[[gnu::tls_model("initial-exec")]] THREADLOCAL uptr __hwasan_tls;
+
+namespace __hwasan {
+
+// These are known parameters passed to the hwasan runtime on thread creation.
+struct Thread::InitState {
+  uptr stack_bottom, stack_top;
+};
+
+static void FinishThreadInitialization(Thread *thread);
+
+void InitThreads() {
+  // This is the minimal alignment needed for the storage where hwasan threads
+  // and their stack ring buffers are placed. This alignment is necessary so the
+  // stack ring buffer can perform a simple calculation to get the next element
+  // in the RB. The instructions for this calculation are emitted by the
+  // compiler. (Full explanation in hwasan_thread_list.h.)
+  uptr alloc_size = UINT64_C(1) << kShadowBaseAlignment;
+  uptr thread_start = reinterpret_cast(
+  MmapAlignedOrDieOnFatalError(alloc_size, alloc_size, __func__));
+
+  InitThreadList(thread_start, alloc_size);
+
+  // Create the hwasan thread object for the current (main) thread. Stack info
+  // for this thread is known from information passed via
+  // __sanitizer_startup_hook.
+  const Thread::InitState state = {
+  .stack_bottom = __sanitizer::MainThreadStackBase,
+  .stack_top =
+  __sanitizer::MainThreadStackBase + __sanitizer::MainThreadStackSize,
+  };
+  FinishThreadInitialization(hwasanThreadList().CreateCurrentThread());
+}
+
+uptr *GetCurrentThreadLongPtr() { return &__hwasan_tls; }
+
+// This is called from the parent thread before the new thread is created. Here
+// we can propagate known info like the stack bounds to Thread::Init before
+// jumping into the thread. We cannot initialize the stack ring buffer yet since
+// we have not entered the new thread.
+static void *BeforeThreadCreateHook(uptr user_id, bool detached,
+const char *name, uptr stack_bottom,
+uptr stack_size) {
+  const Thread::InitState state = {
+  .stack_bottom = stack_bottom,
+  .stack_top = stack_bottom + stack_size,
+  };
+  return hwasanThreadList().CreateCurrentThread();
+}
+
+// This sets the stack top and bottom according to the InitState passed to
+// CreateCurrentThread above.
+void Thread::InitStackAndTls(const InitState *state) {
+  CHECK_NE(state->stack_bottom, 0);
+  CHECK_NE(state->stack_top, 0);
+  stack_bottom_ = state->stack_bottom;
+  stack_top_ = state->stack_top;
+  tls_end_ = tls_begin_ = 0;
+}
+
+// This is called after creating a new thread with the pointer returned by
+// BeforeThreadCreateHook. We are still in the creating thread and should check
+// if it was actually created correctly.
+static void ThreadCreateHook(void *hook, bool aborted) {
+  Thread *thread = static_cast(hook);
+  if (!aborted) {
+// The thread was created successfully.
+// ThreadStartHook can 

[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D105099#2847933 , 
@HazardyKnusperkeks wrote:

> In D105099#2847328 , 
> @MyDeveloperDay wrote:
>
>> Seem similar to D90232: [clang-format] Formatting constructor initializer 
>> lists by putting them always on different lines (update to D14484) 
>>  which seems to have got stalled
>>
>> I sort of feel I prefer the design where we have an enum rather than 
>> introducing a separate option.
>
> Yeah I thought, I already saw something like that.
>
> I too think the way with the enum is a better one.

I was aware of that one. Didn't it get blocked because it failed the unit 
tests? Besides, it didn't handle the `AfterColon` case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D104647: [analyzer] Support SVal::getType for pointer-to-member values

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



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:85
   const NamedDecl *D;
+  QualType T;
   llvm::ImmutableList L;

What prevents you from obtaining the type from `D`? I guess `NamedDecl` itself 
doesn't provide a `getType()` on its own but what specific sub-classes can `D` 
be that don't have a type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104647

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


[clang] 8d21d54 - [CodeGen] Stop creating fake FunctionDecls when generating IR for

2021-06-29 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2021-06-29T14:22:33-07:00
New Revision: 8d21d5472501460933e78aead04cf59579025ba4

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

LOG: [CodeGen] Stop creating fake FunctionDecls when generating IR for
functions implicitly generated by the compiler

These fake functions would cause clang to crash if the changes proposed
in https://reviews.llvm.org/D98799 were made.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGNonTrivialStruct.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGen/constructor-attribute.c
clang/test/CodeGen/debug-info-oslog.c
clang/test/CodeGenObjC/nontrivial-c-struct-exception.m

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9579d706b2ae5..2f2d5e6c83d77 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1681,7 +1681,6 @@ llvm::Function 
*CodeGenFunction::generateBuiltinOSLogHelperFunction(
   }
 
   QualType ReturnTy = Ctx.VoidTy;
-  QualType FuncionTy = Ctx.getFunctionType(ReturnTy, ArgTys, {});
 
   // The helper function has linkonce_odr linkage to enable the linker to merge
   // identical functions. To ensure the merging always happens, 'noinline' is
@@ -1701,14 +1700,7 @@ llvm::Function 
*CodeGenFunction::generateBuiltinOSLogHelperFunction(
 Fn->addFnAttr(llvm::Attribute::NoInline);
 
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
-  IdentifierInfo *II = (Name);
-  FunctionDecl *FD = FunctionDecl::Create(
-  Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), 
II,
-  FuncionTy, nullptr, SC_PrivateExtern, false, false);
-  // Avoid generating debug location info for the function.
-  FD->setImplicit();
-
-  StartFunction(FD, ReturnTy, Fn, FI, Args);
+  StartFunction(GlobalDecl(), ReturnTy, Fn, FI, Args);
 
   // Create a scope with an artificial location for the body of this function.
   auto AL = ApplyDebugLocation::CreateArtificial(*this);

diff  --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp 
b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index 9c6bbbc048b72..ad505fc5a0d4f 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -472,14 +472,10 @@ template  struct GenFuncBase {
 F->setVisibility(llvm::GlobalValue::HiddenVisibility);
 CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, F, /*IsThunk=*/false);
 CGM.SetLLVMFunctionAttributesForDefinition(nullptr, F);
-IdentifierInfo *II = (FuncName);
-FunctionDecl *FD = FunctionDecl::Create(
-Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
-II, Ctx.getFunctionType(Ctx.VoidTy, llvm::None, {}), nullptr,
-SC_PrivateExtern, false, false);
 CodeGenFunction NewCGF(CGM);
 setCGF();
-CGF->StartFunction(FD, Ctx.VoidTy, F, FI, Args);
+CGF->StartFunction(GlobalDecl(), Ctx.VoidTy, F, FI, Args);
+auto AL = ApplyDebugLocation::CreateArtificial(*CGF);
 std::array Addrs =
 getParamAddrs(std::make_index_sequence{}, Alignments, Args, CGF);
 asDerived().visitStructFields(QT, CharUnits::Zero(), Addrs);

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 183ec7c2842f2..cf277ca347e43 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2611,15 +2611,6 @@ static llvm::Function 
*createGlobalInitOrCleanupFn(CodeGen::CodeGenModule ,
   return GlobalInitOrCleanupFn;
 }
 
-static FunctionDecl *
-createGlobalInitOrCleanupFnDecl(CodeGen::CodeGenModule , StringRef FnName) 
{
-  ASTContext  = CGM.getContext();
-  QualType FunctionTy = Ctx.getFunctionType(Ctx.VoidTy, llvm::None, {});
-  return FunctionDecl::Create(
-  Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
-  (FnName), FunctionTy, nullptr, SC_Static, false, false);
-}
-
 void CodeGenModule::unregisterGlobalDtorsWithUnAtExit() {
   for (const auto  : DtorsUsingAtExit) {
 int Priority = I.first;
@@ -2629,13 +2620,11 @@ void CodeGenModule::unregisterGlobalDtorsWithUnAtExit() 
{
 llvm::Function *GlobalCleanupFn =
 createGlobalInitOrCleanupFn(*this, GlobalCleanupFnName);
 
-FunctionDecl *GlobalCleanupFD =
-createGlobalInitOrCleanupFnDecl(*this, GlobalCleanupFnName);
-
 CodeGenFunction CGF(*this);
-CGF.StartFunction(GlobalDecl(GlobalCleanupFD), getContext().VoidTy,
-  GlobalCleanupFn, getTypes().arrangeNullaryFunction(),
-  FunctionArgList(), SourceLocation(), SourceLocation());
+CGF.StartFunction(GlobalDecl(), getContext().VoidTy, GlobalCleanupFn,
+  getTypes().arrangeNullaryFunction(), FunctionArgList(),
+ 

[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D105099#2847332 , @MyDeveloperDay 
wrote:

> We already have
>
> `AllowAllConstructorInitializersOnNextLine` and 
> `ConstructorInitializerAllOnOneLineOrOnePerLine`
>
> Sort of feels like we need to combine them with this,
>
> I should also say I'd quite like this functionality, its just how do we 
> deliver it via the options that I think we might want to think about, as I 
> sort of feel the 3 options (if we introduced another) are competing with each 
> other.

`AllowAllConstructorInitializersOnNextLine` is like a sub-option of 
`ConstructorInitializerAllOnOneLineOrOnePerLine`; it has no effect unless the 
latter is `true`. The new `ConstructorInitializerAlwaysOnePerLine` option, if 
set to `true`, overrides `ConstructorInitializerAllOnOneLineOrOnePerLine` as it 
should with //Always//. I think it would be contrived to combine these options 
in an enum. Is it even practical to do so without breaking the unit tests and 
backward compatibility?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D105148: [CMake] Don't use -Bsymbolic-functions for MinGW targets

2021-06-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

> but I don't know if the solaris linker supports -Bsymbolic-functions or not.

According to a Solaris "man pages section 1: User Commands", 
-Bsymbolic-functions is supported.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105148

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


[PATCH] D105017: [analyzer] LValueToRValueBitCasts should evaluate to an r-value

2021-06-29 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.

So it worked out of the box? Great!


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

https://reviews.llvm.org/D105017

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


[PATCH] D105151: [OPENMP]Fix PR50733: unexpected final value of list-item in linear clause in loop construct.

2021-06-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: mikerice, jdoerfert.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a project: clang.

Currently the last value of linear is calculated as var = init + num_iters * 
step.
Replaced it with var = var_priv, i.e. original variable gets the value
of the last private copy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105151

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp

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


[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-06-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I'm (happily) surprised this required so few changes!




Comment at: clang/include/clang/Basic/LangOptions.h:690-691
+
+  /// The translation unit is a partial translation unit, growing 
incrementally.
+  TU_Partial
 };

I don't think this is clear enough about the difference between `TU_Prefix` and 
`TU_Partial`. I think the difference is:

* `TU_Prefix` is an incomplete prefix of a translation unit. Because it's not 
complete, we don't perform (most) finalization steps (eg, template 
instantiation) at the end.
* `TU_Partial` is a complete translation unit that we might nonetheless 
incrementally extend later. Because it is complete (and we might want to 
generate code for it), we do perform template instantiation, but because it 
might be extended later, we don't warn if it declares or uses undefined 
internal-linkage symbols.

I wonder if `TU_Incremental` would be a better name than `TU_Partial`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D104918

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


[PATCH] D105148: [CMake] Don't use -Bsymbolic-functions for MinGW targets

2021-06-29 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: MaskRay, phosek.
Herald added subscribers: fedor.sergeev, mgorny.
mstorsjo requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

This is an ELF specific option which isn't supported for Windows/MinGW
targets, even if the MinGW linker otherwise uses a ld.bfd like linker
interface.

In llvm-shlib, there's already a separate if statement for

  if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)

but I don't know if the solaris linker supports -Bsymbolic-functions
or not.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105148

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,11 +50,13 @@
   # Solaris ld does not accept global: *; so there is no way to version 
*all* global symbols
   set(LIB_NAMES 
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
 ${LIB_NAMES})
 endif()
-# Optimize function calls for default visibility definitions to avoid PLT 
and
-# reduce dynamic relocations.
-# Note: for -fno-pic default, the address of a function may be different 
from
-# inside and outside libLLVM.so.
-target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+if (NOT MINGW)
+  # Optimize function calls for default visibility definitions to avoid 
PLT and
+  # reduce dynamic relocations.
+  # Note: for -fno-pic default, the address of a function may be different 
from
+  # inside and outside libLLVM.so.
+  target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+endif()
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -50,6 +50,6 @@
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE)
+if (NOT APPLE AND NOT MINGW)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,11 +50,13 @@
   # Solaris ld does not accept global: *; so there is no way to version *all* global symbols
   set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
 endif()
-# Optimize function calls for default visibility definitions to avoid PLT and
-# reduce dynamic relocations.
-# Note: for -fno-pic default, the address of a function may be different from
-# inside and outside libLLVM.so.
-target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+if (NOT MINGW)
+  # Optimize function calls for default visibility definitions to avoid PLT and
+  # reduce dynamic relocations.
+  # Note: for -fno-pic default, the address of a function may be different from
+  # inside and outside libLLVM.so.
+  target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
+endif()
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -50,6 +50,6 @@
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE)
+if (NOT APPLE AND NOT MINGW)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104925: [Analyzer] Improve report of file read at end-of-file condition.

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

In D104925#2846283 , @balazske wrote:

> I could not find a way to pass the needed information from the BugReport to 
> the `NoteTag`. The "sequence number" (in `EofSeqMap`) is only known when the 
> bug is detected, this should be passed to the `NoteTag` somehow.

You can //capture// it.

That's the whole point of note tags, to have access to all the information from 
both the bug report and the moment of time the event has happened.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104925

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


[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

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

I suspect that you might want to include `OperationKinds.def` instead of 
`OperationKinds.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

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


[PATCH] D104601: [Preprocessor] Implement -fnormalize-whitespace.

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

In D104601#2847400 , @aaron.ballman 
wrote:

> ... would add that it's very common for implementers to ask developers to run 
> their code through `-E` mode to submit preprocessed output in order to 
> reproduce a customer issue with the compiler, and I worry that uses of this 
> flag will have unintended consequences in that scenario.

Why would one add `-fnormalize-whitespace` for this use case?

> The "very long line" example mentioned by @dblaikie is sort of along these 
> lines (sorry for the bad pun).

I can add a forced line breaks (after/before 80 cols? configurable?) if 
requested.




Comment at: clang/lib/Frontend/PrintPreprocessedOutput.cpp:174
+  ///on being on the same line, such as directives.
+  void HandleWhitespaceBeforeTok(Token , bool RequireSpace,
+ bool RequireSameLine);

aaron.ballman wrote:
> Can `Tok` be `const Token &` instead?
Note that this is a renamed `bool HandleFirstTokOnLine(Token )`. Renamed 
because it is now called for every token.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D104601: [Preprocessor] Implement -fnormalize-whitespace.

2021-06-29 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 355350.
Meinersbur marked 6 inline comments as done.
Meinersbur added a comment.

- Address review by @aaron.ballman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/PreprocessorOutputOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/test/CXX/lex/lex.pptoken/p3-2a.cpp
  clang/test/Preprocessor/c99-6_10_3_4_p5.c
  clang/test/Preprocessor/c99-6_10_3_4_p6.c
  clang/test/Preprocessor/comment_save.c
  clang/test/Preprocessor/first-line-indent.c
  clang/test/Preprocessor/hash_line.c
  clang/test/Preprocessor/line-directive-output-normcol.c
  clang/test/Preprocessor/line-directive-output.c
  clang/test/Preprocessor/macro_space.c
  clang/test/Preprocessor/normalize-whitespace.c
  clang/test/Preprocessor/print_line_include.c
  clang/test/Preprocessor/stringize_space.c

Index: clang/test/Preprocessor/stringize_space.c
===
--- clang/test/Preprocessor/stringize_space.c
+++ clang/test/Preprocessor/stringize_space.c
@@ -1,16 +1,18 @@
 // RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s | FileCheck --strict-whitespace %s --check-prefix=NORMWS
 
 #define A(b) -#b  ,  - #b  ,  -# b  ,  - # b
 A()
 
 // CHECK: {{^}}-"" , - "" , -"" , - ""{{$}}
-
+// NORMWS: {{^}}-"",-"",-"",-""
 
 #define t(x) #x
 t(a
 c)
 
 // CHECK: {{^}}"a c"{{$}}
+// NORMWS-SAME: "a c"
 
 #define str(x) #x
 #define f(x) str(-x)
@@ -18,6 +20,7 @@
 1)
 
 // CHECK: {{^}}"-1"
+// NORMWS-SAME: "-1"
 
 #define paste(a,b) str(a&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCOL
+// RUN: %clang_cc1 -E -C -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCCOL
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMWS
+// RUN: %clang_cc1 -E -C -P -fnormalize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=NORMCWS
+
+#define NOT_OMP  omp  something
+#define HASH #
+
+  int  a; /*  span-comment  */
+  int  b  ;   //  line-comment
+  _Pragma  (  "omp  barrier"  ) x //  more line-comments
+  #pragma  omp  nothing  //  another comment
+HASH  pragma  NOT_OMP
+  int  e;// again a line
+  int  f  ;
+
+
+// NORMCOL:  {{^}}# 9 "{{.*}}normalize-whitespace.c"{{$}}
+// NORMCOL:  {{^}}int a;{{$}}
+// NORMCOL-NEXT: {{^}}int b;{{$}}
+// NORMCOL-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMCOL-NEXT: # 11 "{{.*}}normalize-whitespace.c"
+// NORMCOL-NEXT: {{^}}x{{$}}
+// NORMCOL-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMCOL-NEXT: {{^ }}#pragma omp something{{$}}
+// NORMCOL-NEXT: {{^}}int e;{{$}}
+// NORMCOL-NEXT: {{^}}int f;{{$}}
+
+// FIXME: Comments after pragmas disappear, even without -fnormalize-whitespace
+// NORMCCOL:  {{^}}# 9 "{{.*}}normalize-whitespace.c"{{$}}
+// NORMCCOL:  {{^}}int a;/*  span-comment  */{{$}}
+// NORMCCOL-NEXT: {{^}}int b;//  line-comment{{$}}
+// NORMCCOL-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMCCOL-NEXT: # 11 "{{.*}}normalize-whitespace.c"
+// NORMCCOL-NEXT: {{^}}x//  more line-comments{{$}}
+// NORMCCOL-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMCCOL-NEXT: {{^ }}#pragma omp something{{$}}
+// NORMCCOL-NEXT: {{^}}int e;// again a line{{$}}
+// NORMCCOL-NEXT: {{^}}int f;{{$}}
+
+// NORMWS:  {{^}}int a;int b;{{$}}
+// NORMWS-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMWS-NEXT: {{^}}x{{$}}
+// NORMWS-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMWS-NEXT: {{^ }}#pragma omp something int e;int f;{{$}}
+
+// FIXME: Comments after pragmas disappear, even without -fnormalize-whitespace
+// NORMCWS:  {{^}}int a;/*  span-comment  */int b;//  line-comment{{$}}
+// NORMCWS-NEXT: {{^}}#pragma omp barrier{{$}}
+// NORMCWS-NEXT: {{^}}x//  more line-comments{{$}}
+// NORMCWS-NEXT: {{^}}#pragma omp nothing{{$}}
+// NORMCWS-NEXT: {{^ }}#pragma omp something int e;// again a line{{$}}
+// NORMCWS-NEXT: {{^}}int f;
+
Index: clang/test/Preprocessor/macro_space.c
===
--- clang/test/Preprocessor/macro_space.c
+++ clang/test/Preprocessor/macro_space.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -E -P -fnormalize-whitespace %s | FileCheck --strict-whitespace %s --check-prefix=NORMWS
 
 #define FOO1()
 #define FOO2(x)x
@@ -13,24 +14,32 @@
 
 TEST(FOO1,)
 // CHECK: FOO1 <> < > <> <> < > <> < > < >
+// NORMWS: FOO1<><><><><><><><>
 
 TEST(FOO2,)
 // CHECK: FOO2 <> < > <> <> < > <> < > < >
+// NORMWS-SAME: FOO2<><><><><><><><>
 
 TEST(FOO3,)
 // CHECK: FOO3 <> < > <> <> < > <> < > < >
+// NORMWS-SAME: FOO3<><><><><><><><>
 
 TEST(FOO4,)
 // CHECK: FOO4 < > < > < > < > < > < > < > 

[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-29 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Formatting part and tests look good to me, but I'd rather see this patch merge 
all related boolean options into one enum.
Just thinking out loud, but is it doable to merge 
AllowAllConstructorInitializersOnNextLine, 
ConstructorInitializerAllOnOneLineOrOnePerLine and this patch's 
ConstructorInitializerAlwaysOnePerLine into e.g. ConstructorInitializerStyle: 
AllowNextLine | NonBinPack==AllOnOneLineOrOnePerLine | OnePerLine. And one 
other enum value for the default case without special handling.
Of course, we'd need to keep that backward compatible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D104388: [clang-format] PR50727 C# Invoke Lamda Expression indentation incorrect

2021-06-29 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe added a subscriber: krasimir.
jbcoe added a comment.

Some outstanding nits to address but this looks good to me.

With @krasimir I implemented a good fraction of the C# support and am confident 
that these changes are an improvement.


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

https://reviews.llvm.org/D104388

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


[PATCH] D104388: [clang-format] PR50727 C# Invoke Lamda Expression indentation incorrect

2021-06-29 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I can't help with C# part either, unfortunately.
I'll chime in if I see something strange, but current patch looks okay to me. I 
let other reviewers (@exv) accept it when they feel it's ok.




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1793
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
   // replace this by using parseAssigmentExpression() inside.
   do {

Unrelated nit: typo in parseAssignment.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1797
+  // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType
+  // TT_FatArrow. The always start an expression or a child block if
+  // followed by a curly.

"The*y* always"... ?



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1798
+  // TT_FatArrow. The always start an expression or a child block if
+  // followed by a curly.
   if (FormatTok->is(TT_FatArrow)) {

curly brace?


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

https://reviews.llvm.org/D104388

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


[PATCH] D105145: [clang][Fuchsia] Remove relative-vtables multilibs

2021-06-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr.
leonardchan added a project: clang.
Herald added a subscriber: mgorny.
leonardchan requested review of this revision.

As of D102374 , relative vtables is enabled 
on Fuchsia by default, so we don't need any of the RV multilibs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105145

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -222,41 +222,15 @@
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 
-set(RUNTIMES_${target}+relative-vtables_LLVM_BUILD_COMPILER_RT OFF CACHE 
BOOL "")
-set(RUNTIMES_${target}+relative-vtables_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_BUILD_COMPILER_RT OFF 
CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_USE_SANITIZER "Address" 
CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_USE_SANITIZER 
"Address" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;compat;asan+noexcept;relative-vtables;relative-vtables+noexcept;relative-vtables+asan;relative-vtables+asan+noexcept"
 CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;compat;asan+noexcept" CACHE STRING 
"")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_compat_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -222,41 +222,15 @@
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
 set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
 
-set(RUNTIMES_${target}+relative-vtables_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables_CMAKE_CXX_FLAGS 

[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-06-29 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp updated this revision to Diff 355332.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105142

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/aarch64-inline-asm.c
  clang/test/CodeGen/asm-goto.c
  clang/test/CodeGen/ms-intrinsics.c
  clang/test/CodeGen/z-hard-register-inline-asm.c
  clang/test/Sema/z-hard-register-inline-asm.c

Index: clang/test/Sema/z-hard-register-inline-asm.c
===
--- /dev/null
+++ clang/test/Sema/z-hard-register-inline-asm.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -triple s390x-ibm-linux -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple s390x-ibm-zos -fsyntax-only -verify
+
+void f1() {
+  int a, b;
+  __asm("lhi %0,5\n"
+: "={r2}"(a)
+:);
+
+  __asm("lgr %0,%1\n"
+: "={r2}"(a)
+: "{r1}"(b));
+
+  __asm("lgr %0,%1\n"
+: "={r2}"(a)
+: "{%r1}"(b));
+
+  __asm("lgr %0,%1\n"
+: "=&{r1}"(a)
+: "{r2}"(b));
+
+  __asm("lhi %0,5\n"
+: "={r2"(a) // expected-error {{invalid output constraint '={r2' in asm}}
+:);
+
+  __asm("lhi %0,5\n"
+: "={r17}"(a) // expected-error {{invalid output constraint '={r17}' in asm}}
+:);
+
+  __asm("lhi %0,5\n"
+: "={}"(a) // expected-error {{invalid output constraint '={}' in asm}}
+:);
+
+  __asm("lhi %0,5\n"
+: "=&{r2"(a) // expected-error {{invalid output constraint '=&{r2' in asm}}
+:);
+
+  __asm("lgr %0,%1\n"
+: "=r"(a)
+: "{r1"(b)); // expected-error {{invalid input constraint '{r1' in asm}}
+
+  __asm("lgr %0,%1\n"
+: "=r"(a)
+: "{}"(b)); // expected-error {{invalid input constraint '{}' in asm}}
+
+  __asm("lgr %0,%1\n"
+: "={r1}"(a)
+: "{r17}"(b)); // expected-error {{invalid input constraint '{r17}' in asm}}
+}
Index: clang/test/CodeGen/z-hard-register-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/z-hard-register-inline-asm.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple s390x-ibm-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple s390x-ibm-zos -emit-llvm -o - %s | FileCheck %s
+
+void f1() {
+  int a, b;
+  register int c asm("r1");
+  register int d asm("r2");
+
+  // CHECK-COUNT-2: call i32 asm "lhi $0,5\0A", "={r1}"
+  __asm("lhi %0,5\n"
+: "={r1}"(a)
+:
+:);
+  __asm("lhi %0,5\n"
+: "=r"(c)
+:
+:);
+
+  // CHECK-COUNT-2: call i32 asm "lgr $0,$1\0A", "={r1},{r2}"
+  __asm("lgr %0,%1\n"
+: "={r1}"(a)
+: "{r2}"(b)
+:);
+  __asm("lgr %0,%1\n"
+: "=r"(c)
+: "r"(d)
+:);
+
+  // CHECK-COUNT-2: call i32 asm "lgr $0,$1\0A", "={r1},{r2}"
+  __asm("lgr %0,%1\n"
+: "={%r1}"(a)
+: "{%r2}"(b)
+:);
+  __asm("lgr %0,%1\n"
+: "={r1}"(a)
+: "{%r2}"(b)
+:);
+
+  // CHECK-COUNT-2: call i32 asm "lgr $0,$1\0A", "=&{r1},{r2}"
+  __asm("lgr %0,%1\n"
+: "=&{r1}"(a)
+: "{%r2}"(b)
+:);
+  __asm("lgr %0,%1\n"
+: "="(c)
+: "r"(d)
+:);
+}
Index: clang/test/CodeGen/ms-intrinsics.c
===
--- clang/test/CodeGen/ms-intrinsics.c
+++ clang/test/CodeGen/ms-intrinsics.c
@@ -36,12 +36,12 @@
   return __movsb(Dest, Src, Count);
 }
 // CHECK-I386-LABEL: define{{.*}} void @test__movsb
-// CHECK-I386:   call { i8*, i8*, i32 } asm sideeffect "rep movsb", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i32 %Count)
+// CHECK-I386:   call { i8*, i8*, i32 } asm sideeffect "rep movsb", "={di},={si},={cx},{di},{si},{cx},~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i32 %Count)
 // CHECK-I386:   ret void
 // CHECK-I386: }
 
 // CHECK-X64-LABEL: define{{.*}} void @test__movsb
-// CHECK-X64:   call { i8*, i8*, i64 } asm sideeffect "rep movsb", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i64 %Count)
+// CHECK-X64:   call { i8*, i8*, i64 } asm sideeffect "rep movsb", "={di},={si},={cx},{di},{si},{cx},~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i64 %Count)
 // CHECK-X64:   ret void
 // CHECK-X64: }
 
@@ -49,12 +49,12 @@
   return __stosw(Dest, Data, Count);
 }
 // CHECK-I386-LABEL: define{{.*}} void @test__stosw
-// CHECK-I386:   call { i16*, i32 } asm sideeffect "rep stosw", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* %Dest, i32 %Count)
+// CHECK-I386:   call { i16*, i32 } asm sideeffect "rep stosw", "={di},={cx},{ax},{di},{cx},~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* %Dest, i32 %Count)
 // 

[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-06-29 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp created this revision.
Herald added subscribers: pengfei, jfb, tpr.
anirudhp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Relevant RFCs posted here

https://lists.llvm.org/pipermail/llvm-dev/2021-June/151370.html
https://gcc.gnu.org/pipermail/gcc/2021-June/236269.html

- This is put up as an RFC patch to get feedback about the introduction of a 
new inline asm constraint which supports hard register operands
- This is mostly a clang change, since the LLVM IR for the inline assembly 
already supports the {...} syntax which the backend recognizes. This change 
merely completes the loop in terms of introducing a user facing constraint 
which maps to it.

The following design decisions were taken for this patch:

For the Sema side:

- We validate the "{" constraint using a two-phase validation approach. 
Firstly, we check if there is a target dependent implementation to handle the 
{} constraint. If it fails, then we move on to a target agnostic check 
where we parse and validate the {} constraint.
- Why do we do this? Well, there are some targets which already process the 
{...} as a user facing constraint. For example the AMDGPU target. It supports 
syntax of the form {register-name} as well as {register-name[...]}. Moving this 
implementation to the target agnostic side seems to set a precedent, that we 
can keep extending the target agnostic implementation based on new cases for 
certain targets, which would be better served of moving it to the respective 
target.
- In terms of the target agnostic validation, we simply check for the following 
syntax {.*}. The parsed out content within the two curly braces is checked to 
see whether its a "valid GCC register".

For the Clang CodeGen side:

- Most of the work is done in the `AddVariableConstraints` function in 
CGStmt.cpp, which is responsible for emitting the LLVM IR corresponding to the 
usage of an actual register that the backend can use. Coincidentally, the LLVM 
IR is also {...}. As mentioned above, this is essentially mapping the LLVM 
Inline Assembly IR back to a user facing inline asm constraint.
- Within this function we add in logic to check if the constraint is of the 
form [&]{...} in addition to the "register asm" construct.
- A scenario where it was applicable to apply both the "register asm" construct 
and the "hard register inline asm constraint" was diagnosed as an unsupported 
error because there's no way the compiler will know which register the user 
meant. The safest option here is to error out explicitly, and put onus back on 
the user.
- To achieve this, and refactor it in a nice way, most of the logic pertaining 
to the "register asm" construct has been moved into a separate function called 
`ShouldApplyRegisterVariableConstraint` which deduces whether to apply the 
"register asm" construct or not.
- Furthermore, the GCCReg field is set with the "Register" only if the register 
is validated to be a "valid GCC Register" type. To me it doesn't make a lot of 
sense to set GCC Reg to something that might not necessarily be a "valid GCC 
register" as defined by respective targets. Would we have a case where we could 
have a {.*} constraint where the contents inside the curly brace is not a valid 
register? Yes. For example, The x86 target supports the "@cca" constraint, 
which is validated on the Sema side as a valid constraint, and before 
processing is converted to "{@cca}" (via the `convertAsmConstraint` function. 
"@cca" is not a valid "GCC register name". So in these case, we'll simply emit 
the constraint without setting GCCReg (with the assumption that the respective 
backends deal with it appropriately)

Tests:

- Various tests were updated to account for the new behaviour.
- I added a few SystemZ tests because we work on the Z backend, but I have no 
issues adding testing for multiple targets.
- There were a few mentions of "waiting" for the GCC implementation of the same 
to land before the Clang side lands. As mentioned above, the intent to 
implement it on the GCC side has already been put forward via the RFC. I have 
no issues "parking" this implementation until its ready to be merged in. 
However, it might be good to hash out any open questions/concerns in the 
interim.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105142

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/aarch64-inline-asm.c
  clang/test/CodeGen/asm-goto.c
  clang/test/CodeGen/ms-intrinsics.c
  clang/test/CodeGen/z-hard-register-inline-asm.c

Index: clang/test/CodeGen/z-hard-register-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/z-hard-register-inline-asm.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple s390x-ibm-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 

[PATCH] D104085: [compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia

2021-06-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Let me know if this should be split up also. I think this might be small and 
and simple enough for one patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104085

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


[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread Stefan Pintilie 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 rG90dfd059198e: [Clang] Add option to handle behaviour of 
vector bool/vector pixel. (authored by stefanp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
  clang/test/CodeGen/vector-compat-pixel-bool.c
  clang/test/CodeGen/vector-compat-ternary.c
  clang/test/CodeGen/vector-compat.c

Index: clang/test/CodeGen/vector-compat.c
===
--- /dev/null
+++ clang/test/CodeGen/vector-compat.c
@@ -0,0 +1,152 @@
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=mixed -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=xl -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: @ui8(
+// CHECK: [[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned char ui8(vector unsigned char a, vector unsigned char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si8(
+// CHECK: [[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector signed char si8(vector signed char a, vector signed char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @ui16(
+// CHECK: [[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned short ui16(vector unsigned short a, vector unsigned short b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si16(
+// CHECK: [[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 

[clang] 90dfd05 - [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2021-06-29T14:07:12-05:00
New Revision: 90dfd059198ed94334f9b1ccfd29b566feb75e8b

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

LOG: [Clang] Add option to handle behaviour of vector bool/vector pixel.

Added the option `-altivec-src-compat=[mixed,gcc,xl]`. The default at this time 
is `mixed`.

The default behavior for clang is for all vector compares to return a scalar 
unless the vectors being
compared are vector bool or vector pixel. In that case the compare returns a
vector. With the gcc case all vector compares return vectors and in the xl case
all vector compares return scalars.

This patch does not change the default behavior of clang.

This option will be used in future patches to implement behaviour compatibility 
for the vector bool/pixel types.

Reviewed By: bmahjour

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

Added: 
clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
clang/test/CodeGen/vector-compat-pixel-bool.c
clang/test/CodeGen/vector-compat-ternary.c
clang/test/CodeGen/vector-compat.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b5b8bc6aa3c57..70a22fd2506a3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7441,6 +7441,12 @@ def warn_deprecated_volatile_structured_binding : 
Warning<
   "volatile qualifier in structured binding declaration is deprecated">,
   InGroup;
 
+def warn_deprecated_altivec_src_compat : Warning<
+  "Current handling of vector bool and vector pixel types in this context are "
+  "deprecated. The default behaviour will soon change to that implied by the "
+  "'-altivec-compat=xl' option">,
+  InGroup>;
+
 def err_catch_incomplete_ptr : Error<
   "cannot catch pointer to incomplete type %0">;
 def err_catch_incomplete_ref : Error<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index b6d9160f89a00..465bad8d7d112 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -126,6 +126,8 @@ LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
  LaxVectorConversionKind::All, "lax vector conversions")
+ENUM_LANGOPT(AltivecSrcCompat, AltivecSrcCompatKind, 2,
+ AltivecSrcCompatKind::Default, "Altivec source compatibility")
 LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d618daf3d23c2..d04ce52a550ef 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -244,6 +244,18 @@ class LangOptions : public LangOptionsBase {
 All,
   };
 
+  enum class AltivecSrcCompatKind {
+// All vector compares produce scalars except vector pixel and vector bool.
+// The types vector pixel and vector bool return vector results.
+Mixed,
+// All vector compares produce vector results as in GCC.
+GCC,
+// All vector compares produce scalars as in XL.
+XL,
+// Default clang behaviour.
+Default = Mixed,
+  };
+
   enum class SignReturnAddressScopeKind {
 /// No signing for any function.
 None,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index af004e0c28b54..301f59207c4a5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3823,6 +3823,18 @@ def u : JoinedOrSeparate<["-"], "u">, Group;
 def v : Flag<["-"], "v">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Show commands to run and use verbose output">,
   MarshallingInfoFlag>;
+def altivec_src_compat : Joined<["-"], "faltivec-src-compat=">,
+  Flags<[CC1Option]>, Group,
+  HelpText<"Source-level compatibility for Altivec vectors (for PowerPC "
+   "targets). This includes results of vector comparison (scalar for "
+   "'xl', vector for 'gcc') as well as behavior when initializing with 
"
+   "a scalar (splatting for 'xl', element zero only for 'gcc'). For "
+   "'mixed', the compatibility is as 'gcc' for 

[PATCH] D104085: [compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia

2021-06-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 355323.
leonardchan added a comment.

Ok. Ready for reviews.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104085

Files:
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp

Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -46,7 +46,12 @@
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
   InitStackAndTls(state);
+#if !SANITIZER_FUCHSIA
+  // Do not initialize the stack ring buffer just yet on Fuchsia. Threads will
+  // be initialized before we enter the thread itself, so we will instead call
+  // this later.
   InitStackRingBuffer(stack_buffer_start, stack_buffer_size);
+#endif
 }
 
 void Thread::InitStackRingBuffer(uptr stack_buffer_start,
Index: compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
===
--- /dev/null
+++ compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -0,0 +1,159 @@
+//===-- hwasan_fuchsia.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file is a part of HWAddressSanitizer and contains Fuchsia-specific
+/// code.
+///
+//===--===//
+
+#include "sanitizer_common/sanitizer_fuchsia.h"
+#if SANITIZER_FUCHSIA
+
+#include "hwasan.h"
+#include "hwasan_interface_internal.h"
+#include "hwasan_report.h"
+#include "hwasan_thread.h"
+#include "hwasan_thread_list.h"
+
+// This TLS variable contains the location of the stack ring buffer and can be
+// used to always find the hwasan thread object associated with the current
+// running thread.
+SANITIZER_INTERFACE_ATTRIBUTE
+[[gnu::tls_model("initial-exec")]] THREADLOCAL uptr __hwasan_tls;
+
+namespace __hwasan {
+
+// These are known parameters passed to the hwasan runtime on thread creation.
+struct Thread::InitState {
+  uptr stack_bottom, stack_top;
+};
+
+static void FinishThreadInitialization(Thread *thread);
+
+void InitThreads() {
+  // This is the minimal alignment needed for the storage where hwasan threads
+  // and their stack ring buffers are placed. This alignment is necessary so the
+  // stack ring buffer can perform a simple calculation to get the next element
+  // in the RB. The instructions for this calculation are emitted by the
+  // compiler. (Full explanation in hwasan_thread_list.h.)
+  uptr alloc_size = UINT64_C(1) << kShadowBaseAlignment;
+  uptr thread_start = reinterpret_cast(
+  MmapAlignedOrDieOnFatalError(alloc_size, alloc_size, __func__));
+
+  InitThreadList(thread_start, alloc_size);
+
+  // Create the hwasan thread object for the current (main) thread. Stack info
+  // for this thread is known from information passed via
+  // __sanitizer_startup_hook.
+  const Thread::InitState state = {
+  .stack_bottom = __sanitizer::MainThreadStackBase,
+  .stack_top =
+  __sanitizer::MainThreadStackBase + __sanitizer::MainThreadStackSize,
+  };
+  FinishThreadInitialization(hwasanThreadList().CreateCurrentThread());
+}
+
+uptr *GetCurrentThreadLongPtr() { return &__hwasan_tls; }
+
+// This is called from the parent thread before the new thread is created. Here
+// we can propagate known info like the stack bounds to Thread::Init before
+// jumping into the thread. We cannot initialize the stack ring buffer yet since
+// we have not entered the new thread.
+static void *BeforeThreadCreateHook(uptr user_id, bool detached,
+const char *name, uptr stack_bottom,
+uptr stack_size) {
+  const Thread::InitState state = {
+  .stack_bottom = stack_bottom,
+  .stack_top = stack_bottom + stack_size,
+  };
+  return hwasanThreadList().CreateCurrentThread();
+}
+
+// This sets the stack top and bottom according to the InitState passed to
+// CreateCurrentThread above.
+void Thread::InitStackAndTls(uptr stack_buffer_start, uptr stack_buffer_size,
+ const InitState *state) {
+  CHECK_NE(state->stack_bottom, 0);
+  CHECK_NE(state->stack_top, 0);
+  stack_bottom_ = state->stack_bottom;
+  stack_top_ = state->stack_top;
+  tls_end_ = tls_begin_ = 0;
+}
+
+// This is called after creating a new thread with the pointer returned by
+// BeforeThreadCreateHook. We are still in the creating thread and should check
+// if it was actually created correctly.
+static void ThreadCreateHook(void *hook, bool aborted) {
+ 

[PATCH] D105097: [clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast

2021-06-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2120
+  } else
+Addr = EmitLValue(E).getAddress(CGF);
   Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy));

I don't think it's legal to use EmitLValue here at all; the emitted IR could 
have side-effects.

Since we have the vector insert/extract intrinsics now, can we just use them 
here instead of going through the load/store dance?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105097

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


[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp updated this revision to Diff 355320.
stefanp added a comment.

Removed the lines that specified that checks were auto generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
  clang/test/CodeGen/vector-compat-pixel-bool.c
  clang/test/CodeGen/vector-compat-ternary.c
  clang/test/CodeGen/vector-compat.c

Index: clang/test/CodeGen/vector-compat.c
===
--- /dev/null
+++ clang/test/CodeGen/vector-compat.c
@@ -0,0 +1,152 @@
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=mixed -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=xl -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: @ui8(
+// CHECK: [[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned char ui8(vector unsigned char a, vector unsigned char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si8(
+// CHECK: [[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector signed char si8(vector signed char a, vector signed char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @ui16(
+// CHECK: [[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned short ui16(vector unsigned short a, vector unsigned short b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si16(
+// CHECK: [[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector signed short si16(vector signed short a, vector signed 

[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp updated this revision to Diff 355315.
stefanp added a comment.

Updated test cases to avoid failures on non assert builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
  clang/test/CodeGen/vector-compat-pixel-bool.c
  clang/test/CodeGen/vector-compat-ternary.c
  clang/test/CodeGen/vector-compat.c

Index: clang/test/CodeGen/vector-compat.c
===
--- /dev/null
+++ clang/test/CodeGen/vector-compat.c
@@ -0,0 +1,152 @@
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=mixed -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=xl -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: @ui8(
+// CHECK: [[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned char ui8(vector unsigned char a, vector unsigned char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si8(
+// CHECK: [[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector signed char si8(vector signed char a, vector signed char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @ui16(
+// CHECK: [[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned short ui16(vector unsigned short a, vector unsigned short b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si16(
+// CHECK: [[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector signed short si16(vector signed short a, vector signed short 

[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D103615#2847965 , @stefanp wrote:

> In D103615#2847650 , @dblaikie 
> wrote:
>
>> In D103615#2847118 , @bmahjour 
>> wrote:
>>
>>> In D103615#2847047 , @stefanp 
>>> wrote:
>>>
 I'm sorry I missed the asserts requirement.
 I will recommit this patch after I add `REQUIRES: asserts`.
>>>
>>> Instead of disabling the tests for non-assert builds, can we just remove 
>>> the `entry:` checks at the beginning of each function? The rest of the IR 
>>> checks should pass since they use a regexp so they should match for either 
>>> named or unnamed instructions.
>>
>> (generally: disabling the test in non-asserts builds isn't the right path, 
>> modifying the test so it doesn't depend on asserts IR naming is the right 
>> path)
>>
>> Yes, probably removing the `entry:` check would be sufficient - give it a 
>> test locally and see how it goes. (it does mean the "CHECK-NEXT" after that 
>> (for the first instruction) would have to be a plain "CHECK" - so that the 
>> test could pass both in the presence and absence of the entry label.
>
> I've removed all of the `entry:` checks and changed for next line to `CHECK:` 
> and that seems to be working with assertions off. I will recommit the patch 
> like that if this is preferred.

Sounds alright to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

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


[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp added a comment.

In D103615#2847650 , @dblaikie wrote:

> In D103615#2847118 , @bmahjour 
> wrote:
>
>> In D103615#2847047 , @stefanp 
>> wrote:
>>
>>> I'm sorry I missed the asserts requirement.
>>> I will recommit this patch after I add `REQUIRES: asserts`.
>>
>> Instead of disabling the tests for non-assert builds, can we just remove the 
>> `entry:` checks at the beginning of each function? The rest of the IR checks 
>> should pass since they use a regexp so they should match for either named or 
>> unnamed instructions.
>
> (generally: disabling the test in non-asserts builds isn't the right path, 
> modifying the test so it doesn't depend on asserts IR naming is the right 
> path)
>
> Yes, probably removing the `entry:` check would be sufficient - give it a 
> test locally and see how it goes. (it does mean the "CHECK-NEXT" after that 
> (for the first instruction) would have to be a plain "CHECK" - so that the 
> test could pass both in the presence and absence of the entry label.

I've removed all of the `entry:` checks and changed for next line to `CHECK:` 
and that seems to be working with assertions off. I will recommit the patch 
like that if this is preferred.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

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


[PATCH] D104946: [AMDGPU] Add builtin functions image_bvh_intersect_ray

2021-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 355309.
yaxunl added a comment.

Add check for ISA. Add comments about argument types.


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

https://reviews.llvm.org/D104946

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl

Index: clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl
@@ -0,0 +1,61 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1030 -S \
+// RUN:   -emit-llvm -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1030 -S \
+// RUN:   -cl-std=CL2.0 -o - %s | FileCheck -check-prefix=ISA %s
+
+// Test llvm.amdgcn.image.bvh.intersect.ray intrinsic.
+
+// The clang builtin functions __builtin_amdgcn_image_bvh_intersect_ray* use
+// postfixes to indicate the types of the 1st, 4th, and 5th arguments.
+// By default, the 1st argument is i32, the 4/5-th arguments are float4.
+// Postfix l indicates the 1st argument is i64 and postfix h indicates
+// the 4/5-th arguments are half4.
+
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+typedef half half4 __attribute__((ext_vector_type(4)));
+typedef uint uint4 __attribute__((ext_vector_type(4)));
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i32.v4f32
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray(global uint4* out, uint node_ptr,
+  float ray_extent, float4 ray_origin, float4 ray_dir, float4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i32.v4f16
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray_h(global uint4* out, uint node_ptr,
+  float ray_extent, float4 ray_origin, half4 ray_dir, half4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray_h(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i64.v4f32
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray_l(global uint4* out, ulong node_ptr,
+  float ray_extent, float4 ray_origin, float4 ray_dir, float4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray_l(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
+// CHECK: call <4 x i32> @llvm.amdgcn.image.bvh.intersect.ray.i64.v4f16
+// ISA: image_bvh_intersect_ray
+void test_image_bvh_intersect_ray_lh(global uint4* out, ulong node_ptr,
+  float ray_extent, float4 ray_origin, half4 ray_dir, half4 ray_inv_dir,
+  uint4 texture_descr)
+{
+  *out = __builtin_amdgcn_image_bvh_intersect_ray_lh(node_ptr, ray_extent,
+   ray_origin, ray_dir, ray_inv_dir, texture_descr);
+}
+
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15745,6 +15745,23 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
+  case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_lh: {
+llvm::Value *NodePtr = EmitScalarExpr(E->getArg(0));
+llvm::Value *RayExtent = EmitScalarExpr(E->getArg(1));
+llvm::Value *RayOrigin = EmitScalarExpr(E->getArg(2));
+llvm::Value *RayDir = EmitScalarExpr(E->getArg(3));
+llvm::Value *RayInverseDir = EmitScalarExpr(E->getArg(4));
+llvm::Value *TextureDescr = EmitScalarExpr(E->getArg(5));
+
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_image_bvh_intersect_ray,
+   {NodePtr->getType(), RayDir->getType()});
+return Builder.CreateCall(F, {NodePtr, RayExtent, RayOrigin, RayDir,
+  RayInverseDir, TextureDescr});
+  }
+
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
 return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_x, 0, 1024);
Index: clang/include/clang/Basic/BuiltinsAMDGPU.def
===
--- clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -215,6 +215,17 @@
 TARGET_BUILTIN(__builtin_amdgcn_permlanex16, "UiUiUiUiUiIbIb", "nc", "gfx10-insts")
 TARGET_BUILTIN(__builtin_amdgcn_mov_dpp8, "UiUiIUi", "nc", 

[PATCH] D105087: [clang-format] PR49960 clang-format doesn't handle ASI after "return" on JavaScript

2021-06-29 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1015
+if (!eof()) {
+  if (Next->is(tok::identifier)) {
+// Peek the next token.

can you add comments explaining what syntax is being detected here?



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1019
+FormatToken *NextNext = Tokens->getNextToken();
+Tokens->setPosition(StoredPosition);
+if (NextNext && NextNext->is(tok::equal))

parsePPEndIf uses a different method to peek - any opinion on why you're doing 
it differently here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105087

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


[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-29 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D105099#2847328 , @MyDeveloperDay 
wrote:

> Seem similar to D90232: [clang-format] Formatting constructor initializer 
> lists by putting them always on different lines (update to D14484) 
>  which seems to have got stalled
>
> I sort of feel I prefer the design where we have an enum rather than 
> introducing a separate option.

Yeah I thought, I already saw something like that.

I too think the way with the enum is a better one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D105087: [clang-format] PR49960 clang-format doesn't handle ASI after "return" on JavaScript

2021-06-29 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

It's a strange language :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105087

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


[PATCH] D104946: [AMDGPU] Add builtin functions image_bvh_intersect_ray

2021-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:221-224
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray, 
"V4UiUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_h, 
"V4UiUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_l, 
"V4UiWUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_lh, 
"V4UiWUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")

yaxunl wrote:
> arsenm wrote:
> > The intrinsic signature suggests the 1st and 4th/5th arguments are 
> > overloadable. How does this handle the various supported types?
> By convention, we do not define overloaded target specific clang builtins. In 
> stead we use postfixes to indicate the types. In this case, we use the 
> following naming convention:
> 
> h - 4/5-th args are half
> d - 4/5-th args are double
> l - first arg is i64
> 
> by default - 1st arg is i32, 4/5-th args are float.
> 
> Currently we are missing functions for 4/5-th args are double. I will add 
> them.
> 
It seems we do not support 4/50th args to be double. So the current definitions 
are all that we support.


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

https://reviews.llvm.org/D104946

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


[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D103615#2847704 , @bmahjour wrote:

>> (generally: disabling the test in non-asserts builds isn't the right path, 
>> modifying the test so it doesn't depend on asserts IR naming is the right 
>> path)
>
> Agreed.
>
>> Yes, probably removing the entry: check would be sufficient - give it a test 
>> locally and see how it goes. (it does mean the "CHECK-NEXT" after that (for 
>> the first instruction) would have to be a plain "CHECK" - so that the test 
>> could pass both in the presence and absence of the entry label.
>
> Right.
>
>> Yeah, seems like a weird choice to me too (though has been around a long 
>> time, so folks are pretty used to it) - might be worth bringing it up on 
>> llvm-dev. I think we now have a flag to enable this functionality that works 
>> even in non-asserts builds (maybe?) so maybe if we just change the default 
>> for assert builds so it's always opt-in via a flag, then it's consistent 
>> between asserts and non-asserts builds.
>
> Do you happen to know what that option is? Thanks!

Generally called "discard value names" - clang has `-f{no-}discard-value-names` 
- the various command line tools (opt, llc, etc) have some similar flags with 
spelling more suitable to the various command line syntaxes, etc...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

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


[PATCH] D105135: [Internalize] Preserve variables externally initialized.

2021-06-29 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: clang/test/CodeGenCUDA/host-used-device-var.cu:20
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;

BTW, as clang codegen tests, those checks should not rely on middle-end 
optimizations to work correctly.



Comment at: clang/test/CodeGenCUDA/unused-global-var.cu:20
 
-// NEGCHK-NOT: @v1
-__device__ int v1;

BTW, as clang codegen tests, those checks should not rely on middle-end 
optimizations to work correctly.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105135

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


[clang] aaba371 - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-29 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-29T13:26:23-04:00
New Revision: aaba37187fda7f5a7fdc4c1e6129cbaaa1bbf709

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

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e7428..20f6afa76cbb3 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions );
+  virtual void adjust(DiagnosticsEngine , LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c74..4c2859e5eda7f 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions ) {
+void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70ba..fac786dbcf9e2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions ) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2bb..244a6e0446905 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02fa..d431dda970222 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions ) {
+void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee00..18ee1194c759d 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option 

[PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-29 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaaba37187fda: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104729

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -704,7 +704,7 @@
   if (!instance->hasTarget())
 return nullptr;
 
-  instance->getTarget().adjust(instance->getLangOpts());
+  instance->getTarget().adjust(*diagnostics_engine, instance->getLangOpts());
 
   if (!action->BeginSourceFile(*instance,
instance->getFrontendOpts().Inputs[0]))
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -658,7 +658,8 @@
   //
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  m_compiler->getTarget().adjust(m_compiler->getLangOpts());
+  m_compiler->getTarget().adjust(m_compiler->getDiagnostics(),
+		 m_compiler->getLangOpts());
 
   // 6. Set up the diagnostic buffer for reporting errors
 
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere.
-Target->adjust(LangOpt);
+Target->adjust(PP.getDiagnostics(), LangOpt);
 
 // Initialize the preprocessor.
 PP.Initialize(*Target);

[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-06-29 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

Sorry for not updating. Was down with fever.
This patch does *not* work now. `operationKindFromOverloadedOperator` is broken 
because the maps don't get populated. I am not entirely sure why this is 
happening.
Will try to fix tomorrow. @NoQ, @vsavchenko, @xazax.hun, @teemperor do you have 
a hunch as to why this may be happening?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

___
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-06-29 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG952944c12c0a: [ObjC][ARC] Dont add operand bundle 
clang.arc.attachedcall to a call if (authored by ahatanak).

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
@@ -2939,8 +2939,12 @@
   ValueTransform doAfterCall,
   ValueTransform doFallback) {
   CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP();
+  auto *callBase = dyn_cast(value);
 
-  if (llvm::CallInst *call = dyn_cast(value)) {
+  if (callBase && llvm::objcarc::hasAttachedCallOpBundle(callBase)) {
+// Fall back if the call base has operand bundle "clang.arc.attachedcall".
+value = doFallback(CGF, value);
+  } else if (llvm::CallInst *call = dyn_cast(value)) {
 // Place the retain immediately following the call.
 CGF.Builder.SetInsertPoint(call->getParent(),
++llvm::BasicBlock::iterator(call));


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
@@ -2939,8 +2939,12 @@
   ValueTransform doAfterCall,
   ValueTransform doFallback) {
   CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP();
+  auto *callBase = dyn_cast(value);
 
-  if (llvm::CallInst *call = dyn_cast(value)) {
+  if (callBase && llvm::objcarc::hasAttachedCallOpBundle(callBase)) {
+// Fall back if the call base has operand bundle "clang.arc.attachedcall".
+value = doFallback(CGF, value);
+  } else if (llvm::CallInst *call = dyn_cast(value)) {
 // Place the retain immediately following the call.
 CGF.Builder.SetInsertPoint(call->getParent(),
++llvm::BasicBlock::iterator(call));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105135: [Internalize] Preserve variables externally initialized.

2021-06-29 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: yaxunl, bogner.
Herald added subscribers: ormris, hiraditya.
hliao requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

- ``externally_initialized`` variables would be initialized or modified 
elsewhere. Particularly, CUDA or HIP may have host code to initialize or modify 
``externally_initialized`` device variables, which may not be explicitly 
referenced on the device side but may still be used through the host side 
interfaces. Not preserving them triggers the elimination of them in the 
GlobalDCE and breaks the user code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105135

Files:
  clang/test/CodeGenCUDA/host-used-device-var.cu
  clang/test/CodeGenCUDA/unused-global-var.cu
  llvm/lib/Transforms/IPO/Internalize.cpp
  llvm/test/Transforms/Internalize/externally-initialized.ll


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggestes, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast())
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -17,12 +17,6 @@
 
 // Check unused device/constant variables are eliminated.
 
-// NEGCHK-NOT: @v1
-__device__ int v1;
-
-// NEGCHK-NOT: @v2
-__constant__ int v2;
-
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -17,12 +17,6 @@
 
 // Check device variables used by neither host nor device functioins are not 
kept.
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;
-
-// DEV-NEG-NOT: @v2
-__constant__ int v2;
-
 // DEV-NEG-NOT: @_ZL2v3
 static __device__ int v3;
 


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggestes, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast())
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -17,12 +17,6 @@
 
 // Check unused device/constant variables are eliminated.
 
-// NEGCHK-NOT: @v1
-__device__ int v1;
-
-// NEGCHK-NOT: @v2
-__constant__ int v2;
-
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -17,12 +17,6 @@
 
 // Check device variables used by neither host nor device functioins are not kept.
 
-// DEV-NEG-NOT: @v1
-__device__ int v1;
-
-// DEV-NEG-NOT: @v2
-__constant__ int v2;
-
 // DEV-NEG-NOT: @_ZL2v3
 static __device__ int v3;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] 952944c - [ObjC][ARC] Don't add operand bundle clang.arc.attachedcall to a call if

2021-06-29 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2021-06-29T10:23:01-07:00
New Revision: 952944c12c0aa917e97805e929b5cd4e40866f91

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

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

This bug was causing the call to `replaceAllUsesWith` to crash because
the old call instruction and the new call instruction were the same.

rdar://74957948

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

Added: 
clang/test/CodeGenObjCXX/arc-rv-attr.mm

Modified: 
clang/lib/CodeGen/CGObjC.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 6c36dde1f526d..63429b1d4f653 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -2939,8 +2939,12 @@ static llvm::Value 
*emitARCOperationAfterCall(CodeGenFunction ,
   ValueTransform doAfterCall,
   ValueTransform doFallback) {
   CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP();
+  auto *callBase = dyn_cast(value);
 
-  if (llvm::CallInst *call = dyn_cast(value)) {
+  if (callBase && llvm::objcarc::hasAttachedCallOpBundle(callBase)) {
+// Fall back if the call base has operand bundle "clang.arc.attachedcall".
+value = doFallback(CGF, value);
+  } else if (llvm::CallInst *call = dyn_cast(value)) {
 // Place the retain immediately following the call.
 CGF.Builder.SetInsertPoint(call->getParent(),
++llvm::BasicBlock::iterator(call));

diff  --git a/clang/test/CodeGenObjCXX/arc-rv-attr.mm 
b/clang/test/CodeGenObjCXX/arc-rv-attr.mm
new file mode 100644
index 0..0f4519bd527d9
--- /dev/null
+++ b/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()};
+}



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


[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour added a comment.

> (generally: disabling the test in non-asserts builds isn't the right path, 
> modifying the test so it doesn't depend on asserts IR naming is the right 
> path)

Agreed.

> Yes, probably removing the entry: check would be sufficient - give it a test 
> locally and see how it goes. (it does mean the "CHECK-NEXT" after that (for 
> the first instruction) would have to be a plain "CHECK" - so that the test 
> could pass both in the presence and absence of the entry label.

Right.

> Yeah, seems like a weird choice to me too (though has been around a long 
> time, so folks are pretty used to it) - might be worth bringing it up on 
> llvm-dev. I think we now have a flag to enable this functionality that works 
> even in non-asserts builds (maybe?) so maybe if we just change the default 
> for assert builds so it's always opt-in via a flag, then it's consistent 
> between asserts and non-asserts builds.

Do you happen to know what that option is? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

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


[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D103615#2847118 , @bmahjour wrote:

> In D103615#2847047 , @stefanp wrote:
>
>> I'm sorry I missed the asserts requirement.
>> I will recommit this patch after I add `REQUIRES: asserts`.
>
> Instead of disabling the tests for non-assert builds, can we just remove the 
> `entry:` checks at the beginning of each function? The rest of the IR checks 
> should pass since they use a regexp so they should match for either named or 
> unnamed instructions.

(generally: disabling the test in non-asserts builds isn't the right path, 
modifying the test so it doesn't depend on asserts IR naming is the right path)

Yes, probably removing the `entry:` check would be sufficient - give it a test 
locally and see how it goes. (it does mean the "CHECK-NEXT" after that (for the 
first instruction) would have to be a plain "CHECK" - so that the test could 
pass both in the presence and absence of the entry label.

In D103615#2847124 , @bmahjour wrote:

> In D103615#2846245 , @dblaikie 
> wrote:
>
>> As mentioned in the reverting commit - these tests fail in non-asserts 
>> builds, because they assume named IR instructions (like the named entry BB 
>> label), which aren't provided on a non-asserts build (there's a flag to turn 
>> them on - but that's probably not the right fix - making the test resilient 
>> to non-asserts IR is probably the right fix).
>>
>> Leaving non-asserts builds broken for 12 hours (maybe I'm the first one to 
>> come across/report it - but I'd expect there are some buildbots that would 
>> fail, etc) is quite a while - best to be avoided when possible.
>
> This is a bit off topic, but I'm just curious about clang's rationale for 
> producing different IR depending on whether asserts are on/off? Seems strange 
> and undesirable to me.

Yeah, seems like a weird choice to me too (though has been around a long time, 
so folks are pretty used to it) - might be worth bringing it up on llvm-dev. I 
think we now have a flag to enable this functionality that works even in 
non-asserts builds (maybe?) so maybe if we just change the default for assert 
builds so it's always opt-in via a flag, then it's consistent between asserts 
and non-asserts builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

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


[PATCH] D105092: [PoC][RISCV] Add the tail policy argument to builtins/intrinsics.

2021-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1148
+if (HasPolicy) {
+  ProtoMaskSeq.push_back("z");
+}

khchen wrote:
> maybe the policy argument should be a constant value ("Kz")?
Agreed.



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:80
+
+  HasPolicyShift = HasVLOpShift + 1,
+  HasPolicyMask = 1 << HasPolicyShift,

This should be HasPolicyOpShift and HasPolicyOpMask to match SEWOp/VLOp naming.



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:138
 
+static inline bool hasPolicy(uint64_t TSFlags) {
+  return TSFlags & HasPolicyMask;

hasPolicyOp



Comment at: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp:401
+const MachineOperand  = MI.getOperand(NumOperands - 1);
+TailAgnostic = Op.getImm();
+  }

Probably need to mask this to bit 0. `TailAgnostic = Op.getImm() & 1`. As 
written we'll set TailAgnostic if any bit in the immediate is non-zero.



Comment at: llvm/lib/Target/RISCV/RISCVInstrFormats.td:182
+
+  bit HasPolicy = false;
+  let TSFlags{16} = HasPolicy;

HasPolicyOp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105092

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


[PATCH] D104285: [analyzer] Retrieve value by direct index from list initialization of constant array declaration.

2021-06-29 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@chrish_ericsson_atx
Thanks for the new test case. I'll handle it ASAP.

> To be clear, neither this new reproducer nor the one I originally posted fail 
> if commit b30521c28a4d 
>  is 
> reverted.  Is it worth considering reverting that commit until a patch that 
> addresses the original problem and doesn't introduce these new regressions is 
> available?

I don't think we should revert b30521c28a4d 
 because 
it corrects symbol representation in CSA and fixes two bugs: 
https://bugs.llvm.org/show_bug.cgi?id=37503 and 
https://bugs.llvm.org/show_bug.cgi?id=49007. Another point of non-revert is 
that your cases were previously hidden in CSA core and that's good to find 
them. I'm afraid it's a dubious idea to return back old bugs in favor of not 
seeing new ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104285

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


[PATCH] D104925: [Analyzer] Improve report of file read at end-of-file condition.

2021-06-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Is it better to save the actual `ExplodedNode` in the note tag? Then the error 
node of the `BugReport` can be used to search the bug path and check if the 
saved node is encountered. In this way a `NoteTag` could be used and the 
"sequence numbers" would be unnecessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104925

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


[PATCH] D105120: [clang] Fix UB when string.front() is used for the empty string

2021-06-29 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 355261.
DmitryPolukhin added a comment.

Fix clang-tidy style warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105120

Files:
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -700,6 +700,10 @@
 SmallVector Argv = {Clang, File, "-D", File};
 llvm::SplitString(Flags, Argv);
 
+// Trim double quotation from the argumnets if any.
+for (auto *It = Argv.begin(); It != Argv.end(); ++It)
+  *It = It->trim("\"");
+
 SmallString<32> Dir;
 llvm::sys::path::system_temp_directory(false, Dir);
 
@@ -962,5 +966,12 @@
   EXPECT_EQ(getCommand("bar.cpp"), "clang bar.cpp -D bar.cpp -Dflag");
 }
 
+TEST_F(ExpandResponseFilesTest, ExpandResponseFilesEmptyArgument) {
+  addFile(path(StringRef("rsp1.rsp")), "-Dflag");
+
+  add("foo.cpp", "clang", "@rsp1.rsp \"\"");
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag ");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -54,7 +54,8 @@
   Argv.reserve(Cmd.CommandLine.size());
   for (auto  : Cmd.CommandLine) {
 Argv.push_back(Arg.c_str());
-SeenRSPFile |= Arg.front() == '@';
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
   }
   if (!SeenRSPFile)
 continue;


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -700,6 +700,10 @@
 SmallVector Argv = {Clang, File, "-D", File};
 llvm::SplitString(Flags, Argv);
 
+// Trim double quotation from the argumnets if any.
+for (auto *It = Argv.begin(); It != Argv.end(); ++It)
+  *It = It->trim("\"");
+
 SmallString<32> Dir;
 llvm::sys::path::system_temp_directory(false, Dir);
 
@@ -962,5 +966,12 @@
   EXPECT_EQ(getCommand("bar.cpp"), "clang bar.cpp -D bar.cpp -Dflag");
 }
 
+TEST_F(ExpandResponseFilesTest, ExpandResponseFilesEmptyArgument) {
+  addFile(path(StringRef("rsp1.rsp")), "-Dflag");
+
+  add("foo.cpp", "clang", "@rsp1.rsp \"\"");
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag ");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -54,7 +54,8 @@
   Argv.reserve(Cmd.CommandLine.size());
   for (auto  : Cmd.CommandLine) {
 Argv.push_back(Arg.c_str());
-SeenRSPFile |= Arg.front() == '@';
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
   }
   if (!SeenRSPFile)
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95807: [Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-29 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D95807#2846358 , @ChuanqiXu wrote:

>> note that we don't really need to run Inliner again on the ramp function 
>> after split
>
> This isn't accurate. The inline may run again for ramp function after split 
> and it's required by coro elide.

If there is an inlining opportunity, it should have happened pre-split, right? 
Is there any reason it didn't happen pre-split but only post-split?

> It seems like that we don't need the attribute `CORO_PRESPLIT_ATTR` any more, 
> do we? If yes, I think we should remove them.

It's still needed by the legacy pass manager. I don't want to break that yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

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


[PATCH] D104601: [Preprocessor] Implement -fnormalize-whitespace.

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

I'm still mulling over the feature, but I have some nits with the patch while I 
was exploring it. I share the concerns raised by @dblaikie and would add that 
it's very common for implementers to ask developers to run their code through 
`-E` mode to submit preprocessed output in order to reproduce a customer issue 
with the compiler, and I worry that uses of this flag will have unintended 
consequences in that scenario. However, I don't yet have a concrete "this code 
demonstrates the problem I'm worried about" example to discuss, so this worry 
may be unfounded. The "very long line" example mentioned by @dblaikie is sort 
of along these lines (sorry for the bad pun).




Comment at: clang/docs/ClangCommandLineReference.rst:2480
+
+Ignore the whitespace from the input file when emitting preprocessor output. 
It will only contain whitespace when necessary, e.g. to keep two minus signs 
from merging into to an increment operator. Useful with the -P option to 
normlize whitespace such that two files with only formatted changes are equal.
+

You might want to wrap this to 80-col limits.



Comment at: clang/lib/Frontend/PrintPreprocessedOutput.cpp:135
+  /// Ensure that the output stream position is at the beginning of a new line
+  /// and inserts one if it does not.It is intended to ensure that directives
+  /// inserted by the directives not from the input source (such as #line) are





Comment at: clang/lib/Frontend/PrintPreprocessedOutput.cpp:137
+  /// inserted by the directives not from the input source (such as #line) are
+  /// in the first column. To insert newlines the represent the input, use
+  /// MoveToLine(/*...*/, /*RequireStartOfLine=*/true).





Comment at: clang/lib/Frontend/PrintPreprocessedOutput.cpp:174
+  ///on being on the same line, such as directives.
+  void HandleWhitespaceBeforeTok(Token , bool RequireSpace,
+ bool RequireSameLine);

Can `Tok` be `const Token &` instead?



Comment at: clang/lib/Frontend/PrintPreprocessedOutput.cpp:181
+  /// In these cases the next output will be the first column on the line and
+  /// make it possible to insert indention. The newline is was inserted
+  /// implicitly when at the beginning of the file.





Comment at: clang/lib/Frontend/PrintPreprocessedOutput.cpp:635
+ bool RequireSameLine) 
{
+  // These tokens are not expand to anything and don't need whitespace before
+  // them.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D105127: Implement P1401R5

2021-06-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Support Narrowing conversions to bool in if constexpr condition
under C++23 language mode.

Only if constexpr is implemented as the behavior of static_assert
is already conforming.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105127

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5;>P1401R5
-  No
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
===
--- clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
 // RUN: %clang_cc1 -std=c++1z -verify %s -DUNDEFINED
+// RUN: %clang_cc1 -std=c++2b -verify %s
+// RUN: %clang_cc1 -std=c++2b -verify %s -DUNDEFINED
 
 #ifdef UNDEFINED
 // "used but not defined" errors don't get produced if we have more interesting
@@ -40,17 +42,41 @@
 namespace ccce {
   void f() {
 if (5) {}
-if constexpr (5) {} // expected-error {{cannot be narrowed}}
+if constexpr (5) {
+}
   }
   template void g() {
-if constexpr (N) {} // expected-error {{cannot be narrowed}}
+if constexpr (N) {
+}
   }
-  template void g<5>(); // expected-note {{instantiation of}}
+  template void g<5>();
   void h() {
-if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (4.3) {
+}
 constexpr void *p = nullptr;
-if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+if constexpr (p) {
+}
   }
+
+  void not_constant(int b) {
+if constexpr (bool(b)) {
+} // expected-error {{constexpr if condition is not a constant expression}}
+if constexpr (b) {
+} // expected-error {{constexpr if condition is not a constant expression}}
+  }
+
+#if __cplusplus <= 202002
+  // expected-error@45 {{cannot be narrowed}}
+  // expected-error@48 {{cannot be narrowed}}
+  // expected-note@50  {{instantiation of}}
+  // expected-error@52 {{conversion from 'double' to 'bool' is not allowed in a converted constant expression}}
+  // expected-error@54 {{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}}
+#else
+  // expected-warning@52 {{implicit conversion from 'double' to 'bool' changes value}}
+#endif
+  // expected-note@58 {{cannot be used in a constant expression}}
+  // expected-note@59 {{cannot be used in a constant expression}}
+  // expected-note@57 2{{declared here}}
 }
 
 namespace generic_lambda {
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3920,11 +3920,21 @@
   // expression, implicitly converted to bool.
   //
   // FIXME: Return this value to the caller so they don't need to recompute it.
-  llvm::APSInt Value(/*BitWidth*/1);
-  return (IsConstexpr && !CondExpr->isValueDependent())
- ? CheckConvertedConstantExpression(CondExpr, Context.BoolTy, Value,
-CCEK_ConstexprIf)
- : PerformContextuallyConvertToBool(CondExpr);
+
+  if ((IsConstexpr && !LangOpts.CPlusPlus2b) && !CondExpr->isValueDependent()) {
+llvm::APSInt Value(/*BitWidth*/ 1);
+return CheckConvertedConstantExpression(CondExpr, Context.BoolTy, Value,
+CCEK_ConstexprIf);
+  }
+  ExprResult E = PerformContextuallyConvertToBool(CondExpr);
+  if (!IsConstexpr || CondExpr->isValueDependent())
+return E;
+
+  llvm::APSInt Cond;
+  E = VerifyIntegerConstantExpression(
+  E.get(), ,
+  diag::err_constexpr_if_condition_expression_is_not_constant);
+  return E;
 }
 
 /// Helper function to determine whether this is the (deprecated) C++
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1487,6 +1487,8 @@
 // C++ declarations
 def err_static_assert_expression_is_not_constant : Error<
   "static_assert expression is not an integral constant expression">;
+def err_constexpr_if_condition_expression_is_not_constant : Error<
+  "constexpr if 

[PATCH] D104052: [clang] Fix CallExpr dependence bit may not respecting all its arguments.

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

Ping - curious about your thoughts here!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104052

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


[PATCH] D104056: [clangd][nfc] Show more information in logs when compiler instance prepare fails

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

Thanks, LGTM

Sorry about the delay - we got sidetracked into some ideas about whether these 
errors should actually be surfaced to the user as diagnostics instead. But that 
shouldn't block this patch.




Comment at: clang-tools-extra/clangd/ParsedAST.cpp:296
+elog("Failed to prepare a compiler instance: {0}",
+ ASTDiags.getNumErrors()
+ ? static_cast(ASTDiags.take().back()).Message

there's a bunch of logic that determines which diags we actually end up storing.

I'd suggest always calling take() and testing whether the result is empty, 
rather than using getNumErrors() which bypasses all our logic.

Luckily, we do (always?) end up storing the relevant diags here, assuming 
they're errors without a source location attached.
However I don't think we should hard-code that assumption here.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104056

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


[PATCH] D104617: [clangd] Type hints for structured bindings

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

Cool!




Comment at: clang-tools-extra/clangd/InlayHints.cpp:40
+// types would be "tuple_element::type".
+TypeHintPolicy.PrintCanonicalTypes = true;
   }

nridge wrote:
> While playing around with this, it did occur to me that in some cases it's 
> more helpful to print sugared types than canonical types, for example in a 
> case like this:
> 
> ```
> template 
> struct SomeLongType {};
> 
> using ShortType = SomeLongType;
> 
> ShortType func();
> 
> auto x = func();  // would prefer "ShortType" as hint
> ```
> 
> However, it turns out that `AutoType` doesn't retain the sugared type to 
> begin with (there's a FIXME about that 
> [here](https://searchfox.org/llvm/rev/e497b12a69604b6d691312a30f6b86da4f18f7f8/clang/include/clang/AST/Type.h#4953)),
>  so setting `PrintCanonicalTypes=true` doesn't actually regress cases like 
> this (they were already printing the canonical type).
This makes sense - can you add a comment with a short version of this?
// Often we'd prefer sugar types for `auto`, but the AST doesn't retain them 
anyway.



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:466
+  // Hint individual bindings, not the aggregate.
   assertTypeHints(R"cpp(
+// 1. Struct with public fields.

since we have the handy assertTypeHints function, can we split this into 
several separate tests?
(Or one table-driven test so at least the test code + corresponding assertions 
are next to each other)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104617

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


[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

We already have

`AllowAllConstructorInitializersOnNextLine` and 
`ConstructorInitializerAllOnOneLineOrOnePerLine`

Sort of feels like we need to combine them with this,

I should also say I'd quite like this functionality, its just how do we deliver 
it via the options that I think we might want to think about, as I sort of feel 
the 3 options (if we introduced another) are competing with each other.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

2021-06-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Seem similar to D90232: [clang-format] Formatting constructor initializer lists 
by putting them always on different lines (update to D14484) 
 which seems to have got stalled

I sort of feel I prefer the design where we have an enum rather than 
introducing a separate option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099

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


[PATCH] D105017: [analyzer] LValueToRValueBitCasts should evaluate to an r-value

2021-06-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:543
   case CK_VectorSplat: {
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;

steakhal wrote:
> NoQ wrote:
> > You didn't start it but that's, ugh, not a great name for the function to 
> > handle the new cast.
> > 
> > I wouldn't mind eliminating the function entirely and inlining the 
> > implementation as it actually makes the code easier to read, for once.
> I'm going to do that in an NFC follow-up patch.
D105125


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

https://reviews.llvm.org/D105017

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


[PATCH] D105017: [analyzer] LValueToRValueBitCasts should evaluate to an r-value

2021-06-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:543
   case CK_VectorSplat: {
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;

NoQ wrote:
> You didn't start it but that's, ugh, not a great name for the function to 
> handle the new cast.
> 
> I wouldn't mind eliminating the function entirely and inlining the 
> implementation as it actually makes the code easier to read, for once.
I'm going to do that in an NFC follow-up patch.


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

https://reviews.llvm.org/D105017

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


[PATCH] D105017: [analyzer] LValueToRValueBitCasts should evaluate to an r-value

2021-06-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 355245.
steakhal marked an inline comment as done.
steakhal added a comment.

Evaluate `LValueToRValueBitCast`s the same way as we evaluate `LValueToRValue` 
casts.
Extended the tests accordingly.

Thanks for the hint @NoQ!
It looks much better now.


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

https://reviews.llvm.org/D105017

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Analysis/builtin_bitcast.cpp


Index: clang/test/Analysis/builtin_bitcast.cpp
===
--- /dev/null
+++ clang/test/Analysis/builtin_bitcast.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection
+
+template  void clang_analyzer_dump(T);
+
+__attribute__((always_inline)) static inline constexpr unsigned int 
_castf32_u32(float __A) {
+  return __builtin_bit_cast(unsigned int, __A); // no-warning
+}
+
+void test(int i) {
+  _castf32_u32(42);
+
+  float f = 42;
+
+  // Loading from a floating point value results in unknown,
+  // which later materializes as a conjured value.
+  auto g = __builtin_bit_cast(unsigned int, f);
+  clang_analyzer_dump(g);
+  // expected-warning-re@-1 ^conj_\$[0-9]+{unsigned int,
+
+  auto g2 = __builtin_bit_cast(unsigned int, 42.0f);
+  clang_analyzer_dump(g2);
+  // expected-warning-re@-1 ^conj_\$[0-9]+{unsigned int,
+
+  auto g3 = __builtin_bit_cast(unsigned int, i);
+  clang_analyzer_dump(g3);
+  // expected-warning-re@-1 ^reg_\$[0-9]+
+
+  auto g4 = __builtin_bit_cast(unsigned long, );
+  clang_analyzer_dump(g4);
+  // expected-warning@-1 {{ [as 64 bit integer]}}
+}
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -304,7 +304,8 @@
   ExplodedNodeSet dstPreStmt;
   getCheckerManager().runCheckersForPreStmt(dstPreStmt, Pred, CastE, *this);
 
-  if (CastE->getCastKind() == CK_LValueToRValue) {
+  if (CastE->getCastKind() == CK_LValueToRValue ||
+  CastE->getCastKind() == CK_LValueToRValueBitCast) {
 for (ExplodedNodeSet::iterator I = dstPreStmt.begin(), E = 
dstPreStmt.end();
  I!=E; ++I) {
   ExplodedNode *subExprNode = *I;
@@ -332,6 +333,7 @@
 
 switch (CastE->getCastKind()) {
   case CK_LValueToRValue:
+  case CK_LValueToRValueBitCast:
 llvm_unreachable("LValueToRValue casts handled earlier.");
   case CK_ToVoid:
 continue;
@@ -380,7 +382,6 @@
   case CK_Dependent:
   case CK_ArrayToPointerDecay:
   case CK_BitCast:
-  case CK_LValueToRValueBitCast:
   case CK_AddressSpaceConversion:
   case CK_BooleanToSignedIntegral:
   case CK_IntegralToPointer:


Index: clang/test/Analysis/builtin_bitcast.cpp
===
--- /dev/null
+++ clang/test/Analysis/builtin_bitcast.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection
+
+template  void clang_analyzer_dump(T);
+
+__attribute__((always_inline)) static inline constexpr unsigned int _castf32_u32(float __A) {
+  return __builtin_bit_cast(unsigned int, __A); // no-warning
+}
+
+void test(int i) {
+  _castf32_u32(42);
+
+  float f = 42;
+
+  // Loading from a floating point value results in unknown,
+  // which later materializes as a conjured value.
+  auto g = __builtin_bit_cast(unsigned int, f);
+  clang_analyzer_dump(g);
+  // expected-warning-re@-1 ^conj_\$[0-9]+{unsigned int,
+
+  auto g2 = __builtin_bit_cast(unsigned int, 42.0f);
+  clang_analyzer_dump(g2);
+  // expected-warning-re@-1 ^conj_\$[0-9]+{unsigned int,
+
+  auto g3 = __builtin_bit_cast(unsigned int, i);
+  clang_analyzer_dump(g3);
+  // expected-warning-re@-1 ^reg_\$[0-9]+
+
+  auto g4 = __builtin_bit_cast(unsigned long, );
+  clang_analyzer_dump(g4);
+  // expected-warning@-1 {{ [as 64 bit integer]}}
+}
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -304,7 +304,8 @@
   ExplodedNodeSet dstPreStmt;
   getCheckerManager().runCheckersForPreStmt(dstPreStmt, Pred, CastE, *this);
 
-  if (CastE->getCastKind() == CK_LValueToRValue) {
+  if (CastE->getCastKind() == CK_LValueToRValue ||
+  CastE->getCastKind() == CK_LValueToRValueBitCast) {
 for (ExplodedNodeSet::iterator I = dstPreStmt.begin(), E = dstPreStmt.end();
  I!=E; ++I) {
   ExplodedNode *subExprNode = *I;
@@ -332,6 +333,7 @@
 
 switch (CastE->getCastKind()) {
   case CK_LValueToRValue:
+  case CK_LValueToRValueBitCast:
 llvm_unreachable("LValueToRValue casts 

[PATCH] D103040: Print default template argument if manually specified in typedef declaration.

2021-06-29 Thread Vassil Vassilev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc33ebad73516: Print default template argument if manually 
specified in typedef declaration. (authored by reikdas, committed by 
v.g.vassilev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103040

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/test/SemaTemplate/class-template-id.cpp
  clang/test/SemaTemplate/default-arguments-ast-print.cpp


Index: clang/test/SemaTemplate/default-arguments-ast-print.cpp
===
--- clang/test/SemaTemplate/default-arguments-ast-print.cpp
+++ clang/test/SemaTemplate/default-arguments-ast-print.cpp
@@ -10,3 +10,15 @@
   // CHECK: int Foo::method1()
   return 10;
 }
+
+int test_typedef() {
+  typedef Foo TypedefArg;
+  // CHECK: typedef Foo TypedefArg;
+  return 10;
+}
+
+int test_typedef2() {
+  typedef Foo TypedefArg;
+  // CHECK: typedef Foo TypedefArg;
+  return 10;
+}
Index: clang/test/SemaTemplate/class-template-id.cpp
===
--- clang/test/SemaTemplate/class-template-id.cpp
+++ clang/test/SemaTemplate/class-template-id.cpp
@@ -9,9 +9,9 @@
   if (ptr)
 return ptr; // okay
   else if (ptr2)
-return ptr2; // expected-error{{cannot initialize return object of type 
'A *' with an lvalue of type 'const A *'}}
+return ptr2; // expected-error{{cannot initialize return object of type 
'A *' (aka 'A *') with an lvalue of type 'const A 
*'}}
   else {
-return ptr3; // expected-error{{cannot initialize return object of type 
'A *' with an lvalue of type 'A *'}}
+return ptr3; // expected-error{{cannot initialize return object of type 
'A *' (aka 'A *') with an lvalue of type 'A *'}}
   }
 }
 
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1449,8 +1449,7 @@
 T->getTemplateName().print(OS, Policy);
   }
 
-  const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : 
nullptr;
-  printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL);
+  printTemplateArgumentList(OS, T->template_arguments(), Policy);
   spaceBeforePlaceHolder(OS);
 }
 


Index: clang/test/SemaTemplate/default-arguments-ast-print.cpp
===
--- clang/test/SemaTemplate/default-arguments-ast-print.cpp
+++ clang/test/SemaTemplate/default-arguments-ast-print.cpp
@@ -10,3 +10,15 @@
   // CHECK: int Foo::method1()
   return 10;
 }
+
+int test_typedef() {
+  typedef Foo TypedefArg;
+  // CHECK: typedef Foo TypedefArg;
+  return 10;
+}
+
+int test_typedef2() {
+  typedef Foo TypedefArg;
+  // CHECK: typedef Foo TypedefArg;
+  return 10;
+}
Index: clang/test/SemaTemplate/class-template-id.cpp
===
--- clang/test/SemaTemplate/class-template-id.cpp
+++ clang/test/SemaTemplate/class-template-id.cpp
@@ -9,9 +9,9 @@
   if (ptr)
 return ptr; // okay
   else if (ptr2)
-return ptr2; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'const A *'}}
+return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}}
   else {
-return ptr3; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'A *'}}
+return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}}
   }
 }
 
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1449,8 +1449,7 @@
 T->getTemplateName().print(OS, Policy);
   }
 
-  const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : nullptr;
-  printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL);
+  printTemplateArgumentList(OS, T->template_arguments(), Policy);
   spaceBeforePlaceHolder(OS);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c33ebad - Print default template argument if manually specified in typedef declaration.

2021-06-29 Thread Vassil Vassilev via cfe-commits

Author: Pratyush Das
Date: 2021-06-29T14:57:26Z
New Revision: c33ebad73516ffcf7b00821a430aa6a0199941f0

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

LOG: Print default template argument if manually specified in typedef 
declaration.

If a default template type argument is manually specified to be of the default
type, then it is committed when printing the template.

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

Added: 


Modified: 
clang/lib/AST/TypePrinter.cpp
clang/test/SemaTemplate/class-template-id.cpp
clang/test/SemaTemplate/default-arguments-ast-print.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 720cab917a22..47e48506dc96 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1449,8 +1449,7 @@ void TypePrinter::printTemplateId(const 
TemplateSpecializationType *T,
 T->getTemplateName().print(OS, Policy);
   }
 
-  const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : 
nullptr;
-  printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL);
+  printTemplateArgumentList(OS, T->template_arguments(), Policy);
   spaceBeforePlaceHolder(OS);
 }
 

diff  --git a/clang/test/SemaTemplate/class-template-id.cpp 
b/clang/test/SemaTemplate/class-template-id.cpp
index b32a03e478d9..50cb3ef59ea4 100644
--- a/clang/test/SemaTemplate/class-template-id.cpp
+++ b/clang/test/SemaTemplate/class-template-id.cpp
@@ -9,9 +9,9 @@ A *foo(A *ptr, A const *ptr2, A *ptr3) {
   if (ptr)
 return ptr; // okay
   else if (ptr2)
-return ptr2; // expected-error{{cannot initialize return object of type 
'A *' with an lvalue of type 'const A *'}}
+return ptr2; // expected-error{{cannot initialize return object of type 
'A *' (aka 'A *') with an lvalue of type 'const A 
*'}}
   else {
-return ptr3; // expected-error{{cannot initialize return object of type 
'A *' with an lvalue of type 'A *'}}
+return ptr3; // expected-error{{cannot initialize return object of type 
'A *' (aka 'A *') with an lvalue of type 'A *'}}
   }
 }
 

diff  --git a/clang/test/SemaTemplate/default-arguments-ast-print.cpp 
b/clang/test/SemaTemplate/default-arguments-ast-print.cpp
index 9ed17a79de0d..4623f0a8cdf4 100644
--- a/clang/test/SemaTemplate/default-arguments-ast-print.cpp
+++ b/clang/test/SemaTemplate/default-arguments-ast-print.cpp
@@ -10,3 +10,15 @@ int Foo::method1() {
   // CHECK: int Foo::method1()
   return 10;
 }
+
+int test_typedef() {
+  typedef Foo TypedefArg;
+  // CHECK: typedef Foo TypedefArg;
+  return 10;
+}
+
+int test_typedef2() {
+  typedef Foo TypedefArg;
+  // CHECK: typedef Foo TypedefArg;
+  return 10;
+}



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


[PATCH] D104952: [hexagon] Add {hvx,}hexagon_{protos,circ_brev...}

2021-06-29 Thread Brian Cain via Phabricator via cfe-commits
bcain updated this revision to Diff 355234.
bcain added a comment.

Removed some unavailable instructions.

Added include order fix in hexagon_circ_brev


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104952

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/hexagon_circ_brev_intrinsics.h
  clang/lib/Headers/hexagon_protos.h
  clang/lib/Headers/hexagon_types.h
  clang/lib/Headers/hvx_hexagon_protos.h
  clang/test/Headers/hexagon-audio-headers.c
  clang/test/Headers/hexagon-headers.c
  clang/test/Headers/hexagon-hvx-headers.c

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


[PATCH] D105120: [clang] Fix UB when string.front() is used for the empty string

2021-06-29 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 355233.
DmitryPolukhin added a comment.

Replace tab with spaces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105120

Files:
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -700,6 +700,10 @@
 SmallVector Argv = {Clang, File, "-D", File};
 llvm::SplitString(Flags, Argv);
 
+// Trim double quotation from the argumnets if any.
+for (auto It = Argv.begin(); It != Argv.end(); ++It)
+  *It = It->trim("\"");
+
 SmallString<32> Dir;
 llvm::sys::path::system_temp_directory(false, Dir);
 
@@ -962,5 +966,12 @@
   EXPECT_EQ(getCommand("bar.cpp"), "clang bar.cpp -D bar.cpp -Dflag");
 }
 
+TEST_F(ExpandResponseFilesTest, ExpandResponseFilesEmptyArgument) {
+  addFile(path(StringRef("rsp1.rsp")), "-Dflag");
+
+  add("foo.cpp", "clang", "@rsp1.rsp \"\"");
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag ");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -54,7 +54,8 @@
   Argv.reserve(Cmd.CommandLine.size());
   for (auto  : Cmd.CommandLine) {
 Argv.push_back(Arg.c_str());
-SeenRSPFile |= Arg.front() == '@';
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
   }
   if (!SeenRSPFile)
 continue;


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -700,6 +700,10 @@
 SmallVector Argv = {Clang, File, "-D", File};
 llvm::SplitString(Flags, Argv);
 
+// Trim double quotation from the argumnets if any.
+for (auto It = Argv.begin(); It != Argv.end(); ++It)
+  *It = It->trim("\"");
+
 SmallString<32> Dir;
 llvm::sys::path::system_temp_directory(false, Dir);
 
@@ -962,5 +966,12 @@
   EXPECT_EQ(getCommand("bar.cpp"), "clang bar.cpp -D bar.cpp -Dflag");
 }
 
+TEST_F(ExpandResponseFilesTest, ExpandResponseFilesEmptyArgument) {
+  addFile(path(StringRef("rsp1.rsp")), "-Dflag");
+
+  add("foo.cpp", "clang", "@rsp1.rsp \"\"");
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag ");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -54,7 +54,8 @@
   Argv.reserve(Cmd.CommandLine.size());
   for (auto  : Cmd.CommandLine) {
 Argv.push_back(Arg.c_str());
-SeenRSPFile |= Arg.front() == '@';
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
   }
   if (!SeenRSPFile)
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105120: [clang] Fix UB when string.front() is used for the empty string

2021-06-29 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added reviewers: kadircet, lh123, sammccall, hokein, 
ilya-biryukov.
DmitryPolukhin added projects: clang, clang-tools-extra.
Herald added a subscriber: usaxena95.
DmitryPolukhin requested review of this revision.

Compilation database might have empty string as a command line argument.
But ExpandResponseFilesDatabase::expand doesn't expect this and assumes
that string.front() can be used for any argument. It is undefined behaviour if
string is empty. With debug build mode it causes crash in clangd.

Test Plan: check-clang


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105120

Files:
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -700,6 +700,10 @@
 SmallVector Argv = {Clang, File, "-D", File};
 llvm::SplitString(Flags, Argv);
 
+// Trim double quotation from the argumnets if any.
+for (auto It = Argv.begin(); It != Argv.end(); ++It)
+  *It = It->trim("\"");
+
 SmallString<32> Dir;
 llvm::sys::path::system_temp_directory(false, Dir);
 
@@ -962,5 +966,12 @@
   EXPECT_EQ(getCommand("bar.cpp"), "clang bar.cpp -D bar.cpp -Dflag");
 }
 
+TEST_F(ExpandResponseFilesTest, ExpandResponseFilesEmptyArgument) {
+  addFile(path(StringRef("rsp1.rsp")), "-Dflag");
+
+  add("foo.cpp", "clang", "@rsp1.rsp \"\"");
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag ");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -54,7 +54,8 @@
   Argv.reserve(Cmd.CommandLine.size());
   for (auto  : Cmd.CommandLine) {
 Argv.push_back(Arg.c_str());
-SeenRSPFile |= Arg.front() == '@';
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
   }
   if (!SeenRSPFile)
 continue;


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -700,6 +700,10 @@
 SmallVector Argv = {Clang, File, "-D", File};
 llvm::SplitString(Flags, Argv);
 
+// Trim double quotation from the argumnets if any.
+for (auto It = Argv.begin(); It != Argv.end(); ++It)
+  *It = It->trim("\"");
+
 SmallString<32> Dir;
 llvm::sys::path::system_temp_directory(false, Dir);
 
@@ -962,5 +966,12 @@
   EXPECT_EQ(getCommand("bar.cpp"), "clang bar.cpp -D bar.cpp -Dflag");
 }
 
+TEST_F(ExpandResponseFilesTest, ExpandResponseFilesEmptyArgument) {
+  addFile(path(StringRef("rsp1.rsp")), "-Dflag");
+
+  add("foo.cpp", "clang", "@rsp1.rsp \"\"");
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag ");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -54,7 +54,8 @@
   Argv.reserve(Cmd.CommandLine.size());
   for (auto  : Cmd.CommandLine) {
 Argv.push_back(Arg.c_str());
-SeenRSPFile |= Arg.front() == '@';
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
   }
   if (!SeenRSPFile)
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >