[PATCH] D152275: Use memory region declaration intrinsic when generating code for array subscripts

2023-06-15 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D152275#4418363 , @efriedma wrote:

> - Not sure how this interacts with full restrict and related proposals.

the full restrict PropagateAndConvertNoAlias pass will need to learn about it, 
but that should be trivial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152275

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


[PATCH] D126956: [tbaa] Handle base classes in struct tbaa

2022-07-06 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b3247bf9f71: [tbaa] Handle base classes in struct tbaa 
(authored by brunodf, committed by jeroen.dobbelaere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126956

Files:
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/test/CodeGen/tbaa-class.cpp
  clang/unittests/CodeGen/TBAAMetadataTest.cpp

Index: clang/unittests/CodeGen/TBAAMetadataTest.cpp
===
--- clang/unittests/CodeGen/TBAAMetadataTest.cpp
+++ clang/unittests/CodeGen/TBAAMetadataTest.cpp
@@ -968,13 +968,10 @@
   MConstInt(0)),
 MConstInt(0));
 
-  auto ClassDerived = MMTuple(
-MMString("_ZTS7Derived"),
-MMTuple(
-  MMString("short"),
-  OmnipotentCharCXX,
-  MConstInt(0)),
-MConstInt(4));
+  auto ClassDerived =
+  MMTuple(MMString("_ZTS7Derived"), ClassBase, MConstInt(0),
+  MMTuple(MMString("short"), OmnipotentCharCXX, MConstInt(0)),
+  MConstInt(4));
 
   const Instruction *I = match(BB,
   MInstruction(Instruction::Store,
@@ -1047,13 +1044,10 @@
   MConstInt(0)),
 MConstInt(Compiler.PtrSize));
 
-  auto ClassDerived = MMTuple(
-MMString("_ZTS7Derived"),
-MMTuple(
-  MMString("short"),
-  OmnipotentCharCXX,
-  MConstInt(0)),
-MConstInt(Compiler.PtrSize + 4));
+  auto ClassDerived =
+  MMTuple(MMString("_ZTS7Derived"), ClassBase, MConstInt(0),
+  MMTuple(MMString("short"), OmnipotentCharCXX, MConstInt(0)),
+  MConstInt(Compiler.PtrSize + 4));
 
   const Instruction *I = match(BB,
   MInstruction(Instruction::Store,
Index: clang/test/CodeGen/tbaa-class.cpp
===
--- clang/test/CodeGen/tbaa-class.cpp
+++ clang/test/CodeGen/tbaa-class.cpp
@@ -51,6 +51,25 @@
uint32_t f32_2;
 };
 
+class StructT {
+public:
+  uint32_t f32_2;
+  void foo();
+};
+class StructM1 : public StructS, public StructT {
+public:
+  uint16_t f16_2;
+};
+class StructDyn {
+public:
+  uint32_t f32_2;
+  virtual void foo();
+};
+class StructM2 : public StructS, public StructDyn {
+public:
+  uint16_t f16_2;
+};
+
 uint32_t g(uint32_t *s, StructA *A, uint64_t count) {
 // CHECK-LABEL: define{{.*}} i32 @_Z1g
 // CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa [[TAG_i32:!.*]]
@@ -199,6 +218,30 @@
   return b1->a.f32;
 }
 
+uint32_t g13(StructM1 *M, StructS *S) {
+  // CHECK-LABEL: define{{.*}} i32 @_Z3g13
+  // CHECK: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // CHECK: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // PATH-LABEL: define{{.*}} i32 @_Z3g13
+  // PATH: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_S_f16]]
+  // PATH: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_M1_f16_2:!.*]]
+  S->f16 = 1;
+  M->f16_2 = 4;
+  return S->f16;
+}
+
+uint32_t g14(StructM2 *M, StructS *S) {
+  // CHECK-LABEL: define{{.*}} i32 @_Z3g14
+  // CHECK: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // CHECK: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // PATH-LABEL: define{{.*}} i32 @_Z3g14
+  // PATH: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_S_f16]]
+  // PATH: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_M2_f16_2:!.*]]
+  S->f16 = 1;
+  M->f16_2 = 4;
+  return S->f16;
+}
+
 // CHECK: [[TYPE_char:!.*]] = !{!"omnipotent char", [[TAG_cxx_tbaa:!.*]],
 // CHECK: [[TAG_cxx_tbaa]] = !{!"Simple C++ TBAA"}
 // CHECK: [[TAG_i32]] = !{[[TYPE_i32:!.*]], [[TYPE_i32]], i64 0}
@@ -222,11 +265,17 @@
 // OLD-PATH: [[TYPE_S]] = !{!"_ZTS7StructS", [[TYPE_SHORT]], i64 0, [[TYPE_INT]], i64 4}
 // OLD-PATH: [[TAG_S_f16]] = !{[[TYPE_S]], [[TYPE_SHORT]], i64 0}
 // OLD-PATH: [[TAG_S2_f32_2]] = !{[[TYPE_S2:!.*]], [[TYPE_INT]], i64 12}
-// OLD-PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12}
+// OLD-PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_S]], i64 0, [[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TAG_C_b_a_f32]] = !{[[TYPE_C:!.*]], [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TYPE_C]] = !{!"_ZTS7StructC", [[TYPE_SHORT]], i64 0, [[TYPE_B]], i64 4, [[TYPE_INT]], i64 28}
 // OLD-PATH: [[TAG_D_b_a_f32]] = !{[[TYPE_D:!.*]], [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TYPE_D]] = !{!"_ZTS7StructD", [[TYPE_SHORT]], i64 0, [[TYPE_B]], i64 4, [[TYPE_INT]], i64 28, [[TYPE_CHAR]], i64 32}
+// OLD-PATH: [[TAG_M1_f16_2]] = !{[[TYPE_M1:!.*]], [[TYPE_SHORT]], i64 12}
+// OLD-PATH: [[TYPE_M1]] = !{!"_ZTS8StructM1", [[TYPE_S]], i64 0, [[TYPE_T:!.*]], i64 8, [[TYPE_SHORT]], i64 12}
+// OLD_PATH: [[TYPE_T]] = !{!"_ZTS7StructT", [[TYPE_INT]], i64 0}
+// OLD-PATH: [[TAG_M2_f16_2]] = !{[[TYPE_M2:!.*]], [[TYPE_SHORT]], i64 20}
+// OLD-PATH: [[TYPE_M2]] = !{!"_ZTS8StructM2", [[TYPE_DYN:!.*]], i64 0, [[TYPE_S]], i64 12, [[TYPE_SHORT]], i64 20}
+// OLD_PATH: [[TYPE_DYN]] = !{!"_ZTS9StructDyn", [[TYPE_INT]], i64 8}
 

[PATCH] D126956: [tbaa] Handle base classes in struct tbaa

2022-07-06 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere accepted this revision.
jeroen.dobbelaere 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/D126956/new/

https://reviews.llvm.org/D126956

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


[PATCH] D126956: [tbaa] Handle base classes in struct tbaa

2022-06-23 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D126956#3604978 , @fhahn wrote:

> Please take a look and revert the patch if the fix isn't trivial.

the patch has already been reverted so Bruno can investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126956

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


[PATCH] D126956: [tbaa] Handle base classes in struct tbaa

2022-06-23 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcdc59e2202c1: [tbaa] Handle base classes in struct tbaa 
(authored by brunodf, committed by jeroen.dobbelaere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126956

Files:
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/test/CodeGen/tbaa-class.cpp
  clang/unittests/CodeGen/TBAAMetadataTest.cpp


Index: clang/unittests/CodeGen/TBAAMetadataTest.cpp
===
--- clang/unittests/CodeGen/TBAAMetadataTest.cpp
+++ clang/unittests/CodeGen/TBAAMetadataTest.cpp
@@ -968,13 +968,10 @@
   MConstInt(0)),
 MConstInt(0));
 
-  auto ClassDerived = MMTuple(
-MMString("_ZTS7Derived"),
-MMTuple(
-  MMString("short"),
-  OmnipotentCharCXX,
-  MConstInt(0)),
-MConstInt(4));
+  auto ClassDerived =
+  MMTuple(MMString("_ZTS7Derived"), ClassBase, MConstInt(0),
+  MMTuple(MMString("short"), OmnipotentCharCXX, MConstInt(0)),
+  MConstInt(4));
 
   const Instruction *I = match(BB,
   MInstruction(Instruction::Store,
@@ -1047,13 +1044,10 @@
   MConstInt(0)),
 MConstInt(Compiler.PtrSize));
 
-  auto ClassDerived = MMTuple(
-MMString("_ZTS7Derived"),
-MMTuple(
-  MMString("short"),
-  OmnipotentCharCXX,
-  MConstInt(0)),
-MConstInt(Compiler.PtrSize + 4));
+  auto ClassDerived =
+  MMTuple(MMString("_ZTS7Derived"), ClassBase, MConstInt(0),
+  MMTuple(MMString("short"), OmnipotentCharCXX, MConstInt(0)),
+  MConstInt(Compiler.PtrSize + 4));
 
   const Instruction *I = match(BB,
   MInstruction(Instruction::Store,
Index: clang/test/CodeGen/tbaa-class.cpp
===
--- clang/test/CodeGen/tbaa-class.cpp
+++ clang/test/CodeGen/tbaa-class.cpp
@@ -222,7 +222,7 @@
 // OLD-PATH: [[TYPE_S]] = !{!"_ZTS7StructS", [[TYPE_SHORT]], i64 0, 
[[TYPE_INT]], i64 4}
 // OLD-PATH: [[TAG_S_f16]] = !{[[TYPE_S]], [[TYPE_SHORT]], i64 0}
 // OLD-PATH: [[TAG_S2_f32_2]] = !{[[TYPE_S2:!.*]], [[TYPE_INT]], i64 12}
-// OLD-PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_SHORT]], i64 8, 
[[TYPE_INT]], i64 12}
+// OLD-PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_S]], i64 0, 
[[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TAG_C_b_a_f32]] = !{[[TYPE_C:!.*]], [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TYPE_C]] = !{!"_ZTS7StructC", [[TYPE_SHORT]], i64 0, 
[[TYPE_B]], i64 4, [[TYPE_INT]], i64 28}
 // OLD-PATH: [[TAG_D_b_a_f32]] = !{[[TYPE_D:!.*]], [[TYPE_INT]], i64 12}
@@ -244,7 +244,7 @@
 // NEW-PATH: [[TYPE_S]] = !{[[TYPE_CHAR]], i64 8, !"_ZTS7StructS", 
[[TYPE_SHORT]], i64 0, i64 2, [[TYPE_INT]], i64 4, i64 4}
 // NEW-PATH: [[TAG_S_f16]] = !{[[TYPE_S]], [[TYPE_SHORT]], i64 0, i64 2}
 // NEW-PATH: [[TAG_S2_f32_2]] = !{[[TYPE_S2:!.*]], [[TYPE_INT]], i64 12, i64 4}
-// NEW-PATH: [[TYPE_S2]] = !{[[TYPE_CHAR]], i64 16, !"_ZTS8StructS2", 
[[TYPE_SHORT]], i64 8, i64 2, [[TYPE_INT]], i64 12, i64 4}
+// NEW-PATH: [[TYPE_S2]] = !{[[TYPE_CHAR]], i64 16, !"_ZTS8StructS2", 
[[TYPE_S]], i64 0, i64 8, [[TYPE_SHORT]], i64 8, i64 2, [[TYPE_INT]], i64 12, 
i64 4}
 // NEW-PATH: [[TAG_C_b_a_f32]] = !{[[TYPE_C:!.*]], [[TYPE_INT]], i64 12, i64 4}
 // NEW-PATH: [[TYPE_C]] = !{[[TYPE_CHAR]], i64 32, !"_ZTS7StructC", 
[[TYPE_SHORT]], i64 0, i64 2, [[TYPE_B]], i64 4, i64 24, [[TYPE_INT]], i64 28, 
i64 4}
 // NEW-PATH: [[TAG_D_b_a_f32]] = !{[[TYPE_D:!.*]], [[TYPE_INT]], i64 12, i64 4}
Index: clang/lib/CodeGen/CodeGenTBAA.cpp
===
--- clang/lib/CodeGen/CodeGenTBAA.cpp
+++ clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -336,6 +336,30 @@
 const RecordDecl *RD = TTy->getDecl()->getDefinition();
 const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
 SmallVector Fields;
+if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) {
+  // Handle C++ base classes. Non-virtual bases can treated a a kind of
+  // field. Virtual bases are more complex and omitted, but avoid an
+  // incomplete view for NewStructPathTBAA.
+  if (CodeGenOpts.NewStructPathTBAA && CXXRD->getNumVBases() != 0)
+return BaseTypeMetadataCache[Ty] = nullptr;
+  for (const CXXBaseSpecifier &B : CXXRD->bases()) {
+if (B.isVirtual())
+  continue;
+QualType BaseQTy = B.getType();
+const CXXRecordDecl *BaseRD = BaseQTy->getAsCXXRecordDecl();
+if (BaseRD->isEmpty())
+  continue;
+llvm::MDNode *TypeNode = isValidBaseType(BaseQTy)
+ ? getBaseTypeInfo(BaseQTy)
+ : getTypeInfo(BaseQTy);
+if (!TypeNode)
+  return BaseTypeMetadataCache[Ty] = nullptr;
+uint64_t Offset = Layout.getBaseClassOffset(BaseRD).getQuantity();
+uint64_t Size = Context.getTypeSizeInChars(BaseQTy).getQua

[PATCH] D126956: [tbaa] Handle base classes in struct tbaa

2022-06-15 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere accepted this revision.
jeroen.dobbelaere 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/D126956/new/

https://reviews.llvm.org/D126956

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


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

2021-12-14 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere accepted this revision.
jeroen.dobbelaere added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D115320

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


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

2021-12-14 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added inline comments.



Comment at: clang/test/CodeGen/avoidTBAAonASMstore.cpp:3
+double foo(double z) {
+  // CHECK-LABEL: define{{.*}} double @_Z3food
+  unsigned short ControlWord;

Shouldn't this be `STORE-LINE-LABEL: ...` ?


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

https://reviews.llvm.org/D115320

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


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

2021-12-11 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

We're almost there.  But the testcase is now not testing what it should be 
testing. Also the unused `CHECK:` must be adapted.


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

https://reviews.llvm.org/D115320

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


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

2021-12-10 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:2511
+return LValue::MakeAddr(Addr, T, getContext(), LValueBaseInfo(Source),
+CGM.returnNullTBAA());
+  }

Looking at how a 'null tbaa'is produced in other places (grep for 
'TBAAAccessInfo()', I would just do a 'TBAAAccessInfo()' here and omit the new 
''returnNullTBAA' method.





Comment at: clang/test/CodeGen/avoidTBAAonASMstore.cpp:6
+   __asm { fnstcw word ptr[ControlWord] };
+// CHECK: store i64 %2, i64* %1, align 4
+// CHECK-NOT: !tbaa

Will this also work in release mode ? Maybe abstract away the %2 and %1.



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

https://reviews.llvm.org/D115320

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


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

2021-12-09 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

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


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

https://reviews.llvm.org/D115320

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


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

2021-12-07 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

Do you have a testcase ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115320

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


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

2021-12-01 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

A number of buildbots started failing after submission. Reverted for now so we 
can investigate if the new produced errors are valid or not.


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] D111639: [Sema] check PseudoObject when rebuilding CXXOperatorCallExpr in template instantiation

2021-12-01 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c047a8e1332: [Sema] check PseudoObject when rebuilding 
CXXOperatorCallExpr in template… (authored by jeroen.dobbelaere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111639

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/PR51855.cpp
  clang/test/SemaObjCXX/instantiate-property-access.mm

Index: clang/test/SemaObjCXX/instantiate-property-access.mm
===
--- clang/test/SemaObjCXX/instantiate-property-access.mm
+++ clang/test/SemaObjCXX/instantiate-property-access.mm
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DDEPENDENT -verify %s
 // expected-no-diagnostics
 
 class C {};
@@ -9,6 +10,10 @@
 
 C operator += (C c1, C c2);
 
+C operator++(C c1);
+
+bool operator!(C c1);
+
 enum TextureType { TextureType3D  };
 
 @interface Texture
@@ -16,9 +21,13 @@
 @property  C c;
 @end
 
-template  class Framebuffer {
+template  class Framebuffer {
 public:
-  Texture **color_attachment;  
+#ifdef DEPENDENT
+  T **color_attachment;
+#else
+  Texture **color_attachment;
+#endif
   Framebuffer();
 };
 
@@ -28,8 +37,15 @@
   (void)(color_attachment[0].c == color_attachment[0].c);
   (void)(color_attachment[0].c == 1);
   (void)(1 == color_attachment[0].c);
+  (void)(!color_attachment[0].textureType);
+  ++color_attachment[0].textureType;
+  (void)(!color_attachment[0].c);
 }
 
 void foo() {
+#ifdef DEPENDENT
+  Framebuffer();
+#else
   Framebuffer();
+#endif
 }
Index: clang/test/SemaCXX/PR51855.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR51855.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -S -triple %itanium_abi_triple -fms-extensions -emit-llvm %s -o - | FileCheck %s
+
+struct F {};
+
+F operator*=(F &lhs, int rhs);
+
+F operator++(F &lhs);
+
+struct S {
+  short _m;
+  S(short _m) : _m(_m) {}
+
+  void putM(short rhs) { _m = rhs; }
+  short getM() { return _m; }
+
+  __declspec(property(get = getM, put = putM)) short theData;
+};
+
+int test1a(int i) {
+  S tmp(i);
+  tmp.theData *= 2;
+  return tmp.theData;
+}
+
+// CHECK-LABEL: define {{.*}} @_Z6test1ai(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+template 
+int test1b(int i) {
+  T tmp(i);
+  tmp.theData *= 2;
+  return tmp.theData;
+}
+
+template int test1b(int);
+
+// CHECK-LABEL: define {{.*}} @_Z6test1bI1SEii(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+int test2a(int i) {
+  S tmp(i);
+  ++tmp.theData;
+  return tmp.theData;
+}
+
+// CHECK-LABEL: define {{.*}} i32 @_Z6test2ai(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+template 
+int test2b(int i) {
+  T tmp(i);
+  ++tmp.theData;
+  return tmp.theData;
+}
+
+template int test2b(int);
+
+// CHECK-LABEL: define {{.*}} i32 @_Z6test2bI1SEii(
+// CHECK: call void @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -14630,18 +14630,28 @@
   Expr *Callee = OrigCallee->IgnoreParenCasts();
   bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
 
-  if (First->getObjectKind() == OK_ObjCProperty) {
-BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
-if (BinaryOperator::isAssignmentOp(Opc))
-  return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
- First, Second);
+  if (const BuiltinType *pty = First->getType()->getAsPlaceholderType()) {
+if (Second && !isPostIncDec) {
+  BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
+  if (pty->getKind() == BuiltinType::PseudoObject &&
+  BinaryOperator::isAssignmentOp(Opc))
+return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc,
+   Opc, First, Second);
+} else {
+  UnaryOperatorKind Opc =
+  UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
+  if (pty->getKind() == BuiltinType::PseudoObject &&
+  UnaryOperator::isIncrementDecrementOp(Opc))
+return SemaRef.checkPseudoObjectIncDec(/*Scope=*/nullptr, OpLoc, Opc,
+   First);
+}
 ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
 if (Result.isInvalid())
   return ExprError();
 Firs

[PATCH] D104777: PR50767: clear non-distinct debuginfo for function with nodebug definition after undecorated declaration

2021-06-29 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4d8871a898b3: PR50767: clear non-distinct debuginfo for 
function with nodebug definition… (authored by brunodf, committed by 
jeroen.dobbelaere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104777

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/attr-nodebug2.c


Index: clang/test/CodeGen/attr-nodebug2.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -debugger-tuning=gdb 
-dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -debug-info-kind=limited -debugger-tuning=gdb 
-dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+  int a = 10;
+  a++;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// CHECK-LABEL: define{{.*}} void @use()
+// CHECK-SAME:  !dbg
+// CHECK-SAME:  {
+// CHECK:   !dbg
+// CHECK:   }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @t1()
+// CHECK-NOT:   !dbg
+// CHECK-SAME:  {
+// CHECK-NOT:   !dbg
+// CHECK:   }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1304,8 +1304,14 @@
   QualType ResTy = BuildFunctionArgList(GD, Args);
 
   // Check if we should generate debug info for this function.
-  if (FD->hasAttr())
-DebugInfo = nullptr; // disable debug info indefinitely for this function
+  if (FD->hasAttr()) {
+// Clear non-distinct debug info that was possibly attached to the function
+// due to an earlier declaration without the nodebug attribute
+if (Fn)
+  Fn->setSubprogram(nullptr);
+// Disable debug info indefinitely for this function
+DebugInfo = nullptr;
+  }
 
   // The function might not have a body if we're generating thunks for a
   // function declaration.


Index: clang/test/CodeGen/attr-nodebug2.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -debug-info-kind=limited -debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+  int a = 10;
+  a++;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// CHECK-LABEL: define{{.*}} void @use()
+// CHECK-SAME:  !dbg
+// CHECK-SAME:  {
+// CHECK:   !dbg
+// CHECK:   }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @t1()
+// CHECK-NOT:   !dbg
+// CHECK-SAME:  {
+// CHECK-NOT:   !dbg
+// CHECK:   }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1304,8 +1304,14 @@
   QualType ResTy = BuildFunctionArgList(GD, Args);
 
   // Check if we should generate debug info for this function.
-  if (FD->hasAttr())
-DebugInfo = nullptr; // disable debug info indefinitely for this function
+  if (FD->hasAttr()) {
+// Clear non-distinct debug info that was possibly attached to the function
+// due to an earlier declaration without the nodebug attribute
+if (Fn)
+  Fn->setSubprogram(nullptr);
+// Disable debug info indefinitely for this function
+DebugInfo = nullptr;
+  }
 
   // The function might not have a body if we're generating thunks for a
   // function declaration.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96960: [clang] functions with the 'const' or 'pure' attribute must always return.

2021-02-18 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46757ccb49ab: [clang] functions with the 'const' 
or 'pure' attribute must always return. (authored by 
jeroen.dobbelaere).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96960

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/complex-builtins.c
  clang/test/CodeGen/complex-libcalls.c
  clang/test/CodeGen/function-attributes.c
  clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
  clang/test/Sema/libbuiltins-ctype-powerpc64.c
  clang/test/Sema/libbuiltins-ctype-x86_64.c

Index: clang/test/Sema/libbuiltins-ctype-x86_64.c
===
--- clang/test/Sema/libbuiltins-ctype-x86_64.c
+++ clang/test/Sema/libbuiltins-ctype-x86_64.c
@@ -62,4 +62,4 @@
 // CHECK: declare i32 @toupper(i32) [[NUW_RO:#[0-9]+]]
 
 // CHECK: attributes [[NUW_RO]] = { nounwind readonly{{.*}} }
-// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly }
+// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly willreturn }
Index: clang/test/Sema/libbuiltins-ctype-powerpc64.c
===
--- clang/test/Sema/libbuiltins-ctype-powerpc64.c
+++ clang/test/Sema/libbuiltins-ctype-powerpc64.c
@@ -62,4 +62,4 @@
 // CHECK: declare signext i32 @toupper(i32 signext) [[NUW_RO:#[0-9]+]]
 
 // CHECK: attributes [[NUW_RO]] = { nounwind readonly{{.*}} }
-// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly }
+// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly willreturn }
Index: clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
===
--- clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
+++ clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
@@ -15,8 +15,8 @@
 // CHECK: declare i32 @_Z1tv() [[TF2:#[0-9]+]]
 
 // CHECK: attributes [[TF]] = { {{.*}} }
-// CHECK: attributes [[NUW_RN]] = { nounwind readnone{{.*}} }
-// CHECK: attributes [[NUW_RO]] = { nounwind readonly{{.*}} }
+// CHECK: attributes [[NUW_RN]] = { nounwind readnone willreturn{{.*}} }
+// CHECK: attributes [[NUW_RO]] = { nounwind readonly willreturn{{.*}} }
 // CHECK: attributes [[TF2]] = { {{.*}} }
-// CHECK: attributes [[NUW_RN_CALL]] = { nounwind readnone }
-// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly }
+// CHECK: attributes [[NUW_RN_CALL]] = { nounwind readnone willreturn }
+// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly willreturn }
Index: clang/test/CodeGen/function-attributes.c
===
--- clang/test/CodeGen/function-attributes.c
+++ clang/test/CodeGen/function-attributes.c
@@ -115,5 +115,5 @@
 // CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
-// CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
+// CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone willreturn }
 // CHECK: attributes [[RT_CALL]] = { optsize returns_twice }
Index: clang/test/CodeGen/complex-libcalls.c
===
--- clang/test/CodeGen/complex-libcalls.c
+++ clang/test/CodeGen/complex-libcalls.c
@@ -133,7 +133,7 @@
 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
 // HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE:#[0-9]+]]
 // HAS_ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]]
-// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
+// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[WILLRETURN_NOT_READNONE:#[0-9]+]]
 
   cpow(f,f);   cpowf(f,f);  cpowl(f,f);
 
@@ -202,3 +202,4 @@
 
 // HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} }
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO: attributes [[WILLRETURN_NOT_READNONE]] = { nounwind willreturn {{.*}} }
Index: clang/test/CodeGen/complex-builtins.c
===
--- clang/test/CodeGen/complex-builtins.c
+++ clang/test/CodeGen/complex-builtins.c
@@ -133,7 +133,7 @@
 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
 // HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE:#[0-9]+]]
 // HAS_ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]]
-// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_

[PATCH] D93040: [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments.

2021-02-01 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added inline comments.



Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:929
 
-if (MDNode *M = NI->getMetadata(LLVMContext::MD_alias_scope))
-  NI->setMetadata(LLVMContext::MD_alias_scope, MDMap[M]);
+if (MDNode *M = I->getMetadata(LLVMContext::MD_alias_scope))
+  I->setMetadata(LLVMContext::MD_alias_scope, MDMap[M]);

@nikic In the full restrict patches, we also check if the instruction was 
already handled. I was able to trigger this with an assertion and I have a more 
or less reduced testcase.

Either we keep a SmallPtrSet and check if the instruction was already handled 
(this is what the full restrict version does; See D68509 
InlineFunction.cpp#969). Or we only replace the metadata if it is in the MDMap 
(by using MDMap.lookup(M).

Any preference ?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93040

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


[PATCH] D93040: [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments.

2021-01-23 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D93040#2517769 , @jdoerfert wrote:

> In D93040#2517758 , @xbolva00 wrote:
>
>> http://llvm-compile-time-tracker.com/compare.php?from=344afa853fcfcc085cb5c957b4a07c7ea013bb1b&to=2b9a834c43cb1f93d33958c14b695896bb4e9c1e&stat=size-text
>>
>> Codesize regression 1% for tramp3d. Can you check it?
>
> I assume this to be a secondary effect of having the instructions in the 
> first place. Maybe some unroll or inline size threshold needs to be thought 
> about them. At the end of the day, we might not be able to avoid something 
> like this as we make `!noalias` correct, though, I imagine the threshold 
> theory which can be resolved.

The loop unrolling/rotating and the cleanup patches are not yet committed. You 
can see the effect of those here:

http://llvm-compile-time-tracker.com/compare.php?from=344afa853fcfcc085cb5c957b4a07c7ea013bb1b&to=eaf871f4e7fde26cd755cc4c2d67f2c244c66f18&stat=size-text

Also see D95141  for links to more results.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93040

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


[PATCH] D93040: [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments.

2021-01-23 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b9a834c43cb: [InlineFunction] Use 
llvm.experimental.noalias.scope.decl for noalias arguments. (authored by 
jeroen.dobbelaere).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93040

Files:
  clang/test/CodeGen/aarch64-ls64.c
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-retcon-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/Coroutines/ex2.ll
  llvm/test/Transforms/Coroutines/ex3.ll
  llvm/test/Transforms/Coroutines/ex4.ll
  llvm/test/Transforms/Inline/launder.invariant.group.ll
  llvm/test/Transforms/Inline/noalias-calls-always.ll
  llvm/test/Transforms/Inline/noalias-calls.ll
  llvm/test/Transforms/Inline/noalias-calls2.ll
  llvm/test/Transforms/Inline/noalias-cs.ll
  llvm/test/Transforms/Inline/noalias.ll
  llvm/test/Transforms/Inline/noalias2.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
  llvm/test/Transforms/PhaseOrdering/pr39282.ll

Index: llvm/test/Transforms/PhaseOrdering/pr39282.ll
===
--- llvm/test/Transforms/PhaseOrdering/pr39282.ll
+++ llvm/test/Transforms/PhaseOrdering/pr39282.ll
@@ -19,12 +19,20 @@
 define void @pr39282(i32* %addr1, i32* %addr2) {
 ; CHECK-LABEL: @pr39282(
 ; CHECK-NEXT:  start:
-; CHECK-NEXT:[[X_I:%.*]] = load i32, i32* [[ADDR1:%.*]], align 4, !alias.scope !0, !noalias !3
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META0:metadata !.*]])
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META3:metadata !.*]])
+; CHECK-NEXT:[[X_I:%.*]] = load i32, i32* [[ADDR1:%.*]], align 4, !alias.scope !3, !noalias !0
 ; CHECK-NEXT:[[ADDR1I_1:%.*]] = getelementptr inbounds i32, i32* [[ADDR1]], i64 1
 ; CHECK-NEXT:[[ADDR2I_1:%.*]] = getelementptr inbounds i32, i32* [[ADDR2:%.*]], i64 1
-; CHECK-NEXT:[[X_I_1:%.*]] = load i32, i32* [[ADDR1I_1]], align 4, !alias.scope !0, !noalias !3
-; CHECK-NEXT:store i32 [[X_I]], i32* [[ADDR2]], align 4, !alias.scope !3, !noalias !0
-; CHECK-NEXT:store i32 [[X_I_1]], i32* [[ADDR2I_1]], align 4, !alias.scope !3, !noalias !0
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META0]])
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META3]])
+; CHECK-NEXT:[[X_I_1:%.*]] = load i32, i32* [[ADDR1I_1]], align 4, !alias.scope !3, !noalias !0
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META0]])
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META3]])
+; CHECK-NEXT:store i32 [[X_I]], i32* [[ADDR2]], align 4, !alias.scope !0, !noalias !3
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META0]])
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META3]])
+; CHECK-NEXT:store i32 [[X_I_1]], i32* [[ADDR2I_1]], align 4, !alias.scope !0, !noalias !3
 ; CHECK-NEXT:ret void
 ;
 start:
Index: llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
===
--- llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
+++ llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
@@ -70,6 +70,7 @@
 ; CHECK-NEXT:[[I2:%.*]] = alloca [[TMP0:%.*]], align 8
 ; CHECK-NEXT:[[I1_SROA_0_0_I5_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0]], %0* [[ARG:%.*]], i64 0, i32 0
 ; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i32*, i32** [[I1_SROA_0_0_I5_SROA_IDX]], align 8
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META0:metadata !.*]])
 ; CHECK-NEXT:[[I_SROA_0_0_I6_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0]], %0* [[I2]], i64 0, i32 0
 ; CHECK-NEXT:store i32* [[I1_SROA_0_0_COPYLOAD]], i32** [[I_SROA_0_0_I6_SROA_IDX]], align 8
 ; CHECK-NEXT:tail call void @_Z7escape01S(%0* nonnull byval(%0) align 8 [[I2]])
@@ -109,6 +110,7 @@
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:[[I1_SROA_0_0_I4_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[ARG:%.*]], i64 0, i32 0
 ; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i32*, i32** [[I1_SROA_0_0_I4_SROA_IDX]], align 8
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl([[META3:metadata !.*]])
 ; CHECK-NEXT:[[I5:%.*]] = tail call i32 @_Z4condv()
 ; CHECK-NEXT:[[I6_NOT:%.*]] = icmp eq i32 [[I5]], 0
 ; CHECK-NEXT:br i1 [[I6_NOT]], label [[BB10:%.*]], label [[BB7:%.*]]
Index: llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
==

[PATCH] D93038: [NFC] clang/test/openMP/target_codegen.cpp should not depend on ssa name

2021-01-07 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

Thanks !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93038

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


[PATCH] D94233: [NFC] make clang/test/CodeGen/arm_neon_intrinsics.c resistent to function attribute id changes

2021-01-07 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

Thanks !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94233

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


[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2020-07-24 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.
Herald added a subscriber: dang.

Found some issue when looking at this code:  -ftrapping_math and 
-fno_trapping_math will never have effect




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3155
+  if (Args.hasArg(OPT_ftrapping_math)) {
+Opts.setFPExceptionMode(LangOptions::FPE_Strict);
+  }

Calling 'Opts.setFPExceptionMode(xx)' here has no effect, as it will be 
overruled later on, on line 3174 !
Same is true on line 3159



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


[PATCH] D82574: Merge TableGen files used for clang options

2020-07-10 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

I think that 'clang/include/clang/Driver/CC1Options.td' should also be removed ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82574



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-10 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D74935#1909909 , @jdoerfert wrote:

> I would say that once we get modeling for indirect restrict we can adapt the 
> lang ref accordingly. For now there is only have outer level restrict/noalias.


Why not try to get right now ? The first reason that you give for the change in 
wording is

> '1. To match the restrict semantics when we lower it to noalias.'

Currently there is no mechanism to accurately describe nested restrict pointers 
in LLVM-IR. imho, that means that
we should adapt the wording in a more specific way. Something like:

This guarantee only holds for memory locations that are *modified*, by any 
means, during the execution the function.
  + Note that, just like C99 restrict, in this context, memory locations whose 
content is used as a pointer value to modify a memory location,
  + are also considered to modify the former memory locations.
The attribute

> 
> 
>>> 2. The extended `noalias` deduction D73428 
>>> .

[..]

>> That sounds good. Is there also a testcase (similar to D74935#1907100 
>>  or D74935#1907939 
>>  ) that explicitly checks that 
>> 'noalias' is not deduced ?
> 
> I'll add one :)

thanks !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-06 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D74935#1908665 , @jdoerfert wrote:

> I think we conflate two things here:
>
> 1. The modifications to the LangRef which should be in accordance with the C 
> standard (at least I haven't seen you contradict the new wording directly).


imho, the proposed wording is still confusing, and does not handle the case 
with the extra indirections.
Unless the 'by any means' was meant to also include the  '.. Every  access  
that modifies X shall be considered also to modify P,for the purposes of this 
subclause. .. ' from the restrict specification.
If that is the idea, we should mention it explicitly.

> 2. The extended `noalias` deduction D73428 .
> 
>   If you look at the commit message in D73428 
> , it says that `noalias` is not just derived 
> for all `readonly` arguments. In your example we access `unknown` memory, 
> e.g., `**pA=42`, so case (1) cannot be applied. For case (2) we need to show 
> that the loads of `pA` and `pB` do not alias, which we cannot.

That sounds good. Is there also a testcase (similar to D74935#1907100 
 or D74935#1907939 
 ) that explicitly checks that 
'noalias' is not deduced ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-05 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D74935#1907939 , @jdoerfert wrote:

> In D74935#1907100 , 
> @jeroen.dobbelaere wrote:
>
> > Just to give an example:
> >
> >   int foo(int* restrict *pA, int* restrict *pB) {
> > int tmp=**pB;
> > **pA=42;
> > return tmp - **pB; // **pA and **pB can refer to the same objects
> >   }
> >
> >
> > [...]
>
>
> `*pA` and `*pB` are both restrict qualified pointers, are they not?
>  If so, why can they point to the same location?


For the original example, *pA and *pB might be the same restrict pointer:

  int* restrict pC = ;
  foo(&pC, &pC);

> I mean, w/o the side channel stuff the two `int *` values may alias
>  even if you have `noalias` on the arguments (https://godbolt.org/z/J9v_gK).

And that is correct, as *pA might be equal to *pB for that case (even if pA and 
pB are not equal).

Restrictness adds additional information (ignoring for a moment the 'read only' 
case (see note *4)):

   // case A
   int * restrict prC;
   int * restrict prD;
   // pC and pD are separate (*1) restrict pointers  => they point to their own 
separate sets of objects set(prC), set(prD), aka prC != prD (*2)
  
   // case B
   int * restrict * prpE; 
   int * restrict * prpF;
   // prpE and prpF are _not_ restrict pointers, so prpE could be equal to prpF 
(prpE == prpF) or not (prpE != prpF)
   // *prpE and *prpF are restrict pointers. When prpE == prpF, they represent 
the same restrict pointer.
   // *prpE could point to prC or prD or a different restrict pointer => 
set(*prpE) =union(set(prC), set(prD), ...)
   // also *prpF can point to union(set(prC), set(prD), ...)
  
   // case C
   int * restrict * restrict prprG;  
   int * restrict * restrict prprH;
   // prprG and prprH are separate (*3) restrict pointers => they point to 
their own separate sets of objects set(prprG) and set(prprH)
   // because of that: prprG != prprH
   // and *prprG and *prprH represent also separate (see previous line) 
restrict points
   // So *prprG and *prprH must point to their own separate sets of objects 
set(*prprG) and set(*prprH) 
  
   // The difference between between case B and case C is that in B, prpE could 
be equal to prpF (mayAlias), and because of that, *prpE could be equal to *prpF.
   // By proving that prprG != prprH, it automatically follows that *prprG != 
*prprH (except for (*4))
  
  // Notes:
  // (*1)  &prC != &prD 
  // (*2) it actually is: for all i,j for which prC[i] and prD[j] are 'valid',  
&prC[i] != &prD[j]
  // (*3)  &prprG != &prprH
  // (*4) The restrict definition contains a relaxation when restrict pointers 
are only used for reading memory: 
  //   In that case, separate restrict pointers are allowed to point to the 
same set of objects... except for:
  //  But: it also states that (6.7.3.1 paragraph 4 : '.. Every  access  that 
modifies X shall be considered also to modify P,for the purposes of this 
subclause. .. '
  //  Which means that if your write to **prprG, it is _as if_ you also write 
to *prprG and because of that, both prprG and *prprG must point to their own 
set of objects set(prprG) and set(*prprG)
  //  and those sets must also be different from set(prprH) and set(*prprH)

Now, in the original example, we have 'case B'.  pA could be equal to pB 
(mayAlias), and because of that, *pA could be equal to *pB.

  int foo(int* restrict *pA, int* restrict *pB);

When we can proof that pA != pB (noalias), then *pA and *pB represent different 
restrict pointers and *pA != *pB. (different restrict pointers point to their 
own set of objects)

So, adding the 'noalias' attribute to %pA and %pB will change the behavior of 
foo().

hmm... this explanation is maybe getting too long ?
The short conclusion should be:

- adding 'noalias' to a pointer argument, because it is only used to read 
memory, might lead to 'wrong code'
- two 'noalias' pointer arguments should not overlap

or relaxed:

- two 'noalias' pointer arguments can only overlap if they (at any level of 
indirection) are never used to write to memory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-05 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

Just to give an example:

  int foo(int* restrict *pA, int* restrict *pB) {
int tmp=**pB;
**pA=42;
return tmp - **pB; // **pA and **pB can refer to the same objects
  }

This gives following llvm-ir code with the 'full noalias' clang version (after 
optimizations):

  ; Function Attrs: nofree nounwind uwtable
  define dso_local i32 @foo(i32** nocapture %pA, i32** nocapture readonly %pB) 
local_unnamed_addr #0 !noalias !2 {
  entry:
%0 = load i32*, i32** %pB, noalias_sidechannel i32** undef, align 8, !tbaa 
!5, !noalias !2
%1 = tail call i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i64(i32* 
%0, i8* null, i32** %pB, i32** undef, i64 0, metadata !2), !tbaa !5, !noalias !2
%2 = load i32, i32* %0, noalias_sidechannel i32* %1, align 4, !tbaa !9, 
!noalias !2
%3 = load i32*, i32** %pA, noalias_sidechannel i32** undef, align 8, !tbaa 
!5, !noalias !2
%4 = tail call i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i64(i32* 
%3, i8* null, i32** %pA, i32** undef, i64 0, metadata !2), !tbaa !5, !noalias !2
store i32 42, i32* %3, noalias_sidechannel i32* %4, align 4, !tbaa !9, 
!noalias !2
%5 = load i32, i32* %0, noalias_sidechannel i32* %1, align 4, !tbaa !9, 
!noalias !2
%sub = sub nsw i32 %2, %5
ret i32 %sub
  }

When adding 'noalias' to the arguments (my understanding is that this  is what 
the attributer would deduce, as pA and pB are only read):

  ; Function Attrs: nofree nounwind uwtable
  define dso_local i32 @foo(i32** noalias nocapture %pA, i32** noalias 
nocapture readonly %pB) local_unnamed_addr #0 !noalias !2 {
  entry:
%0 = load i32*, i32** %pB, noalias_sidechannel i32** undef, align 8, !tbaa 
!5, !noalias !2
%1 = tail call i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i64(i32* 
%0, i8* null, i32** %pB, i32** undef, i64 0, metadata !2), !tbaa !5, !noalias !2
%2 = load i32, i32* %0, noalias_sidechannel i32* %1, align 4, !tbaa !9, 
!noalias !2
%3 = load i32*, i32** %pA, noalias_sidechannel i32** undef, align 8, !tbaa 
!5, !noalias !2
%4 = tail call i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i64(i32* 
%3, i8* null, i32** %pA, i32** undef, i64 0, metadata !2), !tbaa !5, !noalias !2
store i32 42, i32* %3, noalias_sidechannel i32* %4, align 4, !tbaa !9, 
!noalias !2
%5 = load i32, i32* %0, noalias_sidechannel i32* %1, align 4, !tbaa !9, 
!noalias !2
%sub = sub nsw i32 %2, %5
ret i32 %sub
  }

and reoptimizing, we now get:

  ; Function Attrs: nofree nounwind uwtable
  define dso_local i32 @foo(i32** noalias nocapture %pA, i32** noalias 
nocapture readonly %pB) local_unnamed_addr #0 !noalias !2 {
  entry:
%0 = load i32*, i32** %pA, noalias_sidechannel i32** undef, align 8, !tbaa 
!5, !noalias !2
%1 = tail call i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i64(i32* 
%0, i8* null, i32** %pA, i32** undef, i64 0, metadata !2), !tbaa !5, !noalias !2
store i32 42, i32* %0, noalias_sidechannel i32* %1, align 4, !tbaa !9, 
!noalias !2
ret i32 0
  }

'%sub' is optimized away because the now the alias analyzer deduces that '%pA' 
and '%pB' cannot refer to the same objects. This implies (because of restrict) 
that '*%pA' and '*%pB' cannot refer to the same objects and because of that, 
the 'store i32' could not have interfered with the 'load i32'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-04 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

The reason I bring this up, is that in the full restrict implementation (D68484 
), the alias analysis will do a recursive 
analysis, proving that *pA and *pB will never alias, because pA and pB will 
never alias. But this phrasing will break that assumption.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-04 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

Be aware that c99 restrict has a special case for nested restrict that makes 
the rules stronger:

  void f(int* restrict *restrict pA, int* restrict * restrict pB) {
**pA=**pB;
  }

although pA and pB are only read,  (c99 6.7.3.1 #4) specifies that, writing to 
**pA is as if you are also writing to *pA.
Which means for this case, that pA and pB will point to there own sets of 
objects, and because of that, *pA and *pB also point to their own (different) 
sets of objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D75285: Mark restrict pointer or reference to const as invariant

2020-03-03 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D75285#1902788 , @Anastasia wrote:

> In D75285#1896610 , @rjmccall wrote:
>
> > Are you sure `restrict` alone isn't good enough?  It doesn't directly tell 
> > you that the memory is invariant, but it's usually simple to prove that the 
> > memory isn't modified within the `restrict` scope, which might be 
> > sufficient.
>
>
> Do you mean to prove in analysis passes? Should we emit some sort of hints 
> from the frontend to indicate what to look for?


Not sure what you mean with 'hints from the frontend', but D68484 
 (and later) contain a significant improvement 
to clang's handling of restrict. That could make the restrict path feasible (if 
that would support the actual use case).


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

https://reviews.llvm.org/D75285



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


[PATCH] D75285: Mark restrict pointer or reference to const as invariant

2020-02-28 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

I don't think that 'restrict' is a good match for this behavior. For c++, the 
alias_set proposal 
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4150.pdf) would be a 
better match.
You would put the read access of *p in its own universe; or even better, 
something like

  struct X {
int a;
char [[alias_set(MyOwnUniverseForX_b)]]  b;
  };

Unfortunatly, there is no implementation yet.

Imho, adding a '__attribute__((invariant))' or something similar (immutable ? 
const_invariant ?) would be a better approach. (hmm, I like 'immutable')

  char test2(X *x) {
const char __attribute__((immutable))  *p = (const char 
__attribute__((immutable))*)&(x->b);
// for all i:  p[i] will never be modified.
return *p;
  }

Extra precautions are probably needed to ensure that the initialization of x->b 
is separated from the usage of it.


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

https://reviews.llvm.org/D75285



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


[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-25 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere accepted this revision.
jeroen.dobbelaere added a comment.
This revision is now accepted and ready to land.

Looks good to me.


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

https://reviews.llvm.org/D74878



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


[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-24 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

Will this also give a warning when passing a .ll file to a release clang, 
without explicitly  passing the '-fdiscard-value-names' ? Is this what we want 
it to be ?


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

https://reviews.llvm.org/D74878



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


[PATCH] D72523: [remark][diagnostics] Using clang diagnostic handler for IR input files

2020-02-18 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

This change triggers a crash in a release build of llvm:
See https://bugs.llvm.org/show_bug.cgi?id=44896


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72523



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


[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-01-29 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere accepted this revision.
jeroen.dobbelaere added a comment.

This patch looks good to me.

I do agree with John that it would be good to add the warning to a warning 
group.


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

https://reviews.llvm.org/D73360



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