Question about Constant Expressions

Hi!

Is there a pass that will remove constant expressions from appearing
within other expressions? For instance it would convert the call:
  %tmp20 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([4 x
i8]* @.str, i32 0, i32 0), i32 %tmp18 ) ; <i32> [#uses=0]

Into:
  %tmpFresh = getelementptr [4 x i8]* @.str, i32 0, i32 0 ; <i8*> [#uses = 1]
  %tmp20 = tail call i32 (i8*, ...)* @printf( i8* %tmpFresh, i32
%tmp18 ) ; <i32> [#uses=0]

(Ideally it would do this as an .s -> .s transformation and be
accessible through a tool like opt).

Thanks,
Ben Chambers

Chris,

We used to have a 'lowerconstantexpr' pass in transforms/scalar. I don't
know how to see deleted files in svn though.

They should be "seen" in the certain revision, before they were deleted.

We used to have a 'lowerconstantexpr' pass in transforms/scalar. I don't know how to see deleted files in svn though.

-Chris

If you know the exact path, you should be able to 'svn log FILENAME' to discover the revision before it was deleted. 'svn log FOLDER' or a binary search with 'svn ls FOLDER@REV' might be useful, too. Once you find the REVBEFORE deletion and the REVAFTER deletion, FILENAME can be recovered in several ways…

To just print the file contents to stdout:

   svn cat FILENAME@REVBEFORE

To revert the change, re-adding the file to the working copy:

   svn merge -R REVAFTER:REVBEFORE FILENAME

To resurrect the file out of history, re-adding it to the working copy:

   svn copy FILENAME@REVBEFORE FILENAME

The last two will be equivalent for a single file deletion. The former is more general, though; it can revert an entire change, not just resurrect a file.

— Gordon

How can you see these in viewcv?

-Chris

How hard would it be to compile this pass and add it to the passes
that opt can run? Is this something I should be able to do relatively
quickly? What was the name of the file(s) that implemented the pass?

Thanks,
Ben

Add ?rev=XXXX as parameter to your viewcvs.cgi url. I don't know where llvm's viewcvs is located, but e.g. for our compiler:
http://www.freepascal.org/cgi-bin/viewcvs.cgi/?rev=2000

Jonas

How hard would it be to compile this pass and add it to the passes
that opt can run? Is this something I should be able to do relatively
quickly? What was the name of the file(s) that implemented the pass?

It should be easy, modulo it bitrotting. It is already built as an opt pass. The filename was LowerConstantExpr.cpp IIRC.

-Chris

Chris:

It was in the 1.5 release but not subsequent to that. You can find this
by looking for the file in the branches that were converted from
subversion. You can find the file you're looking for here:

http://llvm.org/viewvc/llvm-project/llvm/branches/release_15/lib/Transforms/Scalar/LowerConstantExprs.cpp?view=log

Reid.

I think I have this pass working again. I have two questions:
   (1) Once I've gotten the pass to compile, it should be visible to
opt, right? Or do I have to add it to a makefile somewhere? I don't
think I do since it got compiled by make, but after going through opt
still doesn't display the option or allow me to run it.
   (2) After I finish resurrecting this pass is anyone else interested
in it? I could post it here or anywhere else if someone wanted it.

-- Ben Chambers