[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-29 Thread via cfe-commits

b-sumner wrote:

Just noting here that all ASAN testing on the staging branch is blocked and 
other problems could creep in while it remains so.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Alex Voicu via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

AlexVlx wrote:

> > I don't think mixing languages with different LangAS maps is sound
> 
> It is entirely sound, and required for this entire system to work

I am aware of what we decided to do. Whether or not that is actually sound is a 
different kettle of fish, but let's agree to disagree and move on. Stepping 
back, I'm trying to figure out what the actual suggestion is. Reverting the 
change is wrong, because there are other targets where for which 0 is 
definitely not a sound default, and this impacts more than the 
`used`/`compiler.used` arrays. Seems like there are two viable options:

1. I'm going to propose changing `emitUsed` anyway, since that makes sense even 
if the AS is indeed mostly meaningless there
2. IMHO OCL should default to `AMDGPUDefIsGenMap` for its LangAS map, which 
would "fix" this as well.
 
If there's some third reasonable solution, I apologise for missing it - please 
share!

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Matt Arsenault via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

arsenm wrote:

> I don't think mixing languages with different LangAS maps is sound

It is entirely sound, and required for this entire system to work (e.g. we 
implement the libraries in OpenCL used by all the languages). The point of the 
LangAS is to map to the target address space, which does not care what the 
language is. Different languages should be trying to be ABI compatible with 
each other, which includes emitting the correct IR address space 

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx edited 
https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Alex Voicu via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

AlexVlx wrote:

> The IR address space is a pure target concept. Any address space error would 
> be on the frontend emitting the wrong IR for the target

I don't think mixing languages with different LangAS maps is sound, OCL 
originating BC is not generic BC. There's no "error" here, the FE is doing what 
is asked of it (indiscriminately assuming that AS 0 is some generic/flat 
pointer that is valid everywhere is rather risque, as per prior conversation in 
this review). The actual problem is, AFAICT, that when we call 
`AMDGPUTargetInfo::adjust` we indiscriminately set private as default for any 
and all OCL compilations? There's a 6 year old `TODO`, which may or may not be 
vestigial at this point.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Alex Voicu via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

AlexVlx wrote:

> Fixing emitUsed probably is a feasible solution, but GlobalsInt8PtrTy will 
> cause the used array containing pointers to addr space 1, which is not 
> backward compatible for HIP. Maybe just use pointer to addr space 0 type as 
> before.

This would be wrong, assuming that 0 / Unqual is generally equivalent with some 
form of generic pointer is the core problem here. I'm not exactly sure what you 
mean by "backward compatible" here though, both the HIP source and whatever BC 
gets linked should go through the same toolchain, surely? Also, what @arsenm 
said sounds about right.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Matt Arsenault via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

arsenm wrote:

llvm.used should be using the default globals addrspace. I believe there is 
special case linker code to handle mismatched address spaces for the intrinsic 
globals, so I don't think fixing this would break anything 

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Yaxun Liu via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

yxsamliu wrote:

Fixing emitUsed probably is a feasible solution, but GlobalsInt8PtrTy will 
cause the used array containing pointers to addr space 1, which is not backward 
compatible for HIP. Maybe just use pointer to addr space 0 type as before.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-28 Thread Matt Arsenault via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

arsenm wrote:

The IR address space is a pure target concept. Any address space error would be 
on the frontend emitting the wrong IR for the target 

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-27 Thread via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

b-sumner wrote:

The AMDGPU address space mapping is at 
https://llvm.org/docs/AMDGPUUsage.html#address-spaces and address space 0 is 
not private.  The address space for all languages compiled for the AMDGPU 
target is consistent.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-27 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx edited 
https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-27 Thread Alex Voicu via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

AlexVlx wrote:

This seems to be an error on ASAN's side, it's relying on non-guaranteed 
behaviour and linking BC emanating from different languages with different AS 
maps. To wit, 0 is private for OCL, so having `llvm.used` and 
`llvm.compiler.used` be global arrays of pointers to private is somewhat 
suspect. I will / should fix `emitUsed` to rely on GlobalsInt8PtrTy, which 
seems like the right thing to do anyway, but whilst that'll make ASAN "work", 
it doesn't make ASAN correct, IMHO.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-27 Thread Yaxun Liu via cfe-commits


@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  Int8PtrTy = llvm::PointerType::get(LLVMContext,

yxsamliu wrote:

This seems to cause regressions for HIP -fsanitize=address.

Basically rocm device library for ASAN is compiled from OpenCL source code, for 
which the default address space is mapped to addr space 5 in IR. Int8PtrTy  is 
used to determine the pointer type in the llvm.compiler.used global array, 
which causes the pointers in that array to be in addr space 5. However, for HIP 
those are in addr space 0. The variable from different bitcode are appended 
together by the linker. The linker checks their type and emits error since they 
do not match.

https://godbolt.org/z/s48fTj7Pv

Before this change, the pointers are in addr space 0 for both HIP and OpenCL, 
therefore no such issue.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-19 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx closed 
https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-16 Thread Alex Voicu via cfe-commits


@@ -23,8 +26,8 @@ struct B : A {
 void g(A *a) { a->foo(); }
 
 // CHECK1-LABEL: define{{.*}} void @_ZN5test14fooAEv()
-// CHECK1: call void @_ZN5test11AC1Ev(ptr
-// CHECK1: %[[VTABLE:.*]] = load ptr addrspace(1), ptr %{{.*}}
+// CHECK1: call{{.*}} void @_ZN5test11AC1Ev(ptr {{((addrspace(4)){0,1})}}

AlexVlx wrote:

Right, so what I'll do is: merge this as is, and then revisit the test and 
rework it along the lines you and @jrtc27 are suggesting, since it looks as if 
I'll need to mess with it again for another piece of work.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-14 Thread Alexander Richardson via cfe-commits


@@ -23,8 +26,8 @@ struct B : A {
 void g(A *a) { a->foo(); }
 
 // CHECK1-LABEL: define{{.*}} void @_ZN5test14fooAEv()
-// CHECK1: call void @_ZN5test11AC1Ev(ptr
-// CHECK1: %[[VTABLE:.*]] = load ptr addrspace(1), ptr %{{.*}}
+// CHECK1: call{{.*}} void @_ZN5test11AC1Ev(ptr {{((addrspace(4)){0,1})}}

arichardson wrote:

I'd say this is probably fine for now, but these tests should be deduplicated 
and cleaned up in a follow-up.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-14 Thread Alexander Richardson via cfe-commits


@@ -1,14 +1,17 @@
 // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -std=c++11 -emit-llvm -o %t.ll 
-O1 -disable-llvm-passes -fms-extensions -fstrict-vtable-pointers
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 
-disable-llvm-passes -fms-extensions -fstrict-vtable-pointers
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers
 // FIXME: Assume load should not require -fstrict-vtable-pointers
 
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK4 --input-file=%t.ll %s
-// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK-MS --input-file=%t.ms.ll %s
 // RUN: FileCheck --check-prefix=CHECK6 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK7 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK8 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK9 --input-file=%t.ll %s

arichardson wrote:

Maybe it would be easier to autogenerate these check lines and just have the 
RUN: lines be:

```
// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -std=c++11 -emit-llvm -o - -O1 
-disable-llvm-passes -fms-extensions -fstrict-vtable-pointers | FileCheck %s 
--check-prefix=CHECK-AMDGCN
// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o - -O1 
-disable-llvm-passes -fms-extensions -fstrict-vtable-pointers | FileCheck %s 
--check-prefix=CHECK-MS
// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers | FileCheck %s --check-prefix=CHECK-SPIRV
```

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-12 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx edited 
https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-12 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx commented:

> Please fix the commit message before you merge; otherwise LGTM 

For the commit message I was thinking something along the following lines: `At 
the moment, Clang is rather liberal in assuming that 0 (and by extension 
unqualified) is always a safe default. This does not work for targets that 
actually use a different value for the default / generic AS (for example, the 
SPIRV that obtains from HIPSPV or SYCL). This patch is a first, fairly safe 
step towards trying to clear things up by querying a modules default AS from 
the target, rather than assuming it's 0, alongside fixing a few places where 
things break / we encode the 0 AS assumption. A bunch of existing tests are 
extended to check for non-zero default AS usage.`

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-08 Thread Alex Voicu via cfe-commits


@@ -23,8 +26,8 @@ struct B : A {
 void g(A *a) { a->foo(); }
 
 // CHECK1-LABEL: define{{.*}} void @_ZN5test14fooAEv()
-// CHECK1: call void @_ZN5test11AC1Ev(ptr
-// CHECK1: %[[VTABLE:.*]] = load ptr addrspace(1), ptr %{{.*}}
+// CHECK1: call{{.*}} void @_ZN5test11AC1Ev(ptr {{((addrspace(4)){0,1})}}

AlexVlx wrote:

Hmm, I can rework the regexp (it would still be icky), but it's not going to 
help with the issue I don't think. I would prefer to not spam another prefix, 
which is the only other way I can see for dealing with this without duplicating 
the test, but if the lack of love is extreme I can probably go that way.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-07 Thread Alex Voicu via cfe-commits


@@ -1,14 +1,17 @@
 // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -std=c++11 -emit-llvm -o %t.ll 
-O1 -disable-llvm-passes -fms-extensions -fstrict-vtable-pointers
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 
-disable-llvm-passes -fms-extensions -fstrict-vtable-pointers
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers
 // FIXME: Assume load should not require -fstrict-vtable-pointers
 
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK4 --input-file=%t.ll %s
-// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK-MS --input-file=%t.ms.ll %s
 // RUN: FileCheck --check-prefix=CHECK6 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK7 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK8 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK9 --input-file=%t.ll %s

AlexVlx wrote:

Ah, the renumbering is a consequence of merging in the base 
`vtable-assume-load.cpp` test; initially when I "wrote" this one, I had removed 
the `CHECK-MS` case, which just made it look awkward when compared with the 
base, as @arichardson pointed out in another comment, so I merely brought that 
back in so that it looks less odd when comparing with the base case. Apologies 
for the noise.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-07 Thread Jessica Clarke via cfe-commits


@@ -1,14 +1,17 @@
 // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -std=c++11 -emit-llvm -o %t.ll 
-O1 -disable-llvm-passes -fms-extensions -fstrict-vtable-pointers
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 
-disable-llvm-passes -fms-extensions -fstrict-vtable-pointers
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers
 // FIXME: Assume load should not require -fstrict-vtable-pointers
 
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK4 --input-file=%t.ll %s
-// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK-MS --input-file=%t.ms.ll %s
 // RUN: FileCheck --check-prefix=CHECK6 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK7 --input-file=%t.ll %s
 // RUN: FileCheck --check-prefix=CHECK8 --input-file=%t.ll %s
+// RUN: FileCheck --check-prefix=CHECK9 --input-file=%t.ll %s

jrtc27 wrote:

Why renumber everything? Just add yours to the end?

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-07 Thread Jessica Clarke via cfe-commits


@@ -23,8 +26,8 @@ struct B : A {
 void g(A *a) { a->foo(); }
 
 // CHECK1-LABEL: define{{.*}} void @_ZN5test14fooAEv()
-// CHECK1: call void @_ZN5test11AC1Ev(ptr
-// CHECK1: %[[VTABLE:.*]] = load ptr addrspace(1), ptr %{{.*}}
+// CHECK1: call{{.*}} void @_ZN5test11AC1Ev(ptr {{((addrspace(4)){0,1})}}

jrtc27 wrote:

I don’t love how this isn’t checking the address space is correct for each, 
only that it’s one of the two valid ones

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-07 Thread Alexander Richardson via cfe-commits

https://github.com/arichardson approved this pull request.


https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-07 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx edited 
https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-07 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx commented:

> Would be good to fold 
> clang/test/CodeGenCXX/vtable-assume-load-nonzero-default-address-space.cpp 
> into one of the files it was copied from, otherwise LGTM. 

Apologies for the delay, I was away; should be sorted now.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-03 Thread Alexander Richardson via cfe-commits


@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers
+// FIXME: Assume load should not require -fstrict-vtable-pointers
+
+// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s

arichardson wrote:

Sounds good to me

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-03 Thread Alexander Richardson via cfe-commits

https://github.com/arichardson approved this pull request.

Would be good to fold 
clang/test/CodeGenCXX/vtable-assume-load-nonzero-default-address-space.cpp into 
one of the files it was copied from, otherwise LGTM.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-02 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

Please fix the commit message before you merge; otherwise LGTM

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-01 Thread Alex Voicu via cfe-commits


@@ -1370,7 +1370,7 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable, 
IntrWillReturn] in {
 
 // The result of eh.typeid.for depends on the enclosing function, but inside a
 // given function it is 'const' and may be CSE'd etc.
-def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
+def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty], 
[IntrNoMem]>;
 
 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;

AlexVlx wrote:

Possibly, but it's a slightly different matter which I should probably deal 
with in another PR, wherein we handle the fact that the Program AS needn't be 
0. AFAICT these intrinsics are here to support GCC's `__builtin_eh_return`, and 
the pointer arg is supposed to point to a handler function in the Program AS. I 
think it's preferable to handle that topic independently since it'll spawn its 
own lively discussion, no doubt.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-01 Thread Alex Voicu via cfe-commits


@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers
+// FIXME: Assume load should not require -fstrict-vtable-pointers
+
+// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s

AlexVlx wrote:

If you do not mind, I will take it up as a subsequent activity, as I'd have to 
figure out the rationale of the test to see how to collapse it. For now, it 
would be nice to not tickle the dragon too much, this has already grown quite a 
bit beyond its initial state:)

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-04-29 Thread Alexander Richardson via cfe-commits


@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers
+// FIXME: Assume load should not require -fstrict-vtable-pointers
+
+// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s

arichardson wrote:

Does not need to be fixed as part of this change but would be great to 
consolidate those tests in a follow-up change.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-04-29 Thread Alexander Richardson via cfe-commits

https://github.com/arichardson commented:

Spotted one more duplicate test, otherwise looks good to me with the reworded 
TODO comment suggestion.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-04-29 Thread Alexander Richardson via cfe-commits


@@ -1370,7 +1370,7 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable, 
IntrWillReturn] in {
 
 // The result of eh.typeid.for depends on the enclosing function, but inside a
 // given function it is 'const' and may be CSE'd etc.
-def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
+def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty], 
[IntrNoMem]>;
 
 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;

arichardson wrote:

Doesn't this intrinsic need the same llvm_anyptr_ty overload?

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-04-29 Thread Alexander Richardson via cfe-commits


@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers
+// FIXME: Assume load should not require -fstrict-vtable-pointers
+
+// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s

arichardson wrote:

I really don't understand why all these different CHECK lines are here... 
Should just be a single invocation (and could pipe directly to FileCheck). 
Looks like it dates all the way back to https://reviews.llvm.org/D11859.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-04-29 Thread Alexander Richardson via cfe-commits

https://github.com/arichardson edited 
https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-04-29 Thread Alexander Richardson via cfe-commits


@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 %s -triple=spirv64-unknown-unknown -fsycl-is-device 
-std=c++11 -emit-llvm -o %t.ll -O1 -disable-llvm-passes -fms-extensions 
-fstrict-vtable-pointers

arichardson wrote:

This test should be merged with the existing address-space.cpp test. I also 
noticed that the address space one has some missing changes compared to the 
baseline so ideally that would be merged with the base test, but can be done in 
a separate pull request.

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-04-24 Thread Alex Voicu via cfe-commits


@@ -2216,7 +2216,7 @@ static llvm::Value *EmitTypeidFromVTable(CodeGenFunction 
, const Expr *E,
 }
 
 llvm::Value *CodeGenFunction::EmitCXXTypeidExpr(const CXXTypeidExpr *E) {
-  llvm::Type *PtrTy = llvm::PointerType::getUnqual(getLLVMContext());
+  llvm::Type *PtrTy = Int8PtrTy;

AlexVlx wrote:

It could be `GlobalsInt8PtrTy`, but the main roadblock would require something 
that @rjmccall suggested looking into, namely adding the ability to declare a 
default AS for a class type, which stdlib implementations could then re-use. 
Having said that, I've neither had the time to look into it, nor figured out if 
this would work in general, considering we need to compose with stdlib 
implementations other than libc++. Having said that, perhaps the TODO: should 
actually be at the end of the comment, and just say something along the lines 
of "investigate if it is possible to remove this limitation"?

https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits