[llvm-dev] API to Differentiate between SSA and non SSA form (original) (raw)

mats petersson via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 21 01:37:24 PDT 2017


On 19 April 2017 at 17:22, Anshuman Dhuliya via llvm-dev < llvm-dev at lists.llvm.org> wrote:

Is it the case that for each C stack variable there will always be and 'alloca' statement. If so, we can identify all such variables.

That would only hold true before the mem2reg pass, which makes the alloca into registers whenever possible.

And conversely, the compiler may well introduce temporary allocas that aren't referring to any variable in the source code.

I'd be surprised if there is a trivial way to tell this - more likely, you need source-code information (e.g. AST-level) to perform such analysis. Possibly debug info would be helpful too.

-- Mats

And globals can be identified separately, I guess... Thanks & Regards Anshuman Dhuliya PhD Scholar CSE Department IIT Bombay Mumbai, India

On Wed, Apr 19, 2017 at 9:20 PM, Pushpinder Singh <_ _pushpinderdhaliwal00 at gmail.com> wrote: Hello everyone, We are working on a particular points-to analysis. The final output of that analysis should not have the LLVM SSA temporaries (like, %0, %1). My doubt is that whether we can extract the normal C variables from LLVM IR or is there any way to differentiate between SSA temporary and local C variable? For e.g. in GCC I can check whether a particular variable is an SSA temporary like, if(TREECODE(t) == SSANAME) return true; Basically, I want to skip all those %0, %1 temporaries. But keep all those which refer to C variables. One way to do this would be to check whether a Value has been given a name by using hasName function. But it does not work every time. For e.g. in case of getelementptr instruction, this name refers to a member name of a structure (which is in SSA form). E.g., define void @f() { entry: %s = alloca %struct.A, align 8 %a = alloca i32, align 4 ; I can know that this is a C variable store i32 10, i32* %a, align 4 %b = getelementptr inbounds %struct.A, %struct.A* %s, i32 0, i32 1 ; but this is not store i32* %a, i32** %b, align 8 ; and this is not a C variable, so hasName logic can not work here. %a1 = getelementptr inbounds %struct.A, %struct.A* %s, i32 0, i32 0 store i32 30, i32* %a1, align 8 ret void } Thanks, Pushpinder Singh


LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170421/de6b18a0/attachment.html>



More information about the llvm-dev mailing list