aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorAnton Sidorenko <anton.sidorenko@syntacore.com>2024-08-26 15:11:24 +0300
committerGitHub <noreply@github.com>2024-08-26 15:11:24 +0300
commit2f91e98120f168b7ded6cb34d546dba178515cc4 (patch)
treeb78e499f4c18409ea3f52830f65a2d0a0be4b98c /llvm/lib/CodeGen/MachineInstr.cpp
parent3be955abbccaf1c9ca590834d5e5b27ab1f24b77 (diff)
downloadllvm-2f91e98120f168b7ded6cb34d546dba178515cc4.zip
llvm-2f91e98120f168b7ded6cb34d546dba178515cc4.tar.gz
llvm-2f91e98120f168b7ded6cb34d546dba178515cc4.tar.bz2
[RISCV] Mark symbols used in inline asm for relocations as referenced (#104925)
Commit 5cd8d53cac00f taught RISCVMergeBaseOffset to handle inline asm, however there is at least one case uncovered for integrated as. In the example below compiler generates pcrel relocation (mcmodel=medany) ``` volatile double double_val = 1.0; void foo() { asm volatile("fld f0, %0 \n\t" : : "m"(double_val) : "memory"); } ``` And fails with the folliwng error ``` error: could not find corresponding %pcrel_hi | "fld f0, %0 \n\t" <inline asm>:1:2: note: instantiated into assembly here | fld f0, %pcrel_lo(.Lpcrel_hi0)(a0) ``` After transformations MachineFunction contains inline asm instructions with '.Lpcrel_hi0' symbol that is not defined in inline asm, but referenced. ``` ... = AUIPC ...(riscv-pcrel-hi) @double_val, pre-instr-symbol <mcsymbol .Lpcrel_hi0> INLINEASM &"fld f0, $0 \0A\09" ... target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi0> ``` So, when AsmParser processes 'fld', it has to create a new symbol as '.Lpcrel_hi0' already exists but not known to be referenced in inline asm. AsmParser avoids conflicts by renaming referenced by 'fld' symbol with '.Lpcrel_hi00' name which does not exist. Resulting erroneous asm ``` .Lpcrel_hi0: auipc a0, %pcrel_hi(double_val) #APP fld ft0, %pcrel_lo(.Lpcrel_hi00)(a0) ``` This change adds symbols used in memory operands to the list of referenced ones. Godbolt link: https://godbolt.org/z/aqrrsWKoK -- on the left you can find incorrect labels for the integrated-as and on the right an error when compiling to the binary object.
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
0 files changed, 0 insertions, 0 deletions