[clang] [clang] Replace uses of CreatePointerBitCastOrAddrSpaceCast (NFC) (PR #68277)

Björn Pettersson via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 6 02:39:32 PDT 2023


================
@@ -1123,9 +1123,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
     if (!CurFnInfo->getReturnInfo().getIndirectByVal()) {
       ReturnValuePointer =
           CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
-      Builder.CreateStore(Builder.CreatePointerBitCastOrAddrSpaceCast(
-                              ReturnValue.getPointer(), Int8PtrTy),
-                          ReturnValuePointer);
+      Builder.CreateStore(ReturnValue.getPointer(), ReturnValuePointer);
----------------
bjope wrote:

So `ReturnValue.getPointer()` is guaranteed to be an unqualified pointer?

I'm just wondering why this hasn't been just a pointer bitcast in the past. But even if it would cast away an address space it seems a bit weird.
Not sure if it is worth an assert now when we bypass all the castIsValid checks etc that would have been done in the past.

(And maybe the "result.ptr" should be created with `ReturnValue.getPointer().getType()` rather than using Int8PtrTy. Although I consider that as out of scope for this patch.)

https://github.com/llvm/llvm-project/pull/68277


More information about the cfe-commits mailing list