This patch allows lowering of PIC addresses by using PC-relative addressing for DSO-local symbols and accessing the address through the global offset table for non-DSO-local symbols.
Builds on D54143
Paths
| Differential D55303
[RISCV] Add lowering of addressing sequences for PIC ClosedPublic Authored by lewis-revill on Dec 4 2018, 5:08 PM.
Details Summary This patch allows lowering of PIC addresses by using PC-relative addressing for DSO-local symbols and accessing the address through the global offset table for non-DSO-local symbols. Builds on D54143
Diff Detail
Event TimelineHerald added subscribers: llvm-commits, jocewei, PkmX and 14 others. · View Herald TranscriptDec 4 2018, 5:08 PM lewis-revill added a parent revision: D54143: [RISCV] Generate address sequences suitable for mcmodel=medium. Comment Actions Half of this (the MC side of the GOT modifier) is already proposed in D55279. Also note that the assembly modifier is not %got_hi but %got_pcrel_hi after a discussion with upstream (check the assembler manual) to clearly convey that it's a PC-relative relocation to the GOT entry rather than generating a GOT index as would be the case on some older architectures. I did however, like you, use GOT_HI in the various LLVM-internal enumeration entries to match the name of the relocation. This revision now requires changes to proceed.Dec 4 2018, 7:03 PM Comment Actions That's an interesting coincidence! I think I'll rebase this patch on top of that patch since it seems likely to make it upstream. Comment Actions It's probably worth noting that the %pcrel_lo relocations to the label appear to be evaluated to a constant when -mattr=+relax is not provided... I remember someone said that this was going to be made default? If so I think it would be good to wait for that before this is commited. lewis-revill added a parent revision: D55279: [RISCV] Support assembling %got_pcrel_hi operator.Dec 5 2018, 11:07 AM Comment Actions
Ah, that would be because D54029 isn't yet merged. lewis-revill added a parent revision: D54029: [RISCV] Properly evaluate fixup_riscv_pcrel_lo12.Dec 6 2018, 9:55 AM lewis-revill removed a parent revision: D54029: [RISCV] Properly evaluate fixup_riscv_pcrel_lo12.Dec 6 2018, 10:33 AM lewis-revill added a parent revision: D55325: [RISCV] Add assembler support for LA pseudo-instruction.Dec 10 2018, 7:43 PM Comment Actions Almost there now from my point of view, but we'll see what the others say (especially Alex).
lewis-revill removed a child revision: D55304: [RISCV] Lower calls through PLT.Dec 11 2018, 12:50 PM jrtc27 removed a parent revision: D55279: [RISCV] Support assembling %got_pcrel_hi operator.Dec 11 2018, 4:16 PM
lewis-revill added inline comments.
lewis-revill retitled this revision from [RISCV, WIP] Add lowering of addressing sequences for PIC to [RISCV] Add lowering of addressing sequences for PIC. Comment ActionsMove getAddrPIC() and isPositionIndependent() checks to getAddr() lewis-revill added inline comments.
lewis-revill added a child revision: D55305: [RISCV] Add lowering of global TLS addresses.Dec 13 2018, 1:28 PM Comment Actions Minor comment above but other than that this looks good to me too.
Comment Actions One minor comment, but otherwise I think this is ready to land now?
Comment Actions Please add RV64 RUN lines to pic-models.ll and add nounwind attributes, otherwise this looks good to me. Thanks! Closed by commit rL363058: [RISCV] Add lowering of addressing sequences for PIC (authored by lewis-revill). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 176741 lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
lib/Target/RISCV/MCTargetDesc/RISCVFixupKinds.h
lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h
lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
lib/Target/RISCV/RISCVISelLowering.h
lib/Target/RISCV/RISCVISelLowering.cpp
lib/Target/RISCV/RISCVMCInstLower.cpp
lib/Target/RISCV/Utils/RISCVBaseInfo.h
test/CodeGen/RISCV/pic-models.ll
test/MC/RISCV/rv32i-invalid.s
test/MC/RISCV/rv32i-valid.s
|
Flags is never provided so it's always 0; can we drop it?