[LLVMdev] [RFC] "noclone" function attribute
Krzysztof Parzyszek
kparzysz at codeaurora.org
Sat Dec 1 09:19:24 PST 2012
On 12/1/2012 10:02 AM, James Molloy wrote:
>
> I'm proposing a new function attribute, "noclone", with the semantics that "calls to functions marked "noclone" cannot be cloned or duplicated into the same function.". That is, it is illegal to call J = I->clone() then attach J to the same basic block as I if I is marked "noclone".
The class Loop has something similar in it:
/// isSafeToClone - Return true if the loop body is safe to clone in
practice.
/// Routines that reform the loop CFG and split edges often fail on
indirectbr.
bool Loop::isSafeToClone() const {
// Return false if any loop blocks contain indirectbrs.
for (Loop::block_iterator I = block_begin(), E = block_end(); I != E;
++I) {
if (isa<IndirectBrInst>((*I)->getTerminator()))
return false;
}
return true;
}
Maybe a similar interface could be added to Instruction, and an
instruction would declare itself unsafe to clone if it was a call to a
function with the attribute that you are proposing.
I could imagine that this may not the only example of an instruction
that should not be cloned.
I'd only suggest that the attribute is called something like
"noclonecalls", or (preferably) something shorter that clarifies that
it's the calls that shouldn't be cloned. :)
-Krzysztof
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-dev
mailing list