Files
clang-p2996/llvm/test/CodeGen/X86/relptr-rodata.ll
Fangrui Song 04a67528d3 [MC] Simplify MCBinaryExpr/MCUnaryExpr printing by reducing parentheses (#133674)
The existing pretty printer generates excessive parentheses for
MCBinaryExpr expressions. This update removes unnecessary parentheses
of MCBinaryExpr with +/- operators and MCUnaryExpr.
Since relocatable expressions only use + and -, this change improves
readability in most cases.

Examples:

- (SymA - SymB) + C now prints as SymA - SymB + C.
  This updates the output of -fexperimental-relative-c++-abi-vtables for
  AArch64 and x86 to `.long _ZN1B3fooEv@PLT-_ZTV1B-8`
- expr + (MCTargetExpr) now prints as expr + MCTargetExpr, with this
  change primarily affecting AMDGPUMCExpr.
2025-03-30 22:03:14 -07:00

46 lines
1.6 KiB
LLVM

; RUN: llc -relocation-model=pic -data-sections -o - %s | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
@hidden = external hidden global i8
@default = external global i8
; CHECK: .section .rodata.rodata
; CHECK: rodata:
; CHECK: .long hidden-rodata
@rodata = hidden constant i32 trunc (i64 sub (i64 ptrtoint (ptr @hidden to i64), i64 ptrtoint (ptr @rodata to i64)) to i32)
; CHECK: .section .data.rel.ro.relro1
; CHECK: relro1:
; CHECK: .long default-relro1
@relro1 = hidden constant i32 trunc (i64 sub (i64 ptrtoint (ptr @default to i64), i64 ptrtoint (ptr @relro1 to i64)) to i32)
; CHECK: .section .data.rel.ro.relro2
; CHECK: relro2:
; CHECK: .long hidden-relro2
@relro2 = constant i32 trunc (i64 sub (i64 ptrtoint (ptr @hidden to i64), i64 ptrtoint (ptr @relro2 to i64)) to i32)
; CHECK: .section .rodata.obj
; CHECK-NEXT: .globl obj
; CHECK: obj:
; CHECK: .long 0
; CHECK: .long hidden_func-obj-4
declare hidden void @hidden_func()
; Ensure that inbound GEPs with constant offsets are also resolved.
@obj = dso_local unnamed_addr constant { { i32, i32 } } {
{ i32, i32 } {
i32 0,
i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @hidden_func to i64), i64 ptrtoint (ptr getelementptr inbounds ({ { i32, i32 } }, ptr @obj, i32 0, i32 0, i32 1) to i64)) to i32)
} }, align 4
; CHECK: .section .rodata.rodata2
; CHECK-NEXT: .globl rodata2
; CHECK: rodata2:
; CHECK: .long extern_func@PLT-rodata2
declare void @extern_func()
@rodata2 = dso_local constant i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @extern_func to i64), i64 ptrtoint (ptr @rodata2 to i64)) to i32)