ConstantInt::get only works for arguments < 128.
SimplifyLibCalls probably has to be audited to make sure it does not make this mistake elsewhere. Also, if this code knows that the type will be unsigned, obviously one arm of this is dead. Reid, can you take a look into this further? llvm-svn: 22566
This commit is contained in:
		
							parent
							
								
									546fd5944e
								
							
						
					
					
						commit
						e17c5d0e59
					
				| 
						 | 
					@ -962,8 +962,12 @@ struct StrLenOptimization : public LibCallOptimization
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // strlen("xyz") -> 3 (for example)
 | 
					    // strlen("xyz") -> 3 (for example)
 | 
				
			||||||
    ci->replaceAllUsesWith(
 | 
					    const Type *Ty = SLC.getTargetData()->getIntPtrType();
 | 
				
			||||||
        ConstantInt::get(SLC.getTargetData()->getIntPtrType(),len));
 | 
					    if (Ty->isSigned())
 | 
				
			||||||
 | 
					      ci->replaceAllUsesWith(ConstantSInt::get(Ty, len));
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      ci->replaceAllUsesWith(ConstantUInt::get(Ty, len));
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
    ci->eraseFromParent();
 | 
					    ci->eraseFromParent();
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue