mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	DeadStoreElimination can treat byval parameters as if there were alloca's for the purpose of removing end-of-function stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46351 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -261,9 +261,6 @@ bool DSE::handleEndBlock(BasicBlock& BB, | ||||
|   for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ){ | ||||
|     --BBI; | ||||
|      | ||||
|     if (deadPointers.empty()) | ||||
|       break; | ||||
|      | ||||
|     // If we find a store whose pointer is dead... | ||||
|     if (StoreInst* S = dyn_cast<StoreInst>(BBI)) { | ||||
|       if (!S->isVolatile()) { | ||||
| @@ -271,8 +268,12 @@ bool DSE::handleEndBlock(BasicBlock& BB, | ||||
|         // See through pointer-to-pointer bitcasts | ||||
|         TranslatePointerBitCasts(pointerOperand); | ||||
|        | ||||
|         if (isa<AllocaInst>(pointerOperand) &&  | ||||
|             deadPointers.count(cast<AllocaInst>(pointerOperand))) { | ||||
|         // Alloca'd pointers or byval arguments (which are functionally like | ||||
|         // alloca's) are valid candidates for removal. | ||||
|         if ( (isa<AllocaInst>(pointerOperand) &&  | ||||
|               deadPointers.count(cast<AllocaInst>(pointerOperand))) || | ||||
|              (isa<Argument>(pointerOperand) && | ||||
|               cast<Argument>(pointerOperand)->hasByValAttr())) { | ||||
|           // Remove it! | ||||
|           MD.removeInstruction(S); | ||||
|          | ||||
|   | ||||
							
								
								
									
										10
									
								
								test/Transforms/DeadStoreElimination/byval.ll
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								test/Transforms/DeadStoreElimination/byval.ll
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| ; RUN: llvm-as < %s | opt -dse | llvm-dis | not grep store | ||||
|  | ||||
| %struct.x = type { i32, i32, i32, i32 } | ||||
|  | ||||
| define i32 @foo(%struct.x* byval  %a) nounwind  { | ||||
| entry: | ||||
| 	%tmp2 = getelementptr %struct.x* %a, i32 0, i32 0 | ||||
| 	store i32 1, i32* %tmp2, align 4 | ||||
| 	ret i32 1 | ||||
| } | ||||
		Reference in New Issue
	
	Block a user