getModuleIdentifier() returns <stdin>

Hi all,

I’m writing my own pass and use “opt” to launch it. In my pass, I’d like to see the name of the module I’m working on, so I use getModuleIdentifier(), trying to get the name such as “test.bc.” But the result is always .

Could anyone please help me on this?

Thank you very much.

Jack

Jack Tzu-Han Hung wrote:

Hi all,

I'm writing my own pass and use "opt" to launch it. In my pass, I'd like to see the name of the module I'm working on, so I use getModuleIdentifier(), trying to get the name such as "test.bc." But the result is always <stdin>.

Could anyone please help me on this?
  

Is opt reading the input bitcode from standard input (as opposed to being given a filename)? If so, that is probably why the module is named stdin.

-- John T.

Hi John,

I run my pass this way:

opt -mypass <input.bc >output.bc

So I think “input.bc” is what I should expect, right?

Thanks,
Jack

Jack Tzu-Han Hung wrote:

Hi John,

I run my pass this way:

opt -mypass <input.bc >output.bc

So I think "input.bc" is what I should expect, right?
  

You're telling the shell to pipe input.bc into the standard input of opt. The opt program never sees the filename.

Instead, do this:

opt -mypass input.bc -f -o output.bc

This passes the filename on opt's command line. opt will open the file on its own, and then the Module should get a name similar to that of the file from which it came.

-- John T.

Hello, Jack

opt -mypass <input.bc >output.bc

So I think "input.bc" is what I should expect, right?

No, stdin is correct in such situation.

Hi Jack,

opt -mypass <input.bc >output.bc

So I think "input.bc" is what I should expect, right?

Nope, this way you're only telling the filename to your shell, opt doesn't see
it.

You should run
  opt input.bc -mypass -o output.bc
instead.

Gr.

Matthijs