[llvm] [GVN] Invalidate ICF cache when clearing the instructions (PR #68145)

Wael Yehia via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 12:54:55 PDT 2023


w2yehia wrote:

We hit this on AIX while building python with -flto. Here's a reduced testcase:
```
; ModuleID = 'reduced.bc'
target datalayout = "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512"
target triple = "powerpc64-ibm-aix7.3.0.0"

%struct.PyGetSetDef = type { ptr, ptr, ptr, ptr, ptr }
%struct.anon.28 = type { ptr, ptr, ptr, ptr, ptr, ptr }

@_PyMem_Raw = external global %struct.PyGetSetDef
@__profc_PyMem_SetAllocator = external global [5 x i64]
@__profc_PyMem_RawFree = external global [1 x i64]

define i32 @_PyMem_SetDefaultAllocator() #0 {
entry:
  %call = call fastcc i32 @pymem_set_default_allocator()
  ret i32 0
}

define fastcc i32 @pymem_set_default_allocator() #0 {
entry:
  store ptr @_PyMem_RawFree, ptr getelementptr inbounds (%struct.PyGetSetDef, ptr @_PyMem_Raw, i64 0, i32 4), align 8
  %pgocount6.i31 = load i64, ptr getelementptr inbounds ([5 x i64], ptr @__profc_PyMem_SetAllocator, i64 0, i64 1), align 8
  store i64 %pgocount6.i31, ptr @__profc_PyMem_SetAllocator, align 8
  ret i32 0
}

; Function Attrs: nounwind willreturn
declare void @_PyMem_RawFree() #1

define void @PyMem_RawFree(ptr %ptr) #0 {
entry:
  %pgocount = load i64, ptr %ptr, align 8
  %0 = or i64 %pgocount, 1
  store i64 %0, ptr @__profc_PyMem_RawFree, align 8
  %1 = load ptr, ptr getelementptr inbounds (%struct.PyGetSetDef, ptr @_PyMem_Raw, i64 0, i32 4), align 8
  tail call void %1(ptr null, ptr null)
  ret void
}

declare fastcc void @pathconfig_set_from_config(ptr nocapture)

define void @_PyConfig_InitPathConfig(i1 %cmp.not.i) #0 {
entry:
  %pathconfig.i11 = alloca [0 x [0 x %struct.anon.28]], i32 0, align 8
  %prefix.i.i.i.i = getelementptr %struct.anon.28, ptr %pathconfig.i11, i64 0, i32 1
  call fastcc void @pathconfig_set_from_config(ptr %pathconfig.i11)
  br i1 %cmp.not.i, label %if.end.i, label %config_calculate_pathconfig.exit

if.end.i:                                         ; preds = %entry
  %0 = load ptr, ptr %pathconfig.i11, align 8
  %cmp.not.i.i = icmp eq ptr %0, null
  %1 = load ptr, ptr %prefix.i.i.i.i, align 8
  %cmp.not.i66.i = icmp eq ptr %1, null
  %or.cond = select i1 %cmp.not.i.i, i1 %cmp.not.i66.i, i1 false
  br i1 %or.cond, label %config_calculate_pathconfig.exit, label %common.ret

common.ret:                                       ; preds = %config_calculate_pathconfig.exit, %if.end.i
  ret void

config_calculate_pathconfig.exit:                 ; preds = %if.end.i, %entry
  %call.i89.i = call i32 @_PyMem_SetDefaultAllocator()
  %2 = load ptr, ptr %pathconfig.i11, align 8
  call void @PyMem_RawFree(ptr %2)
  call void @PyMem_RawFree(ptr %prefix.i.i.i.i)
  br label %common.ret
}

attributes #0 = { "target-cpu"="pwr7" "target-features"="+altivec,+bpermd,+extdiv,+isa-v206-instructions,+vsx,-aix-small-local-exec-tls,-crbits,-crypto,-direct-move,-htm,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe" }
attributes #1 = { nounwind willreturn }
```

https://github.com/llvm/llvm-project/pull/68145


More information about the llvm-commits mailing list