llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.27k stars 12.09k forks source link

[PPCMergeStringPool] Global variables replaced with GEP instructions where not legal #88844

Closed nikic closed 6 months ago

nikic commented 7 months ago
target datalayout = "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
target triple = "ppc64le-redhat-linux-gnu"

@id = private unnamed_addr constant [4 x i8] c"@id\00", align 1

; Higher-aligned dummy to make sure it is first in the string pool.
@dummy = private unnamed_addr constant [1 x i32] [i32 42], align 4

define ptr @test() personality ptr @__gnu_objc_personality_v0 {
  invoke void @foo(ptr @dummy)
          to label %cont unwind label %unwind

cont:
  unreachable

unwind:
  %lp = landingpad { ptr, i32 }
          catch ptr @id
  %id = tail call i32 @llvm.eh.typeid.for(ptr @id)
  resume { ptr, i32 } %lp
}

declare i32 @__gnu_objc_personality_v0(...)

declare i32 @llvm.eh.typeid.for(ptr)

declare void @foo()

PPC string pool merging replaces the @id uses with string pool references. Both of these (in catch and in llvm.eh.typeid.for) are illegal as they are required to be constants.

llvmbot commented 7 months ago

@llvm/issue-subscribers-backend-powerpc

Author: Nikita Popov (nikic)

```llvm target datalayout = "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512" target triple = "ppc64le-redhat-linux-gnu" @id = private unnamed_addr constant [4 x i8] c"@id\00", align 1 ; Higher-aligned dummy to make sure it is first in the string pool. @dummy = private unnamed_addr constant [1 x i32] [i32 42], align 4 define ptr @test() personality ptr @__gnu_objc_personality_v0 { invoke void @foo(ptr @dummy) to label %cont unwind label %unwind cont: unreachable unwind: %lp = landingpad { ptr, i32 } catch ptr @id %id = tail call i32 @llvm.eh.typeid.for(ptr @id) resume { ptr, i32 } %lp } declare i32 @__gnu_objc_personality_v0(...) declare i32 @llvm.eh.typeid.for(ptr) declare void @foo() ``` PPC string pool merging replaces the `@id` uses with string pool references. Both of these (in catch and in llvm.eh.typeid.for) are illegal as they are required to be constants.
nikic commented 6 months ago

/cherry-pick 3a3aeb8eba40e981d3a9ff92175f949c2f3d4434

llvmbot commented 6 months ago

Failed to cherry-pick: 3a3aeb8eba40e981d3a9ff92175f949c2f3d4434

https://github.com/llvm/llvm-project/actions/runs/9012367245

Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request

nikic commented 6 months ago

Backport PR: https://github.com/llvm/llvm-project/pull/91557