Adding noalias attribute to malloc return
This commit is contained in:
14
ctx.cpp
14
ctx.cpp
@@ -3285,6 +3285,20 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
|
||||
// pointer, so just emit the IR directly.
|
||||
llvm::Instruction *ci =
|
||||
llvm::CallInst::Create(func, argVals, name ? name : "", bblock);
|
||||
|
||||
// Copy noalias attribute to call instruction, to enable better
|
||||
// alias analysis.
|
||||
// TODO: what other attributes needs to be copied?
|
||||
// TODO: do the same for varing path.
|
||||
#if defined (LLVM_3_3)
|
||||
llvm::CallInst *cc = llvm::dyn_cast<llvm::CallInst>(ci);
|
||||
if (cc &&
|
||||
cc->getCalledFunction() &&
|
||||
cc->getCalledFunction()->doesNotAlias(0)) {
|
||||
cc->addAttribute(0, llvm::Attribute::NoAlias);
|
||||
}
|
||||
#endif
|
||||
|
||||
AddDebugPos(ci);
|
||||
return ci;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user