Mercurial > hg > CbC > CbC_llvm
comparison lib/Analysis/MemoryLocation.cpp @ 120:1172e4bd9c6f
update 4.0.0
author | mir3636 |
---|---|
date | Fri, 25 Nov 2016 19:14:25 +0900 |
parents | afa8332a0e37 |
children | 803732b1fca8 |
comparison
equal
deleted
inserted
replaced
101:34baf5011add | 120:1172e4bd9c6f |
---|---|
88 MTI->getAAMetadata(AATags); | 88 MTI->getAAMetadata(AATags); |
89 | 89 |
90 return MemoryLocation(MTI->getRawDest(), Size, AATags); | 90 return MemoryLocation(MTI->getRawDest(), Size, AATags); |
91 } | 91 } |
92 | 92 |
93 // FIXME: This code is duplicated with BasicAliasAnalysis and should be hoisted | |
94 // to some common utility location. | |
95 static bool isMemsetPattern16(const Function *MS, | |
96 const TargetLibraryInfo &TLI) { | |
97 if (TLI.has(LibFunc::memset_pattern16) && | |
98 MS->getName() == "memset_pattern16") { | |
99 FunctionType *MemsetType = MS->getFunctionType(); | |
100 if (!MemsetType->isVarArg() && MemsetType->getNumParams() == 3 && | |
101 isa<PointerType>(MemsetType->getParamType(0)) && | |
102 isa<PointerType>(MemsetType->getParamType(1)) && | |
103 isa<IntegerType>(MemsetType->getParamType(2))) | |
104 return true; | |
105 } | |
106 | |
107 return false; | |
108 } | |
109 | |
110 MemoryLocation MemoryLocation::getForArgument(ImmutableCallSite CS, | 93 MemoryLocation MemoryLocation::getForArgument(ImmutableCallSite CS, |
111 unsigned ArgIdx, | 94 unsigned ArgIdx, |
112 const TargetLibraryInfo &TLI) { | 95 const TargetLibraryInfo &TLI) { |
113 AAMDNodes AATags; | 96 AAMDNodes AATags; |
114 CS->getAAMetadata(AATags); | 97 CS->getAAMetadata(AATags); |
157 | 140 |
158 // We can bound the aliasing properties of memset_pattern16 just as we can | 141 // We can bound the aliasing properties of memset_pattern16 just as we can |
159 // for memcpy/memset. This is particularly important because the | 142 // for memcpy/memset. This is particularly important because the |
160 // LoopIdiomRecognizer likes to turn loops into calls to memset_pattern16 | 143 // LoopIdiomRecognizer likes to turn loops into calls to memset_pattern16 |
161 // whenever possible. | 144 // whenever possible. |
162 if (CS.getCalledFunction() && | 145 LibFunc::Func F; |
163 isMemsetPattern16(CS.getCalledFunction(), TLI)) { | 146 if (CS.getCalledFunction() && TLI.getLibFunc(*CS.getCalledFunction(), F) && |
147 F == LibFunc::memset_pattern16 && TLI.has(F)) { | |
164 assert((ArgIdx == 0 || ArgIdx == 1) && | 148 assert((ArgIdx == 0 || ArgIdx == 1) && |
165 "Invalid argument index for memset_pattern16"); | 149 "Invalid argument index for memset_pattern16"); |
166 if (ArgIdx == 1) | 150 if (ArgIdx == 1) |
167 return MemoryLocation(Arg, 16, AATags); | 151 return MemoryLocation(Arg, 16, AATags); |
168 if (const ConstantInt *LenCI = dyn_cast<ConstantInt>(CS.getArgument(2))) | 152 if (const ConstantInt *LenCI = dyn_cast<ConstantInt>(CS.getArgument(2))) |