Skip to content
Snippets Groups Projects
Commit f0d299c1 authored by Prakalp Srivastava's avatar Prakalp Srivastava
Browse files

Do not allow argument type mungling for __visc__ calls. Changes to...

Do not allow argument type mungling for __visc__ calls. Changes to lib/Transforms/InstCombine/InstCombineCalls.cpp
parent 9a12aab2
No related branches found
No related tags found
No related merge requests found
......@@ -758,6 +758,20 @@ Instruction *InstCombiner::visitInvokeInst(InvokeInst &II) {
return visitCallSite(&II);
}
// Check if it is a visc call
static bool isVISCCall(const ImmutableCallSite &CS) {
if (!CS.getInstruction()) {
// This is not a call site
return false;
}
if (const CallInst *call = dyn_cast<CallInst>(CS.getInstruction())) {
if(const Function *F = call->getCalledFunction()) {
return F->getName().startswith("__visc__");
}
}
return false;
}
/// isSafeToEliminateVarargsCast - If this cast does not affect the value
/// passed through the varargs area, we can eliminate the use of the cast.
static bool isSafeToEliminateVarargsCast(const CallSite CS,
......@@ -767,6 +781,11 @@ static bool isSafeToEliminateVarargsCast(const CallSite CS,
if (!CI->isLosslessCast())
return false;
// If this is a visc dummy call, avoid mungling types. We need types for
// generating correct visc code.
if(isVISCCall(CS))
return false;
// The size of ByVal arguments is derived from the type, so we
// can't change to a type with a different size. If the size were
// passed explicitly we could avoid this check.
......@@ -780,6 +799,7 @@ static bool isSafeToEliminateVarargsCast(const CallSite CS,
return false;
if (!TD || TD->getTypeAllocSize(SrcTy) != TD->getTypeAllocSize(DstTy))
return false;
return true;
}
......@@ -976,7 +996,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
}
// transformConstExprCastCall - If the callee is a constexpr cast of a function,
// attempt to move the cast to the arguments of the call/invoke.
// attempt to move the cast to the arg\numents of the call/invoke.
//
bool InstCombiner::transformConstExprCastCall(CallSite CS) {
Function *Callee =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment