llvm.org GIT mirror llvm / bc245c0
[MC] Ensure that pending labels are flushed when -mc-relax-all flag is used Summary: The current implementation doesn't always flush all pending labels beforeemitting data which can result in an incorrectly placed labels in case when when instruction bundling is enabled and -mc-relax-all flag is being used. To address this issue, we always flush pending labels before emitting data. The change was tested by running PNaCl toolchain trybots with -mc-relax-all flag set. Fixes https://code.google.com/p/nativeclient/issues/detail?id=4063 Test Plan: Regression test attached Reviewers: mseaborn Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D10325 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240870 91177308-0d34-0410-b5e6-96231b3b80d8 Petr Hosek 4 years ago
2 changed file(s) with 39 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
123123 const SMLoc &Loc) {
124124 MCStreamer::EmitValueImpl(Value, Size, Loc);
125125 MCDataFragment *DF = getOrCreateDataFragment();
126 flushPendingLabels(DF, DF->getContents().size());
126127
127128 MCLineEntry::Make(this, getCurrentSection().first);
128129
361362
362363 void MCObjectStreamer::EmitBytes(StringRef Data) {
363364 MCLineEntry::Make(this, getCurrentSection().first);
364 getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end());
365 MCDataFragment *DF = getOrCreateDataFragment();
366 flushPendingLabels(DF, DF->getContents().size());
367 DF->getContents().append(Data.begin(), Data.end());
365368 }
366369
367370 void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment,
409412 // Associate GPRel32 fixup with data and resize data area
410413 void MCObjectStreamer::EmitGPRel32Value(const MCExpr *Value) {
411414 MCDataFragment *DF = getOrCreateDataFragment();
415 flushPendingLabels(DF, DF->getContents().size());
412416
413417 DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
414418 Value, FK_GPRel_4));
418422 // Associate GPRel32 fixup with data and resize data area
419423 void MCObjectStreamer::EmitGPRel64Value(const MCExpr *Value) {
420424 MCDataFragment *DF = getOrCreateDataFragment();
425 flushPendingLabels(DF, DF->getContents().size());
421426
422427 DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
423428 Value, FK_GPRel_4));
427432 void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
428433 // FIXME: A MCFillFragment would be more memory efficient but MCExpr has
429434 // problems evaluating expressions across multiple fragments.
430 getOrCreateDataFragment()->getContents().append(NumBytes, FillValue);
435 MCDataFragment *DF = getOrCreateDataFragment();
436 flushPendingLabels(DF, DF->getContents().size());
437 DF->getContents().append(NumBytes, FillValue);
431438 }
432439
433440 void MCObjectStreamer::EmitZeros(uint64_t NumBytes) {
0 # RUN: llvm-mc -triple=i686-nacl -filetype=obj %s -o - \
1 # RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
2 # RUN: llvm-mc -triple=i686-nacl -filetype=obj -mc-relax-all %s -o - \
3 # RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
4
5 .bundle_align_mode 5
6 .text
7 .align 32, 0x90
8 # CHECK: 0: movl $14, 8(%esp)
9 movl $.str2, 8(%esp)
10 # CHECK: 8: movl $7, 4(%esp)
11 movl $.str1, 4(%esp)
12 # CHECK: 10: movl $0, (%esp)
13 movl $.str, (%esp)
14
15 .type .str,@object
16 .section .rodata,"a",@progbits
17 .str:
18 .asciz "hello1"
19 .size .str, 7
20
21 .type .str1,@object
22 .str1:
23 .asciz "hello2"
24 .size .str1, 7
25
26 .type .str2,@object
27 .str2:
28 .asciz "hello3"
29 .size .str2, 7