[llvm] [PowerPC] Alignment of toc-data symbol should not be increased during optimizations (PR #94593)
Kai Luo via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 02:18:01 PDT 2024
https://github.com/bzEq updated https://github.com/llvm/llvm-project/pull/94593
>From a499354b0dd9cc987fd9d0a9c6cd270e1a32bb66 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail at cn.ibm.com>
Date: Thu, 6 Jun 2024 09:07:13 +0000
Subject: [PATCH] Fix
---
llvm/lib/IR/Globals.cpp | 8 ++++++++
llvm/test/CodeGen/PowerPC/tocdata-firm-alignment.ll | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 6f071847bb58a..2943a2aa0cf63 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -335,6 +335,14 @@ bool GlobalObject::canIncreaseAlignment() const {
if (isELF && !isDSOLocal())
return false;
+ bool isXCOFF =
+ (!Parent || Triple(Parent->getTargetTriple()).isOSBinFormatXCOFF());
+ if (isXCOFF)
+ if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
+ // GV with toc-data attribute is put in the region same as toc entry.
+ // Its alignment should be the same as toc entry.
+ return !GV->hasAttribute("toc-data");
+
return true;
}
diff --git a/llvm/test/CodeGen/PowerPC/tocdata-firm-alignment.ll b/llvm/test/CodeGen/PowerPC/tocdata-firm-alignment.ll
index c982713d4f8d3..4ecec36bc977a 100644
--- a/llvm/test/CodeGen/PowerPC/tocdata-firm-alignment.ll
+++ b/llvm/test/CodeGen/PowerPC/tocdata-firm-alignment.ll
@@ -5,7 +5,7 @@ target triple = "powerpc-ibm-aix7.2.0.0"
%struct.widget = type { i8, i8, i8 }
-; CHECK: @global = {{.*}}constant %struct.widget { i8 4, i8 0, i8 0 }, align 8 #0
+; CHECK: @global = {{.*}}constant %struct.widget { i8 4, i8 0, i8 0 }, align 4 #0
@global = constant %struct.widget { i8 4, i8 0, i8 0 }, align 4 #0
define void @baz() #1 {
More information about the llvm-commits
mailing list