Question on "phi-node-folding-threshold"

Hi All,

For a custom backend I’m developing, where jumps are not particularly expensive, I want to reduce the phi-node-folding-threshold attribute value from the default 2 to just 1, as it produces better code in my case.

I first tried to set the attribute as a clang command line option, but it does not seem to be available. ( I tried “clang -phi-node-folding-threshold=1” but this returns an “unknown argument” error)

However, it works as intended if I replace the default value by hard coding in it in SimplifyCFG.cpp and recompiling clang

My question is, Is there a way to set that attribute to a different value for a specific target?. Or at least to set it on the command line?

Thanks in advance

John

You can set it on the command line by doing "clang -mllvm -phi-node-folding-threshold=1” The -mllvm tells clang to pass the next argument through to the command line system used by IR passes.

Hi Craig,

This worked. Thank you very much.

Is there a way to specify this by default for a particular target?. I implemented a LLVM backend and added all the required code so that Clang recognises it as a target, but I’m unsure about how to deal with this particularly. Ideally, Clang should use ‘phi-node-folding-threshold=1’ automatically when my target is specified. Any suggestions are appreciated.

Thanks again.

John

You can probably force it from Clang::RenderTargetOptions. Various targets force some -mllvm options from there.

Hi Craig,

Thank you, this was useful.

John