[LLVMdev] [RFC] "noclone" function attribute

James Molloy James.Molloy at arm.com
Sat Dec 1 09:25:41 PST 2012


> 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 experimented with something similar to this, where Instruction::clone ensured it wasn't "noclone" - if it was, it asserted. But that broke the use-case of cloning whole functions.

My patch extends Loop::isSafeToClone to check if a callinst is contained which is "noclone".

I agree about the naming, but have yet to think of something more snappy :)

Cheers,

James
______________________________________
From: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] On Behalf Of Krzysztof Parzyszek [kparzysz at codeaurora.org]
Sent: 01 December 2012 17:19
To: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] [RFC] "noclone" function attribute

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
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list