|
@@ -5479,32 +5479,34 @@ void CGMSHLSLRuntime::EmitHLSLOutParamConversionInit(
|
|
argLV = CGF.EmitLValue(Arg);
|
|
argLV = CGF.EmitLValue(Arg);
|
|
if (argLV.isSimple())
|
|
if (argLV.isSimple())
|
|
argAddr = argLV.getAddress();
|
|
argAddr = argLV.getAddress();
|
|
- // When there's argument need to lower like buffer/cbuffer load, need to
|
|
|
|
- // copy to let the lower not happen on argument when calle is noinline or
|
|
|
|
- // extern functions. Will do it in HLLegalizeParameter after known which
|
|
|
|
- // functions are extern but before inline.
|
|
|
|
- bool bConstGlobal = false;
|
|
|
|
- Value *Ptr = argAddr;
|
|
|
|
- while (GEPOperator *GEP = dyn_cast_or_null<GEPOperator>(Ptr)) {
|
|
|
|
- Ptr = GEP->getPointerOperand();
|
|
|
|
- }
|
|
|
|
- if (GlobalVariable *GV = dyn_cast_or_null<GlobalVariable>(Ptr)) {
|
|
|
|
- bConstGlobal = m_ConstVarAnnotationMap.count(GV) | GV->isConstant();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Skip copy-in copy-out when safe.
|
|
|
|
- // The unsafe case will be global variable alias with parameter.
|
|
|
|
- // Then global variable is updated in the function, the parameter will
|
|
|
|
- // be updated silently. For non global variable or constant global
|
|
|
|
- // variable, it should be safe.
|
|
|
|
- if (argAddr &&
|
|
|
|
- (isa<AllocaInst>(Ptr) || isa<Argument>(Ptr) || bConstGlobal)) {
|
|
|
|
- llvm::Type *ToTy = CGF.ConvertType(ParamTy.getNonReferenceType());
|
|
|
|
- if (argAddr->getType()->getPointerElementType() == ToTy &&
|
|
|
|
- // Check clang Type for case like int cast to unsigned.
|
|
|
|
- ParamTy.getNonReferenceType().getCanonicalType().getTypePtr() ==
|
|
|
|
- Arg->getType().getCanonicalType().getTypePtr())
|
|
|
|
- continue;
|
|
|
|
|
|
+ // TODO: enable avoid copy for lib profile.
|
|
|
|
+ if (!m_bIsLib) {
|
|
|
|
+ // When there's argument need to lower like buffer/cbuffer load, need to
|
|
|
|
+ // copy to let the lower not happen on argument when calle is noinline
|
|
|
|
+ // or extern functions. Will do it in HLLegalizeParameter after known
|
|
|
|
+ // which functions are extern but before inline.
|
|
|
|
+ bool bConstGlobal = false;
|
|
|
|
+ Value *Ptr = argAddr;
|
|
|
|
+ while (GEPOperator *GEP = dyn_cast_or_null<GEPOperator>(Ptr)) {
|
|
|
|
+ Ptr = GEP->getPointerOperand();
|
|
|
|
+ }
|
|
|
|
+ if (GlobalVariable *GV = dyn_cast_or_null<GlobalVariable>(Ptr)) {
|
|
|
|
+ bConstGlobal = m_ConstVarAnnotationMap.count(GV) | GV->isConstant();
|
|
|
|
+ }
|
|
|
|
+ // Skip copy-in copy-out when safe.
|
|
|
|
+ // The unsafe case will be global variable alias with parameter.
|
|
|
|
+ // Then global variable is updated in the function, the parameter will
|
|
|
|
+ // be updated silently. For non global variable or constant global
|
|
|
|
+ // variable, it should be safe.
|
|
|
|
+ if (argAddr &&
|
|
|
|
+ (isa<AllocaInst>(Ptr) || isa<Argument>(Ptr) || bConstGlobal)) {
|
|
|
|
+ llvm::Type *ToTy = CGF.ConvertType(ParamTy.getNonReferenceType());
|
|
|
|
+ if (argAddr->getType()->getPointerElementType() == ToTy &&
|
|
|
|
+ // Check clang Type for case like int cast to unsigned.
|
|
|
|
+ ParamTy.getNonReferenceType().getCanonicalType().getTypePtr() ==
|
|
|
|
+ Arg->getType().getCanonicalType().getTypePtr())
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
argType = argLV.getType(); // TBD: Can this be different than Arg->getType()?
|
|
argType = argLV.getType(); // TBD: Can this be different than Arg->getType()?
|
|
argAlignment = argLV.getAlignment();
|
|
argAlignment = argLV.getAlignment();
|