From: Rafael Espindola Date: Mon, 2 Apr 2018 23:20:30 +0000 (+0000) Subject: Align stubs for external and common global variables to pointer size. X-Git-Tag: llvmorg-7.0.0-rc1~9160 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c58750cc41e105ad26dd225b23049907341ad85;p=platform%2Fupstream%2Fllvm.git Align stubs for external and common global variables to pointer size. This patch fixes PR36885: clang++ generates unaligned stub symbol holding a pointer. Patch by Rahul Chaudhry! llvm-svn: 329030 --- diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index da4244b..2926ea6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1336,6 +1336,7 @@ bool AsmPrinter::doFinalization(Module &M) { OutStreamer->SwitchSection(TLOF.getDataSection()); const DataLayout &DL = M.getDataLayout(); + EmitAlignment(Log2_32(DL.getPointerSize())); for (const auto &Stub : Stubs) { OutStreamer->EmitLabel(Stub.first); OutStreamer->EmitSymbolValue(Stub.second.getPointer(), diff --git a/llvm/test/CodeGen/X86/catch.ll b/llvm/test/CodeGen/X86/catch.ll index be7466e..5c0bc50 100644 --- a/llvm/test/CodeGen/X86/catch.ll +++ b/llvm/test/CodeGen/X86/catch.ll @@ -3,7 +3,11 @@ ; PR18390 ; We used to assert creating this label. The name itself is not critical. It ; just needs to be a unique local symbol. -; CHECK: .L.Lstr.DW.stub: +; PR36885 +; The stub symbol should have pointer-size (8 byte) alignment. +; CHECK: .data +; CHECK-NEXT: .p2align 3 +; CHECK-NEXT: .L.Lstr.DW.stub: ; CHECK-NEXT: .quad .Lstr @str = private unnamed_addr constant [12 x i8] c"NSException\00"