[PATCH] D142048: [Phabricator] Fix __ptr32 arguments passed to builtins
Ariel Burton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 19 09:55:57 PST 2023
Ariel-Burton updated this revision to Diff 490569.
Ariel-Burton added a comment.
- Adjust formatting to conform to git-clang-format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142048/new/
https://reviews.llvm.org/D142048
Files:
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/address-space-ptr32.c
Index: clang/test/CodeGen/address-space-ptr32.c
===================================================================
--- clang/test/CodeGen/address-space-ptr32.c
+++ clang/test/CodeGen/address-space-ptr32.c
@@ -38,3 +38,31 @@
int_star __ptr32 p;
return sizeof(p);
}
+
+typedef __SIZE_TYPE__ size_t;
+size_t strlen(const char *);
+
+size_t test_calling_strlen_with_32_bit_pointer ( char *__ptr32 s ) {
+ // CHECK-LABEL: define dso_local i64 @test_calling_strlen_with_32_bit_pointer(ptr addrspace(270) noundef %s)
+ // CHECK-NEXT: entry:
+ // CHECK-NEXT: %s.addr = alloca ptr addrspace(270), align 4
+ // CHECK-NEXT: store ptr addrspace(270) %s, ptr %s.addr, align 4
+ // CHECK-NEXT: %0 = load ptr addrspace(270), ptr %s.addr, align 4
+ // CHECK-NEXT: %1 = addrspacecast ptr addrspace(270) %0 to ptr
+ // CHECK-NEXT: %call = call i64 @strlen(ptr noundef %1)
+ // CHECK-NEXT: ret i64 %call
+ return strlen ( s );
+}
+
+// CHECK-LABEL: declare dso_local i64 @strlen(ptr noundef)
+
+size_t test_calling_strlen_with_64_bit_pointer ( char *s ) {
+ // CHECK-LABEL: define dso_local i64 @test_calling_strlen_with_64_bit_pointer(ptr noundef %s)
+ // CHECK-NEXT: entry:
+ // CHECK-NEXT: %s.addr = alloca ptr, align 8
+ // CHECK-NEXT: store ptr %s, ptr %s.addr, align 8
+ // CHECK-NEXT: %0 = load ptr, ptr %s.addr, align 8
+ // CHECK-NEXT: %call = call i64 @strlen(ptr noundef %0)
+ // CHECK-NEXT: ret i64 %call
+ return strlen ( s );
+}
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6650,10 +6650,10 @@
return nullptr;
Expr *Arg = ArgRes.get();
QualType ArgType = Arg->getType();
- if (!ParamType->isPointerType() ||
- ParamType.hasAddressSpace() ||
+ if (!ParamType->isPointerType() || ParamType.hasAddressSpace() ||
!ArgType->isPointerType() ||
- !ArgType->getPointeeType().hasAddressSpace()) {
+ !ArgType->getPointeeType().hasAddressSpace() ||
+ isPtrSizeAddressSpace(ArgType->getPointeeType().getAddressSpace())) {
OverloadParams.push_back(ParamType);
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142048.490569.patch
Type: text/x-patch
Size: 2208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230119/deb4cf14/attachment-0001.bin>
More information about the cfe-commits
mailing list