[PATCH] D112190: [clang] Don't clear AST if we have consumers running after the main action

2021-10-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Misc/clear-ast-before-backend-plugins.c:3-8
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend 
-emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext %s 2>&1 
| FileCheck %s --check-prefix=YES
+// YES: Clearing AST
+
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend 
-emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext 
-add-plugin print-fns -plugin-arg-print-fns help %s 2>&1 | FileCheck %s 
--check-prefix=NO
+// NO-NOT: Clearing AST
+

Can you test that the "consumers running after the main action" are actually 
running here in a relatively lightweight manner? (ie: in a way that depends on 
as little details of their behavior as possible, just that they ran)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112190

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


[PATCH] D112102: [RISCV] Reduce the number of RISCV vector builtins by an order of magnitude.

2021-10-20 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D112102#3075400 , @craig.topper 
wrote:

> In D112102#3074656 , @frasercrmck 
> wrote:
>
>> Minor typo in the description: `differnet`
>>
>> Does this help with compile times, binary sizes, etc?
>
> This reduces the clang binary size by 2.34 megabytes according to my local 
> release+asserts build.
>
> I think there might be a small decrease in lit test time. If not, I don't see 
> any reason it would increase with this patch. The header file size does 
> decrease.

My fault. This patch decreases the binary size. The testing time increases due 
to D112020 . This patch decreases the header 
file size indeed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112102

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


[PATCH] D112143: [X86][ABI] Do not return float/double from x87 registers when x87 is disabled

2021-10-20 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei planned changes to this revision.
pengfei added a comment.

Found a mistake, working on that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112143

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


[PATCH] D110452: [modules] Fix tracking ObjCInterfaceType decl when there are multiple definitions.

2021-10-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 381130.
vsapsai added a comment.

Rebase and trigger a new round of pre-merge checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110452

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Modules/decldef.mm
  clang/test/Modules/interface-diagnose-missing-import.m

Index: clang/test/Modules/interface-diagnose-missing-import.m
===
--- clang/test/Modules/interface-diagnose-missing-import.m
+++ clang/test/Modules/interface-diagnose-missing-import.m
@@ -1,11 +1,11 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 %s -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/interface-diagnose-missing-import -verify
+// expected-no-diagnostics
 @interface Buggy
 @end
 
 @import Foo.Bar;
 
-@interface Buggy (MyExt) // expected-error {{definition of 'Buggy' must be imported from module 'Foo' before it is required}}
+// No diagnostic for inaccessible 'Buggy' definition because we have another definition right in this file.
+@interface Buggy (MyExt)
 @end
-
-// expected-note@Foo/RandoPriv.h:3{{definition here is not reachable}}
Index: clang/test/Modules/decldef.mm
===
--- clang/test/Modules/decldef.mm
+++ clang/test/Modules/decldef.mm
@@ -1,10 +1,12 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_1 -DUSE_2 -DUSE_3 -DUSE_4
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_2 -DUSE_3 -DUSE_4
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_3 -DUSE_4
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_4
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_1 -DUSE_2 -DUSE_3 -DUSE_4 -DUSE_5
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_2 -DUSE_3 -DUSE_4 -DUSE_5
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_3 -DUSE_4 -DUSE_5
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_4 -DUSE_5
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_5
 
 // expected-note@Inputs/def.h:5 0-1{{here}}
+// expected-note@Inputs/def.h:11 0-1{{here}}
 // expected-note@Inputs/def.h:16 0-1{{here}}
 // expected-note@Inputs/def-include.h:11 0-1{{here}}
 
@@ -51,11 +53,17 @@
 }
 
 void testDef() {
+#ifdef USE_4
   [def defMethod];
+  #ifndef USED
+  // expected-error@-2{{definition of 'Def' must be imported from module 'decldef.Def' before it is required}}
+  #define USED
+  #endif
+#endif
 }
 
 void testDef2() {
-#ifdef USE_4
+#ifdef USE_5
   def2->func();
   def3->func();
   #ifndef USED
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -5323,11 +5323,8 @@
 return FD->getDefinition();
   if (TagDecl *TD = dyn_cast(D))
 return TD->getDefinition();
-  // The first definition for this ObjCInterfaceDecl might be in the TU
-  // and not associated with any module. Use the one we know to be complete
-  // and have just seen in a module.
   if (ObjCInterfaceDecl *ID = dyn_cast(D))
-return ID;
+return ID->getDefinition();
   if (ObjCProtocolDecl *PD = dyn_cast(D))
 return PD->getDefinition();
   if (TemplateDecl *TD = dyn_cast(D))
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -821,6 +821,13 @@
/*isKindOf=*/false);
 }
 
+ObjCInterfaceDecl *ObjCInterfaceType::getDecl() const {
+  ObjCInterfaceDecl *Canon = Decl->getCanonicalDecl();
+  if (ObjCInterfaceDecl *Def = Canon->getDefinition())
+return Def;
+  return Canon;
+}
+
 const ObjCObjectPointerType *ObjCObjectPointerType::stripObjCKindOfTypeAndQuals(
const ASTContext ) const {
   if (!isKindOfType() && qual_empty())
Index: clang/lib/AST/DeclObjC.cpp
===
--- clang/lib/AST/DeclObjC.cpp
+++ clang/lib/AST/DeclObjC.cpp
@@ -603,10 +603,6 @@
   assert(!hasDefinition() && "ObjC class already has a definition");
   Data.setPointer(new (getASTContext()) DefinitionData());
   Data.getPointer()->Definition = this;
-
-  // Make the type point at the 

[PATCH] D110287: [modules] While merging ObjCInterfaceDecl definitions, merge them as decl contexts too.

2021-10-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5931267db26: [modules] While merging ObjCInterfaceDecl 
definitions, merge them as decl… (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110287

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/odr_hash.mm


Index: clang/test/Modules/odr_hash.mm
===
--- clang/test/Modules/odr_hash.mm
+++ clang/test/Modules/odr_hash.mm
@@ -241,12 +241,12 @@
 @end
 @interface Interface5  {
 @public
-  T x;
+  T y;
 }
 @end
 @interface Interface6  {
 @public
-  T1 x;
+  T1 z;
 }
 @end
 #elif defined(SECOND)
@@ -257,14 +257,21 @@
 @end
 @interface Interface5  {
 @public
-  T x;
+  T y;
 }
 @end
 @interface Interface6  {
 @public
-  T2 x;
+  T2 z;
 }
 @end
+#else
+// expected-error@first.h:* {{'Interface4::x' from module 'FirstModule' is not 
present in definition of 'Interface4' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'Interface5::y' from module 'FirstModule' is not 
present in definition of 'Interface5' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'y' does not match}}
+// expected-error@first.h:* {{'Interface6::z' from module 'FirstModule' is not 
present in definition of 'Interface6' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'z' does not match}}
 #endif
 
 namespace Types {
@@ -276,22 +283,22 @@
 };
 struct Invalid2 {
   Interface5 *I;
-  decltype(I->x) x;
+  decltype(I->y) y;
 };
 struct Invalid3 {
   Interface6 *I;
-  decltype(I->x) x;
+  decltype(I->z) z;
 };
 #else
 Invalid1 i1;
 // expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid1::x' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid1' 
in module 'SecondModule'}}
 // expected-note@second.h:* {{declaration of 'x' does not match}}
 Invalid2 i2;
-// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid2::x' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid2' 
in module 'SecondModule'}}
-// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid2::y' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid2' 
in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'y' does not match}}
 Invalid3 i3;
-// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid3::x' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid3' 
in module 'SecondModule'}}
-// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid3::z' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid3' 
in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'z' does not match}}
 #endif
 
 }  // namespace ObjCTypeParam
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1177,6 +1177,12 @@
 
 void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
  struct ObjCInterfaceDecl::DefinitionData &) {
+  struct ObjCInterfaceDecl::DefinitionData  = D->data();
+  if (DD.Definition != NewDD.Definition) {
+Reader.MergedDeclContexts.insert(
+std::make_pair(NewDD.Definition, DD.Definition));
+  }
+
   // FIXME: odr checking?
 }
 


Index: clang/test/Modules/odr_hash.mm
===
--- clang/test/Modules/odr_hash.mm
+++ clang/test/Modules/odr_hash.mm
@@ -241,12 +241,12 @@
 @end
 @interface Interface5  {
 @public
-  T x;
+  T y;
 }
 @end
 @interface Interface6  {
 @public
-  T1 x;
+  T1 z;
 }
 @end
 #elif defined(SECOND)
@@ -257,14 +257,21 @@
 @end
 @interface Interface5  {
 @public
-  T x;
+  T y;
 }
 @end
 @interface Interface6  {
 @public
-  T2 x;
+  T2 z;
 }
 @end
+#else
+// expected-error@first.h:* {{'Interface4::x' from module 'FirstModule' is not present in definition of 'Interface4' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'Interface5::y' from module 'FirstModule' is not present in definition of 'Interface5' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'y' does not match}}
+// expected-error@first.h:* {{'Interface6::z' from module 'FirstModule' is not present in definition of 'Interface6' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'z' does not match}}
 #endif
 
 namespace Types {
@@ -276,22 +283,22 @@
 };
 struct Invalid2 {
   Interface5 *I;
-  

[clang] c593126 - [modules] While merging ObjCInterfaceDecl definitions, merge them as decl contexts too.

2021-10-20 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2021-10-20T18:48:29-07:00
New Revision: c5931267db26d71351c634df06006d9c818ff158

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

LOG: [modules] While merging ObjCInterfaceDecl definitions, merge them as decl 
contexts too.

While working on https://reviews.llvm.org/D110280 I've tried to merge
decl contexts as it seems to be correct and matching our handling of
decl contexts from different modules. It's not required for the fix in
https://reviews.llvm.org/D110280 but it revealed a missing diagnostic,
so separating this change into a separate commit.

Renamed some variables to distinguish diagnostic like "declaration of
'x' does not match" for different cases.

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

Added: 


Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp
clang/test/Modules/odr_hash.mm

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index f2c2023cbf233..7aab708d00e4a 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1177,6 +1177,12 @@ void ASTDeclReader::ReadObjCDefinitionData(
 
 void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
  struct ObjCInterfaceDecl::DefinitionData &) {
+  struct ObjCInterfaceDecl::DefinitionData  = D->data();
+  if (DD.Definition != NewDD.Definition) {
+Reader.MergedDeclContexts.insert(
+std::make_pair(NewDD.Definition, DD.Definition));
+  }
+
   // FIXME: odr checking?
 }
 

diff  --git a/clang/test/Modules/odr_hash.mm b/clang/test/Modules/odr_hash.mm
index 86ddd16b94fb7..276bd58624eca 100644
--- a/clang/test/Modules/odr_hash.mm
+++ b/clang/test/Modules/odr_hash.mm
@@ -241,12 +241,12 @@ @interface Interface4  {
 @end
 @interface Interface5  {
 @public
-  T x;
+  T y;
 }
 @end
 @interface Interface6  {
 @public
-  T1 x;
+  T1 z;
 }
 @end
 #elif defined(SECOND)
@@ -257,14 +257,21 @@ @interface Interface4  {
 @end
 @interface Interface5  {
 @public
-  T x;
+  T y;
 }
 @end
 @interface Interface6  {
 @public
-  T2 x;
+  T2 z;
 }
 @end
+#else
+// expected-error@first.h:* {{'Interface4::x' from module 'FirstModule' is not 
present in definition of 'Interface4' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'Interface5::y' from module 'FirstModule' is not 
present in definition of 'Interface5' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'y' does not match}}
+// expected-error@first.h:* {{'Interface6::z' from module 'FirstModule' is not 
present in definition of 'Interface6' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'z' does not match}}
 #endif
 
 namespace Types {
@@ -276,22 +283,22 @@ @interface Interface6  {
 };
 struct Invalid2 {
   Interface5 *I;
-  decltype(I->x) x;
+  decltype(I->y) y;
 };
 struct Invalid3 {
   Interface6 *I;
-  decltype(I->x) x;
+  decltype(I->z) z;
 };
 #else
 Invalid1 i1;
 // expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid1::x' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid1' 
in module 'SecondModule'}}
 // expected-note@second.h:* {{declaration of 'x' does not match}}
 Invalid2 i2;
-// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid2::x' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid2' 
in module 'SecondModule'}}
-// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid2::y' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid2' 
in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'y' does not match}}
 Invalid3 i3;
-// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid3::x' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid3' 
in module 'SecondModule'}}
-// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'Types::ObjCTypeParam::Invalid3::z' from module 
'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid3' 
in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'z' does not match}}
 #endif
 
 }  // namespace ObjCTypeParam



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


[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-20 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

In D111863#3074404 , @housel wrote:

> To be clear, this new code parses exactly as much of each FDE as the existing 
> `__register_frame`/`__unw_add_dynamic_fde` does, including doing the same 
> work to compute the record length. Neither needs to parse the instructions at 
> registration time.

Right -- I should have actually looked at the implementation of 
`__unw_add_dynamic_fde`. ;)

@joerg -- We have always registered every FDE in the JIT. This is an 
improvement over what we have, not a regression. Is there some more efficient 
approach that you would recommend? Otherwise I think this should go in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[clang] 34188f2 - [Driver][OpenBSD] Some improvements to the external assembler handling

2021-10-20 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2021-10-20T21:05:14-04:00
New Revision: 34188f237f2574dda2447d85fe2b1aa65b5321ce

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

LOG: [Driver][OpenBSD] Some improvements to the external assembler handling

- Pass CPU variant for ARM
- Pass MIPS CPU in addition to the ABI

Added: 


Modified: 
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp 
b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index a2404e0d62067..96abac57764f7 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "OpenBSD.h"
+#include "Arch/ARM.h"
 #include "Arch/Mips.h"
 #include "Arch/Sparc.h"
 #include "CommonArgs.h"
@@ -30,6 +31,8 @@ void openbsd::Assembler::ConstructJob(Compilation , const 
JobAction ,
   const char *LinkingOutput) const {
   const toolchains::OpenBSD  =
   static_cast(getToolChain());
+  const Driver  = ToolChain.getDriver();
+  const llvm::Triple  = ToolChain.getTriple();
 
   claimNoWarnArgs(Args);
   ArgStringList CmdArgs;
@@ -41,6 +44,15 @@ void openbsd::Assembler::ConstructJob(Compilation , const 
JobAction ,
 CmdArgs.push_back("--32");
 break;
 
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb: {
+StringRef MArch, MCPU;
+arm::getARMArchCPUFromArgs(Args, MArch, MCPU, /*FromAs*/ true);
+std::string Arch = arm::getARMTargetCPU(MCPU, MArch, Triple);
+CmdArgs.push_back(Args.MakeArgString("-mcpu=" + Arch));
+break;
+  }
+
   case llvm::Triple::ppc:
 CmdArgs.push_back("-mppc");
 CmdArgs.push_back("-many");
@@ -48,10 +60,8 @@ void openbsd::Assembler::ConstructJob(Compilation , const 
JobAction ,
 
   case llvm::Triple::sparcv9: {
 CmdArgs.push_back("-64");
-std::string CPU = getCPUName(ToolChain.getDriver(), Args,
- ToolChain.getTriple());
-CmdArgs.push_back(
-sparc::getSparcAsmModeForCPU(CPU, ToolChain.getTriple()));
+std::string CPU = getCPUName(D, Args, Triple);
+CmdArgs.push_back(sparc::getSparcAsmModeForCPU(CPU, Triple));
 AddAssemblerKPIC(ToolChain, Args, CmdArgs);
 break;
   }
@@ -60,12 +70,15 @@ void openbsd::Assembler::ConstructJob(Compilation , const 
JobAction ,
   case llvm::Triple::mips64el: {
 StringRef CPUName;
 StringRef ABIName;
-mips::getMipsCPUAndABI(Args, ToolChain.getTriple(), CPUName, ABIName);
+mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+
+CmdArgs.push_back("-march");
+CmdArgs.push_back(CPUName.data());
 
 CmdArgs.push_back("-mabi");
 CmdArgs.push_back(mips::getGnuCompatibleMipsABIName(ABIName).data());
 
-if (ToolChain.getTriple().isLittleEndian())
+if (Triple.isLittleEndian())
   CmdArgs.push_back("-EL");
 else
   CmdArgs.push_back("-EB");

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index ae1aa64416907..c2ffe2a0397cd 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -56,6 +56,8 @@
 // Check passing options to the assembler for various OpenBSD targets
 // RUN: %clang -target amd64-pc-openbsd -m32 -### -no-integrated-as -c %s 2>&1 
\
 // RUN:   | FileCheck -check-prefix=CHECK-AMD64-M32 %s
+// RUN: %clang -target arm-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM %s
 // RUN: %clang -target powerpc-unknown-openbsd -### -no-integrated-as -c %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-POWERPC %s
 // RUN: %clang -target sparc64-unknown-openbsd -### -no-integrated-as -c %s 
2>&1 \
@@ -69,10 +71,11 @@
 // RUN: %clang -target mips64el-unknown-openbsd -fPIC -### -no-integrated-as 
-c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-MIPS64EL-PIC %s
 // CHECK-AMD64-M32: as{{.*}}" "--32"
+// CHECK-ARM: as{{.*}}" "-mcpu=cortex-a8"
 // CHECK-POWERPC: as{{.*}}" "-mppc" "-many"
 // CHECK-SPARC64: as{{.*}}" "-64" "-Av9a"
-// CHECK-MIPS64: as{{.*}}" "-mabi" "64" "-EB"
-// CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
+// CHECK-MIPS64: as{{.*}}" "-march" "mips3" "-mabi" "64" "-EB"
+// CHECK-MIPS64-PIC: as{{.*}}" "-march" "mips3" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
 



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


LLVM build master will be restarted soon

2021-10-20 Thread Galina Kistanova via cfe-commits
 Hello,

LLVM build master will be restarted in the nearest hour.

Thanks

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


[PATCH] D110287: [modules] While merging ObjCInterfaceDecl definitions, merge them as decl contexts too.

2021-10-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D110287#3075590 , @dblaikie wrote:

> In D110287#3074175 , @vsapsai wrote:
>
>> What would be a better way to deal with changes in areas where I'm more 
>> experienced in (Obj-C decl merging on AST deserialization) and still want to 
>> run pre-merge checks on other platforms? I got unofficial sign-offs 
>> internally but people defer to me because I've worked more in this area.
>
> Oh, sure - you can use Phabricator's draft support to just send the change 
> for CI testing without sending a review to the mailing list: 
> https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line

D'oh, haven't realized that. Thanks for the advice!

>> I believe this change is pretty trivial, while for D110452 
>>  I want another opinion. But one-line 
>> change in D110453  is trivial too and I 
>> don't think that waiting for reviews for half a year would improve its 
>> quality substantially.
>
> Reviews shouldn't/generally don't take half a year, especially for smaller, 
> clearly correct changes. Pinging reviews if they're not getting traction can 
> help get some attention, though sometimes more direct calls for assistance 
> may be necessary/beneficial.

Thanks, appreciate the advice. It is a sore subject for me, so I'll refrain 
from digging myself a deeper hole.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110287

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


[PATCH] D110287: [modules] While merging ObjCInterfaceDecl definitions, merge them as decl contexts too.

2021-10-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review! I'll commit this and other changes in the stack after 
testing with the current "main" and making sure the bots on other platforms are 
happy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110287

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-10-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D109632#3076648 , @rmaz wrote:

> In D109632#3076586 , @vsapsai wrote:
>
>> I'm curious to get the results for an empty module cache because clean 
>> builds are also important for us.
>
> I should measure this too. What would you suggest for the approach, to clean 
> the module cache before each build, retry and average? How much weight should 
> be given to the clean vs populated module cache numbers?

I am compiling just a single file and before each compilation I

1. Delete ModuleCache.noindex
2. Create ModuleCache.noindex directory
3. Create ModuleCache.noindex/Session.modulevalidation file

Then retry multiple times and average. Given my experience, calculating 
standard deviation can be useful too.

I'm wondering what your numbers will be but for me I think they are fairly 
meaningless due to high deviation. That's why I don't think it's worth 
assigning any weight to the clean module cache build (at least for individual 
files).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-10-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

And for the empty module cache the numbers are

| **File**| **Baseline (s)** | **Set Dedupe (s)** | **No external (s)** 
| **Set Dedupe (percentage of baseline)** | **No external (percentage of 
baseline)** |
| Project1. File1 | 14.080673| 13.6296118   | 13.6954484
| 96.797% | 97.264% 
 |
| Project1. File2 | 15.2273466 | 14.6111798   | 
14.7935872| 95.954% | 97.151%   
   |
| Project1. File3 | 14.0047568 | 13.5988174   | 
13.6155526| 97.101% | 97.221%   
   |
| Project1. File4 | 13.0449874 | 12.5867316   | 
12.8005844| 96.487% | 98.126%   
   |
| Project1. File5 | 14.3756674 | 13.7928578   | 
13.7562042| 95.946% | 95.691%  
   |
|

Though in this case the variance is much higher than before. Roughly it is 10 
times higher and can reach 0.25. With such variance I think the difference 
between different fix approaches isn't meaningful and even comparing with the 
baseline is shaky. I haven't investigated further but suspect that the time of 
building modules dominates `addMethodToGlobalList` time and we cannot notice a 
meaningful difference.

Methodology note: take average of 5 compilations instead of 8 as each 
compilation is longer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D112135: [ARM] Fix inline assembly referencing floating point registers on soft-float targets

2021-10-20 Thread Pavel Kosov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb9a0dc293cf: [ARM] Fix inline assembly referencing floating 
point registers on soft-float… (authored by kpdev42).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112135

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c


Index: clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c
===
--- /dev/null
+++ clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c
@@ -0,0 +1,29 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple arm -target-feature -fpregs -verify=arm-nofp %s
+
+// w: A 32, 64, or 128-bit floating-point/SIMD register: s0-s31, d0-d31, or 
q0-q15.
+float test_w(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=w"(x)
+  : "w"(x)); // No error expected.
+  // arm-nofp-error@7 {{invalid output constraint '=w' in asm}}
+  return x;
+}
+
+// x: A 32, 64, or 128-bit floating-point/SIMD register: s0-s15, d0-d7, or 
q0-q3.
+float test_x(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=x"(x)
+  : "x"(x)); // No error expected.
+  // arm-nofp-error@16 {{invalid output constraint '=x' in asm}}
+  return x;
+}
+
+// t: A 32, 64, or 128-bit floating-point/SIMD register: s0-s31, d0-d15, or 
q0-q7.
+float test_t(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=t"(x)
+  : "t"(x)); // No error expected.
+  // arm-nofp-error@25 {{invalid output constraint '=t' in asm}}
+  return x;
+}
Index: clang/lib/Basic/Targets/ARM.h
===
--- clang/lib/Basic/Targets/ARM.h
+++ clang/lib/Basic/Targets/ARM.h
@@ -78,6 +78,7 @@
   unsigned Unaligned : 1;
   unsigned DotProd : 1;
   unsigned HasMatMul : 1;
+  unsigned FPRegsDisabled : 1;
 
   enum {
 LDREX_B = (1 << 0), /// byte (8-bit)
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -446,6 +446,7 @@
   HasFloat16 = true;
   ARMCDECoprocMask = 0;
   HasBFloat16 = false;
+  FPRegsDisabled = false;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "-fp64".
@@ -522,6 +523,8 @@
   ARMCDECoprocMask |= (1U << Coproc);
 } else if (Feature == "+bf16") {
   HasBFloat16 = true;
+} else if (Feature == "-fpregs") {
+  FPRegsDisabled = true;
 }
   }
 
@@ -978,6 +981,8 @@
   case 't': // s0-s31, d0-d31, or q0-q15
   case 'w': // s0-s15, d0-d7, or q0-q3
   case 'x': // s0-s31, d0-d15, or q0-q7
+if (FPRegsDisabled)
+  return false;
 Info.setAllowsRegister();
 return true;
   case 'j': // An immediate integer between 0 and 65535 (valid for MOVW)


Index: clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c
===
--- /dev/null
+++ clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c
@@ -0,0 +1,29 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple arm -target-feature -fpregs -verify=arm-nofp %s
+
+// w: A 32, 64, or 128-bit floating-point/SIMD register: s0-s31, d0-d31, or q0-q15.
+float test_w(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=w"(x)
+  : "w"(x)); // No error expected.
+  // arm-nofp-error@7 {{invalid output constraint '=w' in asm}}
+  return x;
+}
+
+// x: A 32, 64, or 128-bit floating-point/SIMD register: s0-s15, d0-d7, or q0-q3.
+float test_x(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=x"(x)
+  : "x"(x)); // No error expected.
+  // arm-nofp-error@16 {{invalid output constraint '=x' in asm}}
+  return x;
+}
+
+// t: A 32, 64, or 128-bit floating-point/SIMD register: s0-s31, d0-d15, or q0-q7.
+float test_t(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=t"(x)
+  : "t"(x)); // No error expected.
+  // arm-nofp-error@25 {{invalid output constraint '=t' in asm}}
+  return x;
+}
Index: clang/lib/Basic/Targets/ARM.h
===
--- clang/lib/Basic/Targets/ARM.h
+++ clang/lib/Basic/Targets/ARM.h
@@ -78,6 +78,7 @@
   unsigned Unaligned : 1;
   unsigned DotProd : 1;
   unsigned HasMatMul : 1;
+  unsigned FPRegsDisabled : 1;
 
   enum {
 LDREX_B = (1 << 0), /// byte (8-bit)
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -446,6 +446,7 @@
   HasFloat16 = true;
   ARMCDECoprocMask = 0;
   HasBFloat16 = false;
+  FPRegsDisabled = false;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "-fp64".
@@ -522,6 +523,8 @@
   ARMCDECoprocMask 

[clang] cb9a0dc - [ARM] Fix inline assembly referencing floating point registers on soft-float targets

2021-10-20 Thread Pavel Kosov via cfe-commits

Author: Pavel Kosov
Date: 2021-10-21T02:39:10+03:00
New Revision: cb9a0dc293cf4ca451d625c6a54e491d8c11e591

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

LOG: [ARM] Fix inline assembly referencing floating point registers on 
soft-float targets

Fixes PR: https://bugs.llvm.org/show_bug.cgi?id=52230

Reviewed By: nickdesaulniers

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

OS Laboratory, Huawei Russian Research Institute, Saint-Petersburg

Added: 
clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c

Modified: 
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 909187df9c04f..fc6b01c87fd22 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -446,6 +446,7 @@ bool 
ARMTargetInfo::handleTargetFeatures(std::vector ,
   HasFloat16 = true;
   ARMCDECoprocMask = 0;
   HasBFloat16 = false;
+  FPRegsDisabled = false;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "-fp64".
@@ -522,6 +523,8 @@ bool 
ARMTargetInfo::handleTargetFeatures(std::vector ,
   ARMCDECoprocMask |= (1U << Coproc);
 } else if (Feature == "+bf16") {
   HasBFloat16 = true;
+} else if (Feature == "-fpregs") {
+  FPRegsDisabled = true;
 }
   }
 
@@ -978,6 +981,8 @@ bool ARMTargetInfo::validateAsmConstraint(
   case 't': // s0-s31, d0-d31, or q0-q15
   case 'w': // s0-s15, d0-d7, or q0-q3
   case 'x': // s0-s31, d0-d15, or q0-q7
+if (FPRegsDisabled)
+  return false;
 Info.setAllowsRegister();
 return true;
   case 'j': // An immediate integer between 0 and 65535 (valid for MOVW)

diff  --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h
index 0910064a033b6..d54a049042d60 100644
--- a/clang/lib/Basic/Targets/ARM.h
+++ b/clang/lib/Basic/Targets/ARM.h
@@ -78,6 +78,7 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public 
TargetInfo {
   unsigned Unaligned : 1;
   unsigned DotProd : 1;
   unsigned HasMatMul : 1;
+  unsigned FPRegsDisabled : 1;
 
   enum {
 LDREX_B = (1 << 0), /// byte (8-bit)

diff  --git a/clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c 
b/clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c
new file mode 100644
index 0..061e0eeed34e1
--- /dev/null
+++ b/clang/test/Sema/arm_inline_asm_constraints_no_fp_regs.c
@@ -0,0 +1,29 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple arm -target-feature -fpregs -verify=arm-nofp %s
+
+// w: A 32, 64, or 128-bit floating-point/SIMD register: s0-s31, d0-d31, or 
q0-q15.
+float test_w(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=w"(x)
+  : "w"(x)); // No error expected.
+  // arm-nofp-error@7 {{invalid output constraint '=w' in asm}}
+  return x;
+}
+
+// x: A 32, 64, or 128-bit floating-point/SIMD register: s0-s15, d0-d7, or 
q0-q3.
+float test_x(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=x"(x)
+  : "x"(x)); // No error expected.
+  // arm-nofp-error@16 {{invalid output constraint '=x' in asm}}
+  return x;
+}
+
+// t: A 32, 64, or 128-bit floating-point/SIMD register: s0-s31, d0-d15, or 
q0-q7.
+float test_t(float x) {
+  __asm__("vsqrt.f32 %0, %1"
+  : "=t"(x)
+  : "t"(x)); // No error expected.
+  // arm-nofp-error@25 {{invalid output constraint '=t' in asm}}
+  return x;
+}



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


[PATCH] D111109: AddGlobalAnnotations for function with or without function body.

2021-10-20 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Reduced the test further to:

  struct k {
~k() __attribute__((annotate(""))) {}
  };
  void m() { k(); }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D09

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-10-20 Thread Richard Howell via Phabricator via cfe-commits
rmaz added a comment.

In D109632#3076586 , @vsapsai wrote:

> Methodology: clear a modules cache, compile a file once to pre-populate the 
> cache, compile file 8 times and measure elapsed time, take the time average.

This is the same approach I used, although with 3 tries.

> So it looks like "no external" approach is slightly but consistently slower  
> than "set dedupe" approach.

This agrees with what I see with our code too.

> I'm curious to get the results for an empty module cache because clean builds 
> are also important for us.

I should measure this too. What would you suggest for the approach, to clean 
the module cache before each build, retry and average? How much weight should 
be given to the clean vs populated module cache numbers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D112190: [clang] Don't clear AST if we have consumers running after the main action

2021-10-20 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 381112.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112190

Files:
  clang/lib/Frontend/FrontendAction.cpp
  clang/test/Misc/clear-ast-before-backend-plugins.c


Index: clang/test/Misc/clear-ast-before-backend-plugins.c
===
--- /dev/null
+++ clang/test/Misc/clear-ast-before-backend-plugins.c
@@ -0,0 +1,9 @@
+// REQUIRES: plugins, examples, asserts
+
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend 
-emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext %s 2>&1 
| FileCheck %s --check-prefix=YES
+// YES: Clearing AST
+
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend 
-emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext 
-add-plugin print-fns -plugin-arg-print-fns help %s 2>&1 | FileCheck %s 
--check-prefix=NO
+// NO-NOT: Clearing AST
+
+void f() {}
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -217,8 +217,13 @@
 
   // Add to Consumers the main consumer, then all the plugins that go after it
   Consumers.push_back(std::move(Consumer));
-  for (auto  : AfterConsumers) {
-Consumers.push_back(std::move(C));
+  if (!AfterConsumers.empty()) {
+// If we have plugins after the main consumer, which may be the codegen
+// action, they likely will need the ASTContext, so don't clear it in the
+// codegen action.
+CI.getCodeGenOpts().ClearASTBeforeBackend = false;
+for (auto  : AfterConsumers)
+  Consumers.push_back(std::move(C));
   }
 
   return std::make_unique(std::move(Consumers));


Index: clang/test/Misc/clear-ast-before-backend-plugins.c
===
--- /dev/null
+++ clang/test/Misc/clear-ast-before-backend-plugins.c
@@ -0,0 +1,9 @@
+// REQUIRES: plugins, examples, asserts
+
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend -emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext %s 2>&1 | FileCheck %s --check-prefix=YES
+// YES: Clearing AST
+
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend -emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns -plugin-arg-print-fns help %s 2>&1 | FileCheck %s --check-prefix=NO
+// NO-NOT: Clearing AST
+
+void f() {}
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -217,8 +217,13 @@
 
   // Add to Consumers the main consumer, then all the plugins that go after it
   Consumers.push_back(std::move(Consumer));
-  for (auto  : AfterConsumers) {
-Consumers.push_back(std::move(C));
+  if (!AfterConsumers.empty()) {
+// If we have plugins after the main consumer, which may be the codegen
+// action, they likely will need the ASTContext, so don't clear it in the
+// codegen action.
+CI.getCodeGenOpts().ClearASTBeforeBackend = false;
+for (auto  : AfterConsumers)
+  Consumers.push_back(std::move(C));
   }
 
   return std::make_unique(std::move(Consumers));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112190: [clang] Don't clear AST if we have consumers running after the main action

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

Downstream users may have Clang plugins. By default these plugins run
after the main action if they are specified on the command line.

Since these plugins are ASTConsumers, presumably they inspect the AST.
So we shouldn't clear it if any plugins run after the main action.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112190

Files:
  clang/lib/Frontend/FrontendAction.cpp
  clang/test/Misc/clear-ast-before-backend-plugins.c


Index: clang/test/Misc/clear-ast-before-backend-plugins.c
===
--- /dev/null
+++ clang/test/Misc/clear-ast-before-backend-plugins.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend 
-emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext %s 2>&1 
| FileCheck %s --check-prefix=YES
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend 
-emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext 
-add-plugin print-fns -plugin-arg-print-fns help %s 2>&1 | FileCheck %s 
--check-prefix=NO --allow-empty
+// REQUIRES: plugins, examples, asserts
+
+// YES: Clearing AST
+// NO-NOT: Clearing AST
+
+void f() {}
\ No newline at end of file
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -217,8 +217,13 @@
 
   // Add to Consumers the main consumer, then all the plugins that go after it
   Consumers.push_back(std::move(Consumer));
-  for (auto  : AfterConsumers) {
-Consumers.push_back(std::move(C));
+  if (!AfterConsumers.empty()) {
+// If we have plugins after the main consumer, which may be the codegen
+// action, they likely will need the ASTContext, so don't clear it in the
+// codegen action.
+CI.getCodeGenOpts().ClearASTBeforeBackend = false;
+for (auto  : AfterConsumers)
+  Consumers.push_back(std::move(C));
   }
 
   return std::make_unique(std::move(Consumers));


Index: clang/test/Misc/clear-ast-before-backend-plugins.c
===
--- /dev/null
+++ clang/test/Misc/clear-ast-before-backend-plugins.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend -emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext %s 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang_cc1 -mllvm -debug-only=codegenaction -clear-ast-before-backend -emit-obj -o /dev/null -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns -plugin-arg-print-fns help %s 2>&1 | FileCheck %s --check-prefix=NO --allow-empty
+// REQUIRES: plugins, examples, asserts
+
+// YES: Clearing AST
+// NO-NOT: Clearing AST
+
+void f() {}
\ No newline at end of file
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -217,8 +217,13 @@
 
   // Add to Consumers the main consumer, then all the plugins that go after it
   Consumers.push_back(std::move(Consumer));
-  for (auto  : AfterConsumers) {
-Consumers.push_back(std::move(C));
+  if (!AfterConsumers.empty()) {
+// If we have plugins after the main consumer, which may be the codegen
+// action, they likely will need the ASTContext, so don't clear it in the
+// codegen action.
+CI.getCodeGenOpts().ClearASTBeforeBackend = false;
+for (auto  : AfterConsumers)
+  Consumers.push_back(std::move(C));
   }
 
   return std::make_unique(std::move(Consumers));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/test/Analysis/initialization.c:103
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}}
+}

ASDenysPetrov wrote:
> steakhal wrote:
> > martong wrote:
> > > ASDenysPetrov wrote:
> > > > steakhal wrote:
> > > > > I'm pretty sure we should not get `Unknown` for simply loading from a 
> > > > > global variable.
> > > > > That would imply that loading two times subsequently we could not 
> > > > > prove that the value remained the same.
> > > > > But that should remain the same, thus compare equal unless some other 
> > > > > code modifier that memory region.
> > > > > 
> > > > > That could happen for two reasons:
> > > > > 1) There is a racecondition, and another thread modified that 
> > > > > location. But that would be UB, so that could not happen.
> > > > > 2) The global variable is //volatile//, so the hardware might changed 
> > > > > its content- but this global is not volatile so this does not apply.
> > > > > 
> > > > > That being said, this load should have resulted in a //fresh// 
> > > > > conjured symbolic value instead of //unknown//.
> > > > > Could you please check if it did result in //unknown// before your 
> > > > > patch, or you did introduce this behavior?
> > > > I'm not sure I caught your thoughts.
> > > > But I think the things is much simplier:
> > > > `clang_analyzer_eval` can only produce `UNKNOWN` or `TRUE` or `FALSE`. 
> > > > If we know the constraint of `glob_arr_no_init[2]` we return `TRUE` or 
> > > > `FALSE`, and `UNKNOWN` otherwise.
> > > > But in fact I should use `clang_analyzer_dump` here instead of 
> > > > `clang_analyzer_eval`. This is actually my fault. I'll update this.
> > > > Could you please check if it did result in unknown before your patch, 
> > > > or you did introduce this behavior?
> > > 
> > > I've just checked it, it was `Unknown` before this patch as well. 
> > > And actually, that is wrong because the array has static storage duration 
> > > and as such, we know that it is initialized with zeros according to the C 
> > > standard. But, that should be addressed in a follow-up patch (if someone 
> > > has the capacity).
> > > https://stackoverflow.com/questions/32708161/value-of-uninitialized-elements-in-array-of-c-language/32708288
> > Oh true. I was actually tricked by the `initialization.cpp:38`, where I 
> > actually caught this. And in that case, you use `dump()` yet you get 
> > `Unknown` as a result. But the issue remains the same.
> C++ also states about zero-initialization for static storage lifetime 
> duration: http://eel.is/c++draft/basic.start.static#2
> I think it will be among my next patches.
> And in that case, you use dump() yet you get Unknown as a result. But the 
> issue remains the same.
I just realized that I was confused as well :) The `dump` returns a symbolic 
value like `reg_$0`, **not** 
`Unknown`. So my intention of using `eval` was deliberate. Anyway we should 
improve this to produce `FALSE` instead of `UNKNOWN`, since it has a //static 
storage//.


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

https://reviews.llvm.org/D106681

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


[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/test/Analysis/initialization.c:103
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}}
+}

steakhal wrote:
> martong wrote:
> > ASDenysPetrov wrote:
> > > steakhal wrote:
> > > > I'm pretty sure we should not get `Unknown` for simply loading from a 
> > > > global variable.
> > > > That would imply that loading two times subsequently we could not prove 
> > > > that the value remained the same.
> > > > But that should remain the same, thus compare equal unless some other 
> > > > code modifier that memory region.
> > > > 
> > > > That could happen for two reasons:
> > > > 1) There is a racecondition, and another thread modified that location. 
> > > > But that would be UB, so that could not happen.
> > > > 2) The global variable is //volatile//, so the hardware might changed 
> > > > its content- but this global is not volatile so this does not apply.
> > > > 
> > > > That being said, this load should have resulted in a //fresh// conjured 
> > > > symbolic value instead of //unknown//.
> > > > Could you please check if it did result in //unknown// before your 
> > > > patch, or you did introduce this behavior?
> > > I'm not sure I caught your thoughts.
> > > But I think the things is much simplier:
> > > `clang_analyzer_eval` can only produce `UNKNOWN` or `TRUE` or `FALSE`. If 
> > > we know the constraint of `glob_arr_no_init[2]` we return `TRUE` or 
> > > `FALSE`, and `UNKNOWN` otherwise.
> > > But in fact I should use `clang_analyzer_dump` here instead of 
> > > `clang_analyzer_eval`. This is actually my fault. I'll update this.
> > > Could you please check if it did result in unknown before your patch, or 
> > > you did introduce this behavior?
> > 
> > I've just checked it, it was `Unknown` before this patch as well. 
> > And actually, that is wrong because the array has static storage duration 
> > and as such, we know that it is initialized with zeros according to the C 
> > standard. But, that should be addressed in a follow-up patch (if someone 
> > has the capacity).
> > https://stackoverflow.com/questions/32708161/value-of-uninitialized-elements-in-array-of-c-language/32708288
> Oh true. I was actually tricked by the `initialization.cpp:38`, where I 
> actually caught this. And in that case, you use `dump()` yet you get 
> `Unknown` as a result. But the issue remains the same.
C++ also states about zero-initialization for static storage lifetime duration: 
http://eel.is/c++draft/basic.start.static#2
I think it will be among my next patches.


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

https://reviews.llvm.org/D106681

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-10-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Sorry for the delay, I haven't finished testing more projects yet but here are 
my preliminary numbers

| **File**| **Baseline (s)** | **Set Dedupe (s)** | **No external (s)** 
| **Set Dedupe (percentage of baseline)** | **No external (percentage of 
baseline)** |
| Project1. File1 | 1.26146575  | 0.931755875| 
0.943674125 | 73.863% | 74.808% 
 |
| Project1. File2 | 1.444321875  | 1.0868395| 
1.095805875 | 75.249% | 75.870% 
 |
| Project1. File3 | 1.2475025  | 0.94032725| 
0.942943875 | 75.377% | 75.587% 
 |
| Project1. File4 | 1.197715 | 0.98331625| 0.9898685
 | 82.099% | 82.646%
  |
| Project1. File5 | 1.252481375  | 0.94339925| 
0.945766| 75.322% | 75.511% 
 |
|

Methodology: clear a modules cache, compile a file once to pre-populate the 
cache, compile file 8 times and measure elapsed time, take the time average. 
Didn't include files using a precompiled header because that makes cleaning a 
module cache trickier. Standard deviation of the measurements is consistent 
between different approaches and doesn't go above 0.015, so I haven't included 
it here. "Project1" is an app, so it should have a fairly long chain of 
dependencies, though I haven't checked it in details.

So it looks like "no external" approach is slightly but consistently slower  
than "set dedupe" approach. I'm curious to get the results for an empty module 
cache because clean builds are also important for us. And if you see anything 
suspicious in the methodology, please let me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D110436: Add %n format specifier warning to clang-tidy

2021-10-20 Thread Jayson Yan via Phabricator via cfe-commits
Jaysonyan updated this revision to Diff 381103.
Jaysonyan retitled this revision from "Add %n format specifier warning" to "Add 
%n format specifier warning to clang-tidy".
Jaysonyan added a comment.
Herald added a subscriber: mgorny.
Herald added a project: clang-tools-extra.

Move check for `%n` from clang to clang-tidy as a checker under 
`bugprone-percent-n-format-specifier`.


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

https://reviews.llvm.org/D110436

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-percent-n-format-specifier.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-percent-n-format-specifier.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-percent-n-format-specifier.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-percent-n-format-specifier.cpp
@@ -0,0 +1,57 @@
+// RUN: %check_clang_tidy %s bugprone-percent-n-format-specifier %t
+
+#include 
+
+void testVariableArgumentList(int *I, ...) {
+  char Buffer[100];
+  FILE *pFile;
+  pFile = fopen("myFile.txt", "w+");
+  va_list args;
+  va_start(args, I);
+
+  // CHECK-MESSAGES: [[@LINE+1]]:21: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  vfprintf(pFile, "%n", args);
+  // CHECK-MESSAGES: [[@LINE+1]]:13: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  vprintf("%n", args);
+  // CHECK-MESSAGES: [[@LINE+1]]:28: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  vsnprintf(Buffer, 100, "%n", args);
+  // CHECK-MESSAGES: [[@LINE+1]]:22: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  vsprintf(Buffer, "%n", args);
+
+  // CHECK-MESSAGES: [[@LINE+1]]:20: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  vfscanf(pFile, "%n", args);
+  // CHECK-MESSAGES: [[@LINE+1]]:12: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  vscanf("%n", args);
+  // CHECK-MESSAGES: [[@LINE+1]]:21: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  vsscanf(Buffer, "%n", args);
+
+  va_end(args);
+}
+
+void testPrintf() {
+  int *I = nullptr;
+  char Buffer[100];
+  FILE *pFile;
+  pFile = fopen("myFile.txt", "w+");
+  // CHECK-MESSAGES: [[@LINE+1]]:12: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  printf("%n", I);
+  // CHECK-MESSAGES: [[@LINE+1]]:22: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  fprintf(pFile, "I %n", I);
+  // CHECK-MESSAGES: [[@LINE+1]]:27: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  snprintf(Buffer, 100, "%n", I);
+  // CHECK-MESSAGES: [[@LINE+1]]:21: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  sprintf(Buffer, "%n", I);
+}
+
+void testScanf() {
+  int *I = nullptr;
+  char Buffer[100];
+  FILE *pFile;
+  pFile = fopen("myFile.txt", "w+");
+  // CHECK-MESSAGES: [[@LINE+1]]:19: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  fscanf(pFile, "%n", I);
+  // CHECK-MESSAGES: [[@LINE+1]]:11: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  scanf("%n", I);
+  // CHECK-MESSAGES: [[@LINE+1]]:20: warning: usage of %n can lead to unsafe writing to memory [bugprone-percent-n-format-specifier]
+  sscanf(Buffer, "%n", I);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-percent-n-format-specifier.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-percent-n-format-specifier.rst
@@ -0,0 +1,37 @@
+.. title:: clang-tidy - bugprone-percent-n-format-specifier
+
+bugprone-percent-n-format-specifier
+===
+
+Finds any usage of the %n format specifier inside the format string
+of a call to printf, scanf, or any of their derivatives. The %n format
+specifier can lead to unsafe writing to memory.
+
+.. code-block:: c++
+   void f(int * i, ...) {
+ char buffer [100];
+ FILE * pFile;
+ pFile = fopen("myFile.txt", "w+");
+ va_list args;
+ va_start(args, i);
+
+ // Will match any of these printf derivatives
+ printf("%n", i);
+ fprintf(pFile, "%n", i);
+ snprintf(buffer, 100, "%n", i);
+ sprintf(buffer, "%n", i);
+ vprintf("%n", args);
+ 

[PATCH] D112186: [WebAssembly] Add prototype relaxed float to int trunc instructions

2021-10-20 Thread Ng Zhi An via Phabricator via cfe-commits
ngzhian added a subscriber: tlively.
ngzhian added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:18262-18267
+case WebAssembly::BI__builtin_wasm_relaxed_trunc_zero_s_i32x4_f64x2:
+  IntNo = Intrinsic::wasm_relaxed_trunc_zero_signed;
+  break;
+case WebAssembly::BI__builtin_wasm_relaxed_trunc_zero_u_i32x4_f64x2:
+  IntNo = Intrinsic::wasm_relaxed_trunc_zero_unsigned;
+  break;

@tlively I'm having trouble with this, getting this stack trace

```
WidenVectorResult #0: t4: v2i32 = llvm.wasm.relaxed.trunc.zero.signed 
TargetConstant:i32<9112>, t2

Do not know how to widen the result of this operator!
UNREACHABLE executed at 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp:3035!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
Stack dump:
0.  Program arguments: 
/usr/local/google/home/zhin/ssd2/llvm-project/build-wasm/bin/llc 
-asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt 
-wasm-disable-explicit-locals -wasm-keep-registers 
-mattr=+simd128,+relaxed-simd -debug
1.  Running pass 'Function Pass Manager' on module ''.
2.  Running pass 'WebAssembly Instruction Selection' on function 
'@relaxed_trunc_zero_s_v4i32'
 #0 0x7f3012db05bb llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x7f3012db0672 PrintStackTraceSignalHandler(void*) 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x7f3012dae668 llvm::sys::RunSignalHandlers() 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/Support/Signals.cpp:97:20
 #3 0x7f3012db000e SignalHandler(int) 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x7f301276fef0 (/lib/x86_64-linux-gnu/libc.so.6+0x3cef0)
 #5 0x7f301276fe71 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:50:1
 #6 0x7f3012759536 abort ./stdlib/abort.c:81:7
 #7 0x7f3012c5a974 bindingsErrorHandler(void*, char const*, bool) 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/Support/ErrorHandling.cpp:218:55
 #8 0x7f3016e7856c llvm::DAGTypeLegalizer::WidenVectorResult(llvm::SDNode*, 
unsigned int) 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp:3037:71
 #9 0x7f3016e4a338 llvm::DAGTypeLegalizer::run() 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:280:17
#10 0x7f3016e4e34f llvm::SelectionDAG::LegalizeTypes() 
/usr/local/google/home/zhin/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:1055:37
```

Do I need to add some stuff to LegalizeTypes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112186

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


[PATCH] D112186: [WebAssembly] Add prototype relaxed float to int trunc instructions

2021-10-20 Thread Ng Zhi An via Phabricator via cfe-commits
ngzhian created this revision.
Herald added subscribers: ecnelises, sunfish, hiraditya, jgravelle-google, 
sbc100, dschuff.
ngzhian requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.
Herald added projects: clang, LLVM.

Add i32x4.relaxed_trunc_f32x4_s, i32x4.relaxed_trunc_f32x4_u,
i32x4.relaxed_trunc_f64x2_s_zero, i32x4.relaxed_trunc_f64x2_u_zero.

These are only exposed as builtins, and require user opt-in.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112186

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -466,6 +466,40 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: relaxed_trunc_s_v4i32:
+; NO-CHECK-NOT: f32x4
+; CHECK-NEXT: .functype relaxed_trunc_s_v4i32 (v128) -> (v128){{$}}
+; CHECK-NEXT: i32x4.relaxed_trunc_f32x4_s $push[[R:[0-9]+]]=, $0
+; CHECK-NEXT: return $pop[[R]]
+declare <4 x i32> @llvm.wasm.relaxed.trunc.signed.v4i32.v4f32(<4 x float>)
+define <4 x i32> @relaxed_trunc_s_v4i32(<4 x float> %x) {
+  %a = call <4 x i32> @llvm.wasm.relaxed.trunc.signed.v4i32.v4f32(<4 x float> %x)
+  ret <4 x i32> %a
+}
+
+; CHECK-LABEL: relaxed_trunc_u_v4i32:
+; NO-CHECK-NOT: f32x4
+; CHECK-NEXT: .functype relaxed_trunc_u_v4i32 (v128) -> (v128){{$}}
+; CHECK-NEXT: i32x4.relaxed_trunc_f32x4_u $push[[R:[0-9]+]]=, $0
+; CHECK-NEXT: return $pop[[R]]
+declare <4 x i32> @llvm.wasm.relaxed.trunc.unsigned.v4i32.v4f32(<4 x float>)
+define <4 x i32> @relaxed_trunc_u_v4i32(<4 x float> %x) {
+  %a = call <4 x i32> @llvm.wasm.relaxed.trunc.unsigned.v4i32.v4f32(<4 x float> %x)
+  ret <4 x i32> %a
+}
+
+; CHECK-LABEL: relaxed_trunc_zero_s_v4i32:
+; CHECK-NEXT: .functype relaxed_trunc_zero_s_v4i32 (v128) -> (v128){{$}}
+; CHECK-NEXT: i32x4.relaxed_trunc_zero_f64x2_s $push[[R:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x i32> @llvm.wasm.relaxed.trunc.zero.signed.v2i32.v2f64(<2 x double>)
+define <4 x i32> @relaxed_trunc_zero_s_v4i32(<2 x double> %x) {
+  %v = call <2 x i32> @llvm.wasm.relaxed.trunc.zero.signed.v2i32.v2f64(<2 x double> %x)
+  %a = shufflevector <2 x i32> %v, <2 x i32> ,
+   <4 x i32> 
+  ret <4 x i32> %a
+}
+
 ; CHECK-LABEL: trunc_sat_zero_s_v4i32:
 ; CHECK-NEXT: .functype trunc_sat_zero_s_v4i32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: i32x4.trunc_sat_zero_f64x2_s $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1392,3 +1392,20 @@
 
 defm "" : SIMD_RELAXED_FMINMAX;
 defm "" : SIMD_RELAXED_FMINMAX;
+
+//===--===//
+// Relaxed floating-point to int conversions
+//===--===//
+
+multiclass SIMD_RELAXED_CONVERT simdop> {
+  defm op#_#vec :
+RELAXED_I<(outs V128:$dst), (ins V128:$vec), (outs), (ins),
+  [(set (vec.vt V128:$dst), (vec.vt (op (arg.vt V128:$vec],
+  vec.prefix#"."#name#"\t$dst, $vec", vec.prefix#"."#name, simdop>;
+}
+
+defm "" : SIMD_RELAXED_CONVERT;
+defm "" : SIMD_RELAXED_CONVERT;
+
+defm "" : SIMD_RELAXED_CONVERT;
+defm "" : SIMD_RELAXED_CONVERT;
Index: llvm/lib/Target/WebAssembly/WebAssemblyISD.def
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISD.def
+++ llvm/lib/Target/WebAssembly/WebAssemblyISD.def
@@ -50,3 +50,7 @@
 HANDLE_MEM_NODETYPE(GLOBAL_SET)
 HANDLE_MEM_NODETYPE(TABLE_GET)
 HANDLE_MEM_NODETYPE(TABLE_SET)
+
+// Relaxed SIMD proposal.
+HANDLE_NODETYPE(RELAXED_TRUNC_ZERO_S)
+HANDLE_NODETYPE(RELAXED_TRUNC_ZERO_U)
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -214,6 +214,27 @@
 [LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
 
+def int_wasm_relaxed_trunc_signed:
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty],
+[IntrNoMem, IntrSpeculatable]>;
+
+def int_wasm_relaxed_trunc_unsigned:
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty],
+[IntrNoMem, IntrSpeculatable]>;
+
+def int_wasm_relaxed_trunc_zero_signed:
+  Intrinsic<[llvm_anyvector_ty],
+

[libunwind] 070a2dd - [libunwind] Revert "Use the from-scratch testing configuration by default"

2021-10-20 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2021-10-20T17:40:23-04:00
New Revision: 070a2ddcb6657f1b497b8003384bae31e27e497d

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

LOG: [libunwind] Revert "Use the from-scratch testing configuration by default"

This reverts commit 5a8ad80b6fa5cbad58b78384f534b78fca863e7f, which broke
the Bootstrapping build. I'm reverting until we've fixed the issue.

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

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 93fd722475c23..59d489b909e43 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -87,13 +87,7 @@ set(LIBUNWIND_TEST_LINKER_FLAGS "" CACHE STRING
 "Additional linker flags for test programs.")
 set(LIBUNWIND_TEST_COMPILER_FLAGS "" CACHE STRING
 "Additional compiler flags for test programs.")
-
-if (LIBUNWIND_ENABLE_SHARED)
-  set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-shared.cfg.in")
-else()
-  set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-static.cfg.in")
-endif()
-set(LIBUNWIND_TEST_CONFIG "${LIBUNWIND_DEFAULT_TEST_CONFIG}" CACHE STRING
+set(LIBUNWIND_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" 
CACHE STRING
   "The path to the Lit testing configuration to use when running the tests.
If a relative path is provided, it is assumed to be relative to 
'/libunwind/test/configs'.")
 if (NOT IS_ABSOLUTE "${LIBUNWIND_TEST_CONFIG}")



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


[PATCH] D112181: [docs] Remove hard-coded version numbers from sphinx configs

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

Changes in Polly LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112181

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


[PATCH] D111109: AddGlobalAnnotations for function with or without function body.

2021-10-20 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Reduced test case:

  template  void b(a);
  template  class d {
  public:
class e {
public:
  c *f();
};
e *g();
  };
  template  class j;
  template  class j {
  public:
class k {
public:
  k(int *);
  ~k();
};
int n();
d l;
  };
  template  int j::n() {
auto m = l.g()->f();
k a(*m);
b(a);
  }
  template 
  j::k::~k() __attribute__((annotate(""))) {}
  class o {
int m_fn4();
j p;
  };
  int o::m_fn4() { p.n(); }

Please revert the commit if there is no quick and obvious solution. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D09

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


[PATCH] D111833: [clang] Fortify warning for scanf calls with field width too big.

2021-10-20 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv accepted this revision.
george.burgess.iv added a comment.

LGTM. Thanks again!




Comment at: clang/lib/Sema/SemaChecking.cpp:735
+
+auto *FormatExpr = TheCall->getArg(FormatIndex)->IgnoreParenImpCasts();
+

nit: const auto if possible (and below)



Comment at: clang/lib/Sema/SemaChecking.cpp:756
+ScanfDiagnosticFormatHandler H(
+[&](unsigned Index) { return ComputeSizeArgument(Index + DataIndex); },
+Diagnose);

Please put this in a variable and pass that into `H`'s constructor. 
`function_ref` doesn't own the function it points to, so any use of this at 
line >= 758 (e.g., line 768) is a use-after-free.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111833

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


[PATCH] D112181: [docs] Remove hard-coded version numbers from sphinx configs

2021-10-20 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
Herald added a subscriber: mgorny.
Herald added a reviewer: bollu.
Herald added a reviewer: MaskRay.
tstellar requested review of this revision.
Herald added projects: clang, LLVM, clang-tools-extra.
Herald added a subscriber: cfe-commits.

This updates all the non-runtime project release notes to use the
version number from CMake instead of the hard-coded version numbers
in conf.py.

It also hides warnings about pre-releases when the git suffix
is dropped from the LLVM version in CMake.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112181

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/conf.py
  clang/docs/ReleaseNotes.rst
  clang/docs/conf.py
  lld/docs/ReleaseNotes.rst
  lld/docs/conf.py
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/docs/ReleaseNotes.rst
  llvm/docs/conf.py
  polly/docs/ReleaseNotes.rst
  polly/docs/conf.py

Index: polly/docs/conf.py
===
--- polly/docs/conf.py
+++ polly/docs/conf.py
@@ -44,15 +44,6 @@
 project = u'Polly'
 copyright = u'2010-%d, The Polly Team' % date.today().year
 
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = '14.0-devel'
-# The full version, including alpha/beta/rc tags.
-release = '14.0-devel'
-
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
 #language = None
@@ -87,6 +78,11 @@
 # A list of ignored prefixes for module index sorting.
 #modindex_common_prefix = []
 
+in_progress_title = "(In-Progress) " if tags.has("PreRelease") else ""
+
+rst_epilog = f"""
+.. |ReleaseNotesTitle| replace:: {in_progress_title} Release Notes
+"""
 
 # -- Options for HTML output ---
 
Index: polly/docs/ReleaseNotes.rst
===
--- polly/docs/ReleaseNotes.rst
+++ polly/docs/ReleaseNotes.rst
@@ -1,14 +1,15 @@
-=
-Release Notes 14.0 (upcoming)
-=
+===
+Release Notes |release| |ReleaseNotesTitle|
+===
 
-In Polly 14 the following important changes have been incorporated.
+In Polly |version| the following important changes have been incorporated.
 
-.. warning::
+.. only:: PreRelease
 
-  These release notes are for the next release of Polly and describe
-  the new features that have recently been committed to our development
-  branch.
+  .. warning::
+These release notes are for the next release of Polly and describe
+the new features that have recently been committed to our development
+branch.
 
 - The command line option -polly-opt-fusion has been removed. What the
   flag does was frequently misunderstood and is rarely useful. However,
Index: llvm/docs/conf.py
===
--- llvm/docs/conf.py
+++ llvm/docs/conf.py
@@ -61,15 +61,6 @@
 project = u'LLVM'
 copyright = u'2003-%d, LLVM Project' % date.today().year
 
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short version.
-version = '13'
-# The full version, including alpha/beta/rc tags.
-release = '13'
-
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
 #language = None
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -1,21 +1,23 @@
-=
-LLVM 14.0.0 Release Notes
-=
+
+LLVM |release| Release Notes
+
 
 .. contents::
 :local:
 
-.. warning::
-   These are in-progress notes for the upcoming LLVM 14 release.
-   Release notes for previous releases can be found on
-   `the Download Page `_.
+.. only:: PreRelease
+
+  .. warning::
+ These are in-progress notes for the upcoming LLVM |version| release.
+ Release notes for previous releases can be found on
+ `the Download Page `_.
 
 
 Introduction
 
 
 This document contains the release notes for the LLVM Compiler Infrastructure,
-release 14.0.0.  Here we describe the status of LLVM, including major improvements
+release |release|.  Here we describe the status of LLVM, including major improvements
 from the previous release, improvements in various subprojects of LLVM, and
 some of the current users of the code.  All LLVM releases may be downloaded
 from the `LLVM releases web site 

[PATCH] D112098: [ASan] Added stack safety support in address sanitizer.

2021-10-20 Thread Florian Mayer via Phabricator via cfe-commits
fmayer added inline comments.



Comment at: clang/test/CodeGen/asan-stack-safety-analysis.c:1
+// REQUIRES: x86-registered-target
+

fmayer wrote:
> Should this file be in llvm/test/Instrumentation/ instead? Also consider 
> porting some of the tests from HWASan 
> (https://github.com/llvm/llvm-project/blob/main/llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll).
Uhm nevermind my first sentence, sorry about that. This is of course the right 
location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112098

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


[PATCH] D112030: [docs] Remove Makefile.sphinx files

2021-10-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru accepted this revision.
sylvestre.ledru added a comment.

I don't need any time, please land it when you want, I will adjust later :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112030

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


[PATCH] D112098: [ASan] Added stack safety support in address sanitizer.

2021-10-20 Thread Florian Mayer via Phabricator via cfe-commits
fmayer added inline comments.



Comment at: clang/test/CodeGen/asan-stack-safety-analysis.c:1
+// REQUIRES: x86-registered-target
+

Should this file be in llvm/test/Instrumentation/ instead? Also consider 
porting some of the tests from HWASan 
(https://github.com/llvm/llvm-project/blob/main/llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112098

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


[PATCH] D112030: [docs] Remove Makefile.sphinx files

2021-10-20 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D112030#3071393 , @sylvestre.ledru 
wrote:

> I am using them but I can move to sphinx calls.

How much time do you need to transition?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112030

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


[PATCH] D112177: [clang] Do not duplicate "EnableSplitLTOUnit" module flag

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

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112177

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


[PATCH] D112177: [clang] Do not duplicate "EnableSplitLTOUnit" module flag

2021-10-20 Thread David Greene via Phabricator via cfe-commits
greened created this revision.
greened added reviewers: noajshu, phosek, eli.friedman, tejohnson.
greened added a project: LLVM.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
greened requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If clang's output is set to bitcode and LTO is enabled, clang would
unconditionally add the flag to the module.  Unfortunately, if the input were a
bitcode or IR file and had the flag set, this would result in two copies of the
flag, which is illegal IR.  Guard the setting of the flag by checking whether it
already exists.  This follows existing practice for the related "ThinLTO" module
flag.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112177

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/enable-split-lto-unit.ll


Index: clang/test/CodeGen/enable-split-lto-unit.ll
===
--- /dev/null
+++ clang/test/CodeGen/enable-split-lto-unit.ll
@@ -0,0 +1,25 @@
+; Test that we do not duplicate the EnableSplitLTOUnit module flag.
+;
+; Disable the verifier so the compiler doesn't abort and thus lead to empty
+; output and false pass.
+;
+; RUN: %clang_cc1 -fno-legacy-pass-manager -emit-llvm-bc -flto=full 
-disable-llvm-verifier -o - %s | llvm-dis | FileCheck %s --check-prefix=FULL-NPM
+; RUN: %clang_cc1 -fno-legacy-pass-manager -emit-llvm-bc -flto=thin 
-disable-llvm-verifier -o - %s | llvm-dis | FileCheck %s --check-prefix=THIN-NPM
+; RUN: %clang_cc1 -flegacy-pass-manager -emit-llvm-bc -flto=full 
-disable-llvm-verifier -o - %s | llvm-dis | FileCheck %s --check-prefix=FULL-OPM
+; RUN: %clang_cc1 -flegacy-pass-manager -emit-llvm-bc -flto=thin 
-disable-llvm-verifier -o - %s | llvm-dis | FileCheck %s --check-prefix=THIN-OPM
+
+define dso_local void @main() local_unnamed_addr {
+entry:
+  ret void
+}
+
+; FULL-NPM-NOT: !llvm.module.flags = !{!0, !1, !2, !3, !3}
+; FULL-OPM-NOT: !llvm.module.flags = !{!0, !1, !2, !3, !3}
+; THIN-NPM-NOT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
+; THIN-OPM-NOT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
+!llvm.module.flags = !{!0, !1, !2, !3}
+
+!0 = !{i32 1, !"wchar_size", i32 2}
+!1 = !{i32 7, !"frame-pointer", i32 2}
+!2 = !{i32 1, !"ThinLTO", i32 0}
+!3 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1023,8 +1023,9 @@
 if (!ThinLinkOS)
   return;
   }
-  TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
-   CodeGenOpts.EnableSplitLTOUnit);
+  if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
+TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
+ CodeGenOpts.EnableSplitLTOUnit);
   PerModulePasses.add(createWriteThinLTOBitcodePass(
   *OS, ThinLinkOS ? >os() : nullptr));
 } else {
@@ -1038,8 +1039,9 @@
   if (EmitLTOSummary) {
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
-TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- uint32_t(1));
+if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
+  TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
+   uint32_t(1));
   }
 
   PerModulePasses.add(createBitcodeWriterPass(
@@ -1438,8 +1440,9 @@
 if (!ThinLinkOS)
   return;
   }
-  TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
-   CodeGenOpts.EnableSplitLTOUnit);
+  if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
+TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
+ CodeGenOpts.EnableSplitLTOUnit);
   MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? >os()
: nullptr));
 } else {
@@ -1452,8 +1455,9 @@
   if (EmitLTOSummary) {
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
-TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- uint32_t(1));
+if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
+  TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
+   uint32_t(1));
   }
   MPM.addPass(
   BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, 
EmitLTOSummary));


Index: clang/test/CodeGen/enable-split-lto-unit.ll
===
--- /dev/null
+++ clang/test/CodeGen/enable-split-lto-unit.ll
@@ -0,0 +1,25 @@
+; Test that we do 

[clang] 8dc44d8 - Remove include of 'type_info' from ext-int test.

2021-10-20 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-10-20T12:53:51-07:00
New Revision: 8dc44d8dd872eadf112c43fa7784110a43ccb683

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

LOG: Remove include of 'type_info' from ext-int test.

Originally I thought that I needed to do a #include to trick the
compiler into letting me use typeid I believe, but Aaron explained that
it was just looking for the type_info type.  I had to give it some
public/private members to make it emit the same as before, but this
ought to be a 'perfect' replacement.

Added: 


Modified: 
clang/test/CodeGenCXX/ext-int.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/ext-int.cpp 
b/clang/test/CodeGenCXX/ext-int.cpp
index 88b5ff91d470..3d6457f916b7 100644
--- a/clang/test/CodeGenCXX/ext-int.cpp
+++ b/clang/test/CodeGenCXX/ext-int.cpp
@@ -10,7 +10,9 @@
 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -I%S 
-emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,WIN,WIN32,NoNewStructPathTBAA
 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -I%S 
-new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,WIN,WIN32,NewStructPathTBAA
 
-#include 
+namespace std {
+  class type_info { public: virtual ~type_info(); private: const char * name; 
};
+} // namespace std
 
 // Ensure that the layout for these structs is the same as the normal bitfield
 // layouts.



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


[clang] 35037ae - Make dr177x.cpp test work with Windows-32 bit platfroms with 'thiscall'.

2021-10-20 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-10-20T12:38:36-07:00
New Revision: 35037ae1971a92b07783339ee9d7a5da50a2ab4b

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

LOG: Make dr177x.cpp test work with Windows-32 bit platfroms with 'thiscall'.

My downstream noticed that the test failed on windows-32 bit machines
since the types have __attribute__((thiscall)) on them in a few places.
This patch just adds a wildcard to handle that, since it isn't
particularly important to the test.

Added: 


Modified: 
clang/test/CXX/drs/dr177x.cpp

Removed: 




diff  --git a/clang/test/CXX/drs/dr177x.cpp b/clang/test/CXX/drs/dr177x.cpp
index 0ac4deac6a8de..d307988ddbb66 100644
--- a/clang/test/CXX/drs/dr177x.cpp
+++ b/clang/test/CXX/drs/dr177x.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -fexceptions -fcxx-exceptions 
-pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11
 // RUN: %clang_cc1 -std=c++14 %s -fexceptions -fcxx-exceptions 
-pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14
 // RUN: %clang_cc1 -std=c++1z %s -fexceptions -fcxx-exceptions 
-pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14
+// RUN: %clang_cc1 -std=c++1z %s -fexceptions -fcxx-exceptions 
-pedantic-errors -triple i386-windows-pc -ast-dump | FileCheck %s 
--check-prefixes=CHECK,CXX11,CXX14
 
 namespace dr1772 { // dr1772: 14
   // __func__ in a lambda should name operator(), not the containing function.
@@ -10,7 +11,7 @@ namespace dr1772 { // dr1772: 14
   auto x = []() { __func__; };
   // CXX11: LambdaExpr
   // CXX11: CXXRecordDecl
-  // CXX11: CXXMethodDecl{{.+}} operator() 'void () const'
+  // CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'
   // CXX11-NEXT: CompoundStmt
   // CXX11-NEXT: PredefinedExpr{{.+}} 'const char [11]' lvalue __func__
   // CXX11-NEXT: StringLiteral{{.+}} 'const char [11]' lvalue "operator()"
@@ -21,7 +22,7 @@ namespace dr1772 { // dr1772: 14
   // CXX11-NEXT: CompoundStmt
   // CXX11: LambdaExpr
   // CXX11: CXXRecordDecl
-  // CXX11: CXXMethodDecl{{.+}} operator() 'void () const'
+  // CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'
   // CXX11-NEXT: CompoundStmt
   // CXX11-NEXT: PredefinedExpr{{.+}} 'const char [11]' lvalue __func__
   // CXX11-NEXT: StringLiteral{{.+}} 'const char [11]' lvalue "operator()"
@@ -46,7 +47,7 @@ namespace dr1779 { // dr1779: 14
   class ClassTemplate {
 // CHECK: ClassTemplateDecl{{.+}} ClassTemplate
 void MemFunc() {
-  // CHECK: CXXMethodDecl{{.+}} MemFunc 'void ()'
+  // CHECK: CXXMethodDecl{{.+}} MemFunc 'void (){{.*}}'
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: PredefinedExpr{{.+}} '' lvalue __func__
   __func__;
@@ -55,7 +56,7 @@ namespace dr1779 { // dr1779: 14
   };
 
   template  void ClassTemplate::OutOfLineMemFunc() {
-// CHECK: CXXMethodDecl{{.+}}parent{{.+}} OutOfLineMemFunc 'void ()'
+// CHECK: CXXMethodDecl{{.+}}parent{{.+}} OutOfLineMemFunc 'void (){{.*}}'
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: PredefinedExpr{{.+}} '' lvalue __func__
 __func__;
@@ -66,7 +67,7 @@ namespace dr1779 { // dr1779: 14
 // CXX14: FunctionDecl{{.+}}contains_generic_lambda
 // CXX14: LambdaExpr
 // CXX14: CXXRecordDecl
-// CXX14: CXXMethodDecl{{.+}} operator() 'auto (auto) const'
+// CXX14: CXXMethodDecl{{.+}} operator() 'auto (auto) {{.*}}const'
 // CXX14-NEXT: ParmVarDecl
 // CXX14-NEXT: CompoundStmt
 // CXX14-NEXT: PredefinedExpr{{.+}} '' lvalue __func__



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


[clang] 4e21cae - Update ext-int test to have x86 linux/windows before ABI Impl

2021-10-20 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-10-20T12:27:22-07:00
New Revision: 4e21caece0dd72450b6ac72d1bcedd697c666efc

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

LOG: Update ext-int test to have x86 linux/windows before ABI Impl

Writing a quick test to make sure we are aware of the change to the
_ExtInt/_BitInt ABI on x86 (32bit) OSes.

Added: 


Modified: 
clang/test/CodeGenCXX/ext-int.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/ext-int.cpp 
b/clang/test/CodeGenCXX/ext-int.cpp
index 3cbcf1331eaff..88b5ff91d470e 100644
--- a/clang/test/CodeGenCXX/ext-int.cpp
+++ b/clang/test/CodeGenCXX/ext-int.cpp
@@ -1,8 +1,14 @@
-// RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S 
-emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,NoNewStructPathTBAA
-// RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S 
-new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,LIN,NewStructPathTBAA
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S 
-emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,LIN,LIN64,NoNewStructPathTBAA
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S 
-new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,LIN,LIN64,NewStructPathTBAA
 
-// RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S 
-emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,NoNewStructPathTBAA
-// RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S 
-new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,WIN,NewStructPathTBAA
+// RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S 
-emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,WIN,WIN64,NoNewStructPathTBAA
+// RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S 
-new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,WIN,WIN64,NewStructPathTBAA
+
+// RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -I%S 
-emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,LIN,LIN32,NoNewStructPathTBAA
+// RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -I%S 
-new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,LIN,LIN32,NewStructPathTBAA
+
+// RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -I%S 
-emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,WIN,WIN32,NoNewStructPathTBAA
+// RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -I%S 
-new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,WIN,WIN32,NewStructPathTBAA
 
 #include 
 
@@ -36,7 +42,8 @@ struct BitFieldsLong {
   _ExtInt(63) B : 3;
   _ExtInt(63) C : 2;
 };
-// LIN: %struct.BitFieldsLong = type { i8, [7 x i8] }
+// LIN64: %struct.BitFieldsLong = type { i8, [7 x i8] }
+// LIN32: %struct.BitFieldsLong = type { i8, [3 x i8] }
 // WIN: %struct.BitFieldsLong = type { i64 }
 
 struct HasExtIntFirst {
@@ -99,20 +106,23 @@ enum AsEnumUnderlyingType : _ExtInt(9) {
 
 void UnderlyingTypeUsage(AsEnumUnderlyingType Param) {
   // LIN: define{{.*}} void @_Z19UnderlyingTypeUsage20AsEnumUnderlyingType(i9 
signext %
-  // WIN: define dso_local void 
@"?UnderlyingTypeUsage@@YAXW4AsEnumUnderlyingType@@@Z"(i9 %
+  // WIN64: define dso_local void 
@"?UnderlyingTypeUsage@@YAXW4AsEnumUnderlyingType@@@Z"(i9 %
+  // WIN32: define dso_local void 
@"?UnderlyingTypeUsage@@YAXW4AsEnumUnderlyingType@@@Z"(i9 signext %
   AsEnumUnderlyingType Var;
   // CHECK: alloca i9, align 2
   // CHECK: store i9 %{{.*}}, align 2
 }
 
 unsigned _ExtInt(33) ManglingTestRetParam(unsigned _ExtInt(33) Param) {
-// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i64 %
+// LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i64 %
+// LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i33 %
 // WIN: define dso_local i33 
@"?ManglingTestRetParam@@YAU?$_UExtInt@$0CB@@__clang@@U12@@Z"(i33
   return 0;
 }
 
 _ExtInt(33) ManglingTestRetParam(_ExtInt(33) Param) {
-// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i64 %
+// LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i64 %
+// LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i33 %
 // WIN: define dso_local i33 
@"?ManglingTestRetParam@@YAU?$_ExtInt@$0CB@@__clang@@U12@@Z"(i33
   return 0;
 }
@@ -128,7 +138,8 @@ void ManglingInstantiator() {
   _ExtInt(93) A;
   ManglingTestTemplateParam(A);
 // LIN: call void @_Z25ManglingTestTemplateParamIU7_ExtIntILi93EEiEvRT_(i93*
-// WIN: call void 
@"??$ManglingTestTemplateParam@U?$_ExtInt@$0FN@@__clangYAXAEAU?$_ExtInt@$0FN@@__clang@@@Z"(i93*
+// 

[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-10-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:856-860
 // If any updates are made, grabs its users to the worklist because
 // their address spaces can also be possibly updated.
 LLVM_DEBUG(dbgs() << "  to " << NewAS.getValue() << '\n');
 (*InferredAddrSpace)[V] = NewAS.getValue();
 

I.e. I'd move these lines into `updateAddressSpace` and change its return type 
to bool, as we no longer would need NewAS' value.




Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:903-905
 Optional InferAddressSpacesImpl::updateAddressSpace(
-const Value , const ValueToAddrSpaceMapTy ) const {
+const Value , const ValueToAddrSpaceMapTy ,
+PredicatedAddrSpaceMapTy ) const {

hliao wrote:
> tra wrote:
> > I can't say I'm happy about the way updateAddressSpace updates PredicateAS 
> > here, but delegates updates to InferredAddrSpace to the caller. I think 
> > both should be updated in one place -- either here, or in the callee.
> the difference is that, here, we assume a use of pointer could be inferred 
> with a new addrspace. The original is on a def of value.
I'm not sure how it explains why the function returns values to update 
InferredAddrSpace outside of it, but updates PredicatedAS inside.

For consistency sake, I'd update InferredAddrSpace here as well and, possibly, 
combine both maps into a single structure as I've suggested above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

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


[PATCH] D111639: [Sema] check PseudoObject when rebuilding CXXOperatorCallExpr in template instantiation

2021-10-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/test/SemaCXX/PR51855.cpp:71
+// CHECK: call void @_ZN1S4putMEs
+// CHECK: call {{(signext )?i16}} @_ZN1S4getMEv

rnk wrote:
> Please add test coverage for the interesting operators in the code under 
> edit: OO_Subscript, OO_Arrow, OO_Amp. Please also add equivalent coverage to 
> the ObjC test cases, or give me a link to show that it's already covered.
> 
> Maybe OO_Amp is unnecessary, I'm not sure how it is supposed to work for 
> psuedo objects.
Different pseudo-object extensions can define their own rules for different 
syntactic use patterns, but currently there aren't any that have special 
treatment for either unary or binary `&`; you just take the default "r-value" 
path and then see if you can apply the operator to the result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111639

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


[PATCH] D112135: [ARM] Fix inline assembly referencing floating point registers on soft-float targets

2021-10-20 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

thanks for the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112135

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


[PATCH] D112059: Fix inline builtin handling in case of redefinition

2021-10-20 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added subscribers: aaron.ballman, rsmith.
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:1302
   // in case the function pointer is referenced somewhere.
-  if (FD->isInlineBuiltinDeclaration() && Fn) {
+  if (Fn) {
 std::string FDInlineName = (Fn->getName() + ".inline").str();

I don't think we want to do all this work if just `Fn`; ie. create a new 
`std::string` with `.inline` suffix for every function we're going to generate 
code (IR) for.  How about we add an additional unlikely guard:

`if (FD->getBuiltinID() && FN) {`

Because in the usual case, `FD` both has a builtin ID and is an inline builtin 
declaration, while in the exceptional case that this patch addresses, `FD` has 
a builtin ID but is not an inline builtin declaration.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:1319-1321
+// everywhere. That's GCC behavior too. Unfortunately, I cannot find a way
+// to detect that situation before we reach codegen, so do some late
+// replacement.

Perhaps in `Sema::CheckFunctionDeclaration`?  I see there is where we detect 
redeclarations. The calls from there to 
`FunctionDecl::setPreviousDeclaration()` seem to set up the redecl chain.  
Perhaps this exceptional case (or both cases, even) would be handled better 
there?

cc @rsmith @aaron.ballman in case they have feedback/tips/cycles.



Comment at: clang/test/CodeGen/strlen-inline-builtin-redecl.c:8
+unsigned long strnlen(const char *, unsigned long);
+void fortify_panic(const char *);
+

unused decl



Comment at: clang/test/CodeGen/strlen-inline-builtin-redecl.c:10
+
+extern inline __attribute__((always_inline)) __attribute__((gnu_inline)) 
unsigned long strlen(const char *p) {
+  return 1;

Do you mind wrapping this to 80 chars wide? I suspect if you put the two 
`__attribute__`s first, then the formatter will do a better job.  You can also 
combine these, a la `__attribute__((always_inline, gnu_inline))` to cut down on 
line length.


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

https://reviews.llvm.org/D112059

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-20 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp:67
+  if (auto *GA = dyn_cast(Op.getGlobal()))
+return cast(GA->getOperand(0));
   return cast(Op.getGlobal());

arsenm wrote:
> gandhi21299 wrote:
> > arsenm wrote:
> > > I thought aliases could include embedded bitcasts of the function type, 
> > > so the function wouldn't directly appear here
> > Can you please elaborate on "include embedded bitcasts of the function 
> > type"? It's a consequence of the AlwaysInliner where the callee gets 
> > replaced by the alias to a function, ie. @func_alias gets replaced by @func 
> > in the inline-calls.ll test.
> Something like this where the alias changes the type from the original 
> function:
> 
> 
> ```
> @add1alias3 = alias float (float), bitcast (i32 (i32)* @add1 to float(float)*)
> ```
> 
I see, that will probably break the compiler since a bitcast expression is not 
a Function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp:67
+  if (auto *GA = dyn_cast(Op.getGlobal()))
+return cast(GA->getOperand(0));
   return cast(Op.getGlobal());

gandhi21299 wrote:
> arsenm wrote:
> > I thought aliases could include embedded bitcasts of the function type, so 
> > the function wouldn't directly appear here
> Can you please elaborate on "include embedded bitcasts of the function type"? 
> It's a consequence of the AlwaysInliner where the callee gets replaced by the 
> alias to a function, ie. @func_alias gets replaced by @func in the 
> inline-calls.ll test.
Something like this where the alias changes the type from the original function:


```
@add1alias3 = alias float (float), bitcast (i32 (i32)* @add1 to float(float)*)
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-20 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp:67
+  if (auto *GA = dyn_cast(Op.getGlobal()))
+return cast(GA->getOperand(0));
   return cast(Op.getGlobal());

arsenm wrote:
> I thought aliases could include embedded bitcasts of the function type, so 
> the function wouldn't directly appear here
Can you please elaborate on "include embedded bitcasts of the function type"? 
It's a consequence of the AlwaysInliner where the callee gets replaced by the 
alias to a function, ie. @func_alias gets replaced by @func in the 
inline-calls.ll test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:2137
 //
 // Let's see if this is a constant < 0. If so, we reject it out of hand,
 // per CWG1464. Otherwise, if it's not a constant, we must have an

Shame about the whitespace noise. getIntegerConstantExpr guards the block and 
is dominated by isValueDependent.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:2171
 
   Expr *ArgExpr = (ArgDepMatrix->*GetArgDimensionExpr)();
+  if (Optional ArgConst =

this parses as `!ArgExpr->isValueDependent() && 
ArgExpr->getIntegerConstantExpr(S.Context) && ...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112159

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


[PATCH] D110127: [Clang] Support typedef with btf_decl_tag attributes

2021-10-20 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@aaron.ballman ping. This patch just implemented a btf_decl_tag for typedef. 
There is no type attribute involved here. Could you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110127

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


[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Patched up the call sites that are straightforward. There are ~4 calls in 
SemaOpenMP where an `!isValueDependent()` could be dropped if it is safe to 
call PerformContextualImplicitConversion on such a value, which it probably is, 
but it's hard to be certain. There are a few places where Diag() calls would be 
changed by dropping the call, those are also left unchanged here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112159

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


[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

2021-10-20 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@aaron.ballman ping. Did you get time to look at this patch? Esp. any comments 
on this approach with a subclass AttributedBTF vs. putting a StringRef directly 
in Attributed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99

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


[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 381040.
JonChesterfield added a comment.

- drop spurious nl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112159

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaTemplate/atomics.cpp

Index: clang/test/SemaTemplate/atomics.cpp
===
--- clang/test/SemaTemplate/atomics.cpp
+++ clang/test/SemaTemplate/atomics.cpp
@@ -15,3 +15,13 @@
   }
   void h() { g(0); }
 }
+
+// Can pass value dependent integer to atomic builtin
+template 
+void fetchAdd(int *A, int V) {
+  __atomic_fetch_add(A, V, Order);
+}
+
+void fetchAddUse(int *A, int V) {
+  fetchAdd<__ATOMIC_ACQ_REL>(A, V);
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7814,7 +7814,7 @@
 static bool verifyValidIntegerConstantExpr(Sema , const ParsedAttr ,
llvm::APSInt ) {
   const auto *AttrExpr = Attr.getArgAsExpr(0);
-  if (!AttrExpr->isTypeDependent() && !AttrExpr->isValueDependent()) {
+  if (!AttrExpr->isTypeDependent()) {
 if (Optional Res =
 AttrExpr->getIntegerConstantExpr(S.Context)) {
   Result = *Res;
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2169,11 +2169,10 @@
   }
 
   Expr *ArgExpr = (ArgDepMatrix->*GetArgDimensionExpr)();
-  if (!ArgExpr->isValueDependent())
-if (Optional ArgConst =
-ArgExpr->getIntegerConstantExpr(S.Context))
-  if (*ArgConst == *ParamConst)
-return Sema::TDK_Success;
+  if (Optional ArgConst =
+  ArgExpr->getIntegerConstantExpr(S.Context))
+if (*ArgConst == *ParamConst)
+  return Sema::TDK_Success;
   return Sema::TDK_NonDeducedMismatch;
 }
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2137,39 +2137,38 @@
 // Let's see if this is a constant < 0. If so, we reject it out of hand,
 // per CWG1464. Otherwise, if it's not a constant, we must have an
 // unparenthesized array type.
-if (!(*ArraySize)->isValueDependent()) {
-  // We've already performed any required implicit conversion to integer or
-  // unscoped enumeration type.
-  // FIXME: Per CWG1464, we are required to check the value prior to
-  // converting to size_t. This will never find a negative array size in
-  // C++14 onwards, because Value is always unsigned here!
-  if (Optional Value =
-  (*ArraySize)->getIntegerConstantExpr(Context)) {
-if (Value->isSigned() && Value->isNegative()) {
-  return ExprError(Diag((*ArraySize)->getBeginLoc(),
-diag::err_typecheck_negative_array_size)
-   << (*ArraySize)->getSourceRange());
-}
-
-if (!AllocType->isDependentType()) {
-  unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits(
-  Context, AllocType, *Value);
-  if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context))
-return ExprError(
-Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large)
-<< toString(*Value, 10) << (*ArraySize)->getSourceRange());
-}
 
-KnownArraySize = Value->getZExtValue();
-  } else if (TypeIdParens.isValid()) {
-// Can't have dynamic array size when the type-id is in parentheses.
-Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst)
-<< (*ArraySize)->getSourceRange()
-<< FixItHint::CreateRemoval(TypeIdParens.getBegin())
-<< FixItHint::CreateRemoval(TypeIdParens.getEnd());
+// We've already performed any required implicit conversion to integer or
+// unscoped enumeration type.
+// FIXME: Per CWG1464, we are required to check the value prior to
+// converting to size_t. This will never find a negative array size in
+// C++14 onwards, because Value is always unsigned here!
+if (Optional Value =
+(*ArraySize)->getIntegerConstantExpr(Context)) {
+  if (Value->isSigned() && Value->isNegative()) {
+return ExprError(Diag((*ArraySize)->getBeginLoc(),
+  diag::err_typecheck_negative_array_size)
+   

[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 381039.
JonChesterfield added a comment.

- fix up call sites


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112159

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaTemplate/atomics.cpp

Index: clang/test/SemaTemplate/atomics.cpp
===
--- clang/test/SemaTemplate/atomics.cpp
+++ clang/test/SemaTemplate/atomics.cpp
@@ -15,3 +15,13 @@
   }
   void h() { g(0); }
 }
+
+// Can pass value dependent integer to atomic builtin
+template 
+void fetchAdd(int *A, int V) {
+  __atomic_fetch_add(A, V, Order);
+}
+
+void fetchAddUse(int *A, int V) {
+  fetchAdd<__ATOMIC_ACQ_REL>(A, V);
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7814,7 +7814,7 @@
 static bool verifyValidIntegerConstantExpr(Sema , const ParsedAttr ,
llvm::APSInt ) {
   const auto *AttrExpr = Attr.getArgAsExpr(0);
-  if (!AttrExpr->isTypeDependent() && !AttrExpr->isValueDependent()) {
+  if (!AttrExpr->isTypeDependent()) {
 if (Optional Res =
 AttrExpr->getIntegerConstantExpr(S.Context)) {
   Result = *Res;
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2169,11 +2169,11 @@
   }
 
   Expr *ArgExpr = (ArgDepMatrix->*GetArgDimensionExpr)();
-  if (!ArgExpr->isValueDependent())
-if (Optional ArgConst =
-ArgExpr->getIntegerConstantExpr(S.Context))
-  if (*ArgConst == *ParamConst)
-return Sema::TDK_Success;
+  if (Optional ArgConst =
+  ArgExpr->getIntegerConstantExpr(S.Context))
+if (*ArgConst == *ParamConst)
+  return Sema::TDK_Success;
+
   return Sema::TDK_NonDeducedMismatch;
 }
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2137,39 +2137,38 @@
 // Let's see if this is a constant < 0. If so, we reject it out of hand,
 // per CWG1464. Otherwise, if it's not a constant, we must have an
 // unparenthesized array type.
-if (!(*ArraySize)->isValueDependent()) {
-  // We've already performed any required implicit conversion to integer or
-  // unscoped enumeration type.
-  // FIXME: Per CWG1464, we are required to check the value prior to
-  // converting to size_t. This will never find a negative array size in
-  // C++14 onwards, because Value is always unsigned here!
-  if (Optional Value =
-  (*ArraySize)->getIntegerConstantExpr(Context)) {
-if (Value->isSigned() && Value->isNegative()) {
-  return ExprError(Diag((*ArraySize)->getBeginLoc(),
-diag::err_typecheck_negative_array_size)
-   << (*ArraySize)->getSourceRange());
-}
-
-if (!AllocType->isDependentType()) {
-  unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits(
-  Context, AllocType, *Value);
-  if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context))
-return ExprError(
-Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large)
-<< toString(*Value, 10) << (*ArraySize)->getSourceRange());
-}
 
-KnownArraySize = Value->getZExtValue();
-  } else if (TypeIdParens.isValid()) {
-// Can't have dynamic array size when the type-id is in parentheses.
-Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst)
-<< (*ArraySize)->getSourceRange()
-<< FixItHint::CreateRemoval(TypeIdParens.getBegin())
-<< FixItHint::CreateRemoval(TypeIdParens.getEnd());
+// We've already performed any required implicit conversion to integer or
+// unscoped enumeration type.
+// FIXME: Per CWG1464, we are required to check the value prior to
+// converting to size_t. This will never find a negative array size in
+// C++14 onwards, because Value is always unsigned here!
+if (Optional Value =
+(*ArraySize)->getIntegerConstantExpr(Context)) {
+  if (Value->isSigned() && Value->isNegative()) {
+return ExprError(Diag((*ArraySize)->getBeginLoc(),
+  diag::err_typecheck_negative_array_size)
+

[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 381037.
JonChesterfield added a comment.

- fix up call sites


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112159

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaTemplate/atomics.cpp


Index: clang/test/SemaTemplate/atomics.cpp
===
--- clang/test/SemaTemplate/atomics.cpp
+++ clang/test/SemaTemplate/atomics.cpp
@@ -15,3 +15,13 @@
   }
   void h() { g(0); }
 }
+
+// Can pass value dependent integer to atomic builtin
+template 
+void fetchAdd(int *A, int V) {
+  __atomic_fetch_add(A, V, Order);
+}
+
+void fetchAddUse(int *A, int V) {
+  fetchAdd<__ATOMIC_ACQ_REL>(A, V);
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -15501,8 +15501,10 @@
 Optional Expr::getIntegerConstantExpr(const ASTContext ,
 SourceLocation *Loc,
 bool isEvaluated) const {
-  assert(!isValueDependent() &&
- "Expression evaluator can't be called on a dependent expression.");
+  if (isValueDependent()) {
+// Expression evaluator can't succeed on a dependent expression.
+return None;
+  }
 
   APSInt Value;
 


Index: clang/test/SemaTemplate/atomics.cpp
===
--- clang/test/SemaTemplate/atomics.cpp
+++ clang/test/SemaTemplate/atomics.cpp
@@ -15,3 +15,13 @@
   }
   void h() { g(0); }
 }
+
+// Can pass value dependent integer to atomic builtin
+template 
+void fetchAdd(int *A, int V) {
+  __atomic_fetch_add(A, V, Order);
+}
+
+void fetchAddUse(int *A, int V) {
+  fetchAdd<__ATOMIC_ACQ_REL>(A, V);
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -15501,8 +15501,10 @@
 Optional Expr::getIntegerConstantExpr(const ASTContext ,
 SourceLocation *Loc,
 bool isEvaluated) const {
-  assert(!isValueDependent() &&
- "Expression evaluator can't be called on a dependent expression.");
+  if (isValueDependent()) {
+// Expression evaluator can't succeed on a dependent expression.
+return None;
+  }
 
   APSInt Value;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112157: [clang] Disallow mixing SEH and Objective-C exceptions

2021-10-20 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb8829768d77: [clang] Disallow mixing SEH and Objective-C 
exceptions (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112157

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/lib/Sema/ScopeInfo.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/exceptions-seh.mm

Index: clang/test/SemaCXX/exceptions-seh.mm
===
--- /dev/null
+++ clang/test/SemaCXX/exceptions-seh.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -fsyntax-only -fexceptions -fobjc-exceptions -verify %s
+
+void might_crash();
+
+void use_seh_after_objc() {
+  @try { // expected-note {{conflicting '@try' here}}
+might_crash();
+  } @finally {
+  }
+  __try { // expected-error {{cannot use Objective-C '@try' in the same function as SEH '__try'}}
+might_crash();
+  } __except(1) {
+  }
+}
+
+void use_objc_after_seh() {
+  __try { // expected-note {{conflicting '__try' here}}
+might_crash();
+  } __except(1) {
+  }
+  @try { // expected-error {{cannot use Objective-C '@try' in the same function as SEH '__try'}}
+might_crash();
+  } @finally {
+  }
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4187,7 +4187,14 @@
   if (!getLangOpts().ObjCExceptions)
 Diag(AtLoc, diag::err_objc_exceptions_disabled) << "@try";
 
-  setFunctionHasBranchProtectedScope();
+  // Objective-C try is incompatible with SEH __try.
+  sema::FunctionScopeInfo *FSI = getCurFunction();
+  if (FSI->FirstSEHTryLoc.isValid()) {
+Diag(AtLoc, diag::err_mixing_cxx_try_seh_try) << 1;
+Diag(FSI->FirstSEHTryLoc, diag::note_conflicting_try_here) << "'__try'";
+  }
+
+  FSI->setHasObjCTry(AtLoc);
   unsigned NumCatchStmts = CatchStmts.size();
   return ObjCAtTryStmt::Create(Context, AtLoc, Try, CatchStmts.data(),
NumCatchStmts, Finally);
@@ -4423,7 +4430,7 @@
 
   // C++ try is incompatible with SEH __try.
   if (!getLangOpts().Borland && FSI->FirstSEHTryLoc.isValid()) {
-Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
+Diag(TryLoc, diag::err_mixing_cxx_try_seh_try) << 0;
 Diag(FSI->FirstSEHTryLoc, diag::note_conflicting_try_here) << "'__try'";
   }
 
@@ -4507,9 +4514,12 @@
   // SEH __try is incompatible with C++ try. Borland appears to support this,
   // however.
   if (!getLangOpts().Borland) {
-if (FSI->FirstCXXTryLoc.isValid()) {
-  Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
-  Diag(FSI->FirstCXXTryLoc, diag::note_conflicting_try_here) << "'try'";
+if (FSI->FirstCXXOrObjCTryLoc.isValid()) {
+  Diag(TryLoc, diag::err_mixing_cxx_try_seh_try) << FSI->FirstTryType;
+  Diag(FSI->FirstCXXOrObjCTryLoc, diag::note_conflicting_try_here)
+  << (FSI->FirstTryType == sema::FunctionScopeInfo::TryLocIsCXX
+  ? "'try'"
+  : "'@try'");
 }
   }
 
Index: clang/lib/Sema/ScopeInfo.cpp
===
--- clang/lib/Sema/ScopeInfo.cpp
+++ clang/lib/Sema/ScopeInfo.cpp
@@ -37,7 +37,7 @@
   ObjCIsSecondaryInit = false;
   ObjCWarnForNoInitDelegation = false;
   FirstReturnLoc = SourceLocation();
-  FirstCXXTryLoc = SourceLocation();
+  FirstCXXOrObjCTryLoc = SourceLocation();
   FirstSEHTryLoc = SourceLocation();
 
   // Coroutine state
Index: clang/include/clang/Sema/ScopeInfo.h
===
--- clang/include/clang/Sema/ScopeInfo.h
+++ clang/include/clang/Sema/ScopeInfo.h
@@ -175,8 +175,9 @@
   /// First 'return' statement in the current function.
   SourceLocation FirstReturnLoc;
 
-  /// First C++ 'try' statement in the current function.
-  SourceLocation FirstCXXTryLoc;
+  /// First C++ 'try' or ObjC @try statement in the current function.
+  SourceLocation FirstCXXOrObjCTryLoc;
+  enum { TryLocIsCXX, TryLocIsObjC, Unknown } FirstTryType = Unknown;
 
   /// First SEH '__try' statement in the current function.
   SourceLocation FirstSEHTryLoc;
@@ -446,7 +447,14 @@
 
   void setHasCXXTry(SourceLocation TryLoc) {
 setHasBranchProtectedScope();
-FirstCXXTryLoc = TryLoc;
+FirstCXXOrObjCTryLoc = TryLoc;
+FirstTryType = TryLocIsCXX;
+  }
+
+  void setHasObjCTry(SourceLocation TryLoc) {
+setHasBranchProtectedScope();
+FirstCXXOrObjCTryLoc = TryLoc;
+FirstTryType = TryLocIsObjC;
   }
 
   void setHasSEHTry(SourceLocation TryLoc) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ 

[clang] fb88297 - [clang] Disallow mixing SEH and Objective-C exceptions

2021-10-20 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-20T14:18:12-04:00
New Revision: fb8829768d774689c368c49cb3ca17339378cd91

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

LOG: [clang] Disallow mixing SEH and Objective-C exceptions

We already disallow mixing SEH and C++ exceptions, and
mixing SEH and Objective-C exceptions seems to not work (see PR52233).
Emitting an error is friendlier than crashing.

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

Added: 
clang/test/SemaCXX/exceptions-seh.mm

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/ScopeInfo.h
clang/lib/Sema/ScopeInfo.cpp
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e0c36961a9124..13f8fc3de03ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7516,7 +7516,8 @@ def note_throw_in_function : Note<"function declared 
non-throwing here">;
 def err_seh_try_outside_functions : Error<
   "cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls">;
 def err_mixing_cxx_try_seh_try : Error<
-  "cannot use C++ 'try' in the same function as SEH '__try'">;
+  "cannot use %select{C++ 'try'|Objective-C '@try'}0 "
+  "in the same function as SEH '__try'">;
 def err_seh_try_unsupported : Error<
   "SEH '__try' is not supported on this target">;
 def note_conflicting_try_here : Note<

diff  --git a/clang/include/clang/Sema/ScopeInfo.h 
b/clang/include/clang/Sema/ScopeInfo.h
index 5c3bfe7e80cdc..ccd15ea6a818f 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -175,8 +175,9 @@ class FunctionScopeInfo {
   /// First 'return' statement in the current function.
   SourceLocation FirstReturnLoc;
 
-  /// First C++ 'try' statement in the current function.
-  SourceLocation FirstCXXTryLoc;
+  /// First C++ 'try' or ObjC @try statement in the current function.
+  SourceLocation FirstCXXOrObjCTryLoc;
+  enum { TryLocIsCXX, TryLocIsObjC, Unknown } FirstTryType = Unknown;
 
   /// First SEH '__try' statement in the current function.
   SourceLocation FirstSEHTryLoc;
@@ -446,7 +447,14 @@ class FunctionScopeInfo {
 
   void setHasCXXTry(SourceLocation TryLoc) {
 setHasBranchProtectedScope();
-FirstCXXTryLoc = TryLoc;
+FirstCXXOrObjCTryLoc = TryLoc;
+FirstTryType = TryLocIsCXX;
+  }
+
+  void setHasObjCTry(SourceLocation TryLoc) {
+setHasBranchProtectedScope();
+FirstCXXOrObjCTryLoc = TryLoc;
+FirstTryType = TryLocIsObjC;
   }
 
   void setHasSEHTry(SourceLocation TryLoc) {

diff  --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp
index 4857346018ae4..cc7de16de2fdb 100644
--- a/clang/lib/Sema/ScopeInfo.cpp
+++ b/clang/lib/Sema/ScopeInfo.cpp
@@ -37,7 +37,7 @@ void FunctionScopeInfo::Clear() {
   ObjCIsSecondaryInit = false;
   ObjCWarnForNoInitDelegation = false;
   FirstReturnLoc = SourceLocation();
-  FirstCXXTryLoc = SourceLocation();
+  FirstCXXOrObjCTryLoc = SourceLocation();
   FirstSEHTryLoc = SourceLocation();
 
   // Coroutine state

diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index c83ada89d2e07..dc564e318d82d 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -4187,7 +4187,14 @@ Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
   if (!getLangOpts().ObjCExceptions)
 Diag(AtLoc, diag::err_objc_exceptions_disabled) << "@try";
 
-  setFunctionHasBranchProtectedScope();
+  // Objective-C try is incompatible with SEH __try.
+  sema::FunctionScopeInfo *FSI = getCurFunction();
+  if (FSI->FirstSEHTryLoc.isValid()) {
+Diag(AtLoc, diag::err_mixing_cxx_try_seh_try) << 1;
+Diag(FSI->FirstSEHTryLoc, diag::note_conflicting_try_here) << "'__try'";
+  }
+
+  FSI->setHasObjCTry(AtLoc);
   unsigned NumCatchStmts = CatchStmts.size();
   return ObjCAtTryStmt::Create(Context, AtLoc, Try, CatchStmts.data(),
NumCatchStmts, Finally);
@@ -4423,7 +4430,7 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, 
Stmt *TryBlock,
 
   // C++ try is incompatible with SEH __try.
   if (!getLangOpts().Borland && FSI->FirstSEHTryLoc.isValid()) {
-Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
+Diag(TryLoc, diag::err_mixing_cxx_try_seh_try) << 0;
 Diag(FSI->FirstSEHTryLoc, diag::note_conflicting_try_here) << "'__try'";
   }
 
@@ -4507,9 +4514,12 @@ StmtResult Sema::ActOnSEHTryBlock(bool IsCXXTry, 
SourceLocation TryLoc,
   // SEH __try is incompatible with C++ try. Borland appears to support this,
   // however.
   if (!getLangOpts().Borland) {
-if (FSI->FirstCXXTryLoc.isValid()) {
-  Diag(TryLoc, 

[PATCH] D111639: [Sema] check PseudoObject when rebuilding CXXOperatorCallExpr in template instantiation

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



Comment at: clang/lib/Sema/TreeTransform.h:14576
 !Second->getType()->isOverloadableType())
   return getSema().CreateBuiltinArraySubscriptExpr(
   First, Callee->getBeginLoc(), Second, OpLoc);

Can we come here to subscript pointer types? Something like:

```
struct Foo {
  void putM(int* rhs) { _m = rhs; }
  int* getM() { return _m; }
  __declspec(property(get = getM, put = putM)) int* theData;
};
void bar(Foo *p, int idx) {
  p->theData[idx] = 42;
}
```



Comment at: clang/lib/Sema/TreeTransform.h:14578
   First, Callee->getBeginLoc(), Second, OpLoc);
   } else if (Op == OO_Arrow) {
 // -> is never a builtin operation.

Similarly, do we need to cover pseudo objects in this codepath? 
`p->theData->m2`?



Comment at: clang/test/SemaCXX/PR51855.cpp:27
+// CHECK: call void @_ZN1SC1Es
+// CHECK: call {{(signext )?i16}} @_ZN1S4getMEv
+// CHECK: call void @_ZN1S4putMEs

There are many platforms with varying default calling conventions. You will 
either need to generalize these checks to match such conventions, or choose a 
specific triple to test with.

I can think of two targets to try that might fail these check lines: ARM 
targets, and i686-windows-gnu, which will use `x86_thiscallcc`.



Comment at: clang/test/SemaCXX/PR51855.cpp:71
+// CHECK: call void @_ZN1S4putMEs
+// CHECK: call {{(signext )?i16}} @_ZN1S4getMEv

Please add test coverage for the interesting operators in the code under edit: 
OO_Subscript, OO_Arrow, OO_Amp. Please also add equivalent coverage to the ObjC 
test cases, or give me a link to show that it's already covered.

Maybe OO_Amp is unnecessary, I'm not sure how it is supposed to work for psuedo 
objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111639

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


[PATCH] D112157: [clang] Disallow mixing SEH and Objective-C exceptions

2021-10-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D112157

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


[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-10-20 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added a comment.

In D112041#3074418 , @hliao wrote:

> In D112041#3073676 , @rampitec 
> wrote:
>
>> In D112041#3073637 , @hliao wrote:
>>
>>> In D112041#3073560 , @rampitec 
>>> wrote:
>>>
 Is there anything to remove assume() call after address space is inferred? 
 We do not need it anymore.
>>>
>>> along with a few other intrinsics, assume intrinsic is discarded in SDAG 
>>> and GISel.
>>
>> We may want to discard these earlier for the sake of Value::hasOneUse(). 
>> These are really not needed after casts are inserted.
>
> That sounds reasonable but may face the limit due to the fact that we run 
> addrspace inferring several times (if my  memory is right, 3 times if the 
> backend one is counted.) Among them, we expect pointer values are prompted 
> from memory to register so that we could infer addrspace for them further. If 
> we remove these assume intrinsic earlier, there would be the risk that later 
> addrspace inferring may not be able to leverage those assumptions.
> NVPTX runs that inferring just once. But after that, there would be too much 
> optimizations at the IR level.
>
> I checked the most hasOneUse() usage in IR passes. Most of them are not 
> applied to pointer arithmetic. Only a few cases are applied to pointers but 
> also have quite limited conditions. I would expect we may need to enhance 
> them case by case if we found real cases where the extra use from assume 
> intrinsic makes code quality worse.

Thanks, that sounds reasonable. If we start seeing problems because of this we 
can always remove these later. Conceptually LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

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


[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-10-20 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2caf7571e102: [Clang][AST] Resolve FIXME: Remove 
ObjCObjectPointer from (authored by gAlfonso-bit, committed by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110068

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2caf757 - [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from

2021-10-20 Thread Akira Hatanaka via cfe-commits

Author: Alfonso Gregory
Date: 2021-10-20T10:32:46-07:00
New Revision: 2caf7571e1020ae1024ab3f2d52ecc9aea85687d

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

LOG: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from
isSpecifierType

There is no reason to have this here, (since all tests pass) and it
isn't even a specifier anyway. We can just treat it as a pointer
instead.

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

Added: 


Modified: 
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/Type.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 4dcf3d0e6ab12..f2d7a792567d4 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@ static QualType GetBaseType(QualType T) {
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 58cae0378a98c..e7cdf58839631 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@ bool Type::isSpecifierType() const {
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;



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


[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D112159#3075703 , @jdoerfert wrote:

> This makes sense, any reason we don't remove the check at the call sites 
> right away?

There are ~85 of them, will start looking through now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112159

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


[PATCH] D112059: Fix inline builtin handling in case of redefinition

2021-10-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 381014.
serge-sans-paille added a comment.

Avoid walking redecls


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

https://reviews.llvm.org/D112059

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/strlen-inline-builtin-redecl.c


Index: clang/test/CodeGen/strlen-inline-builtin-redecl.c
===
--- /dev/null
+++ clang/test/CodeGen/strlen-inline-builtin-redecl.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64 -S -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s
+//
+// Verifies that clang-generated *.inline are removed when shadowed by an 
external definition
+
+// CHECK-NOT: strlen.inline
+
+unsigned long strnlen(const char *, unsigned long);
+void fortify_panic(const char *);
+
+extern inline __attribute__((always_inline)) __attribute__((gnu_inline)) 
unsigned long strlen(const char *p) {
+  return 1;
+}
+unsigned long mystrlen(char const *s) {
+  return strlen(s);
+}
+unsigned long strlen(const char *s) {
+  return 2;
+}
+unsigned long yourstrlen(char const *s) {
+  return strlen(s);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1299,18 +1299,30 @@
   // When generating code for a builtin with an inline declaration, use a
   // mangled name to hold the actual body, while keeping an external definition
   // in case the function pointer is referenced somewhere.
-  if (FD->isInlineBuiltinDeclaration() && Fn) {
+  if (Fn) {
 std::string FDInlineName = (Fn->getName() + ".inline").str();
 llvm::Module *M = Fn->getParent();
 llvm::Function *Clone = M->getFunction(FDInlineName);
-if (!Clone) {
-  Clone = llvm::Function::Create(Fn->getFunctionType(),
- llvm::GlobalValue::InternalLinkage,
- Fn->getAddressSpace(), FDInlineName, M);
-  Clone->addFnAttr(llvm::Attribute::AlwaysInline);
+if (FD->isInlineBuiltinDeclaration()) {
+  if (!Clone) {
+Clone = llvm::Function::Create(Fn->getFunctionType(),
+   llvm::GlobalValue::InternalLinkage,
+   Fn->getAddressSpace(), FDInlineName, M);
+Clone->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+  Fn->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  Fn = Clone;
+}
+
+// Detect the unusual situation where an inline version is shadowed by a
+// non-inline version. In that case we should pick the external one
+// everywhere. That's GCC behavior too. Unfortunately, I cannot find a way
+// to detect that situation before we reach codegen, so do some late
+// replacement.
+else if (Clone) {
+  Clone->replaceAllUsesWith(Fn);
+  Clone->eraseFromParent();
 }
-Fn->setLinkage(llvm::GlobalValue::ExternalLinkage);
-Fn = Clone;
   }
 
   // Check if we should generate debug info for this function.


Index: clang/test/CodeGen/strlen-inline-builtin-redecl.c
===
--- /dev/null
+++ clang/test/CodeGen/strlen-inline-builtin-redecl.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64 -S -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+//
+// Verifies that clang-generated *.inline are removed when shadowed by an external definition
+
+// CHECK-NOT: strlen.inline
+
+unsigned long strnlen(const char *, unsigned long);
+void fortify_panic(const char *);
+
+extern inline __attribute__((always_inline)) __attribute__((gnu_inline)) unsigned long strlen(const char *p) {
+  return 1;
+}
+unsigned long mystrlen(char const *s) {
+  return strlen(s);
+}
+unsigned long strlen(const char *s) {
+  return 2;
+}
+unsigned long yourstrlen(char const *s) {
+  return strlen(s);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1299,18 +1299,30 @@
   // When generating code for a builtin with an inline declaration, use a
   // mangled name to hold the actual body, while keeping an external definition
   // in case the function pointer is referenced somewhere.
-  if (FD->isInlineBuiltinDeclaration() && Fn) {
+  if (Fn) {
 std::string FDInlineName = (Fn->getName() + ".inline").str();
 llvm::Module *M = Fn->getParent();
 llvm::Function *Clone = M->getFunction(FDInlineName);
-if (!Clone) {
-  Clone = llvm::Function::Create(Fn->getFunctionType(),
- llvm::GlobalValue::InternalLinkage,
- Fn->getAddressSpace(), FDInlineName, M);
-  Clone->addFnAttr(llvm::Attribute::AlwaysInline);
+if (FD->isInlineBuiltinDeclaration()) {
+  if (!Clone) {
+

[clang] 08ed216 - [IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove GlobalIndirectSymbol

2021-10-20 Thread Fangrui Song via cfe-commits

Author: Itay Bookstein
Date: 2021-10-20T10:29:47-07:00
New Revision: 08ed216000b6503a4a4be52f18394d008d5fb8f4

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

LOG: [IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove 
GlobalIndirectSymbol

As discussed in:
* https://reviews.llvm.org/D94166
* https://lists.llvm.org/pipermail/llvm-dev/2020-September/145031.html

The GlobalIndirectSymbol class lost most of its meaning in
https://reviews.llvm.org/D109792, which disambiguated getBaseObject
(now getAliaseeObject) between GlobalIFunc and everything else.
In addition, as long as GlobalIFunc is not a GlobalObject and
getAliaseeObject returns GlobalObjects, a GlobalAlias whose aliasee
is a GlobalIFunc cannot currently be modeled properly. Creating
aliases for GlobalIFuncs does happen in the wild (e.g. glibc). In addition,
calling getAliaseeObject on a GlobalIFunc will currently return nullptr,
which is undesirable because it should return the object itself for
non-aliases.

This patch refactors the GlobalIFunc class to inherit directly from
GlobalObject, and removes GlobalIndirectSymbol (while inlining the
relevant parts into GlobalAlias and GlobalIFunc). This allows for
calling getAliaseeObject() on a GlobalIFunc to return the GlobalIFunc
itself, making getAliaseeObject() more consistent and enabling
alias-to-ifunc to be properly modeled in the IR.

I exercised some judgement in the API clients of GlobalIndirectSymbol:
some were 'monomorphized' for GlobalAlias and GlobalIFunc, and
some remained shared (with the type adapted to become GlobalValue).

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
llvm/include/llvm-c/Core.h
llvm/include/llvm/AsmParser/LLParser.h
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/IR/GlobalAlias.h
llvm/include/llvm/IR/GlobalIFunc.h
llvm/include/llvm/IR/GlobalObject.h
llvm/include/llvm/IR/Value.h
llvm/include/llvm/Transforms/Utils/ValueMapper.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Object/ModuleSymbolTable.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/Utils/SplitModule.cpp
llvm/lib/Transforms/Utils/ValueMapper.cpp
llvm/unittests/IR/ConstantsTest.cpp

Removed: 
llvm/include/llvm/IR/GlobalIndirectSymbol.h



diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 57454a59563a2..e53a8a36974ae 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -317,21 +317,21 @@ void CodeGenModule::applyGlobalValReplacements() {
 
 // This is only used in aliases that we created and we know they have a
 // linear structure.
-static const llvm::GlobalObject *getAliasedGlobal(
-const llvm::GlobalIndirectSymbol ) {
-  llvm::SmallPtrSet Visited;
-  const llvm::Constant *C = 
+static const llvm::GlobalValue *getAliasedGlobal(const llvm::GlobalValue *GV) {
+  llvm::SmallPtrSet Visited;
   for (;;) {
-C = C->stripPointerCasts();
-if (auto *GO = dyn_cast(C))
-  return GO;
-// stripPointerCasts will not walk over weak aliases.
-auto *GIS2 = dyn_cast(C);
-if (!GIS2)
+if (!GV || !Visited.insert(GV).second)
   return nullptr;
-if (!Visited.insert(GIS2).second)
-  return nullptr;
-C = GIS2->getIndirectSymbol();
+
+const llvm::Constant *C;
+if (auto *GA = dyn_cast(GV))
+  C = GA->getAliasee();
+else if (auto *GI = dyn_cast(GV))
+  C = GI->getResolver();
+else
+  return GV;
+
+GV = dyn_cast(C->stripPointerCasts());
   }
 }
 
@@ -350,9 +350,8 @@ void CodeGenModule::checkAliases() {
 else
   llvm_unreachable("Not an alias or ifunc?");
 StringRef MangledName = getMangledName(GD);
-llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
-auto *Alias  = cast(Entry);
-const llvm::GlobalValue *GV = getAliasedGlobal(*Alias);
+llvm::GlobalValue *Alias = GetGlobalValue(MangledName);
+const llvm::GlobalValue *GV = getAliasedGlobal(Alias);
 if (!GV) {
   Error = true;
   Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
@@ -369,7 +368,10 @@ void CodeGenModule::checkAliases() {
 Diags.Report(Location, diag::err_ifunc_resolver_return);
 }
 
-llvm::Constant *Aliasee = Alias->getIndirectSymbol();
+llvm::Constant *Aliasee =
+IsIFunc ? cast(Alias)->getResolver()
+: cast(Alias)->getAliasee();
+
 llvm::GlobalValue *AliaseeGV;
 if (auto CE = 

[PATCH] D108872: [IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove GlobalIndirectSymbol

2021-10-20 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08ed216000b6: [IR] Refactor GlobalIFunc to inherit from 
GlobalObject, Remove… (authored by ibookstein, committed by MaskRay).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108872

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/AsmParser/LLParser.h
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/GlobalAlias.h
  llvm/include/llvm/IR/GlobalIFunc.h
  llvm/include/llvm/IR/GlobalIndirectSymbol.h
  llvm/include/llvm/IR/GlobalObject.h
  llvm/include/llvm/IR/Value.h
  llvm/include/llvm/Transforms/Utils/ValueMapper.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/Utils/SplitModule.cpp
  llvm/lib/Transforms/Utils/ValueMapper.cpp
  llvm/unittests/IR/ConstantsTest.cpp

Index: llvm/unittests/IR/ConstantsTest.cpp
===
--- llvm/unittests/IR/ConstantsTest.cpp
+++ llvm/unittests/IR/ConstantsTest.cpp
@@ -385,7 +385,7 @@
   new GlobalVariable(*M, PtrTy, false, GlobalValue::ExternalLinkage, GEP);
   ASSERT_EQ(GEP, Ref->getInitializer());
 
-  auto *Global = new GlobalVariable(*M, PtrTy, false,
+  auto *Global = new GlobalVariable(*M, IntTy, false,
 GlobalValue::ExternalLinkage, nullptr);
   auto *Alias = GlobalAlias::create(IntTy, 0, GlobalValue::ExternalLinkage,
 "alias", Global, M.get());
Index: llvm/lib/Transforms/Utils/ValueMapper.cpp
===
--- llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -26,7 +26,8 @@
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
-#include "llvm/IR/GlobalIndirectSymbol.h"
+#include "llvm/IR/GlobalAlias.h"
+#include "llvm/IR/GlobalIFunc.h"
 #include "llvm/IR/GlobalObject.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/InlineAsm.h"
@@ -68,7 +69,7 @@
   enum EntryKind {
 MapGlobalInit,
 MapAppendingVar,
-MapGlobalIndirectSymbol,
+MapAliasOrIFunc,
 RemapFunction
   };
   struct GVInitTy {
@@ -79,8 +80,8 @@
 GlobalVariable *GV;
 Constant *InitPrefix;
   };
-  struct GlobalIndirectSymbolTy {
-GlobalIndirectSymbol *GIS;
+  struct AliasOrIFuncTy {
+GlobalValue *GV;
 Constant *Target;
   };
 
@@ -91,7 +92,7 @@
   union {
 GVInitTy GVInit;
 AppendingGVTy AppendingGV;
-GlobalIndirectSymbolTy GlobalIndirectSymbol;
+AliasOrIFuncTy AliasOrIFunc;
 Function *RemapF;
   } Data;
 };
@@ -163,8 +164,8 @@
 bool IsOldCtorDtor,
 ArrayRef NewMembers,
 unsigned MCID);
-  void scheduleMapGlobalIndirectSymbol(GlobalIndirectSymbol , Constant ,
-   unsigned MCID);
+  void scheduleMapAliasOrIFunc(GlobalValue , Constant ,
+   unsigned MCID);
   void scheduleRemapFunction(Function , unsigned MCID);
 
   void flush();
@@ -873,10 +874,17 @@
E.AppendingGVIsOldCtorDtor, makeArrayRef(NewInits));
   break;
 }
-case WorklistEntry::MapGlobalIndirectSymbol:
-  E.Data.GlobalIndirectSymbol.GIS->setIndirectSymbol(
-  mapConstant(E.Data.GlobalIndirectSymbol.Target));
+case WorklistEntry::MapAliasOrIFunc: {
+  GlobalValue *GV = E.Data.AliasOrIFunc.GV;
+  Constant *Target = mapConstant(E.Data.AliasOrIFunc.Target);
+  if (auto *GA = dyn_cast(GV))
+GA->setAliasee(Target);
+  else if (auto *GI = dyn_cast(GV))
+GI->setResolver(Target);
+  else
+llvm_unreachable("Not alias or ifunc");
   break;
+}
 case WorklistEntry::RemapFunction:
   remapFunction(*E.Data.RemapF);
   break;
@@ -1069,16 +1077,18 @@
   AppendingInits.append(NewMembers.begin(), NewMembers.end());
 }
 
-void Mapper::scheduleMapGlobalIndirectSymbol(GlobalIndirectSymbol ,
- Constant , unsigned MCID) {
-  assert(AlreadyScheduled.insert().second && "Should not reschedule");
+void Mapper::scheduleMapAliasOrIFunc(GlobalValue , Constant ,
+ unsigned MCID) {
+  assert(AlreadyScheduled.insert().second && "Should not reschedule");
+  assert((isa(GV) || isa(GV)) &&
+ "Should be alias or 

[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

This makes sense, any reason we don't remove the check at the call sites right 
away?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112159

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


[PATCH] D112059: Fix inline builtin handling in case of redefinition

2021-10-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 381011.
serge-sans-paille added a comment.

Reduce the number of time we would walk redecls.
Simplify test case


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

https://reviews.llvm.org/D112059

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/strlen-inline-builtin-redecl.c


Index: clang/test/CodeGen/strlen-inline-builtin-redecl.c
===
--- /dev/null
+++ clang/test/CodeGen/strlen-inline-builtin-redecl.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64 -S -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s
+//
+// Verifies that clang-generated *.inline are removed when shadowed by an 
external definition
+
+// CHECK-NOT: strlen.inline
+
+unsigned long strnlen(const char *, unsigned long);
+void fortify_panic(const char *);
+
+extern inline __attribute__((always_inline)) __attribute__((gnu_inline)) 
unsigned long strlen(const char *p) {
+  return 1;
+}
+unsigned long mystrlen(char const *s) {
+  return strlen(s);
+}
+unsigned long strlen(const char *s) {
+  return 2;
+}
+unsigned long yourstrlen(char const *s) {
+  return strlen(s);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1299,18 +1299,34 @@
   // When generating code for a builtin with an inline declaration, use a
   // mangled name to hold the actual body, while keeping an external definition
   // in case the function pointer is referenced somewhere.
-  if (FD->isInlineBuiltinDeclaration() && Fn) {
+  if (Fn) {
 std::string FDInlineName = (Fn->getName() + ".inline").str();
 llvm::Module *M = Fn->getParent();
 llvm::Function *Clone = M->getFunction(FDInlineName);
-if (!Clone) {
-  Clone = llvm::Function::Create(Fn->getFunctionType(),
- llvm::GlobalValue::InternalLinkage,
- Fn->getAddressSpace(), FDInlineName, M);
-  Clone->addFnAttr(llvm::Attribute::AlwaysInline);
+if (FD->isInlineBuiltinDeclaration()) {
+  if (!Clone) {
+Clone = llvm::Function::Create(Fn->getFunctionType(),
+   llvm::GlobalValue::InternalLinkage,
+   Fn->getAddressSpace(), FDInlineName, M);
+Clone->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+  Fn->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  Fn = Clone;
+}
+
+// detect the unusual situation where an inline version is shadowed by a
+// non-inline version. In that case we should pick the external one
+// everywhere. That's GCC behavior too. Unfortunately, I cannot find a way
+// to detect that situation before we reach codegen, so do some late
+// replacement.
+else if (Clone) {
+  for (auto const *Redecl : FD->redecls()) {
+if (Redecl->isInlineBuiltinDeclaration()) {
+  Clone->replaceAllUsesWith(Fn);
+  Clone->eraseFromParent();
+}
+  }
 }
-Fn->setLinkage(llvm::GlobalValue::ExternalLinkage);
-Fn = Clone;
   }
 
   // Check if we should generate debug info for this function.


Index: clang/test/CodeGen/strlen-inline-builtin-redecl.c
===
--- /dev/null
+++ clang/test/CodeGen/strlen-inline-builtin-redecl.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64 -S -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+//
+// Verifies that clang-generated *.inline are removed when shadowed by an external definition
+
+// CHECK-NOT: strlen.inline
+
+unsigned long strnlen(const char *, unsigned long);
+void fortify_panic(const char *);
+
+extern inline __attribute__((always_inline)) __attribute__((gnu_inline)) unsigned long strlen(const char *p) {
+  return 1;
+}
+unsigned long mystrlen(char const *s) {
+  return strlen(s);
+}
+unsigned long strlen(const char *s) {
+  return 2;
+}
+unsigned long yourstrlen(char const *s) {
+  return strlen(s);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1299,18 +1299,34 @@
   // When generating code for a builtin with an inline declaration, use a
   // mangled name to hold the actual body, while keeping an external definition
   // in case the function pointer is referenced somewhere.
-  if (FD->isInlineBuiltinDeclaration() && Fn) {
+  if (Fn) {
 std::string FDInlineName = (Fn->getName() + ".inline").str();
 llvm::Module *M = Fn->getParent();
 llvm::Function *Clone = M->getFunction(FDInlineName);
-if (!Clone) {
-  Clone = llvm::Function::Create(Fn->getFunctionType(),
- llvm::GlobalValue::InternalLinkage,
- 

[PATCH] D111993: [libomptarget][WIP] Patch amdgpu DeviceRTL until it compiles

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: openmp/libomptarget/DeviceRTL/src/Synchronization.cpp:92
+}
+// clang/lib/AST/ExprConstant.cpp:14739: bool 
clang::Expr::EvaluateAsInt(clang::Expr::EvalResult&, const clang::ASTContext&, 
clang::Expr::SideEffectsKind, bool) const: Assertion `!isValueDependent() && 
"Expression evaluator can't be called on a dependent expression."' failed.
+

The assert in clang was unrelated to amdgpu, posted a diff at D112159 with a 
fix.

The other atomic builtins codegen with a switch on order when passed a 
variable. That seems like the right thing to do for the amdgpu-specific atomic 
builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111993

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


[PATCH] D112159: Relax assert in ExprConstant to a return None.

2021-10-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: gribozavr, rsmith, ABataev, dblaikie, 
aaron.ballman, jdoerfert.
JonChesterfield requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes a compiler assert on passing a compile time integer to atomic builtins.

Assert introduced in D61522 
Function changed from ->bool to ->Optional in D76646 

Most call sites for getIntegerConstantExpr check the returned optional.
Some check for isValueDependent before calling it.

This leaves some call sites with a redundant call to !isValueDependent
which could be folded into the following call to getIntegerConstantExpr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112159

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaTemplate/atomics.cpp


Index: clang/test/SemaTemplate/atomics.cpp
===
--- clang/test/SemaTemplate/atomics.cpp
+++ clang/test/SemaTemplate/atomics.cpp
@@ -15,3 +15,13 @@
   }
   void h() { g(0); }
 }
+
+// Can pass value dependent integer to atomic builtin
+template 
+void fetchAdd(int *A, int V) {
+  __atomic_fetch_add(A, V, Order);
+}
+
+void fetchAddUse(int *A, int V) {
+  fetchAdd<__ATOMIC_ACQ_REL>(A, V);
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -15501,8 +15501,10 @@
 Optional Expr::getIntegerConstantExpr(const ASTContext ,
 SourceLocation *Loc,
 bool isEvaluated) const {
-  assert(!isValueDependent() &&
- "Expression evaluator can't be called on a dependent expression.");
+  if (isValueDependent()) {
+// Expression evaluator can't succeed on a dependent expression.
+return None;
+  }
 
   APSInt Value;
 


Index: clang/test/SemaTemplate/atomics.cpp
===
--- clang/test/SemaTemplate/atomics.cpp
+++ clang/test/SemaTemplate/atomics.cpp
@@ -15,3 +15,13 @@
   }
   void h() { g(0); }
 }
+
+// Can pass value dependent integer to atomic builtin
+template 
+void fetchAdd(int *A, int V) {
+  __atomic_fetch_add(A, V, Order);
+}
+
+void fetchAddUse(int *A, int V) {
+  fetchAdd<__ATOMIC_ACQ_REL>(A, V);
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -15501,8 +15501,10 @@
 Optional Expr::getIntegerConstantExpr(const ASTContext ,
 SourceLocation *Loc,
 bool isEvaluated) const {
-  assert(!isValueDependent() &&
- "Expression evaluator can't be called on a dependent expression.");
+  if (isValueDependent()) {
+// Expression evaluator can't succeed on a dependent expression.
+return None;
+  }
 
   APSInt Value;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112158: mips: fix search path for multilib o32

2021-10-20 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa created this revision.
wzssyqa added a reviewer: atanasyan.
Herald added subscribers: arichardson, sdardis.
wzssyqa requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In the situation of multilib, the gcc objects are in a /32 directory.
On Debian, the libraries is under /libo32 to avoid confliction.

This patch enables clang find gcc in /32, and C lib in /libo32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112158

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  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
@@ -261,6 +261,10 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel)
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, 
Paths);
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1086,7 +1086,8 @@
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+
Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent);
@@ -2125,11 +2126,11 @@
   static const char *const M68kTriples[] = {
   "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};
 
-  static const char *const MIPSLibDirs[] = {"/lib"};
+  static const char *const MIPSLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSTriples[] = {
   "mips-linux-gnu", "mips-mti-linux", "mips-mti-linux-gnu",
   "mips-img-linux-gnu", "mipsisa32r6-linux-gnu"};
-  static const char *const MIPSELLibDirs[] = {"/lib"};
+  static const char *const MIPSELLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSELTriples[] = {
   "mipsel-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6el-linux-gnu"};
 


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -261,6 +261,10 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel)
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, Paths);
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1086,7 +1086,8 @@
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent);
@@ -2125,11 +2126,11 @@
   static const char *const M68kTriples[] = {
   "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};
 
-  static const char *const MIPSLibDirs[] = {"/lib"};
+  static const char *const MIPSLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSTriples[] = {
   "mips-linux-gnu", "mips-mti-linux", "mips-mti-linux-gnu",
   "mips-img-linux-gnu", "mipsisa32r6-linux-gnu"};
-  static const char *const MIPSELLibDirs[] = {"/lib"};
+  static const char *const MIPSELLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSELTriples[] = {
   "mipsel-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6el-linux-gnu"};
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7562f3d - InvalidPtrChecker - don't dereference a dyn_cast<> - use cast<> instead.

2021-10-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-10-20T18:06:00+01:00
New Revision: 7562f3df89066ab92a816dc23005c45fd642bdf9

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

LOG: InvalidPtrChecker - don't dereference a dyn_cast<> - use cast<> instead.

Avoid dereferencing a nullptr returned by dyn_cast<>, by using cast<> instead 
which asserts that the cast is valid.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
index 18893c2fda15b..378d7ce8150af 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
@@ -146,7 +146,7 @@ void InvalidPtrChecker::postPreviousReturnInvalidatingCall(
   State = State->BindExpr(CE, LCtx, RetVal);
 
   // Remember to this region.
-  const auto *SymRegOfRetVal = dyn_cast(RetVal.getAsRegion());
+  const auto *SymRegOfRetVal = cast(RetVal.getAsRegion());
   const MemRegion *MR =
   const_cast(SymRegOfRetVal->getBaseRegion());
   State = State->set(FD, MR);



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


[PATCH] D112157: [clang] Disallow mixing SEH and Objective-C exceptions

2021-10-20 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
thakis requested review of this revision.

We already disallow mixing SEH and C++ exceptions, and
mixing SEH and Objective-C exceptions seems to not work (see PR52233).
Emitting an error is friendlier than crashing.


https://reviews.llvm.org/D112157

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/lib/Sema/ScopeInfo.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/exceptions-seh.mm

Index: clang/test/SemaCXX/exceptions-seh.mm
===
--- /dev/null
+++ clang/test/SemaCXX/exceptions-seh.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -fsyntax-only -fexceptions -fobjc-exceptions -verify %s
+
+void might_crash();
+
+void use_seh_after_objc() {
+  @try { // expected-note {{conflicting '@try' here}}
+might_crash();
+  } @finally {
+  }
+  __try { // expected-error {{cannot use Objective-C '@try' in the same function as SEH '__try'}}
+might_crash();
+  } __except(1) {
+  }
+}
+
+void use_objc_after_seh() {
+  __try { // expected-note {{conflicting '__try' here}}
+might_crash();
+  } __except(1) {
+  }
+  @try { // expected-error {{cannot use Objective-C '@try' in the same function as SEH '__try'}}
+might_crash();
+  } @finally {
+  }
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4187,7 +4187,14 @@
   if (!getLangOpts().ObjCExceptions)
 Diag(AtLoc, diag::err_objc_exceptions_disabled) << "@try";
 
-  setFunctionHasBranchProtectedScope();
+  // Objective-C try is incompatible with SEH __try.
+  sema::FunctionScopeInfo *FSI = getCurFunction();
+  if (FSI->FirstSEHTryLoc.isValid()) {
+Diag(AtLoc, diag::err_mixing_cxx_try_seh_try) << 1;
+Diag(FSI->FirstSEHTryLoc, diag::note_conflicting_try_here) << "'__try'";
+  }
+
+  FSI->setHasObjCTry(AtLoc);
   unsigned NumCatchStmts = CatchStmts.size();
   return ObjCAtTryStmt::Create(Context, AtLoc, Try, CatchStmts.data(),
NumCatchStmts, Finally);
@@ -4423,7 +4430,7 @@
 
   // C++ try is incompatible with SEH __try.
   if (!getLangOpts().Borland && FSI->FirstSEHTryLoc.isValid()) {
-Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
+Diag(TryLoc, diag::err_mixing_cxx_try_seh_try) << 0;
 Diag(FSI->FirstSEHTryLoc, diag::note_conflicting_try_here) << "'__try'";
   }
 
@@ -4507,9 +4514,12 @@
   // SEH __try is incompatible with C++ try. Borland appears to support this,
   // however.
   if (!getLangOpts().Borland) {
-if (FSI->FirstCXXTryLoc.isValid()) {
-  Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
-  Diag(FSI->FirstCXXTryLoc, diag::note_conflicting_try_here) << "'try'";
+if (FSI->FirstCXXOrObjCTryLoc.isValid()) {
+  Diag(TryLoc, diag::err_mixing_cxx_try_seh_try) << FSI->FirstTryType;
+  Diag(FSI->FirstCXXOrObjCTryLoc, diag::note_conflicting_try_here)
+  << (FSI->FirstTryType == sema::FunctionScopeInfo::TryLocIsCXX
+  ? "'try'"
+  : "'@try'");
 }
   }
 
Index: clang/lib/Sema/ScopeInfo.cpp
===
--- clang/lib/Sema/ScopeInfo.cpp
+++ clang/lib/Sema/ScopeInfo.cpp
@@ -37,7 +37,7 @@
   ObjCIsSecondaryInit = false;
   ObjCWarnForNoInitDelegation = false;
   FirstReturnLoc = SourceLocation();
-  FirstCXXTryLoc = SourceLocation();
+  FirstCXXOrObjCTryLoc = SourceLocation();
   FirstSEHTryLoc = SourceLocation();
 
   // Coroutine state
Index: clang/include/clang/Sema/ScopeInfo.h
===
--- clang/include/clang/Sema/ScopeInfo.h
+++ clang/include/clang/Sema/ScopeInfo.h
@@ -175,8 +175,9 @@
   /// First 'return' statement in the current function.
   SourceLocation FirstReturnLoc;
 
-  /// First C++ 'try' statement in the current function.
-  SourceLocation FirstCXXTryLoc;
+  /// First C++ 'try' or ObjC @try statement in the current function.
+  SourceLocation FirstCXXOrObjCTryLoc;
+  enum { TryLocIsCXX, TryLocIsObjC, Unknown } FirstTryType = Unknown;
 
   /// First SEH '__try' statement in the current function.
   SourceLocation FirstSEHTryLoc;
@@ -446,7 +447,14 @@
 
   void setHasCXXTry(SourceLocation TryLoc) {
 setHasBranchProtectedScope();
-FirstCXXTryLoc = TryLoc;
+FirstCXXOrObjCTryLoc = TryLoc;
+FirstTryType = TryLocIsCXX;
+  }
+
+  void setHasObjCTry(SourceLocation TryLoc) {
+setHasBranchProtectedScope();
+FirstCXXOrObjCTryLoc = TryLoc;
+FirstTryType = TryLocIsObjC;
   }
 
   void setHasSEHTry(SourceLocation TryLoc) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7516,7 +7516,8 

[PATCH] D107878: [SampleFDO] Flow Sensitive Sample FDO (FSAFDO) profile loader

2021-10-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:234
+  if (TM)
+TM->setPGOOption(PGOOpt);
 

@xur Why does TM need a null check - afaict it's already been dereferenced in 
the call tree, and will be again below.

Noticed in a scan-build warning: 
https://llvm.org/reports/scan-build/report-LTOBackend.cpp-runNewPMPasses-34-35dfe9.html#EndPath


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107878

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


[PATCH] D112146: [WebAssembly] Add prototype relaxed float min max instructions

2021-10-20 Thread Thomas Lively 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 rGe1fb13401e1b: [WebAssembly] Add prototype relaxed float min 
max instructions (authored by ngzhian, committed by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112146

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -806,4 +806,16 @@
 # CHECK: i8x16.relaxed_swizzle # encoding: [0xfd,0xa2,0x01]
 i8x16.relaxed_swizzle
 
+# CHECK: f32x4.relaxed_min # encoding: [0xfd,0xb4,0x01]
+f32x4.relaxed_min
+
+# CHECK: f32x4.relaxed_max # encoding: [0xfd,0xe2,0x01]
+f32x4.relaxed_max
+
+# CHECK: f64x2.relaxed_min # encoding: [0xfd,0xd4,0x01]
+f64x2.relaxed_min
+
+# CHECK: f64x2.relaxed_max # encoding: [0xfd,0xee,0x01]
+f64x2.relaxed_max
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -682,6 +682,30 @@
   ret <4 x float> %v
 }
 
+; CHECK-LABEL: relaxed_min_v4f32:
+; CHECK-NEXT: .functype relaxed_min_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.relaxed_min $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.relaxed.min.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @relaxed_min_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.relaxed.min.v4f32(
+<4 x float> %a, <4 x float> %b
+  )
+  ret <4 x float> %v
+}
+
+; CHECK-LABEL: relaxed_max_v4f32:
+; CHECK-NEXT: .functype relaxed_max_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.relaxed_max $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.relaxed.max.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @relaxed_max_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.relaxed.max.v4f32(
+<4 x float> %a, <4 x float> %b
+  )
+  ret <4 x float> %v
+}
+
 ; ==
 ; 2 x f64
 ; ==
@@ -780,3 +804,27 @@
   )
   ret <2 x double> %v
 }
+
+; CHECK-LABEL: relaxed_min_v2f64:
+; CHECK-NEXT: .functype relaxed_min_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.relaxed_min $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.relaxed.min.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @relaxed_min_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.relaxed.min.v2f64(
+<2 x double> %a, <2 x double> %b
+  )
+  ret <2 x double> %v
+}
+
+; CHECK-LABEL: relaxed_max_v2f64:
+; CHECK-NEXT: .functype relaxed_max_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.relaxed_max $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.relaxed.max.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @relaxed_max_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.relaxed.max.v2f64(
+<2 x double> %a, <2 x double> %b
+  )
+  ret <2 x double> %v
+}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1372,3 +1372,23 @@
  [(set (v16i8 V128:$dst),
(int_wasm_relaxed_swizzle (v16i8 V128:$src), (v16i8 V128:$mask)))],
  "i8x16.relaxed_swizzle\t$dst, $src, $mask", "i8x16.relaxed_swizzle", 162>;
+
+//===--===//
+// Relaxed floating-point min and max.
+//===--===//
+
+multiclass SIMD_RELAXED_FMINMAX simdopMin, bits<32> simdopMax> {
+  defm RELAXED_FMIN_#vec :
+RELAXED_I<(outs V128:$dst), (ins V128:$a, V128:$b), (outs), (ins),
+  [(set (vec.vt V128:$dst), (int_wasm_relaxed_min
+(vec.vt V128:$a), (vec.vt V128:$b)))],
+  vec.prefix#".relaxed_min\t$dst, $a, $b", vec.prefix#".relaxed_min", simdopMin>;
+  defm RELAXED_FMAX_#vec :
+RELAXED_I<(outs V128:$dst), (ins V128:$a, 

[clang] e1fb134 - [WebAssembly] Add prototype relaxed float min max instructions

2021-10-20 Thread Thomas Lively via cfe-commits

Author: Zhi An Ng
Date: 2021-10-20T09:41:51-07:00
New Revision: e1fb13401e1b90a912ba83c6d1a82794cfdb8aec

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

LOG: [WebAssembly] Add prototype relaxed float min max instructions

Add relaxed. f32x4.min, f32x4.max, f64x2.min, f64x2.max. These are only
exposed as builtins, and require user opt-in.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 0eecab3c31f26..c30a2a6060169 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -174,5 +174,10 @@ TARGET_BUILTIN(__builtin_wasm_laneselect_i64x2, 
"V2LLiV2LLiV2LLiV2LLi", "nc", "r
 
 TARGET_BUILTIN(__builtin_wasm_relaxed_swizzle_i8x16, "V16ScV16ScV16Sc", "nc", 
"relaxed-simd")
 
+TARGET_BUILTIN(__builtin_wasm_relaxed_min_f32x4, "V4fV4fV4f", "nc", 
"relaxed-simd")
+TARGET_BUILTIN(__builtin_wasm_relaxed_max_f32x4, "V4fV4fV4f", "nc", 
"relaxed-simd")
+TARGET_BUILTIN(__builtin_wasm_relaxed_min_f64x2, "V2dV2dV2d", "nc", 
"relaxed-simd")
+TARGET_BUILTIN(__builtin_wasm_relaxed_max_f64x2, "V2dV2dV2d", "nc", 
"relaxed-simd")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9ef9d4f1c2d9e..d20415f1ced6c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18325,6 +18325,28 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_relaxed_swizzle);
 return Builder.CreateCall(Callee, {Src, Indices});
   }
+  case WebAssembly::BI__builtin_wasm_relaxed_min_f32x4:
+  case WebAssembly::BI__builtin_wasm_relaxed_max_f32x4:
+  case WebAssembly::BI__builtin_wasm_relaxed_min_f64x2:
+  case WebAssembly::BI__builtin_wasm_relaxed_max_f64x2: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+unsigned IntNo;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_relaxed_min_f32x4:
+case WebAssembly::BI__builtin_wasm_relaxed_min_f64x2:
+  IntNo = Intrinsic::wasm_relaxed_min;
+  break;
+case WebAssembly::BI__builtin_wasm_relaxed_max_f32x4:
+case WebAssembly::BI__builtin_wasm_relaxed_max_f64x2:
+  IntNo = Intrinsic::wasm_relaxed_max;
+  break;
+default:
+  llvm_unreachable("unexpected builtin ID");
+}
+Function *Callee = CGM.getIntrinsic(IntNo, LHS->getType());
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   default:
 return nullptr;
   }

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 489565ee09d15..8eb8522d90b5b 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -737,3 +737,31 @@ i8x16 relaxed_swizzle_i8x16(i8x16 x, i8x16 y) {
   return __builtin_wasm_relaxed_swizzle_i8x16(x, y);
   // WEBASSEMBLY: call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %x, <16 
x i8> %y)
 }
+
+f32x4 relaxed_min_f32x4(f32x4 a, f32x4 b) {
+  return __builtin_wasm_relaxed_min_f32x4(a, b);
+  // WEBASSEMBLY: call <4 x float> @llvm.wasm.relaxed.min.v4f32(
+  // WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+f32x4 relaxed_max_f32x4(f32x4 a, f32x4 b) {
+  return __builtin_wasm_relaxed_max_f32x4(a, b);
+  // WEBASSEMBLY: call <4 x float> @llvm.wasm.relaxed.max.v4f32(
+  // WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+f64x2 relaxed_min_f64x2(f64x2 a, f64x2 b) {
+  return __builtin_wasm_relaxed_min_f64x2(a, b);
+  // WEBASSEMBLY: call <2 x double> @llvm.wasm.relaxed.min.v2f64(
+  // WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+f64x2 relaxed_max_f64x2(f64x2 a, f64x2 b) {
+  return __builtin_wasm_relaxed_max_f64x2(a, b);
+  // WEBASSEMBLY: call <2 x double> @llvm.wasm.relaxed.max.v2f64(
+  // WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b)
+  // WEBASSEMBLY-NEXT: ret
+}

diff  --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td 
b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
index d832195609f09..53d63a0d4dcc7 100644
--- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -205,6 +205,15 @@ def int_wasm_relaxed_swizzle :
   

[PATCH] D110287: [modules] While merging ObjCInterfaceDecl definitions, merge them as decl contexts too.

2021-10-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D110287#3074175 , @vsapsai wrote:

> In D110287#3074082 , @dblaikie 
> wrote:
>
>> In D110287#3073804 , @vsapsai 
>> wrote:
>>
>>> Pre-merge checks are passing now after the rebase. I believe it is a 
>>> straightforward change and we are merging decl contexts for other Decls 
>>> already, so merging them for `ObjCInterfaceDecl` makes sense. If there are 
>>> no objections, I plan to land the change on Friday, October 22. If any 
>>> issues come up later, post-commit reviews are welcome as always.
>>
>> Generally this sort of "if no one says anything I'll commit at this time" 
>> thing is to be avoided: The idea is that once something's been sent for 
>> review/the author has requested a second opinion, we want to avoid people 
>> committing that code without review only due to lack of feedback. Please 
>> reach out to reviewers to get a second set of eyes on this before committing.
>
> What would be a better way to deal with changes in areas where I'm more 
> experienced in (Obj-C decl merging on AST deserialization) and still want to 
> run pre-merge checks on other platforms? I got unofficial sign-offs 
> internally but people defer to me because I've worked more in this area.

Oh, sure - you can use Phabricator's draft support to just send the change for 
CI testing without sending a review to the mailing list: 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line

> I believe this change is pretty trivial, while for D110452 
>  I want another opinion. But one-line 
> change in D110453  is trivial too and I 
> don't think that waiting for reviews for half a year would improve its 
> quality substantially.

Reviews shouldn't/generally don't take half a year, especially for smaller, 
clearly correct changes. Pinging reviews if they're not getting traction can 
help get some attention, though sometimes more direct calls for assistance may 
be necessary/beneficial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110287

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


[PATCH] D112146: [WebAssembly] Add prototype relaxed float min max instructions

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112146

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


[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-20 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

In D111542#3074926 , @ASDenysPetrov 
wrote:

> Updated according to the latest suggestions.
> @martong I think now this patch is way more simple and clear than before.

Thanks, indeed! LGTM (with nits about `VD`)!




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1649-1653
+  // NOTE: `VD` is always non-null if `Init` is non-null, so we can check for
+  // null only one of them.
+  const Expr *Init = VD->getAnyInitializer(VD);
   if (!Init)
 return None;

steakhal wrote:
> Wait. But if `VD` is null, you get a null-dereference.
> But you already dereferenced `VD` multiple times, so it cannot be null.
> 
> Oh, but the `getAnyInitializer()` will overwrite it! That's a surprise.
> TBH I would rather pass a fresh uninitialized pointer if you really need the 
> exact decl which actually provided the initialized expression to make this 
> behavior explicit.
> 
> That way, with a properly chosen name you could spare the NOTE comment as 
> well.
Yes I agree, probably it is easier to follow the code if you make it explicit 
that `VD` is overwritten here.


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

https://reviews.llvm.org/D111542

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


[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

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



Comment at: clang/test/Analysis/initialization.c:103
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}}
+}

martong wrote:
> ASDenysPetrov wrote:
> > steakhal wrote:
> > > I'm pretty sure we should not get `Unknown` for simply loading from a 
> > > global variable.
> > > That would imply that loading two times subsequently we could not prove 
> > > that the value remained the same.
> > > But that should remain the same, thus compare equal unless some other 
> > > code modifier that memory region.
> > > 
> > > That could happen for two reasons:
> > > 1) There is a racecondition, and another thread modified that location. 
> > > But that would be UB, so that could not happen.
> > > 2) The global variable is //volatile//, so the hardware might changed its 
> > > content- but this global is not volatile so this does not apply.
> > > 
> > > That being said, this load should have resulted in a //fresh// conjured 
> > > symbolic value instead of //unknown//.
> > > Could you please check if it did result in //unknown// before your patch, 
> > > or you did introduce this behavior?
> > I'm not sure I caught your thoughts.
> > But I think the things is much simplier:
> > `clang_analyzer_eval` can only produce `UNKNOWN` or `TRUE` or `FALSE`. If 
> > we know the constraint of `glob_arr_no_init[2]` we return `TRUE` or 
> > `FALSE`, and `UNKNOWN` otherwise.
> > But in fact I should use `clang_analyzer_dump` here instead of 
> > `clang_analyzer_eval`. This is actually my fault. I'll update this.
> > Could you please check if it did result in unknown before your patch, or 
> > you did introduce this behavior?
> 
> I've just checked it, it was `Unknown` before this patch as well. 
> And actually, that is wrong because the array has static storage duration and 
> as such, we know that it is initialized with zeros according to the C 
> standard. But, that should be addressed in a follow-up patch (if someone has 
> the capacity).
> https://stackoverflow.com/questions/32708161/value-of-uninitialized-elements-in-array-of-c-language/32708288
Oh true. I was actually tricked by the `initialization.cpp:38`, where I 
actually caught this. And in that case, you use `dump()` yet you get `Unknown` 
as a result. But the issue remains the same.


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

https://reviews.llvm.org/D106681

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


[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks, this looks good to me! But, please wait for an approve from @steakhal 
as well.




Comment at: clang/test/Analysis/initialization.c:103
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}}
+}

ASDenysPetrov wrote:
> steakhal wrote:
> > I'm pretty sure we should not get `Unknown` for simply loading from a 
> > global variable.
> > That would imply that loading two times subsequently we could not prove 
> > that the value remained the same.
> > But that should remain the same, thus compare equal unless some other code 
> > modifier that memory region.
> > 
> > That could happen for two reasons:
> > 1) There is a racecondition, and another thread modified that location. But 
> > that would be UB, so that could not happen.
> > 2) The global variable is //volatile//, so the hardware might changed its 
> > content- but this global is not volatile so this does not apply.
> > 
> > That being said, this load should have resulted in a //fresh// conjured 
> > symbolic value instead of //unknown//.
> > Could you please check if it did result in //unknown// before your patch, 
> > or you did introduce this behavior?
> I'm not sure I caught your thoughts.
> But I think the things is much simplier:
> `clang_analyzer_eval` can only produce `UNKNOWN` or `TRUE` or `FALSE`. If we 
> know the constraint of `glob_arr_no_init[2]` we return `TRUE` or `FALSE`, and 
> `UNKNOWN` otherwise.
> But in fact I should use `clang_analyzer_dump` here instead of 
> `clang_analyzer_eval`. This is actually my fault. I'll update this.
> Could you please check if it did result in unknown before your patch, or you 
> did introduce this behavior?

I've just checked it, it was `Unknown` before this patch as well. 
And actually, that is wrong because the array has static storage duration and 
as such, we know that it is initialized with zeros according to the C standard. 
But, that should be addressed in a follow-up patch (if someone has the 
capacity).
https://stackoverflow.com/questions/32708161/value-of-uninitialized-elements-in-array-of-c-language/32708288


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

https://reviews.llvm.org/D106681

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


[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D106681#3075337 , @steakhal wrote:

> I just wanted you to think about these cases.
> BTW this should work for **L1646**:
>
>   extern const int arr[]; // Incomplete array type
>   void top() {
> (void)arr[42];
>   }

Yes this will work for **L1646**. But I've already added similar tests for this 
line: `glob_array_index4` and `struct_arr_index1` functions in 
//initialization.cpp//. I mean it doesn't matter whether it is an incomplete or 
complete type.




Comment at: clang/test/Analysis/initialization.c:103
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}}
+}

steakhal wrote:
> I'm pretty sure we should not get `Unknown` for simply loading from a global 
> variable.
> That would imply that loading two times subsequently we could not prove that 
> the value remained the same.
> But that should remain the same, thus compare equal unless some other code 
> modifier that memory region.
> 
> That could happen for two reasons:
> 1) There is a racecondition, and another thread modified that location. But 
> that would be UB, so that could not happen.
> 2) The global variable is //volatile//, so the hardware might changed its 
> content- but this global is not volatile so this does not apply.
> 
> That being said, this load should have resulted in a //fresh// conjured 
> symbolic value instead of //unknown//.
> Could you please check if it did result in //unknown// before your patch, or 
> you did introduce this behavior?
I'm not sure I caught your thoughts.
But I think the things is much simplier:
`clang_analyzer_eval` can only produce `UNKNOWN` or `TRUE` or `FALSE`. If we 
know the constraint of `glob_arr_no_init[2]` we return `TRUE` or `FALSE`, and 
`UNKNOWN` otherwise.
But in fact I should use `clang_analyzer_dump` here instead of 
`clang_analyzer_eval`. This is actually my fault. I'll update this.


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

https://reviews.llvm.org/D106681

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


[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

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



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1649-1653
+  // NOTE: `VD` is always non-null if `Init` is non-null, so we can check for
+  // null only one of them.
+  const Expr *Init = VD->getAnyInitializer(VD);
   if (!Init)
 return None;

Wait. But if `VD` is null, you get a null-dereference.
But you already dereferenced `VD` multiple times, so it cannot be null.

Oh, but the `getAnyInitializer()` will overwrite it! That's a surprise.
TBH I would rather pass a fresh uninitialized pointer if you really need the 
exact decl which actually provided the initialized expression to make this 
behavior explicit.

That way, with a properly chosen name you could spare the NOTE comment as well.


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

https://reviews.llvm.org/D111542

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


[PATCH] D112102: [RISCV] Reduce the number of RISCV vector builtins by an order of magnitude.

2021-10-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 380982.
craig.topper added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112102

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmerge.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/vmerge-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vmerge-rv64.ll

Index: llvm/test/CodeGen/RISCV/rvv/vmerge-rv64.ll
===
--- llvm/test/CodeGen/RISCV/rvv/vmerge-rv64.ll
+++ llvm/test/CodeGen/RISCV/rvv/vmerge-rv64.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=riscv64 -mattr=+experimental-v,+d -verify-machineinstrs \
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v,+d,+experimental-zfh -verify-machineinstrs \
 ; RUN:   < %s | FileCheck %s
 declare  @llvm.riscv.vmerge.nxv1i8.nxv1i8(
   ,
@@ -1320,3 +1320,333 @@
 
   ret  %a
 }
+
+declare  @llvm.riscv.vmerge.nxv1f16.nxv1f16(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv1f16_nxv1f16_nxv1f16( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv1f16_nxv1f16_nxv1f16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e16, mf4, ta, mu
+; CHECK-NEXT:vmerge.vvm v8, v8, v9, v0
+; CHECK-NEXT:ret
+entry:
+  %a = call  @llvm.riscv.vmerge.nxv1f16.nxv1f16(
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vmerge.nxv2f16.nxv2f16(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv2f16_nxv2f16_nxv2f16( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv2f16_nxv2f16_nxv2f16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e16, mf2, ta, mu
+; CHECK-NEXT:vmerge.vvm v8, v8, v9, v0
+; CHECK-NEXT:ret
+entry:
+  %a = call  @llvm.riscv.vmerge.nxv2f16.nxv2f16(
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vmerge.nxv4f16.nxv4f16(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv4f16_nxv4f16_nxv4f16( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv4f16_nxv4f16_nxv4f16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e16, m1, ta, mu
+; CHECK-NEXT:vmerge.vvm v8, v8, v9, v0
+; CHECK-NEXT:ret
+entry:
+  %a = call  @llvm.riscv.vmerge.nxv4f16.nxv4f16(
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vmerge.nxv8f16.nxv8f16(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv8f16_nxv8f16_nxv8f16( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv8f16_nxv8f16_nxv8f16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e16, m2, ta, mu
+; CHECK-NEXT:vmerge.vvm v8, v8, v10, v0
+; CHECK-NEXT:ret
+entry:
+  %a = call  @llvm.riscv.vmerge.nxv8f16.nxv8f16(
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vmerge.nxv16f16.nxv16f16(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv16f16_nxv16f16_nxv16f16( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv16f16_nxv16f16_nxv16f16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e16, m4, ta, mu
+; CHECK-NEXT:vmerge.vvm v8, v8, v12, v0
+; CHECK-NEXT:ret
+entry:
+  %a = call  @llvm.riscv.vmerge.nxv16f16.nxv16f16(
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vmerge.nxv32f16.nxv32f16(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv32f16_nxv32f16_nxv32f16( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv32f16_nxv32f16_nxv32f16:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e16, m8, ta, mu
+; CHECK-NEXT:vmerge.vvm v8, v8, v16, v0
+; CHECK-NEXT:ret
+entry:
+  %a = call  @llvm.riscv.vmerge.nxv32f16.nxv32f16(
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vmerge.nxv1f32.nxv1f32(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv1f32_nxv1f32_nxv1f32( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv1f32_nxv1f32_nxv1f32:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e32, mf2, ta, mu
+; CHECK-NEXT:vmerge.vvm v8, v8, v9, v0
+; CHECK-NEXT:ret
+entry:
+  %a = call  @llvm.riscv.vmerge.nxv1f32.nxv1f32(
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vmerge.nxv2f32.nxv2f32(
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vmerge_vvm_nxv2f32_nxv2f32_nxv2f32( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vmerge_vvm_nxv2f32_nxv2f32_nxv2f32:
+; CHECK:   # 

[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-10-20 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

@dexonsmith Could you please commit this?


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

https://reviews.llvm.org/D110068

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


[PATCH] D112146: [WebAssembly] Add prototype relaxed float min max instructions

2021-10-20 Thread Ng Zhi An via Phabricator via cfe-commits
ngzhian created this revision.
ngzhian added a reviewer: tlively.
Herald added subscribers: ecnelises, sunfish, hiraditya, jgravelle-google, 
sbc100, dschuff.
ngzhian requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.
Herald added projects: clang, LLVM.

Add relaxed. f32x4.min, f32x4.max, f64x2.min, f64x2.max. These are only
exposed as builtins, and require user opt-in.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112146

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -806,4 +806,16 @@
 # CHECK: i8x16.relaxed_swizzle # encoding: [0xfd,0xa2,0x01]
 i8x16.relaxed_swizzle
 
+# CHECK: f32x4.relaxed_min # encoding: [0xfd,0xb4,0x01]
+f32x4.relaxed_min
+
+# CHECK: f32x4.relaxed_max # encoding: [0xfd,0xe2,0x01]
+f32x4.relaxed_max
+
+# CHECK: f64x2.relaxed_min # encoding: [0xfd,0xd4,0x01]
+f64x2.relaxed_min
+
+# CHECK: f64x2.relaxed_max # encoding: [0xfd,0xee,0x01]
+f64x2.relaxed_max
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -682,6 +682,30 @@
   ret <4 x float> %v
 }
 
+; CHECK-LABEL: relaxed_min_v4f32:
+; CHECK-NEXT: .functype relaxed_min_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.relaxed_min $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.relaxed.min.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @relaxed_min_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.relaxed.min.v4f32(
+<4 x float> %a, <4 x float> %b
+  )
+  ret <4 x float> %v
+}
+
+; CHECK-LABEL: relaxed_max_v4f32:
+; CHECK-NEXT: .functype relaxed_max_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.relaxed_max $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.relaxed.max.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @relaxed_max_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.relaxed.max.v4f32(
+<4 x float> %a, <4 x float> %b
+  )
+  ret <4 x float> %v
+}
+
 ; ==
 ; 2 x f64
 ; ==
@@ -780,3 +804,27 @@
   )
   ret <2 x double> %v
 }
+
+; CHECK-LABEL: relaxed_min_v2f64:
+; CHECK-NEXT: .functype relaxed_min_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.relaxed_min $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.relaxed.min.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @relaxed_min_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.relaxed.min.v2f64(
+<2 x double> %a, <2 x double> %b
+  )
+  ret <2 x double> %v
+}
+
+; CHECK-LABEL: relaxed_max_v2f64:
+; CHECK-NEXT: .functype relaxed_max_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.relaxed_max $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.relaxed.max.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @relaxed_max_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.relaxed.max.v2f64(
+<2 x double> %a, <2 x double> %b
+  )
+  ret <2 x double> %v
+}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1372,3 +1372,23 @@
  [(set (v16i8 V128:$dst),
(int_wasm_relaxed_swizzle (v16i8 V128:$src), (v16i8 V128:$mask)))],
  "i8x16.relaxed_swizzle\t$dst, $src, $mask", "i8x16.relaxed_swizzle", 162>;
+
+//===--===//
+// Relaxed floating-point min and max.
+//===--===//
+
+multiclass SIMD_RELAXED_FMINMAX simdopMin, bits<32> simdopMax> {
+  defm RELAXED_FMIN_#vec :
+RELAXED_I<(outs V128:$dst), (ins V128:$a, V128:$b), (outs), (ins),
+  [(set (vec.vt V128:$dst), (int_wasm_relaxed_min
+(vec.vt V128:$a), (vec.vt V128:$b)))],
+  vec.prefix#".relaxed_min\t$dst, $a, $b", vec.prefix#".relaxed_min", 

[PATCH] D112102: [RISCV] Reduce the number of RISCV vector builtins by an order of magnitude.

2021-10-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D112102#3074656 , @frasercrmck 
wrote:

> Minor typo in the description: `differnet`
>
> Does this help with compile times, binary sizes, etc?

This reduces the clang binary size by 2.34 megabytes according to my local 
release+asserts build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112102

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


[PATCH] D112096: [clang] Add plugin ActionType to run command line plugin before main action

2021-10-20 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe66433fe119: [clang] Add plugin ActionType to run command 
line plugin before main action (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112096

Files:
  clang/examples/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PluginsOrder/PluginsOrder.cpp
  clang/include/clang/Frontend/FrontendAction.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/CMakeLists.txt
  clang/test/Frontend/plugins-order.c

Index: clang/test/Frontend/plugins-order.c
===
--- /dev/null
+++ clang/test/Frontend/plugins-order.c
@@ -0,0 +1,12 @@
+// REQUIRES: plugins, examples
+
+// RUN: %clang_cc1 -load %llvmshlibdir/PluginsOrder%pluginext %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// ALWAYS: always-before
+// ALWAYS-NEXT: always-after
+
+// RUN: %clang_cc1 -load %llvmshlibdir/PluginsOrder%pluginext %s -add-plugin cmd-after -add-plugin cmd-before 2>&1 | FileCheck %s --check-prefix=ALL
+// RUN: %clang_cc1 -load %llvmshlibdir/PluginsOrder%pluginext %s -add-plugin cmd-before -add-plugin cmd-after 2>&1 | FileCheck %s --check-prefix=ALL
+// ALL: cmd-before
+// ALL-NEXT: always-before
+// ALL-NEXT: cmd-after
+// ALL-NEXT: always-after
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -97,6 +97,7 @@
 AnnotateFunctions
 CallSuperAttr
 clang-interpreter
+PluginsOrder
 PrintFunctionNames
 )
 endif ()
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -79,7 +79,7 @@
   if (Plugin.getName() == CI.getFrontendOpts().ActionName) {
 std::unique_ptr P(Plugin.instantiate());
 if ((P->getActionType() != PluginASTAction::ReplaceAction &&
- P->getActionType() != PluginASTAction::Cmdline) ||
+ P->getActionType() != PluginASTAction::CmdlineAfterMainAction) ||
 !P->ParseArgs(
 CI,
 CI.getFrontendOpts().PluginArgs[std::string(Plugin.getName())]))
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -187,14 +187,19 @@
FrontendPluginRegistry::entries()) {
 std::unique_ptr P = Plugin.instantiate();
 PluginASTAction::ActionType ActionType = P->getActionType();
-if (ActionType == PluginASTAction::Cmdline) {
+if (ActionType == PluginASTAction::CmdlineAfterMainAction ||
+ActionType == PluginASTAction::CmdlineBeforeMainAction) {
   // This is O(|plugins| * |add_plugins|), but since both numbers are
   // way below 50 in practice, that's ok.
   if (llvm::any_of(CI.getFrontendOpts().AddPluginActions,
[&](const std::string ) {
  return PluginAction == Plugin.getName();
-   }))
-ActionType = PluginASTAction::AddAfterMainAction;
+   })) {
+if (ActionType == PluginASTAction::CmdlineBeforeMainAction)
+  ActionType = PluginASTAction::AddBeforeMainAction;
+else
+  ActionType = PluginASTAction::AddAfterMainAction;
+  }
 }
 if ((ActionType == PluginASTAction::AddBeforeMainAction ||
  ActionType == PluginASTAction::AddAfterMainAction) &&
Index: clang/include/clang/Frontend/FrontendAction.h
===
--- clang/include/clang/Frontend/FrontendAction.h
+++ clang/include/clang/Frontend/FrontendAction.h
@@ -270,17 +270,18 @@
  const std::vector ) = 0;
 
   enum ActionType {
-Cmdline, ///< Action is determined by the cc1 command-line
-ReplaceAction,   ///< Replace the main action
-AddBeforeMainAction, ///< Execute the action before the main action
-AddAfterMainAction   ///< Execute the action after the main action
+CmdlineBeforeMainAction, ///< Execute the action before the main action if
+ ///< on the command line
+CmdlineAfterMainAction,  ///< Execute the action after the main action if on
+ ///< the command line
+ReplaceAction,   ///< Replace the main action
+AddBeforeMainAction, ///< Execute the action before the main action
+AddAfterMainAction   ///< Execute the action after the main action
   };
   /// Get the action type for this plugin
   ///
-  /// \return The action type. If the 

[clang] fe66433 - [clang] Add plugin ActionType to run command line plugin before main action

2021-10-20 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-20T08:58:20-07:00
New Revision: fe66433fe119819a033827610f7eae4cdd8b1470

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

LOG: [clang] Add plugin ActionType to run command line plugin before main action

Currently we have a way to run a plugin if specified on the command line
after the main action, and ways to unconditionally run the plugin before
or after the main action, but no way to run a plugin if specified on the
command line before the main action.

This introduces the missing option.

This is helpful because -clear-ast-before-backend clears the AST before
codegen, while some plugins may want access to the AST.

Reviewed By: dblaikie

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

Added: 
clang/examples/PluginsOrder/CMakeLists.txt
clang/examples/PluginsOrder/PluginsOrder.cpp
clang/test/Frontend/plugins-order.c

Modified: 
clang/examples/CMakeLists.txt
clang/include/clang/Frontend/FrontendAction.h
clang/lib/Frontend/FrontendAction.cpp
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/test/CMakeLists.txt

Removed: 




diff  --git a/clang/examples/CMakeLists.txt b/clang/examples/CMakeLists.txt
index 300d8d795c674..684d81d180278 100644
--- a/clang/examples/CMakeLists.txt
+++ b/clang/examples/CMakeLists.txt
@@ -8,3 +8,4 @@ add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
 add_subdirectory(Attribute)
 add_subdirectory(CallSuperAttribute)
+add_subdirectory(PluginsOrder)

diff  --git a/clang/examples/PluginsOrder/CMakeLists.txt 
b/clang/examples/PluginsOrder/CMakeLists.txt
new file mode 100644
index 0..289e234ac28c4
--- /dev/null
+++ b/clang/examples/PluginsOrder/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+  clang_target_link_libraries(PluginsOrder PRIVATE
+clangAST
+clangFrontend
+)
+endif()

diff  --git a/clang/examples/PluginsOrder/PluginsOrder.cpp 
b/clang/examples/PluginsOrder/PluginsOrder.cpp
new file mode 100644
index 0..e25ab7aceca85
--- /dev/null
+++ b/clang/examples/PluginsOrder/PluginsOrder.cpp
@@ -0,0 +1,117 @@
+//===- PluginsOrder.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/Frontend/FrontendPluginRegistry.h"
+using namespace clang;
+
+namespace {
+
+class AlwaysBeforeConsumer : public ASTConsumer {
+public:
+  void HandleTranslationUnit(ASTContext &) override {
+llvm::errs() << "always-before\n";
+  }
+};
+
+class AlwaysBeforeAction : public PluginASTAction {
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return std::make_unique();
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+return true;
+  }
+
+  PluginASTAction::ActionType getActionType() override {
+return AddBeforeMainAction;
+  }
+};
+
+class AlwaysAfterConsumer : public ASTConsumer {
+public:
+  void HandleTranslationUnit(ASTContext &) override {
+llvm::errs() << "always-after\n";
+  }
+};
+
+class AlwaysAfterAction : public PluginASTAction {
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return std::make_unique();
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+return true;
+  }
+
+  PluginASTAction::ActionType getActionType() override {
+return AddAfterMainAction;
+  }
+};
+
+class CmdAfterConsumer : public ASTConsumer {
+public:
+  void HandleTranslationUnit(ASTContext &) override {
+llvm::errs() << "cmd-after\n";
+  }
+};
+
+class CmdAfterAction : public PluginASTAction {
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return std::make_unique();
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+return true;
+  }
+
+  PluginASTAction::ActionType getActionType() override {
+return CmdlineAfterMainAction;
+  }
+};
+
+class CmdBeforeConsumer : public ASTConsumer {
+public:
+  void HandleTranslationUnit(ASTContext &) override {
+

[PATCH] D111566: [SYCL] Fix function pointer address space

2021-10-20 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

@vlastik, your commit fixes function pointers on AVR - 
https://github.com/llvm/llvm-project/commit/57fd86de879cf2b4c7001b6d0a09df60877ce24d.
 I suppose this change is required for fixing lvalue references to function 
pointers on AVR as well. Right?


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

https://reviews.llvm.org/D111566

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


[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

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



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:149
+
+RangeSet RangeSet::Factory::unite(RangeSet Original, llvm::APSInt Point) {
+  return unite(Original, Range(ValueFactory.getValue(Point)));

martong wrote:
> ASDenysPetrov wrote:
> > steakhal wrote:
> > > Why do you take `APSInt`s by value? Generally, we take them by reference.
> > I want to send a message to the caller that he can pass an arbitrary 
> > **APSInt** without warrying about making it permanent (aka stored by the 
> > Factory). But we can revise this contract and carry this responsibility to 
> > a caller.
> > Why do you take `APSInt`s by value? Generally, we take them by reference.
> 
> Actually, it is specific to `BasicValueFactory` to cache the `APSInt`s, 
> however, it might not be the best practice. I doubt that somebody has ever 
> measured the performance of passing APSInts by value, so my guess is the 
> caching of `APSInt`s might be an early optimization that might be more 
> harmful than advantageous. On top of all this, we do the caching 
> inconsistently, just consider the member functions of `APSIntType`, they all 
> return by value.
> 
> Perhaps (totally independently from this patch of course), it might be worth 
> to have a measurement/comparison with removed cache and pass by value.
> 
Okay, then we shall leave this as-is now.



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:81
   const llvm::APSInt (BaseType X) {
-llvm::APSInt Dummy = Base;
-Dummy = X;
-return BVF.getValue(Dummy);
+static llvm::APSInt Base{sizeof(BaseType) * 8,
+ std::is_unsigned::value};

ASDenysPetrov wrote:
> steakhal wrote:
> > Shouldn't you use `sizeof(BaseType) * CHAR_BIT` instead?
> Agree. It's better to avoid magic numbers. I'll fix.
It's not only that but just imagine testing a clang on a special hardware where 
they have let's say 9 bit bytes, for parity or something similar stuff.
The test would suddenly break.
Although I suspect there would be many more things to break TBH xD


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

https://reviews.llvm.org/D99797

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


[PATCH] D112020: [RISCV] Use clang_builtin_alias for all RISCV vector intrinsics.

2021-10-20 Thread Craig Topper via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa29dfc089d18: [RISCV] Use clang_builtin_alias for all RISCV 
vector intrinsics. (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D112020?vs=380474=380976#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112020

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -198,7 +198,7 @@
   void emitCodeGenSwitchBody(raw_ostream ) const;
 
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
-  void emitIntrinsicMacro(raw_ostream ) const;
+  void emitIntrinsicFuncDef(raw_ostream ) const;
 
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream ) const;
@@ -855,34 +855,30 @@
   OS << "  break;\n";
 }
 
-void RVVIntrinsic::emitIntrinsicMacro(raw_ostream ) const {
-  OS << "#define " << getName() << "(";
-  if (!InputTypes.empty()) {
-ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "op" << i;
-  }
-  OS << ") \\\n";
-  OS << "__builtin_rvv_" << getName() << "(";
+void RVVIntrinsic::emitIntrinsicFuncDef(raw_ostream ) const {
+  OS << "__attribute__((__clang_builtin_alias__(";
+  OS << "__builtin_rvv_" << getName() << ")))\n";
+  OS << OutputType->getTypeStr() << " " << getName() << "(";
+  // Emit function arguments
   if (!InputTypes.empty()) {
 ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "(" << InputTypes[i]->getTypeStr() << ")(op" << i << ")";
+for (unsigned i = 0; i < InputTypes.size(); ++i)
+  OS << LS << InputTypes[i]->getTypeStr();
   }
-  OS << ")\n";
+  OS << ");\n";
 }
 
 void RVVIntrinsic::emitMangledFuncDef(raw_ostream ) const {
-  OS << "__attribute__((clang_builtin_alias(";
+  OS << "__attribute__((__clang_builtin_alias__(";
   OS << "__builtin_rvv_" << getName() << ")))\n";
   OS << OutputType->getTypeStr() << " " << getMangledName() << "(";
   // Emit function arguments
   if (!InputTypes.empty()) {
 ListSeparator LS;
 for (unsigned i = 0; i < InputTypes.size(); ++i)
-  OS << LS << InputTypes[i]->getTypeStr() << " op" << i;
+  OS << LS << InputTypes[i]->getTypeStr();
   }
-  OS << ");\n\n";
+  OS << ");\n";
 }
 
 
//===--===//
@@ -980,24 +976,32 @@
 return A->getRISCVExtensions() < B->getRISCVExtensions();
   });
 
+  OS << "#define __rvv_ai static __inline__ "
+"__attribute__((__always_inline__, __nodebug__))\n";
+
   // Print intrinsic functions with macro
   emitArchMacroAndBody(Defs, OS, [](raw_ostream , const RVVIntrinsic ) 
{
-Inst.emitIntrinsicMacro(OS);
+OS << "__rvv_ai ";
+Inst.emitIntrinsicFuncDef(OS);
   });
 
+  OS << "#undef __rvv_ai\n\n";
+
   OS << "#define __riscv_v_intrinsic_overloading 1\n";
 
   // Print Overloaded APIs
-  OS << "#define __rvv_overloaded static inline "
+  OS << "#define __rvv_aio static __inline__ "
 "__attribute__((__always_inline__, __nodebug__, __overloadable__))\n";
 
   emitArchMacroAndBody(Defs, OS, [](raw_ostream , const RVVIntrinsic ) 
{
 if (!Inst.isMask() && !Inst.hasNoMaskedOverloaded())
   return;
-OS << "__rvv_overloaded ";
+OS << "__rvv_aio ";
 Inst.emitMangledFuncDef(OS);
   });
 
+  OS << "#undef __rvv_aio\n";
+
   OS << "\n#ifdef __cplusplus\n";
   OS << "}\n";
   OS << "#endif // __cplusplus\n";


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -198,7 +198,7 @@
   void emitCodeGenSwitchBody(raw_ostream ) const;
 
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
-  void emitIntrinsicMacro(raw_ostream ) const;
+  void emitIntrinsicFuncDef(raw_ostream ) const;
 
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream ) const;
@@ -855,34 +855,30 @@
   OS << "  break;\n";
 }
 
-void RVVIntrinsic::emitIntrinsicMacro(raw_ostream ) const {
-  OS << "#define " << getName() << "(";
-  if (!InputTypes.empty()) {
-ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "op" << i;
-  }
-  OS << ") \\\n";
-  OS << "__builtin_rvv_" << getName() << "(";
+void RVVIntrinsic::emitIntrinsicFuncDef(raw_ostream ) const {
+  OS << "__attribute__((__clang_builtin_alias__(";
+  OS << "__builtin_rvv_" << getName() << ")))\n";
+  OS << OutputType->getTypeStr() << " " << getName() << "(";
+  // Emit function arguments
   if (!InputTypes.empty()) {

[clang] a29dfc0 - [RISCV] Use clang_builtin_alias for all RISCV vector intrinsics.

2021-10-20 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-10-20T08:50:42-07:00
New Revision: a29dfc089d18b542694cd26a06bee822ab90fb56

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

LOG: [RISCV] Use clang_builtin_alias for all RISCV vector intrinsics.

Previously we used builtin_alias for overloaded intrinsics, but
macros for the non-overloaded version. This patch changes the
non-overloaded versions to also use builtin_alias, but without
the overloadable attribute.

Reviewed By: khchen, HsiangKai

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

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 6c6ae0ebbdc96..b4fa0e2884705 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -198,7 +198,7 @@ class RVVIntrinsic {
   void emitCodeGenSwitchBody(raw_ostream ) const;
 
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
-  void emitIntrinsicMacro(raw_ostream ) const;
+  void emitIntrinsicFuncDef(raw_ostream ) const;
 
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream ) const;
@@ -855,34 +855,30 @@ void RVVIntrinsic::emitCodeGenSwitchBody(raw_ostream ) 
const {
   OS << "  break;\n";
 }
 
-void RVVIntrinsic::emitIntrinsicMacro(raw_ostream ) const {
-  OS << "#define " << getName() << "(";
-  if (!InputTypes.empty()) {
-ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "op" << i;
-  }
-  OS << ") \\\n";
-  OS << "__builtin_rvv_" << getName() << "(";
+void RVVIntrinsic::emitIntrinsicFuncDef(raw_ostream ) const {
+  OS << "__attribute__((__clang_builtin_alias__(";
+  OS << "__builtin_rvv_" << getName() << ")))\n";
+  OS << OutputType->getTypeStr() << " " << getName() << "(";
+  // Emit function arguments
   if (!InputTypes.empty()) {
 ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "(" << InputTypes[i]->getTypeStr() << ")(op" << i << ")";
+for (unsigned i = 0; i < InputTypes.size(); ++i)
+  OS << LS << InputTypes[i]->getTypeStr();
   }
-  OS << ")\n";
+  OS << ");\n";
 }
 
 void RVVIntrinsic::emitMangledFuncDef(raw_ostream ) const {
-  OS << "__attribute__((clang_builtin_alias(";
+  OS << "__attribute__((__clang_builtin_alias__(";
   OS << "__builtin_rvv_" << getName() << ")))\n";
   OS << OutputType->getTypeStr() << " " << getMangledName() << "(";
   // Emit function arguments
   if (!InputTypes.empty()) {
 ListSeparator LS;
 for (unsigned i = 0; i < InputTypes.size(); ++i)
-  OS << LS << InputTypes[i]->getTypeStr() << " op" << i;
+  OS << LS << InputTypes[i]->getTypeStr();
   }
-  OS << ");\n\n";
+  OS << ");\n";
 }
 
 
//===--===//
@@ -980,24 +976,32 @@ void RVVEmitter::createHeader(raw_ostream ) {
 return A->getRISCVExtensions() < B->getRISCVExtensions();
   });
 
+  OS << "#define __rvv_ai static __inline__ "
+"__attribute__((__always_inline__, __nodebug__))\n";
+
   // Print intrinsic functions with macro
   emitArchMacroAndBody(Defs, OS, [](raw_ostream , const RVVIntrinsic ) 
{
-Inst.emitIntrinsicMacro(OS);
+OS << "__rvv_ai ";
+Inst.emitIntrinsicFuncDef(OS);
   });
 
+  OS << "#undef __rvv_ai\n\n";
+
   OS << "#define __riscv_v_intrinsic_overloading 1\n";
 
   // Print Overloaded APIs
-  OS << "#define __rvv_overloaded static inline "
+  OS << "#define __rvv_aio static __inline__ "
 "__attribute__((__always_inline__, __nodebug__, __overloadable__))\n";
 
   emitArchMacroAndBody(Defs, OS, [](raw_ostream , const RVVIntrinsic ) 
{
 if (!Inst.isMask() && !Inst.hasNoMaskedOverloaded())
   return;
-OS << "__rvv_overloaded ";
+OS << "__rvv_aio ";
 Inst.emitMangledFuncDef(OS);
   });
 
+  OS << "#undef __rvv_aio\n";
+
   OS << "\n#ifdef __cplusplus\n";
   OS << "}\n";
   OS << "#endif // __cplusplus\n";



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


[PATCH] D111982: [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer

2021-10-20 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG16be17ad4b13: [analyzer][NFC] Refactor llvm::isa 
usages in the StaticAnalyzer (authored by steakhal).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D111982?vs=380329=380972#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111982

Files:
  clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
  clang/lib/StaticAnalyzer/Core/Environment.cpp
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/lib/StaticAnalyzer/Core/LoopWidening.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -425,19 +425,7 @@
   // tell if anything still refers to this region. Unlike SymbolicRegions,
   // AllocaRegions don't have associated symbols, though, so we don't actually
   // have a way to track their liveness.
-  if (isa(MR))
-return true;
-
-  if (isa(MR))
-return true;
-
-  if (isa(MR))
-return true;
-
-  if (isa(MR))
-return true;
-
-  return false;
+  return isa(MR);
 }
 
 bool SymbolReaper::isLive(SymbolRef sym) {
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -84,7 +84,7 @@
 // involved.  Blocks can be casted to/from 'id', as they can be treated
 // as Objective-C objects.  This could possibly be handled by enhancing
 // our reasoning of downcasts of symbolic objects.
-if (isa(R) || isa(R))
+if (isa(R))
   return R;
 
 // We don't know what to make of it.  Return a NULL region, which
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -254,8 +254,7 @@
 }
 
 DefinedSVal SValBuilder::getMemberPointer(const NamedDecl *ND) {
-  assert(!ND || isa(ND) || isa(ND) ||
- isa(ND));
+  assert(!ND || (isa(ND)));
 
   if (const auto *MD = dyn_cast_or_null(ND)) {
 // Sema treats pointers to static member functions as have function pointer
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -62,8 +62,8 @@
 : P(r, k), Data(offset) {
 assert(r && "Must have known regions.");
 assert(getOffset() == offset && "Failed to store offset");
-assert((r == r->getBaseRegion() || isa(r) ||
-isa (r)) &&
+assert((r == r->getBaseRegion() ||
+isa(r)) &&
"Not a base");
   }
 public:
@@ -1135,7 +1135,7 @@
   if (Regions)
 Regions->push_back(baseR);
 
-  if (isa(baseR) || isa(baseR)) {
+  if (isa(baseR)) {
 // Invalidate the region by setting its default value to
 // conjured symbol. The type of the symbol is irrelevant.
 DefinedOrUnknownSVal V =
@@ -1224,7 +1224,7 @@
   // detection.
   SVal V = I.getData();
   const MemRegion *R = V.getAsRegion();
-  if (R && isa(R))
+  if (isa_and_nonnull(R))
 VisitBinding(V);
 }
   }
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1012,14 +1012,15 @@
   sReg = getUnknownRegion();
 } else {
   if (D->hasLocalStorage()) {
-sReg = isa(D) || isa(D)
-   ? static_cast(getStackArgumentsRegion(STC))
-   : static_cast(getStackLocalsRegion(STC));
+ 

[PATCH] D111566: [SYCL] Fix function pointer address space

2021-10-20 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

ping


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

https://reviews.llvm.org/D111566

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


[clang] 16be17a - [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer

2021-10-20 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-10-20T17:43:31+02:00
New Revision: 16be17ad4b13deb23c893c3c668076e70b07f289

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

LOG: [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer

It turns out llvm::isa<> is variadic, and we could have used this at a
lot of places.

The following patterns:
  x && isa(x) || isa(x) ...
Will be replaced by:
  isa_and_non_null(x)

Sometimes it caused further simplifications, when it would cause even
more code smell.

Aside from this, keep in mind that within `assert()` or any macro
functions, we need to wrap the isa<> expression within a parenthesis,
due to the parsing of the comma.

Reviewed By: martong

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
clang/lib/StaticAnalyzer/Core/Environment.cpp
clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
clang/lib/StaticAnalyzer/Core/LoopWidening.cpp
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/lib/StaticAnalyzer/Core/Store.cpp
clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
index c06604b6cffef..6154eeb3419c0 100644
--- a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
@@ -93,11 +93,10 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph 
,
   if (!Loc.isValid())
 return;
 
-  if (isa(D) || isa(D)) {
+  if (isa(D)) {
 const NamedDecl *ND = cast(D);
 output << *ND;
-  }
-  else if (isa(D)) {
+  } else if (isa(D)) {
 output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn();
   }
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
index a157ee2da5df4..635eb00e4ca95 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
@@ -160,7 +160,7 @@ static bool isEnclosingFunctionParam(const Expr *E) {
   E = E->IgnoreParenCasts();
   if (const DeclRefExpr *DRE = dyn_cast(E)) {
 const ValueDecl *VD = DRE->getDecl();
-if (isa(VD) || isa(VD))
+if (isa(VD))
   return true;
   }
   return false;
@@ -199,8 +199,7 @@ unsigned 
MacOSKeychainAPIChecker::getTrackedFunctionIndex(StringRef Name,
 static bool isBadDeallocationArgument(const MemRegion *Arg) {
   if (!Arg)
 return false;
-  return isa(Arg) || isa(Arg) ||
- isa(Arg);
+  return isa(Arg);
 }
 
 /// Given the address expression, retrieve the value it's pointing to. Assume

diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index f6b5ba098849f..5db4c72515dc5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -936,7 +936,7 @@ class MallocBugVisitor final : public BugReporterVisitor {
   /// Did not track -> allocated. Other state (released) -> allocated.
   static inline bool isAllocated(const RefState *RSCurr, const RefState 
*RSPrev,
  const Stmt *Stmt) {
-return (Stmt && (isa(Stmt) || isa(Stmt)) &&
+return (isa_and_nonnull(Stmt) &&
 (RSCurr &&
  (RSCurr->isAllocated() || RSCurr->isAllocatedOfSizeZero())) &&
 (!RSPrev ||
@@ -949,8 +949,7 @@ class MallocBugVisitor final : public BugReporterVisitor {
 const Stmt *Stmt) {
 bool IsReleased =
 (RSCurr && RSCurr->isReleased()) && (!RSPrev || !RSPrev->isReleased());
-assert(!IsReleased ||
-   (Stmt && (isa(Stmt) || isa(Stmt))) ||
+assert(!IsReleased || (isa_and_nonnull(Stmt)) ||

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D106681#3074779 , @ASDenysPetrov 
wrote:

> In D106681#3074678 , @steakhal 
> wrote:
>
>> I think it's fine, maybe `NFCi` is would be slightly more accurate, while 
>> stating the minor behavior change and the reason for doing so in the patch 
>> summary could further improve the visibility of this issue.
>>
>> That being said, since it actually changes some behavior, I'd like to 
>> request some tests covering the following (uncovered lines):
>> L1646, L1689, L1699
>
> For **L1646** currently I'm not sure about the exact test, since it is a 
> heritage of the old code, so it just jumped here from the past. If you could 
> give an example I would appreciate this.
> For **L1689** I'll add it.
> For **L1699** I've added //TODO// cases in D104285 
> .

I just wanted you to think about these cases.
BTW this should work for **L1646**:

  extern const int arr[]; // Incomplete array type
  void top() {
(void)arr[42];
  }

And I'm okay with the rest of the uncovered lines.




Comment at: clang/test/Analysis/initialization.c:103
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}}
+}

I'm pretty sure we should not get `Unknown` for simply loading from a global 
variable.
That would imply that loading two times subsequently we could not prove that 
the value remained the same.
But that should remain the same, thus compare equal unless some other code 
modifier that memory region.

That could happen for two reasons:
1) There is a racecondition, and another thread modified that location. But 
that would be UB, so that could not happen.
2) The global variable is //volatile//, so the hardware might changed its 
content- but this global is not volatile so this does not apply.

That being said, this load should have resulted in a //fresh// conjured 
symbolic value instead of //unknown//.
Could you please check if it did result in //unknown// before your patch, or 
you did introduce this behavior?


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

https://reviews.llvm.org/D106681

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


[PATCH] D112143: [X86][ABI] Do not return float/double from x87 registers when x87 is disabled

2021-10-20 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei created this revision.
pengfei added reviewers: aturetsk, echristo, RKSimon, LuoYuanke, craig.topper.
Herald added subscribers: dang, hiraditya.
pengfei requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This is aligned with GCC's behavior.
Also, alias `-mno-fp-ret-in-387` to `-mno-x87`, by which we can fix pr51498.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112143

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86CallingConv.td
  llvm/test/CodeGen/X86/no-x87.ll


Index: llvm/test/CodeGen/X86/no-x87.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/no-x87.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s -check-prefix=X87
+; RUN: llc < %s -mtriple=i686-- -mattr=-x87 | FileCheck %s -check-prefix=NOX87
+
+define float @foo(float %a, float %b) nounwind {
+; X87-LABEL: foo:
+; X87:   # %bb.0: # %entry
+; X87-NEXT:flds {{[0-9]+}}(%esp)
+; X87-NEXT:retl
+;
+; NOX87-LABEL: foo:
+; NOX87:   # %bb.0: # %entry
+; NOX87-NEXT:movl {{[0-9]+}}(%esp), %eax
+; NOX87-NEXT:retl
+entry:
+  ret float %b
+}
Index: llvm/lib/Target/X86/X86CallingConv.td
===
--- llvm/lib/Target/X86/X86CallingConv.td
+++ llvm/lib/Target/X86/X86CallingConv.td
@@ -273,6 +273,10 @@
   // conv.
   CCIfInReg>>>,
+  CCIfNotSubtarget<"hasX87()",
+CCIfType<[f32], CCAssignToReg<[AX, DX, CX]>>>,
+  CCIfNotSubtarget<"hasX87()",
+CCIfType<[f64], CCAssignToReg<[EAX, EDX, ECX]>>>,
   CCIfType<[f32,f64], CCAssignToReg<[FP0, FP1]>>,
   CCIfType<[f16], CCAssignToReg<[XMM0,XMM1,XMM2]>>,
   CCDelegateTo
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -2,6 +2,7 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-x87 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -m80387 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=X87 %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-80387 %s -### 
-o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-fp-ret-in-387 
%s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
 // X87: "-target-feature" "+x87"
 // NO-X87: "-target-feature" "-x87"
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4166,6 +4166,7 @@
 def mno_x87 : Flag<["-"], "mno-x87">, Group;
 def m80387 : Flag<["-"], "m80387">, Alias;
 def mno_80387 : Flag<["-"], "mno-80387">, Alias;
+def mno_fp_ret_in_387 : Flag<["-"], "mno-fp-ret-in-387">, Alias;
 def mmmx : Flag<["-"], "mmmx">, Group;
 def mno_mmx : Flag<["-"], "mno-mmx">, Group;
 def m3dnow : Flag<["-"], "m3dnow">, Group;


Index: llvm/test/CodeGen/X86/no-x87.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/no-x87.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s -check-prefix=X87
+; RUN: llc < %s -mtriple=i686-- -mattr=-x87 | FileCheck %s -check-prefix=NOX87
+
+define float @foo(float %a, float %b) nounwind {
+; X87-LABEL: foo:
+; X87:   # %bb.0: # %entry
+; X87-NEXT:flds {{[0-9]+}}(%esp)
+; X87-NEXT:retl
+;
+; NOX87-LABEL: foo:
+; NOX87:   # %bb.0: # %entry
+; NOX87-NEXT:movl {{[0-9]+}}(%esp), %eax
+; NOX87-NEXT:retl
+entry:
+  ret float %b
+}
Index: llvm/lib/Target/X86/X86CallingConv.td
===
--- llvm/lib/Target/X86/X86CallingConv.td
+++ llvm/lib/Target/X86/X86CallingConv.td
@@ -273,6 +273,10 @@
   // conv.
   CCIfInReg>>>,
+  CCIfNotSubtarget<"hasX87()",
+CCIfType<[f32], CCAssignToReg<[AX, DX, CX]>>>,
+  CCIfNotSubtarget<"hasX87()",
+CCIfType<[f64], CCAssignToReg<[EAX, EDX, ECX]>>>,
   CCIfType<[f32,f64], CCAssignToReg<[FP0, FP1]>>,
   CCIfType<[f16], CCAssignToReg<[XMM0,XMM1,XMM2]>>,
   CCDelegateTo
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -2,6 +2,7 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-x87 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -m80387 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=X87 %s
 // RUN: %clang -target 

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Why does `glob_invalid_index7()` and `glob_invalid_index8()` differ in behavior?
I would expect that the analyzer produces the same `Loc` symbolic value for 
both cases thus, the array access should result in the same behavior regardless 
if `glob_arr6` is used, or acquired a pointer and using that in a subsequent 
operation.
Could you elaborate on this?




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1642
+  //
+  // Previous check for `Idx < 0` guarantee that `Idx` is non-negative.
+  const auto I = static_cast(Idx.getExtValue());

Instead of this comment, you can put an `assert(Idx.isStrictlyPositive())` here.


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

https://reviews.llvm.org/D107339

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


[PATCH] D112013: [clang][ASTImporter] Fix for importing functions with EST_Unevaluated prototype.

2021-10-20 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks! The fix makes sense and looks good to me. Though, it would be nice if 
you could provide a test without the hand crafting of the setTypeSourceInfo, 
but I think that could be done in a follow-up patch.




Comment at: clang/unittests/AST/ASTImporterTest.cpp:6180
+  ASSERT_FALSE(FromCtor->getTypeSourceInfo());
+  // Set a TypeSourceInfo for the function, this state may occur in reality.
+  TypeSourceInfo *FromTSI = FromTU->getASTContext().getTrivialTypeSourceInfo(

shafik wrote:
> balazske wrote:
> > shafik wrote:
> > > steakhal wrote:
> > > > Perhaps, put here a `FIXME` to replace this with a real-world scenario.
> > > I think it is useful to have cases that we run into in practice as a 
> > > regression test but it would be nice to see a more general test as well.
> > What means a "more general test"? Code where the `setTypeSourceInfo` is not 
> > needed? I just could not find out why there is no TypeSourceInfo set. The 
> > involved code part looks like this (comes from Bitcoin):
> > ```
> > void 
> > RegisterSharedValidationInterface(std::shared_ptr 
> > pwalletIn) {
> > // Each connection captures pwalletIn to ensure that each callback is
> > // executed before pwalletIn is destroyed. For more details see #18338.
> > g_signals.m_internals->Register(std::move(pwalletIn));
> > }
> > 
> > void RegisterValidationInterface(CValidationInterface* callbacks)
> > {
> > // Create a shared_ptr with a no-op deleter - CValidationInterface 
> > lifecycle
> > // is managed by the caller.
> > RegisterSharedValidationInterface({callbacks, 
> > [](CValidationInterface*){}});
> > //^ This is the lambda to 
> > be imported.
> > }
> > ```
> > If the same code is used in the test and a simple `CValidationInterface` 
> > and `std::shared_ptr` with appropriate constructor is added there is still 
> > no `TypeSourceInfo` in the needed place.
> Yeah, that is what I meant, a test that did not require the 
> `setTypeSourceInfo` hand crafting.
On one hand, I think this is a through and precisely written test case and we 
had similar test cases before. On the other hand, I agree it is unfortunate 
that we have to change the AST in the test setup.
@balazske Perhaps creduce-ing the to be imported TU with the bitcoin case could 
provide a reduced case that does not require the hand crafting of the 
`setTypeSourceInfo` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112013

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


[clang] 0abb5d2 - [Sema, StaticAnalyzer] Use StringRef::contains (NFC)

2021-10-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-20T08:02:36-07:00
New Revision: 0abb5d293cf7289780542fd9c5f0d84e5aadbdc8

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

LOG: [Sema, StaticAnalyzer] Use StringRef::contains (NFC)

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 1ea9b9e58d4a..a7a48016fe1e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -9773,8 +9773,7 @@ static void CheckFormatString(Sema , const 
FormatStringLiteral *FExpr,
 
   // Emit a warning if the string literal is truncated and does not contain an
   // embedded null character.
-  if (TypeSize <= StrRef.size() &&
-  StrRef.substr(0, TypeSize).find('\0') == StringRef::npos) {
+  if (TypeSize <= StrRef.size() && !StrRef.substr(0, TypeSize).contains('\0')) 
{
 CheckFormatHandler::EmitFormatDiagnostic(
 S, inFunctionCall, Args[format_idx],
 S.PDiag(diag::warn_printf_format_string_not_null_terminated),

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c6c35c6e0cee..5b9568c1ed95 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3213,13 +3213,13 @@ static void handleCodeSegAttr(Sema , Decl *D, const 
ParsedAttr ) {
 bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
   enum FirstParam { Unsupported, Duplicate, Unknown };
   enum SecondParam { None, Architecture, Tune };
-  if (AttrStr.find("fpmath=") != StringRef::npos)
+  if (AttrStr.contains("fpmath="))
 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
<< Unsupported << None << "fpmath=";
 
   // Diagnose use of tune if target doesn't support it.
   if (!Context.getTargetInfo().supportsTargetAttributeTune() &&
-  AttrStr.find("tune=") != StringRef::npos)
+  AttrStr.contains("tune="))
 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
<< Unsupported << None << "tune=";
 
@@ -7570,7 +7570,7 @@ static void handleOpenCLAccessAttr(Sema , Decl *D, 
const ParsedAttr ) {
   // C++ for OpenCL 2021 inherits rule from OpenCL C v3.0.
   if (const auto *PDecl = dyn_cast(D)) {
 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
-if (AL.getAttrName()->getName().find("read_write") != StringRef::npos) {
+if (AL.getAttrName()->getName().contains("read_write")) {
   bool ReadWriteImagesUnsupported =
   (S.getLangOpts().getOpenCLCompatibleVersion() < 200) ||
   (S.getLangOpts().getOpenCLCompatibleVersion() == 300 &&

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 04f8540fe3b1..2109ff25fe7a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -12434,8 +12434,7 @@ static void diagnoseXorMisusedAsPow(Sema , const 
ExprResult ,
   RHSStrRef.startswith("0x") || RHSStrRef.startswith("0X") ||
   (LHSStrRef.size() > 1 && LHSStrRef.startswith("0")) ||
   (RHSStrRef.size() > 1 && RHSStrRef.startswith("0")) ||
-  LHSStrRef.find('\'') != StringRef::npos ||
-  RHSStrRef.find('\'') != StringRef::npos)
+  LHSStrRef.contains('\'') || RHSStrRef.contains('\''))
 return;
 
   bool SuggestXor =

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
index d06c87631bfb..61ff5e59f06d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -785,9 +785,8 @@ void WalkAST::checkDeprecatedOrUnsafeBufferHandling(const 
CallExpr *CE,
 // real flow analysis.
 auto FormatString =
 dyn_cast(CE->getArg(ArgIndex)->IgnoreParenImpCasts());
-if (FormatString &&
-FormatString->getString().find("%s") == StringRef::npos &&
-FormatString->getString().find("%[") == StringRef::npos)
+if (FormatString && !FormatString->getString().contains("%s") &&
+!FormatString->getString().contains("%["))
   BoundsProvided = true;
   }
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
index df88b71ff063..49486ea796c2 

[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-10-20 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 380958.
gAlfonso-bit added a comment.

Rebased to main


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

https://reviews.llvm.org/D110068

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >