[llvm] [llc] set canonical triple in module (PR #203725)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 12:48:35 PDT 2026
AlexMaclean wrote:
> Code should also really be taking the triple from the module. What contexts are reading it from the TargetMachine?
The problem is not that the triple is being read from the TargetMachine. I'll expand on my example from last month to hopefully clarify any confusion about what problem is being addressed.
> tests do not set the triple in the module and without this change the default triple is not set in the module either. This causes the ExpandVariadics pass not to fire breaking assumptions in ISel.
Here is the situation:
1. A module exists without any triple set
2. Someone invokes `llc` without using the `-mtriple` or `-march` command line flags
3. `llc` uses (heavily contested) rules to choose a triple based on mutliple possible sources
3.1 in this case since neither command line nor module provides any triple, `LLVM_DEFAULT_TARGET_TRIPLE=nvptx64-unkown-unkown` is used
4. The NVPTX TargetMachine is selected based on this triple
5. The NVPTX TargetMachine schedules the ExpandVariadics pass
6. When the ExpandVariadics pass runs it looks at the module triple and sees `""`. It does nothing as a result
7. NVPTX was reliant on ExpandVariadics so the program miscompiles
It seems like all the debate is around how step 3 chooses a triple while all my change actually does is make it so that step 4 also puts the triple in the module.
@arsenm Do you agree that a case like this is a problem?
https://github.com/llvm/llvm-project/pull/203725
More information about the llvm-commits
mailing list