forked from rust-lang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PPCMergeStringPool] Avoid replacing constant with instruction (llvm#…
…88846) String pool merging currently, for a reason that's not entirely clear to me, tries to create GEP instructions instead of GEP constant expressions when replacing constant references. It only uses constant expressions in cases where this is required. However, it does not catch all cases where such a requirement exists. For example, the landingpad catch clause has to be a constant. Fix this by always using the constant expression variant, which also makes the implementation simpler. Additionally, there are some edge cases where even replacement with a constant GEP is not legal. The one I am aware of is the llvm.eh.typeid.for intrinsic, so add a special case to forbid replacements for it. Fixes llvm#88844. (cherry picked from commit 3a3aeb8)
- Loading branch information
Showing
5 changed files
with
87 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
llvm/test/CodeGen/PowerPC/mergeable-string-pool-exceptions.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: llc -mtriple=ppc64le-unknown-linux-gnu < %s | FileCheck %s | ||
|
||
@id = private unnamed_addr constant [4 x i8] c"@id\00", align 1 | ||
@id2 = private unnamed_addr constant [5 x i8] c"@id2\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 @test1() personality ptr @__gnu_objc_personality_v0 { | ||
; CHECK-LABEL: test1: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: mflr 0 | ||
; CHECK-NEXT: stdu 1, -32(1) | ||
; CHECK-NEXT: std 0, 48(1) | ||
; CHECK-NEXT: .cfi_def_cfa_offset 32 | ||
; CHECK-NEXT: .cfi_offset lr, 16 | ||
; CHECK-NEXT: addis 3, 2, .L__ModuleStringPool@toc@ha | ||
; CHECK-NEXT: addi 3, 3, .L__ModuleStringPool@toc@l | ||
; CHECK-NEXT: bl foo | ||
; CHECK-NEXT: nop | ||
invoke void @foo(ptr @dummy) | ||
to label %cont unwind label %unwind | ||
|
||
cont: | ||
unreachable | ||
|
||
unwind: | ||
%lp = landingpad { ptr, i32 } | ||
catch ptr @id | ||
resume { ptr, i32 } %lp | ||
} | ||
|
||
define i32 @test2() personality ptr @__gnu_objc_personality_v0 { | ||
; CHECK-LABEL: test2: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: li 3, 1 | ||
; CHECK-NEXT: blr | ||
%id = tail call i32 @llvm.eh.typeid.for(ptr @id2) | ||
ret i32 %id | ||
} | ||
|
||
declare i32 @__gnu_objc_personality_v0(...) | ||
|
||
declare i32 @llvm.eh.typeid.for(ptr) | ||
|
||
declare void @foo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters