aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2025-05-08 07:51:57 +0200
committerGitHub <noreply@github.com>2025-05-08 07:51:57 +0200
commita11d86461e7d7d9bce3d04a39ded1cad394239ca (patch)
tree497af7e016c59073829ade22f7c1ab82c1d55659 /clang/lib/CodeGen/CodeGenFunction.h
parent5df01abe191ff4f848566e239798a2b4d26e1cf4 (diff)
downloadllvm-a11d86461e7d7d9bce3d04a39ded1cad394239ca.zip
llvm-a11d86461e7d7d9bce3d04a39ded1cad394239ca.tar.gz
llvm-a11d86461e7d7d9bce3d04a39ded1cad394239ca.tar.bz2
clang: Fix broken implicit cast to generic address space (#138863)
This fixes emitting undefined behavior where a 64-bit generic pointer is written to a 32-bit slot allocated for a private pointer. This can be seen in test/CodeGenOpenCL/amdgcn-automatic-variable.cl's wrong_pointer_alloca.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 561f8f6..c0bc382 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2861,10 +2861,28 @@ public:
/// more efficient if the caller knows that the address will not be exposed.
llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine &Name = "tmp",
llvm::Value *ArraySize = nullptr);
+
+ /// CreateTempAlloca - This creates a alloca and inserts it into the entry
+ /// block. The alloca is casted to the address space of \p UseAddrSpace if
+ /// necessary.
+ RawAddress CreateTempAlloca(llvm::Type *Ty, LangAS UseAddrSpace,
+ CharUnits align, const Twine &Name = "tmp",
+ llvm::Value *ArraySize = nullptr,
+ RawAddress *Alloca = nullptr);
+
+ /// CreateTempAlloca - This creates a alloca and inserts it into the entry
+ /// block. The alloca is casted to default address space if necessary.
+ ///
+ /// FIXME: This version should be removed, and context should provide the
+ /// context use address space used instead of default.
RawAddress CreateTempAlloca(llvm::Type *Ty, CharUnits align,
const Twine &Name = "tmp",
llvm::Value *ArraySize = nullptr,
- RawAddress *Alloca = nullptr);
+ RawAddress *Alloca = nullptr) {
+ return CreateTempAlloca(Ty, LangAS::Default, align, Name, ArraySize,
+ Alloca);
+ }
+
RawAddress CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align,
const Twine &Name = "tmp",
llvm::Value *ArraySize = nullptr);