[PATCH] D71830: [OpenMP][Part 2] Use reusable OpenMP context/traits handling

2020-02-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: clang/include/clang/Serialization/ASTRecordReader.h:272
+
+  template <> OpenMPTraitInfo *readUserType() { return readOpenMPTraitInfo(); }
+

jdoerfert wrote:
> kiranchandramohan wrote:
> > jdoerfert wrote:
> > > kiranchandramohan wrote:
> > > > jdoerfert wrote:
> > > > > kiranchandramohan wrote:
> > > > > > Compiler throws up this error.
> > > > > > error: explicit specialization in non-namespace scope ‘class 
> > > > > > clang::ASTRecordReader’
> > > > > Oh, my compiler was happy. Let me rebase and see what the pre-merge 
> > > > > bots say so I might get some insight into the problem.
> > > > Were you able to reproduce the error? I was using gcc 9.2 compiler.
> > > I have not seen the error yet. I build with clang. Do you happen to have 
> > > an idea how to refactor this? I will look into it with a new gcc asap.
> > Moving the specialization to the source file seems to fix the issue.
> I will do that then. Did you find the time to look over the rest?
> Moving the specialization to the source file seems to fix the issue.

Like this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71830



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


[PATCH] D68049: Propeller: Clang options for basic block sections

2020-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

If you don't mind, I can push a Diff to this Differential which will address 
these review comments.




Comment at: clang/lib/CodeGen/BackendUtil.cpp:436
+
+  std::ifstream fin(FunctionsListFile);
+  if (!fin.good()) {

`MemoryBuffer::getFile`

avoid fstream.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:977
  OPT_fno_unique_section_names, true);
+  Opts.UniqueBBSectionNames = Args.hasFlag(
+  OPT_funique_bb_section_names, OPT_fno_unique_bb_section_names, false);

This patch requires a rebase.

`Opts.UniqueBBSectionNames = Args.hasArg(OPT_funique_bb_section_names);`

-ffoo and -fno-foo should have a test/Driver/ test.

There is no need to test both -ffoo and -fno-foo for cc1 options.


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

https://reviews.llvm.org/D68049



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


Re: [clang] 0e3a487 - PR12350: Handle remaining cases permitted by CWG DR 244.

2020-02-08 Thread Nico Weber via cfe-commits
(Also, it'd be nice if the "destructor cannot be declared using a type
alias" diag had a fixit attached to it :) )

On Sat, Feb 8, 2020 at 7:09 PM Nico Weber  wrote:

> Our code fails to build with "destructor cannot be declared using a type
> alias" after this, without us changing language mode or anything.
>
> Is that intended? Can this be a default-error-mapped warning so that
> projects have some incremental transition path for this?
>
> On Fri, Feb 7, 2020 at 9:41 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Richard Smith
>> Date: 2020-02-07T18:40:41-08:00
>> New Revision: 0e3a48778408b505946e465abf5c77a2ddd4918c
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c.diff
>>
>> LOG: PR12350: Handle remaining cases permitted by CWG DR 244.
>>
>> Also add extension warnings for the cases that are disallowed by the
>> current rules for destructor name lookup, refactor and simplify the
>> lookup code, and improve the diagnostic quality when lookup fails.
>>
>> The special case we previously supported for converting
>> p->N::S::~S() from naming a class template into naming a
>> specialization thereof is subsumed by a more general rule here (which is
>> also consistent with Clang's historical behavior and that of other
>> compilers): if we can't find a suitable S in N, also look in N::S.
>>
>> The extension warnings are off by default, except for a warning when
>> lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S).
>> That seems sufficiently heinous to warn on by default, especially since
>> we can't support it for a dependent nested-name-specifier.
>>
>> Added:
>>
>>
>> Modified:
>> clang/include/clang/Basic/DiagnosticGroups.td
>> clang/include/clang/Basic/DiagnosticSemaKinds.td
>> clang/lib/AST/NestedNameSpecifier.cpp
>> clang/lib/Sema/DeclSpec.cpp
>> clang/lib/Sema/SemaExprCXX.cpp
>> clang/test/CXX/class/class.mem/p13.cpp
>> clang/test/CXX/drs/dr2xx.cpp
>> clang/test/CXX/drs/dr3xx.cpp
>> clang/test/FixIt/fixit.cpp
>> clang/test/Parser/cxx-decl.cpp
>> clang/test/SemaCXX/constructor.cpp
>> clang/test/SemaCXX/destructor.cpp
>> clang/test/SemaCXX/pseudo-destructors.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
>> b/clang/include/clang/Basic/DiagnosticGroups.td
>> index a2bc29986a07..8c54723cdbab 100644
>> --- a/clang/include/clang/Basic/DiagnosticGroups.td
>> +++ b/clang/include/clang/Basic/DiagnosticGroups.td
>> @@ -192,6 +192,7 @@ def CXX2aDesignator : DiagGroup<"c++2a-designator">;
>>  // designators (including the warning controlled by -Wc++2a-designator).
>>  def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>;
>>  def GNUDesignator : DiagGroup<"gnu-designator">;
>> +def DtorName : DiagGroup<"dtor-name">;
>>
>>  def DynamicExceptionSpec
>>  : DiagGroup<"dynamic-exception-spec",
>> [DeprecatedDynamicExceptionSpec]>;
>>
>> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> index 9de60d3a8d27..82861f0d5d72 100644
>> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> @@ -1911,17 +1911,33 @@ def err_destructor_with_params :
>> Error<"destructor cannot have any parameters">;
>>  def err_destructor_variadic : Error<"destructor cannot be variadic">;
>>  def err_destructor_typedef_name : Error<
>>"destructor cannot be declared using a %select{typedef|type alias}1 %0
>> of the class name">;
>> +def err_undeclared_destructor_name : Error<
>> +  "undeclared identifier %0 in destructor name">;
>>  def err_destructor_name : Error<
>>"expected the class name after '~' to name the enclosing class">;
>> -def err_destructor_class_name : Error<
>> -  "expected the class name after '~' to name a destructor">;
>> -def err_ident_in_dtor_not_a_type : Error<
>> +def err_destructor_name_nontype : Error<
>> +  "identifier %0 after '~' in destructor name does not name a type">;
>> +def err_destructor_expr_mismatch : Error<
>> +  "identifier %0 in object destruction expression does not name the type
>> "
>> +  "%1 of the object being destroyed">;
>> +def err_destructor_expr_nontype : Error<
>>"identifier %0 in object destruction expression does not name a type">;
>>  def err_destructor_expr_type_mismatch : Error<
>>"destructor type %0 in object destruction expression does not match
>> the "
>>"type %1 of the object being destroyed">;
>>  def note_destructor_type_here : Note<
>> -  "type %0 is declared here">;
>> +  "type %0 found by destructor name lookup">;
>> +def note_destructor_nontype_here : Note<
>> +  "non-type declaration found by destructor name lookup">;
>> +def 

[PATCH] D72304: [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-02-08 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8a436c5ea26: [OpenMP][OMPIRBuilder] Add Directives (master 
and critical) to OMPBuilder. (authored by fady f...@lap118789.ornl.gov, 
committed by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D72304?vs=242144=243419#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -613,4 +613,161 @@
   }
 }
 
+TEST_F(OpenMPIRBuilderTest, MasterDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = nullptr;
+
+  BasicBlock *EntryBB = nullptr;
+  BasicBlock *ExitBB = nullptr;
+  BasicBlock *ThenBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock ) {
+if (AllocaIP.isSet())
+  Builder.restoreIP(AllocaIP);
+else
+  Builder.SetInsertPoint(&*(F->getEntryBlock().getFirstInsertionPt()));
+PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+Builder.CreateStore(F->arg_begin(), PrivAI);
+
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+
+Builder.restoreIP(CodeGenIP);
+
+// collect some info for checks later
+ExitBB = FiniBB.getUniqueSuccessor();
+ThenBB = Builder.GetInsertBlock();
+EntryBB = ThenBB->getUniquePredecessor();
+
+// simple instructions for body
+Value *PrivLoad = Builder.CreateLoad(PrivAI, "local.use");
+Builder.CreateICmpNE(F->arg_begin(), PrivLoad);
+  };
+
+  auto FiniCB = [&](InsertPointTy IP) {
+BasicBlock *IPBB = IP.getBlock();
+EXPECT_NE(IPBB->end(), IP.getPoint());
+  };
+
+  Builder.restoreIP(OMPBuilder.CreateMaster(Builder, BodyGenCB, FiniCB));
+  Value *EntryBBTI = EntryBB->getTerminator();
+  EXPECT_NE(EntryBBTI, nullptr);
+  EXPECT_TRUE(isa(EntryBBTI));
+  BranchInst *EntryBr = cast(EntryBB->getTerminator());
+  EXPECT_TRUE(EntryBr->isConditional());
+  EXPECT_EQ(EntryBr->getSuccessor(0), ThenBB);
+  EXPECT_EQ(ThenBB->getUniqueSuccessor(), ExitBB);
+  EXPECT_EQ(EntryBr->getSuccessor(1), ExitBB);
+
+  CmpInst *CondInst = cast(EntryBr->getCondition());
+  EXPECT_TRUE(isa(CondInst->getOperand(0)));
+
+  CallInst *MasterEntryCI = cast(CondInst->getOperand(0));
+  EXPECT_EQ(MasterEntryCI->getNumArgOperands(), 2U);
+  EXPECT_EQ(MasterEntryCI->getCalledFunction()->getName(), "__kmpc_master");
+  EXPECT_TRUE(isa(MasterEntryCI->getArgOperand(0)));
+
+  CallInst *MasterEndCI = nullptr;
+  for (auto  : *ThenBB) {
+Instruction *cur = 
+if (isa(cur)) {
+  MasterEndCI = cast(cur);
+  if (MasterEndCI->getCalledFunction()->getName() == "__kmpc_end_master")
+break;
+  MasterEndCI = nullptr;
+}
+  }
+  EXPECT_NE(MasterEndCI, nullptr);
+  EXPECT_EQ(MasterEndCI->getNumArgOperands(), 2U);
+  EXPECT_TRUE(isa(MasterEndCI->getArgOperand(0)));
+  EXPECT_EQ(MasterEndCI->getArgOperand(1), MasterEntryCI->getArgOperand(1));
+}
+
+TEST_F(OpenMPIRBuilderTest, CriticalDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+
+  BasicBlock *EntryBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock ) {
+// collect some info for checks later
+EntryBB = FiniBB.getUniquePredecessor();
+
+// actual start for bodyCB
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+EXPECT_EQ(EntryBB, CodeGenIPBB);
+
+// body begin
+Builder.restoreIP(CodeGenIP);
+Builder.CreateStore(F->arg_begin(), PrivAI);
+Value *PrivLoad = Builder.CreateLoad(PrivAI, "local.use");
+

[clang] e8a436c - [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-02-08 Thread Johannes Doerfert via cfe-commits

Author: fady
Date: 2020-02-08T18:55:48-06:00
New Revision: e8a436c5ea26f69378e4c1cf3ddb5b647b201e0f

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

LOG: [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

Add support for Master and Critical directive in the OMPIRBuilder. Both make 
use of a new common interface for emitting inlined OMP regions called 
`emitInlinedRegion` which was added in this patch as well.

Also this patch modifies clang to use the new directives when  
`-fopenmp-enable-irbuilder` commandline option is passed.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/critical_codegen.cpp
clang/test/OpenMP/master_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPConstants.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index cd5f7c05..b1fc6bb62adb 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3143,11 +3143,147 @@ static void emitMaster(CodeGenFunction , const 
OMPExecutableDirective ) {
 }
 
 void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective ) {
+  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
+using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+
+const CapturedStmt *CS = S.getInnermostCapturedStmt();
+const Stmt *MasterRegionBodyStmt = CS->getCapturedStmt();
+
+// TODO: Replace with a generic helper function for finalization
+auto FiniCB = [this](InsertPointTy IP) {
+  CGBuilderTy::InsertPointGuard IPG(Builder);
+  assert(IP.getBlock()->end() != IP.getPoint() &&
+ "OpenMP IR Builder should cause terminated block!");
+
+  llvm::BasicBlock *IPBB = IP.getBlock();
+  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
+  assert(DestBB && "Finalization block should have one successor!");
+
+  // erase and replace with cleanup branch.
+  IPBB->getTerminator()->eraseFromParent();
+  Builder.SetInsertPoint(IPBB);
+  CodeGenFunction::JumpDest Dest = getJumpDestInCurrentScope(DestBB);
+  EmitBranchThroughCleanup(Dest);
+};
+
+// TODO: Replace with a generic helper function for emitting body
+auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
+  InsertPointTy CodeGenIP,
+  llvm::BasicBlock ) {
+  // Alloca insertion block should be in the entry block of the containing
+  // function So it expects an empty AllocaIP in which case will reuse the
+  // old alloca insertion point, or a new AllocaIP in the same block as the
+  // old one
+  assert((!AllocaIP.isSet() ||
+  AllocaInsertPt->getParent() == AllocaIP.getBlock()) &&
+ "Insertion point should be in the entry block of containing "
+ "function!");
+  auto OldAllocaIP = AllocaInsertPt;
+  if (AllocaIP.isSet())
+AllocaInsertPt = &*AllocaIP.getPoint();
+  auto OldReturnBlock = ReturnBlock;
+  ReturnBlock = getJumpDestInCurrentScope();
+
+  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+  if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
+CodeGenIPBBTI->eraseFromParent();
+
+  Builder.SetInsertPoint(CodeGenIPBB);
+
+  EmitStmt(MasterRegionBodyStmt);
+
+  if (Builder.saveIP().isSet())
+Builder.CreateBr();
+
+  AllocaInsertPt = OldAllocaIP;
+  ReturnBlock = OldReturnBlock;
+};
+CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, );
+Builder.restoreIP(OMPBuilder->CreateMaster(Builder, BodyGenCB, FiniCB));
+
+return;
+  }
   OMPLexicalScope Scope(*this, S, OMPD_unknown);
   emitMaster(*this, S);
 }
 
 void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective ) {
+  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
+using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+
+const CapturedStmt *CS = S.getInnermostCapturedStmt();
+const Stmt *CriticalRegionBodyStmt = CS->getCapturedStmt();
+const Expr *Hint = nullptr;
+if (const auto *HintClause = S.getSingleClause())
+  Hint = HintClause->getHint();
+
+// TODO: This is slightly 
diff erent from what's currently being done in
+// clang. Fix the Int32Ty to IntPtrTy 

[PATCH] D72304: [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-02-08 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304



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


Re: [clang] 0e3a487 - PR12350: Handle remaining cases permitted by CWG DR 244.

2020-02-08 Thread Nico Weber via cfe-commits
Our code fails to build with "destructor cannot be declared using a type
alias" after this, without us changing language mode or anything.

Is that intended? Can this be a default-error-mapped warning so that
projects have some incremental transition path for this?

On Fri, Feb 7, 2020 at 9:41 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Richard Smith
> Date: 2020-02-07T18:40:41-08:00
> New Revision: 0e3a48778408b505946e465abf5c77a2ddd4918c
>
> URL:
> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c
> DIFF:
> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c.diff
>
> LOG: PR12350: Handle remaining cases permitted by CWG DR 244.
>
> Also add extension warnings for the cases that are disallowed by the
> current rules for destructor name lookup, refactor and simplify the
> lookup code, and improve the diagnostic quality when lookup fails.
>
> The special case we previously supported for converting
> p->N::S::~S() from naming a class template into naming a
> specialization thereof is subsumed by a more general rule here (which is
> also consistent with Clang's historical behavior and that of other
> compilers): if we can't find a suitable S in N, also look in N::S.
>
> The extension warnings are off by default, except for a warning when
> lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S).
> That seems sufficiently heinous to warn on by default, especially since
> we can't support it for a dependent nested-name-specifier.
>
> Added:
>
>
> Modified:
> clang/include/clang/Basic/DiagnosticGroups.td
> clang/include/clang/Basic/DiagnosticSemaKinds.td
> clang/lib/AST/NestedNameSpecifier.cpp
> clang/lib/Sema/DeclSpec.cpp
> clang/lib/Sema/SemaExprCXX.cpp
> clang/test/CXX/class/class.mem/p13.cpp
> clang/test/CXX/drs/dr2xx.cpp
> clang/test/CXX/drs/dr3xx.cpp
> clang/test/FixIt/fixit.cpp
> clang/test/Parser/cxx-decl.cpp
> clang/test/SemaCXX/constructor.cpp
> clang/test/SemaCXX/destructor.cpp
> clang/test/SemaCXX/pseudo-destructors.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
> b/clang/include/clang/Basic/DiagnosticGroups.td
> index a2bc29986a07..8c54723cdbab 100644
> --- a/clang/include/clang/Basic/DiagnosticGroups.td
> +++ b/clang/include/clang/Basic/DiagnosticGroups.td
> @@ -192,6 +192,7 @@ def CXX2aDesignator : DiagGroup<"c++2a-designator">;
>  // designators (including the warning controlled by -Wc++2a-designator).
>  def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>;
>  def GNUDesignator : DiagGroup<"gnu-designator">;
> +def DtorName : DiagGroup<"dtor-name">;
>
>  def DynamicExceptionSpec
>  : DiagGroup<"dynamic-exception-spec",
> [DeprecatedDynamicExceptionSpec]>;
>
> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> index 9de60d3a8d27..82861f0d5d72 100644
> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> @@ -1911,17 +1911,33 @@ def err_destructor_with_params : Error<"destructor
> cannot have any parameters">;
>  def err_destructor_variadic : Error<"destructor cannot be variadic">;
>  def err_destructor_typedef_name : Error<
>"destructor cannot be declared using a %select{typedef|type alias}1 %0
> of the class name">;
> +def err_undeclared_destructor_name : Error<
> +  "undeclared identifier %0 in destructor name">;
>  def err_destructor_name : Error<
>"expected the class name after '~' to name the enclosing class">;
> -def err_destructor_class_name : Error<
> -  "expected the class name after '~' to name a destructor">;
> -def err_ident_in_dtor_not_a_type : Error<
> +def err_destructor_name_nontype : Error<
> +  "identifier %0 after '~' in destructor name does not name a type">;
> +def err_destructor_expr_mismatch : Error<
> +  "identifier %0 in object destruction expression does not name the type "
> +  "%1 of the object being destroyed">;
> +def err_destructor_expr_nontype : Error<
>"identifier %0 in object destruction expression does not name a type">;
>  def err_destructor_expr_type_mismatch : Error<
>"destructor type %0 in object destruction expression does not match the
> "
>"type %1 of the object being destroyed">;
>  def note_destructor_type_here : Note<
> -  "type %0 is declared here">;
> +  "type %0 found by destructor name lookup">;
> +def note_destructor_nontype_here : Note<
> +  "non-type declaration found by destructor name lookup">;
> +def ext_dtor_named_in_wrong_scope : Extension<
> +  "ISO C++ requires the name after '::~' to be found in the same scope as
> "
> +  "the name before '::~'">, InGroup;
> +def ext_dtor_name_missing_template_arguments : Extension<
> +  "ISO C++ requires template argument list in destructor name">,

[PATCH] D73742: [Clang][Driver] After default -fintegrated-cc1, fix report_fatal_error no longer generates preprocessed source + reproducer.sh

2020-02-08 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang/tools/driver/cc1_main.cpp:73
   // defined as an internal software error.  Otherwise, exit with status 1.
-  exit(GenCrashDiag ? 70 : 1);
+  llvm::sys::Process::Exit(GenCrashDiag ? 70 : 1);
 }

arichardson wrote:
> I don't think it matters (yet?) but we should probably also use 
> llvm::sys::Process::Exit() in cc1as_main.cpp?
Changed cc1as_main.cpp as well.


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

https://reviews.llvm.org/D73742



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


[PATCH] D73742: [Clang][Driver] After default -fintegrated-cc1, fix report_fatal_error no longer generates preprocessed source + reproducer.sh

2020-02-08 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 243380.
aganea added a comment.

Minor update -- added support & tested the VEH codepath as well.


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

https://reviews.llvm.org/D73742

Files:
  clang/test/Driver/crash-report.c
  clang/tools/driver/cc1_main.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/Support/CrashRecoveryContext.h
  llvm/include/llvm/Support/Process.h
  llvm/lib/Support/CrashRecoveryContext.cpp
  llvm/lib/Support/ErrorHandling.cpp
  llvm/lib/Support/Process.cpp

Index: llvm/lib/Support/Process.cpp
===
--- llvm/lib/Support/Process.cpp
+++ llvm/lib/Support/Process.cpp
@@ -13,8 +13,9 @@
 #include "llvm/Support/Process.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/Config/llvm-config.h"
 #include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -88,6 +89,13 @@
 
 bool Process::AreCoreFilesPrevented() { return coreFilesPrevented; }
 
+LLVM_ATTRIBUTE_NORETURN
+void Process::Exit(int RetCode) {
+  if (CrashRecoveryContext *CRC = CrashRecoveryContext::GetCurrent())
+CRC->HandleExit(RetCode);
+  ::exit(RetCode);
+}
+
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/Process.inc"
Index: llvm/lib/Support/ErrorHandling.cpp
===
--- llvm/lib/Support/ErrorHandling.cpp
+++ llvm/lib/Support/ErrorHandling.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/WindowsError.h"
@@ -122,7 +123,7 @@
   // files registered with RemoveFileOnSignal.
   sys::RunInterruptHandlers();
 
-  exit(1);
+  sys::Process::Exit(1);
 }
 
 void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
Index: llvm/lib/Support/CrashRecoveryContext.cpp
===
--- llvm/lib/Support/CrashRecoveryContext.cpp
+++ llvm/lib/Support/CrashRecoveryContext.cpp
@@ -14,9 +14,6 @@
 #include "llvm/Support/ThreadLocal.h"
 #include 
 #include 
-#ifdef _WIN32
-#include  // for GetExceptionInformation
-#endif
 #if LLVM_ON_UNIX
 #include  // EX_IOERR
 #endif
@@ -178,6 +175,9 @@
 }
 
 #if defined(_MSC_VER)
+
+#include  // for GetExceptionInformation
+
 // If _MSC_VER is defined, we must have SEH. Use it if it's available. It's way
 // better than VEH. Vectored exception handling catches all exceptions happening
 // on the thread with installed exception handlers, so it can interfere with
@@ -203,6 +203,8 @@
   }
 
   int RetCode = (int)Except->ExceptionRecord->ExceptionCode;
+  if ((RetCode & 0xF000) == 0xE000)
+RetCode &= ~0xF000; // this crash was generated by sys::Process::Exit
 
   // Handle the crash
   const_cast(CRCI)->HandleCrash(
@@ -280,10 +282,13 @@
   // TODO: We can capture the stack backtrace here and store it on the
   // implementation if we so choose.
 
+  int RetCode = (int)ExceptionInfo->ExceptionRecord->ExceptionCode;
+  if ((RetCode & 0xF000) == 0xE000)
+RetCode &= ~0xF000; // this crash was generated by sys::Process::Exit
+
   // Handle the crash
   const_cast(CRCI)->HandleCrash(
-  (int)ExceptionInfo->ExceptionRecord->ExceptionCode,
-  reinterpret_cast(ExceptionInfo));
+  RetCode, reinterpret_cast(ExceptionInfo));
 
   // Note that we don't actually get here because HandleCrash calls
   // longjmp, which means the HandleCrash function never returns.
@@ -416,6 +421,21 @@
 
 #endif // !_MSC_VER
 
+LLVM_ATTRIBUTE_NORETURN
+void CrashRecoveryContext::HandleExit(int RetCode) {
+#if defined(_WIN32)
+  // SEH and VEH
+  ::RaiseException(0xE000 | RetCode, 0, 0, NULL);
+#else
+  // On Unix we don't need to raise an exception, we go directly to
+  // HandleCrash(), then longjmp will unwind the stack for us.
+  CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *)Impl;
+  assert(CRCI && "Crash recovery context never initialized!");
+  CRCI->HandleCrash(RetCode, 0 /*no sig num*/);
+#endif
+  llvm_unreachable("Most likely setjmp wasn't called!");
+}
+
 // FIXME: Portability.
 static void setThreadBackgroundPriority() {
 #ifdef __APPLE__
Index: llvm/include/llvm/Support/Process.h
===
--- llvm/include/llvm/Support/Process.h
+++ llvm/include/llvm/Support/Process.h
@@ -201,6 +201,12 @@
   /// Get the result of a process wide random number generator. The
   /// generator will be automatically seeded in non-deterministic fashion.
   static unsigned GetRandomNumber();
+
+  /// When integrated-cc1 is disabled, terminate the 

[PATCH] D73845: [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu

2020-02-08 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul added a comment.

> I however didn't find how to specify in phabricator a dependency between the 
> two diffs, is that supported in phabricator?

Ah, it can be set as child revision after creating the diff, done so.


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

https://reviews.llvm.org/D73845



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


[PATCH] D73845: [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu

2020-02-08 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 243378.
sthibaul retitled this revision from "[Gnu toolchain] Look at standard GCC 
multilib/multiarch paths by default" to "[Gnu toolchain] Move GCC 
multilib/multiarch paths support from Linux to Gnu".

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

https://reviews.llvm.org/D73845

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

Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -208,15 +208,6 @@
   return Triple.isArch32Bit() ? "lib" : "lib64";
 }
 
-static void addMultilibsFilePaths(const Driver , const MultilibSet ,
-  const Multilib ,
-  StringRef InstallPath,
-  ToolChain::path_list ) {
-  if (const auto  = Multilibs.filePathsCallback())
-for (const auto  : PathsCallback(Multilib))
-  addPathIfExists(D, InstallPath + Path, Paths);
-}
-
 Linux::Linux(const Driver , const llvm::Triple , const ArgList )
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
@@ -224,21 +215,9 @@
   SelectedMultilib = GCCInstallation.getMultilib();
   llvm::Triple::ArchType Arch = Triple.getArch();
   std::string SysRoot = computeSysRoot();
-
-  // Cross-compiling binutils and GCC installations (vanilla and openSUSE at
-  // least) put various tools in a triple-prefixed directory off of the parent
-  // of the GCC installation. We use the GCC triple here to ensure that we end
-  // up with tools that support the same amount of cross compiling as the
-  // detected GCC installation. For example, if we find a GCC installation
-  // targeting x86_64, but it is a bi-arch GCC installation, it can also be
-  // used to target i386.
-  // FIXME: This seems unlikely to be Linux-specific.
   ToolChain::path_list  = getProgramPaths();
-  if (GCCInstallation.isValid()) {
-PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
-   GCCInstallation.getTriple().str() + "/bin")
- .str());
-  }
+
+  Generic_GCC::PushGCCPPaths(PPaths);
 
   Distro Distro(D.getVFS(), Triple);
 
@@ -317,58 +296,8 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
-  // Add the multilib suffixed paths where they are available.
-  if (GCCInstallation.isValid()) {
-const llvm::Triple  = GCCInstallation.getTriple();
-const std::string  =
-std::string(GCCInstallation.getParentLibPath());
-
-// Add toolchain / multilib specific file paths.
-addMultilibsFilePaths(D, Multilibs, SelectedMultilib,
-  GCCInstallation.getInstallPath(), Paths);
-
-// Sourcery CodeBench MIPS toolchain holds some libraries under
-// a biarch-like suffix of the GCC installation.
-addPathIfExists(
-D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(),
-Paths);
-
-// GCC cross compiling toolchains will install target libraries which ship
-// as part of the toolchain under // rather than as
-// any part of the GCC installation in
-// //gcc//. This decision is somewhat
-// debatable, but is the reality today. We need to search this tree even
-// when we have a sysroot somewhere else. It is the responsibility of
-// whomever is doing the cross build targeting a sysroot using a GCC
-// installation that is *not* within the system root to ensure two things:
-//
-//  1) Any DSOs that are linked in from this tree or from the install path
-// above must be present on the system root and found via an
-// appropriate rpath.
-//  2) There must not be libraries installed into
-// // unless they should be preferred over
-// those within the system root.
-//
-// Note that this matches the GCC behavior. See the below comment for where
-// Clang diverges from GCC's behavior.
-addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" +
-   OSLibDir + SelectedMultilib.osSuffix(),
-Paths);
-
-// If the GCC installation we found is inside of the sysroot, we want to
-// prefer libraries installed in the parent prefix of the GCC installation.
-// It is important to *not* use these paths when the GCC installation is
-// outside of the system root as that can pick up unintended libraries.
-// This usually happens when there is an external cross compiler on the
-// host system, and a more minimal sysroot available that is the target of
-// the cross. Note that GCC does include some of these directories in some
-// configurations but this seems somewhere between questionable and simply
- 

[PATCH] D73845: [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu

2020-02-08 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul marked an inline comment as done.
sthibaul added a comment.

>> I feel like in this specific case it may be worth splitting this into two 
>> patches:
> 
> Alright, doing so.

It is now on https://reviews.llvm.org/D74282

I however didn't find how to specify in phabricator a dependency between the 
two diffs, is that supported in phabricator?


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

https://reviews.llvm.org/D73845



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


[PATCH] D73845: [Gnu toolchain] Look at standard GCC multilib/multiarch paths by default

2020-02-08 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul added a comment.

> I feel like in this specific case it may be worth splitting this into two 
> patches:

Alright, doing so.

> isn't Hurd only limited to one GCC target triple (i386-gnu) for the time 
> being?

Right now, yes, but we'll want to bootstrap a 64bit port sooner or later. 
Better have that part ready in llvm to lessen the work of the bootstrap.

> A lot of the factored out bits seem to be still only applicable to Linux at a 
> glance,

? Everything I have seen in here looked to me only gcc-ish way of handling 
multilib and multiarch. It is used the same on other GNU systems using gcc: not 
only GNU/Hurd, but also GNU/kFreeBSD. I do not see anything specific to Linux 
there, only gcc-specific, which is the point of Gnu.cpp :)

> most people (including me) are unlikely to be intimately familiar with the 
> directory/library layout on Hurd, is it possible to provide some more 
> background on the Hurd-specific side of the patch?

It is just a matter of applying the same gcc-ish file layout which is currently 
missing from the existing Hurd.cpp, thus making multilib/multiarch fail to 
work. I don't really know what to explain beyond that: it's just the GNU 
toolchain way, there is no difference between GNU/Linux and GNU/Hurd in that 
regard. Do you perhaps have more precise questions?


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

https://reviews.llvm.org/D73845



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


[PATCH] D73845: [Gnu toolchain] Look at standard GCC multilib/multiarch paths by default

2020-02-08 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

I feel like in this specific case it may be worth splitting this into two 
patches:

- Factoring certain stuff out of `Linux.cpp` into `Gnu.(cpp|h)`.
- Adding that machinery to `Hurd.cpp` with related tests.

Also forgive me if I'm wrong but isn't Hurd only limited to one GCC target 
triple (`i386-gnu`) for the time being? A lot of the factored out bits seem to 
be still only applicable to Linux at a glance, in which case I'm not entirely 
sure of the rationale behind most of the refactoring. Since most people 
(including me) are unlikely to be intimately familiar with the 
directory/library layout on Hurd, is it possible to provide some more 
background on the Hurd-specific side of the patch?




Comment at: clang/lib/Driver/ToolChains/Gnu.h:324
+const std::string , path_list );
+  void AddGCCClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const;

Maybe rename `AddGCCClangSystemIncludeArgs` to `AddMultilibIncludeArgs` for 
brevity/clarity?


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

https://reviews.llvm.org/D73845



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


Re: [PATCH] D68720: Support -fstack-clash-protection for x86

2020-02-08 Thread Serge Guelton via cfe-commits
On Sat, Feb 08, 2020 at 01:26:03PM +, Simon Pilgrim via Phabricator wrote:
> RKSimon added a comment.
> 
> @serge-sans-paille Please can you fix the issues with EXPENSIVE_CHECKS 
> builds: 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-debian/builds/2604

yeah, spotted that... and reverted

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


[clang] 658495e - Revert "Support -fstack-clash-protection for x86"

2020-02-08 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-02-08T14:26:22+01:00
New Revision: 658495e6ecd4f6e9422307379ce8ea959fea8e8f

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

LOG: Revert "Support -fstack-clash-protection for x86"

This reverts commit e229017732bcf1911210903ee9811033d5588e0d.

Failures:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-debian/builds/2604
http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/4308

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/Target/X86/X86CallFrameOptimization.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86FrameLowering.h
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/lib/Target/X86/X86InstrInfo.td

Removed: 
clang/test/CodeGen/stack-clash-protection.c
clang/test/Driver/stack-clash-protection.c
llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
llvm/test/CodeGen/X86/stack-clash-large.ll
llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll
llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
llvm/test/CodeGen/X86/stack-clash-medium.ll
llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
llvm/test/CodeGen/X86/stack-clash-small.ll
llvm/test/CodeGen/X86/stack-clash-unknown-call.ll



diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 609e7fa66c00..24c8ee2bc9ef 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1917,10 +1917,6 @@ Use a strong heuristic to apply stack protectors to 
functions
 
 Emit section containing metadata on function stack sizes
 
-.. option:: -fstack-clash-protection, -fno-stack-clash-protection
-
-Instrument stack allocation to prevent stack clash attacks (x86, non-Windows 
only).
-
 .. option:: -fstandalone-debug, -fno-limit-debug-info, -fno-standalone-debug
 
 Emit full debug info for all types used by the program

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d24cd85673c6..e957550a93cc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -61,10 +61,6 @@ New Compiler Flags
 --
 
 
-- -fstack-clash-protection will provide a protection against the stack clash
-  attack for x86 architecture through automatic probing of each page of
-  allocated stack.
-
 Deprecated Compiler Flags
 -
 

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 48c0df49e32d..21e391912584 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -150,7 +150,6 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when 
-Wa,--no-warn is enabled.
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
 CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
  ///< inline line tables.
-CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
 CODEGENOPT(NoInfsFPMath  , 1, 0) ///< Assume FP arguments, results not 
+-Inf.
 CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP 
zero

diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 95cb81f09922..20b49605eb6f 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -239,10 +239,6 @@ def note_invalid_subexpr_in_const_expr : Note<
 let CategoryName = "Inline Assembly Issue" in {
   def err_asm_invalid_type_in_input : Error<
 "invalid type %0 in asm input for constraint '%1'">;
-
-  def warn_stack_clash_protection_inline_asm : Warning<
-"Unable to protect inline asm that clobbers stack pointer against stack 
clash">,
-InGroup>;
 }
 
 // Sema && Serialization

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index cb5aabdc468f..3a8e35524695 100644
--- 

[PATCH] D68720: Support -fstack-clash-protection for x86

2020-02-08 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@serge-sans-paille Please can you fix the issues with EXPENSIVE_CHECKS builds: 
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-debian/builds/2604


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D73891: [RISCV] Support experimental/unratified extensions

2020-02-08 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:93
+  // If experimental extension, require use of current version number number
+  if (auto ExperimentalExtension = isExperimentalExtension(Ext)) {
+if (!Args.hasArg(options::OPT_menable_experimental_extensions)) {

Hmm... Not sure it makes sense anymore for the function to be called 
`isExperimentalExtension`, because it's not just returning true or false. Just 
off the top of my head I would call it something like 
`getExperimentalExtensionVersion` or ideally something more concise.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:100
+  return false;
+} else if (Major.empty() && Minor.empty()) {
+  std::string Error =

Is just testing `Major.empty()` not sufficient? We can't have a version with 
just a minor version number.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:125
+  // Allow extensions to declare no version number
+  if (Major.empty() && Minor.empty())
+return true;

Ditto.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:366
 default:
   // Currently LLVM supports only "mafdc".
   D.Diag(diag::err_drv_invalid_riscv_ext_arch_name)

Should this comment be updated?



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:102
 
-  // TODO: Handle extensions with version number.
+  // If experimental extension, require use of current version number number
+  if (auto ExperimentalExtension = isExperimentalExtension(Ext)) {

Typo 'number number' ? Also perhaps not accurate to say 'current version 
number', as opposed to something like 'a supported version number'.


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

https://reviews.llvm.org/D73891



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


[clang] e229017 - Support -fstack-clash-protection for x86

2020-02-08 Thread via cfe-commits

Author: serge_sans_paille
Date: 2020-02-08T13:31:52+01:00
New Revision: e229017732bcf1911210903ee9811033d5588e0d

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

LOG: Support -fstack-clash-protection for x86

Implement protection against the stack clash attack [0] through inline stack
probing.

Probe stack allocation every PAGE_SIZE during frame lowering or dynamic
allocation to make sure the page guard, if any, is touched when touching the
stack, in a similar manner to GCC[1].

This extends the existing `probe-stack' mechanism with a special value 
`inline-asm'.
Technically the former uses function call before stack allocation while this
patch provides inlined stack probes and chunk allocation.

Only implemented for x86.

[0] https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt
[1] https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00556.html

This a recommit of 39f50da2a357a8f685b3540246c5d762734e035f with better option
handling and more portable testing

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

Added: 
clang/test/CodeGen/stack-clash-protection.c
clang/test/Driver/stack-clash-protection.c
llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
llvm/test/CodeGen/X86/stack-clash-large.ll
llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll
llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
llvm/test/CodeGen/X86/stack-clash-medium.ll
llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
llvm/test/CodeGen/X86/stack-clash-small.ll
llvm/test/CodeGen/X86/stack-clash-unknown-call.ll

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/Target/X86/X86CallFrameOptimization.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86FrameLowering.h
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/lib/Target/X86/X86InstrInfo.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 24c8ee2bc9ef..609e7fa66c00 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1917,6 +1917,10 @@ Use a strong heuristic to apply stack protectors to 
functions
 
 Emit section containing metadata on function stack sizes
 
+.. option:: -fstack-clash-protection, -fno-stack-clash-protection
+
+Instrument stack allocation to prevent stack clash attacks (x86, non-Windows 
only).
+
 .. option:: -fstandalone-debug, -fno-limit-debug-info, -fno-standalone-debug
 
 Emit full debug info for all types used by the program

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e957550a93cc..d24cd85673c6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -61,6 +61,10 @@ New Compiler Flags
 --
 
 
+- -fstack-clash-protection will provide a protection against the stack clash
+  attack for x86 architecture through automatic probing of each page of
+  allocated stack.
+
 Deprecated Compiler Flags
 -
 

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 21e391912584..48c0df49e32d 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -150,6 +150,7 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when 
-Wa,--no-warn is enabled.
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
 CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
  ///< inline line tables.
+CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
 CODEGENOPT(NoInfsFPMath  , 1, 0) ///< Assume FP arguments, results not 
+-Inf.
 CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP 
zero

diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 20b49605eb6f..95cb81f09922 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ 

[PATCH] D73845: [Gnu toolchain] Look at standard GCC multilib/multiarch paths by default

2020-02-08 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 243359.
sthibaul added a comment.
Herald added a subscriber: ormris.

Right, here is an updated patch


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

https://reviews.llvm.org/D73845

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld.bfd
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld.gold
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/lib/.keep
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/hurd.c

Index: clang/test/Driver/hurd.c
===
--- clang/test/Driver/hurd.c
+++ clang/test/Driver/hurd.c
@@ -11,7 +11,7 @@
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
 // CHECK: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -33,7 +33,7 @@
 // CHECK-STATIC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "crtbeginT.o"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginT.o"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-STATIC: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -53,10 +53,21 @@
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-SHARED: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-SHARED: "crtbeginS.o"
+// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginS.o"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-SHARED: "-L[[SYSROOT]]/usr/lib/i386-gnu"
 // CHECK-SHARED: "-L[[SYSROOT]]/usr/lib/../lib32"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib"
 // CHECK-SHARED: "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as -fuse-ld=ld \
+// RUN: --gcc-toolchain=%S/Inputs/basic_cross_hurd_tree/usr \
+// RUN: --target=i386-pc-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-CROSS %s
+// CHECK-CROSS-NOT: warning:
+// CHECK-CROSS: "-cc1" "-triple" "i386-pc-hurd-gnu"
+// CHECK-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}as" "--32"
+// CHECK-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}ld" {{.*}} "-m" "elf_i386"
+// CHECK-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK-CROSS: "-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/lib"
Index: clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld.gold
===
--- /dev/null
+++ clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld.gold
@@ -0,0 +1 @@
+#!/bin/true
Index: clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld.bfd
===
--- /dev/null
+++ clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld.bfd
@@ -0,0 +1 @@
+#!/bin/true
Index: clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
===
--- /dev/null
+++ clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
@@ -0,0 +1 @@
+ld.gold
\ No newline at end of file
Index: clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
===
--- /dev/null
+++ clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
@@ -0,0 +1 @@
+#!/bin/true
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -208,15 +208,6 @@
   return Triple.isArch32Bit() ? "lib" : "lib64";
 }
 
-static void addMultilibsFilePaths(const Driver , const MultilibSet ,
-  const Multilib ,
-  

[clang] ef83d46 - Use heterogenous lookup for std;:map

2020-02-08 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-02-08T13:28:29+01:00
New Revision: ef83d46b6b428fa1c8614cd28ab6fe3f07f8d075

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

LOG: Use heterogenous lookup for std;:map BuiltModules;
+  std::map> BuiltModules;
 
   /// Should we delete the BuiltModules when we're done?
   bool DeleteBuiltModules = true;

diff  --git a/clang/include/clang/Lex/HeaderSearchOptions.h 
b/clang/include/clang/Lex/HeaderSearchOptions.h
index 30a9d7564fd3..3af49e175395 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -115,7 +115,7 @@ class HeaderSearchOptions {
   std::string ModuleUserBuildPath;
 
   /// The mapping of module names to prebuilt module files.
-  std::map PrebuiltModuleFiles;
+  std::map> PrebuiltModuleFiles;
 
   /// The directories used to load prebuilt module files.
   std::vector PrebuiltModulePaths;

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 0db8df0fada8..fe787918b41b 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1634,15 +1634,15 @@ enum ModuleSource {
 
 /// Select a source for loading the named module and compute the filename to
 /// load it from.
-static ModuleSource
-selectModuleSource(Module *M, StringRef ModuleName, std::string 
,
-   const std::map ,
-   HeaderSearch ) {
+static ModuleSource selectModuleSource(
+Module *M, StringRef ModuleName, std::string ,
+const std::map> ,
+HeaderSearch ) {
   assert(ModuleFilename.empty() && "Already has a module source?");
 
   // Check to see if the module has been built as part of this compilation
   // via a module build pragma.
-  auto BuiltModuleIt = BuiltModules.find(std::string(ModuleName));
+  auto BuiltModuleIt = BuiltModules.find(ModuleName);
   if (BuiltModuleIt != BuiltModules.end()) {
 ModuleFilename = BuiltModuleIt->second;
 return MS_ModuleBuildPragma;

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 73c02d7f6e6d..65d109ebf034 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -145,7 +145,7 @@ std::string HeaderSearch::getCachedModuleFileName(Module 
*Module) {
 std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
 bool FileMapOnly) {
   // First check the module name to pcm file map.
-  auto i(HSOpts->PrebuiltModuleFiles.find(std::string(ModuleName)));
+  auto i(HSOpts->PrebuiltModuleFiles.find(ModuleName));
   if (i != HSOpts->PrebuiltModuleFiles.end())
 return i->second;
 

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h 
b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
index 8bfa5432b811..632540c79b0d 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
@@ -114,7 +114,8 @@ class LLVMSymbolizer {
   Expected getOrCreateObject(const std::string ,
   const std::string );
 
-  std::map> Modules;
+  std::map, std::less<>>
+  Modules;
 
   /// Contains cached results of getOrCreateObjectPair().
   std::map, ObjectPair>

diff  --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h 
b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 1296de75325b..dab0ad9fe055 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -959,7 +959,8 @@ class ModuleSummaryIndex {
   /// with that type identifier's metadata. Produced by per module summary
   /// analysis and consumed by thin link. For more information, see description
   /// above where TypeIdCompatibleVtableInfo is defined.
-  std::map TypeIdCompatibleVtableMap;
+  std::map>
+  TypeIdCompatibleVtableMap;
 
   /// Mapping from original ID to GUID. If original ID can map to multiple
   /// GUIDs, it will be mapped to 0.
@@ -1361,8 +1362,7 @@ class ModuleSummaryIndex {
 TypeId));
   }
 
-  const std::map &
-  typeIdCompatibleVtableMap() const {
+  const auto () const {
 return TypeIdCompatibleVtableMap;
   }
 
@@ -1378,7 +1378,7 @@ class ModuleSummaryIndex {
   /// entry if present in the summary map. This may be used when importing.
   Optional
   getTypeIdCompatibleVtableSummary(StringRef TypeId) const {
-auto I = TypeIdCompatibleVtableMap.find(std::string(TypeId));
+auto I = TypeIdCompatibleVtableMap.find(TypeId);
 if (I == TypeIdCompatibleVtableMap.end())
   return None;
 return I->second;

diff  --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp 
b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index d0948fd9ab8c..84cf4d40318f 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -62,7 +62,7 @@ Expected