Author: rjmccall Date: Fri Jan 12 14:07:01 2018 New Revision: 322406 URL: http://llvm.org/viewvc/llvm-project?rev=322406&view=rev Log: Allocate and access NormalCleanupDest with the natural alignment of i32.
This alignment can be less than 4 on certain embedded targets, which may not even be able to deal with 4-byte alignment on the stack. Patch by Jacob Young! Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=322406&r1=322405&r2=322406&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Fri Jan 12 14:07:01 2018 @@ -624,7 +624,7 @@ static void destroyOptimisticNormalEntry si->eraseFromParent(); // Destroy the load. - assert(condition->getOperand(0) == CGF.NormalCleanupDest); + assert(condition->getOperand(0) == CGF.NormalCleanupDest.getPointer()); assert(condition->use_empty()); condition->eraseFromParent(); } @@ -833,7 +833,7 @@ void CodeGenFunction::PopCleanupBlock(bo if (NormalCleanupDestSlot->hasOneUse()) { NormalCleanupDestSlot->user_back()->eraseFromParent(); NormalCleanupDestSlot->eraseFromParent(); - NormalCleanupDest = nullptr; + NormalCleanupDest = Address::invalid(); } llvm::BasicBlock *BranchAfter = Scope.getBranchAfterBlock(0); @@ -1250,10 +1250,10 @@ void CodeGenFunction::DeactivateCleanupB } Address CodeGenFunction::getNormalCleanupDestSlot() { - if (!NormalCleanupDest) + if (!NormalCleanupDest.isValid()) NormalCleanupDest = - CreateTempAlloca(Builder.getInt32Ty(), "cleanup.dest.slot"); - return Address(NormalCleanupDest, CharUnits::fromQuantity(4)); + CreateDefaultAlignTempAlloca(Builder.getInt32Ty(), "cleanup.dest.slot"); + return NormalCleanupDest; } /// Emits all the code to cause the given temporary to be cleaned up. Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=322406&r1=322405&r2=322406&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 12 14:07:01 2018 @@ -70,7 +70,7 @@ CodeGenFunction::CodeGenFunction(CodeGen IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr), BlockPointer(nullptr), LambdaThisCaptureField(nullptr), - NormalCleanupDest(nullptr), NextCleanupDestIndex(1), + NormalCleanupDest(Address::invalid()), NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr), EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()), DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr), @@ -439,10 +439,11 @@ void CodeGenFunction::FinishFunction(Sou // if compiled with no optimizations. We do it for coroutine as the lifetime // of CleanupDestSlot alloca make correct coroutine frame building very // difficult. - if (NormalCleanupDest && isCoroutine()) { + if (NormalCleanupDest.isValid() && isCoroutine()) { llvm::DominatorTree DT(*CurFn); - llvm::PromoteMemToReg(NormalCleanupDest, DT); - NormalCleanupDest = nullptr; + llvm::PromoteMemToReg( + cast<llvm::AllocaInst>(NormalCleanupDest.getPointer()), DT); + NormalCleanupDest = Address::invalid(); } } Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=322406&r1=322405&r2=322406&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Jan 12 14:07:01 2018 @@ -434,7 +434,7 @@ public: }; /// i32s containing the indexes of the cleanup destinations. - llvm::AllocaInst *NormalCleanupDest; + Address NormalCleanupDest; unsigned NextCleanupDestIndex; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits