Skip to content

Commit a499354

Browse files
author
Kai Luo
committed
Fix
1 parent bf02f81 commit a499354

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

llvm/lib/IR/Globals.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,14 @@ bool GlobalObject::canIncreaseAlignment() const {
335335
if (isELF && !isDSOLocal())
336336
return false;
337337

338+
bool isXCOFF =
339+
(!Parent || Triple(Parent->getTargetTriple()).isOSBinFormatXCOFF());
340+
if (isXCOFF)
341+
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
342+
// GV with toc-data attribute is put in the region same as toc entry.
343+
// Its alignment should be the same as toc entry.
344+
return !GV->hasAttribute("toc-data");
345+
338346
return true;
339347
}
340348

llvm/test/CodeGen/PowerPC/tocdata-firm-alignment.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ target triple = "powerpc-ibm-aix7.2.0.0"
55

66
%struct.widget = type { i8, i8, i8 }
77

8-
; CHECK: @global = {{.*}}constant %struct.widget { i8 4, i8 0, i8 0 }, align 8 #0
8+
; CHECK: @global = {{.*}}constant %struct.widget { i8 4, i8 0, i8 0 }, align 4 #0
99
@global = constant %struct.widget { i8 4, i8 0, i8 0 }, align 4 #0
1010

1111
define void @baz() #1 {

0 commit comments

Comments
 (0)