diff options
author | Zequan Wu <zequanwu@google.com> | 2021-06-22 21:46:21 -0700 |
---|---|---|
committer | Zequan Wu <zequanwu@google.com> | 2021-06-22 21:48:00 -0700 |
commit | f681fd927e883301658dcac9a78109ee0aba12a8 (patch) | |
tree | c5d27bc861da6945886983a633473f7c9e6a63d0 /clang/lib | |
parent | 976926e8ee3e3c9f7c391281eab89e0d1b02092a (diff) | |
download | llvm-f681fd927e883301658dcac9a78109ee0aba12a8.zip llvm-f681fd927e883301658dcac9a78109ee0aba12a8.tar.gz llvm-f681fd927e883301658dcac9a78109ee0aba12a8.tar.bz2 |
Revert "[CodeGen] Don't create fake FunctionDecls when generating block/byref"
That commit causes crash with error "!dbg attachment points at wrong subprogram for function" on iOS platforms.
This reverts commit f4c06bcb67a1eba13a7f164961586dddaf8ebd5f.
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 1326c26..9956d12 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1948,13 +1948,21 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) { if (CGM.supportsCOMDAT()) Fn->setComdat(CGM.getModule().getOrInsertComdat(FuncName)); + IdentifierInfo *II = &C.Idents.get(FuncName); + SmallVector<QualType, 2> ArgTys; ArgTys.push_back(C.VoidPtrTy); ArgTys.push_back(C.VoidPtrTy); + QualType FunctionTy = C.getFunctionType(ReturnTy, ArgTys, {}); + FunctionDecl *FD = FunctionDecl::Create( + C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, + FunctionTy, nullptr, SC_Static, false, false); setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI, CGM); - StartFunction(GlobalDecl(), ReturnTy, Fn, FI, args); + // This is necessary to avoid inheriting the previous line number. + FD->setImplicit(); + StartFunction(FD, ReturnTy, Fn, FI, args); auto AL = ApplyDebugLocation::CreateArtificial(*this); llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo(); @@ -2135,12 +2143,21 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) { if (CGM.supportsCOMDAT()) Fn->setComdat(CGM.getModule().getOrInsertComdat(FuncName)); + IdentifierInfo *II = &C.Idents.get(FuncName); + SmallVector<QualType, 1> ArgTys; ArgTys.push_back(C.VoidPtrTy); + QualType FunctionTy = C.getFunctionType(ReturnTy, ArgTys, {}); + + FunctionDecl *FD = FunctionDecl::Create( + C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, + FunctionTy, nullptr, SC_Static, false, false); setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI, CGM); - StartFunction(GlobalDecl(), ReturnTy, Fn, FI, args); + // This is necessary to avoid inheriting the previous line number. + FD->setImplicit(); + StartFunction(FD, ReturnTy, Fn, FI, args); markAsIgnoreThreadCheckingAtRuntime(Fn); auto AL = ApplyDebugLocation::CreateArtificial(*this); @@ -2378,13 +2395,21 @@ generateByrefCopyHelper(CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo, llvm::Function::Create(LTy, llvm::GlobalValue::InternalLinkage, "__Block_byref_object_copy_", &CGF.CGM.getModule()); + IdentifierInfo *II + = &Context.Idents.get("__Block_byref_object_copy_"); + SmallVector<QualType, 2> ArgTys; ArgTys.push_back(Context.VoidPtrTy); ArgTys.push_back(Context.VoidPtrTy); + QualType FunctionTy = Context.getFunctionType(ReturnTy, ArgTys, {}); + + FunctionDecl *FD = FunctionDecl::Create( + Context, Context.getTranslationUnitDecl(), SourceLocation(), + SourceLocation(), II, FunctionTy, nullptr, SC_Static, false, false); CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); - CGF.StartFunction(GlobalDecl(), ReturnTy, Fn, FI, args); + CGF.StartFunction(FD, ReturnTy, Fn, FI, args); if (generator.needsCopy()) { llvm::Type *byrefPtrType = byrefInfo.Type->getPointerTo(0); @@ -2446,12 +2471,20 @@ generateByrefDisposeHelper(CodeGenFunction &CGF, "__Block_byref_object_dispose_", &CGF.CGM.getModule()); + IdentifierInfo *II + = &Context.Idents.get("__Block_byref_object_dispose_"); + SmallVector<QualType, 1> ArgTys; ArgTys.push_back(Context.VoidPtrTy); + QualType FunctionTy = Context.getFunctionType(R, ArgTys, {}); + + FunctionDecl *FD = FunctionDecl::Create( + Context, Context.getTranslationUnitDecl(), SourceLocation(), + SourceLocation(), II, FunctionTy, nullptr, SC_Static, false, false); CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); - CGF.StartFunction(GlobalDecl(), R, Fn, FI, args); + CGF.StartFunction(FD, R, Fn, FI, args); if (generator.needsDispose()) { Address addr = CGF.GetAddrOfLocalVar(&Src); |