[llvm] [XCOFF] make related SD symbols as isFunction (PR #69553)
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 20 01:54:57 PST 2023
https://github.com/chenzheng1030 updated https://github.com/llvm/llvm-project/pull/69553
>From 9217eedc55eb382ccf45ae55880f9dfb6682b1ac Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 30 Oct 2023 01:42:43 -0400
Subject: [PATCH 1/9] ad XTY_SD type function symbol.
---
llvm/lib/Object/XCOFFObjectFile.cpp | 73 +++++++++++++++++--
llvm/test/CodeGen/PowerPC/aix-text.ll | 12 +--
.../CodeGen/PowerPC/aix-xcoff-funcsect.ll | 12 +--
.../tools/llvm-symbolizer/xcoff-sd-symbol.ll | 4 +-
4 files changed, 82 insertions(+), 19 deletions(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index 07e1054fb654bf5..cf3832ea4511002 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1242,15 +1242,78 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
const XCOFFCsectAuxRef CsectAuxRef = ExpCsectAuxEnt.get();
- // A function definition should be a label definition.
- // FIXME: This is not necessarily the case when -ffunction-sections is
- // enabled.
- if (!CsectAuxRef.isLabel())
+ if (CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_PR)
return false;
- if (CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_PR)
+ // A function definition should not be a common type symbol or a external
+ // symbol.
+ if (CsectAuxRef.getSymbolType() == XCOFF::XTY_CM ||
+ CsectAuxRef.getSymbolType() == XCOFF::XTY_ER)
return false;
+ // If the next symbol is a XTY_LD type symbol with same address, this XTY_SD
+ // symbol is not a function. Otherwise this is a function symbol for
+ // -ffunction-sections.
+ if (CsectAuxRef.getSymbolType() == XCOFF::XTY_SD) {
+ // If this is a csect with size 0, it won't be a function definition.
+ // This is used to hack situation that llvm always generates below symbol
+ // for -ffunction-sections:
+ // m 0x00000000 .text 1 unamex **No Symbol**
+ // a4 0x00000000 0 0 SD PR 0 0
+ if (getSize() == 0)
+ return false;
+
+ Expected<uint64_t> SymbolAddressOrErr = getAddress();
+ if (!SymbolAddressOrErr) {
+ // If there is no address for this symbol, won't be a function.
+ consumeError(SymbolAddressOrErr.takeError());
+ return false;
+ }
+
+ uint8_t NumberOfAuxEntries = getNumberOfAuxEntries();
+
+ // If this is the last main symbol table entry, there won't be XTY_LD type
+ // symbol below.
+ if (getEntryAddress() == getObject()->getSymbolEntryAddressByIndex(
+ getObject()->getNumberOfSymbolTableEntries() -
+ NumberOfAuxEntries - 1))
+ return true;
+
+ DataRefImpl Ref;
+ Ref.p = XCOFFObjectFile::getAdvancedSymbolEntryAddress(
+ getEntryAddress(), NumberOfAuxEntries + 1);
+ XCOFFSymbolRef NextSym = getObject()->toSymbolRef(Ref);
+ if (!NextSym.isCsectSymbol())
+ return true;
+
+ Expected<uint64_t> NextSymbolAddressOrErr = NextSym.getAddress();
+ if (!NextSymbolAddressOrErr) {
+ // If there is no address for next symbol, won't be same with the XTY_SD
+ // symbol's address.
+ consumeError(NextSymbolAddressOrErr.takeError());
+ return true;
+ }
+
+ if (SymbolAddressOrErr.get() != NextSymbolAddressOrErr.get())
+ return true;
+
+ // Check next symbol is XTY_LD. If so, this symbol is not a function.
+ Expected<XCOFFCsectAuxRef> NextCsectAuxEnt = NextSym.getXCOFFCsectAuxRef();
+ if (!NextCsectAuxEnt) {
+ // If the next symbol has no aux entries, won't be a XTY_LD symbol.
+ consumeError(NextCsectAuxEnt.takeError());
+ return true;
+ }
+
+ if (NextCsectAuxEnt.get().getSymbolType() == XCOFF::XTY_LD)
+ return false;
+
+ return true;
+ }
+
+ if (CsectAuxRef.getSymbolType() == XCOFF::XTY_LD)
+ return true;
+
const int16_t SectNum = getSectionNumber();
Expected<DataRefImpl> SI = getObject()->getSectionByNum(SectNum);
if (!SI)
diff --git a/llvm/test/CodeGen/PowerPC/aix-text.ll b/llvm/test/CodeGen/PowerPC/aix-text.ll
index a0d1d0e38d50225..7f7c4e95fe8394d 100644
--- a/llvm/test/CodeGen/PowerPC/aix-text.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-text.ll
@@ -17,13 +17,13 @@ entry:
ret i32 2
}
-; CHECKFS32: 00000000 l .text 00000000 (idx: {{[[:digit:]]*}}) [PR]
-; CHECKFS32-NEXT: 00000000 g .text {{([[:xdigit:]]{8})}} (idx: {{[[:digit:]]*}}) .text[PR]
-; CHECKFS32-NEXT: {{([[:xdigit:]]{8})}} g .text {{([[:xdigit:]]{8})}} (idx: {{[[:digit:]]*}}) .text2[PR]
+; CHECKFS32: 00000000 l .text 00000000 (idx: {{[[:digit:]]*}}) [PR]
+; CHECKFS32-NEXT: 00000000 g F .text {{([[:xdigit:]]{8})}} (idx: {{[[:digit:]]*}}) .text[PR]
+; CHECKFS32-NEXT: {{([[:xdigit:]]{8})}} g F .text {{([[:xdigit:]]{8})}} (idx: {{[[:digit:]]*}}) .text2[PR]
-; CHECKFS64: 0000000000000000 l .text 0000000000000000
-; CHECKFS64-NEXT: 0000000000000000 g .text {{([[:xdigit:]]{16})}} (idx: {{[[:digit:]]*}}) .text[PR]
-; CHECKFS64-NEXT: {{([[:xdigit:]]{16})}} g .text {{([[:xdigit:]]{16})}} (idx: {{[[:digit:]]*}}) .text2[PR]
+; CHECKFS64: 0000000000000000 l .text 0000000000000000
+; CHECKFS64-NEXT: 0000000000000000 g F .text {{([[:xdigit:]]{16})}} (idx: {{[[:digit:]]*}}) .text[PR]
+; CHECKFS64-NEXT: {{([[:xdigit:]]{16})}} g F .text {{([[:xdigit:]]{16})}} (idx: {{[[:digit:]]*}}) .text2[PR]
; CHECK32: 00000000 l .text {{([[:xdigit:]]{8})}} (idx: {{[[:digit:]]*}}) [PR]
; CHECK32-NEXT: {{([[:xdigit:]]{8})}} g F .text (csect: (idx: {{[[:digit:]]*}}) [PR]) 00000000 (idx: {{[[:digit:]]*}}) .text
diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-funcsect.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-funcsect.ll
index 09c517c73dff296..2600fac01425da8 100644
--- a/llvm/test/CodeGen/PowerPC/aix-xcoff-funcsect.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-funcsect.ll
@@ -117,9 +117,9 @@ entry:
; XCOFF32-NEXT: 00000000 l .text 00000000 (idx: 5) [PR]
; XCOFF32-NEXT: 00000000 g .text 00000019 (idx: 7) .foo[PR]
; XCOFF32-NEXT: 00000000 g F .text (csect: (idx: 7) .foo[PR]) 00000000 (idx: 9) .alias_foo
-; XCOFF32-NEXT: 00000020 g .text 00000020 .hidden (idx: 11) .hidden_foo[PR]
-; XCOFF32-NEXT: 00000040 g .text 00000059 (idx: 13) .bar[PR]
-; XCOFF32-NEXT: 000000c0 l .text 0000002a (idx: 15) .static_overalign_foo[PR]
+; XCOFF32-NEXT: 00000020 g F .text 00000020 .hidden (idx: 11) .hidden_foo[PR]
+; XCOFF32-NEXT: 00000040 g F .text 00000059 (idx: 13) .bar[PR]
+; XCOFF32-NEXT: 000000c0 l F .text 0000002a (idx: 15) .static_overalign_foo[PR]
; XCOFF32-NEXT: 000000ec g O .data 0000000c (idx: 17) foo[DS]
; XCOFF32-NEXT: 000000ec g O .data (csect: (idx: 17) foo[DS]) 00000000 (idx: 19) alias_foo
; XCOFF32-NEXT: 000000f8 g O .data 0000000c .hidden (idx: 21) hidden_foo[DS]
@@ -152,9 +152,9 @@ entry:
; XCOFF64-NEXT: 0000000000000000 l .text 0000000000000000 (idx: 5) [PR]
; XCOFF64-NEXT: 0000000000000000 g .text 0000000000000019 (idx: 7) .foo[PR]
; XCOFF64-NEXT: 0000000000000000 g F .text (csect: (idx: 7) .foo[PR]) 0000000000000000 (idx: 9) .alias_foo
-; XCOFF64-NEXT: 0000000000000020 g .text 0000000000000020 .hidden (idx: 11) .hidden_foo[PR]
-; XCOFF64-NEXT: 0000000000000040 g .text 0000000000000059 (idx: 13) .bar[PR]
-; XCOFF64-NEXT: 00000000000000c0 l .text 000000000000002a (idx: 15) .static_overalign_foo[PR]
+; XCOFF64-NEXT: 0000000000000020 g F .text 0000000000000020 .hidden (idx: 11) .hidden_foo[PR]
+; XCOFF64-NEXT: 0000000000000040 g F .text 0000000000000059 (idx: 13) .bar[PR]
+; XCOFF64-NEXT: 00000000000000c0 l F .text 000000000000002a (idx: 15) .static_overalign_foo[PR]
; XCOFF64-NEXT: 00000000000000f0 g O .data 0000000000000018 (idx: 17) foo[DS]
; XCOFF64-NEXT: 00000000000000f0 g O .data (csect: (idx: 17) foo[DS]) 0000000000000000 (idx: 19) alias_foo
; XCOFF64-NEXT: 0000000000000108 g O .data 0000000000000018 .hidden (idx: 21) hidden_foo[DS]
diff --git a/llvm/test/tools/llvm-symbolizer/xcoff-sd-symbol.ll b/llvm/test/tools/llvm-symbolizer/xcoff-sd-symbol.ll
index 781ac72933a1523..aedceb0227b8962 100644
--- a/llvm/test/tools/llvm-symbolizer/xcoff-sd-symbol.ll
+++ b/llvm/test/tools/llvm-symbolizer/xcoff-sd-symbol.ll
@@ -16,10 +16,10 @@ entry:
ret void
}
-; CHECK: ??
+; CHECK: .foo
; CHECK: ??:0:0
; CHECK-EMPTY:
-; CHECK: ??
+; CHECK: .foo1
; CHECK: ??:0:0
; CHECK-EMPTY:
>From c9f10351ddd27dc5f043583b64ad28b320ab58b0 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 30 Oct 2023 21:15:57 -0400
Subject: [PATCH 2/9] address comments
---
llvm/lib/Object/XCOFFObjectFile.cpp | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index cf3832ea4511002..bc99af428dcfe11 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1242,7 +1242,8 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
const XCOFFCsectAuxRef CsectAuxRef = ExpCsectAuxEnt.get();
- if (CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_PR)
+ if (CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_PR &&
+ CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_GL)
return false;
// A function definition should not be a common type symbol or a external
@@ -1263,13 +1264,6 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
if (getSize() == 0)
return false;
- Expected<uint64_t> SymbolAddressOrErr = getAddress();
- if (!SymbolAddressOrErr) {
- // If there is no address for this symbol, won't be a function.
- consumeError(SymbolAddressOrErr.takeError());
- return false;
- }
-
uint8_t NumberOfAuxEntries = getNumberOfAuxEntries();
// If this is the last main symbol table entry, there won't be XTY_LD type
@@ -1286,13 +1280,13 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
if (!NextSym.isCsectSymbol())
return true;
+ Expected<uint64_t> SymbolAddressOrErr = getAddress();
+ if (!SymbolAddressOrErr)
+ return false;
+
Expected<uint64_t> NextSymbolAddressOrErr = NextSym.getAddress();
- if (!NextSymbolAddressOrErr) {
- // If there is no address for next symbol, won't be same with the XTY_SD
- // symbol's address.
- consumeError(NextSymbolAddressOrErr.takeError());
+ if (!NextSymbolAddressOrErr)
return true;
- }
if (SymbolAddressOrErr.get() != NextSymbolAddressOrErr.get())
return true;
>From 6fe33ae04ae413a4c096e1a4a593fca2c380aace Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Sun, 5 Nov 2023 22:04:49 -0500
Subject: [PATCH 3/9] address comments
---
llvm/lib/Object/XCOFFObjectFile.cpp | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index bc99af428dcfe11..f3751b3e800daa1 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1280,15 +1280,7 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
if (!NextSym.isCsectSymbol())
return true;
- Expected<uint64_t> SymbolAddressOrErr = getAddress();
- if (!SymbolAddressOrErr)
- return false;
-
- Expected<uint64_t> NextSymbolAddressOrErr = NextSym.getAddress();
- if (!NextSymbolAddressOrErr)
- return true;
-
- if (SymbolAddressOrErr.get() != NextSymbolAddressOrErr.get())
+ if (cantFail(getAddress()) != cantFail(NextSym.getAddress()))
return true;
// Check next symbol is XTY_LD. If so, this symbol is not a function.
>From 47070d859f3a5edaa49b70bb2abe5331c2823d2f Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Fri, 10 Nov 2023 03:19:52 -0500
Subject: [PATCH 4/9] address comments
---
llvm/include/llvm/Object/XCOFFObjectFile.h | 3 ++
llvm/lib/Object/XCOFFObjectFile.cpp | 32 ++++++----------------
2 files changed, 12 insertions(+), 23 deletions(-)
diff --git a/llvm/include/llvm/Object/XCOFFObjectFile.h b/llvm/include/llvm/Object/XCOFFObjectFile.h
index e3b91961d636c52..9492284ea93d377 100644
--- a/llvm/include/llvm/Object/XCOFFObjectFile.h
+++ b/llvm/include/llvm/Object/XCOFFObjectFile.h
@@ -853,6 +853,9 @@ class xcoff_symbol_iterator : public symbol_iterator {
xcoff_symbol_iterator(const basic_symbol_iterator &B)
: symbol_iterator(B) {}
+ xcoff_symbol_iterator(const XCOFFSymbolRef *Symbol)
+ : symbol_iterator(*Symbol) {}
+
const XCOFFSymbolRef *operator->() const {
return static_cast<const XCOFFSymbolRef *>(symbol_iterator::operator->());
}
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index f3751b3e800daa1..5e28a21205bcc9f 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1252,39 +1252,30 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
CsectAuxRef.getSymbolType() == XCOFF::XTY_ER)
return false;
- // If the next symbol is a XTY_LD type symbol with same address, this XTY_SD
+ // If the next symbol is an XTY_LD type symbol with same address, this XTY_SD
// symbol is not a function. Otherwise this is a function symbol for
// -ffunction-sections.
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_SD) {
// If this is a csect with size 0, it won't be a function definition.
// This is used to hack situation that llvm always generates below symbol
// for -ffunction-sections:
+ // FIXME: remove or replace this meaningless symbol.
// m 0x00000000 .text 1 unamex **No Symbol**
// a4 0x00000000 0 0 SD PR 0 0
if (getSize() == 0)
return false;
- uint8_t NumberOfAuxEntries = getNumberOfAuxEntries();
-
- // If this is the last main symbol table entry, there won't be XTY_LD type
- // symbol below.
- if (getEntryAddress() == getObject()->getSymbolEntryAddressByIndex(
- getObject()->getNumberOfSymbolTableEntries() -
- NumberOfAuxEntries - 1))
- return true;
-
- DataRefImpl Ref;
- Ref.p = XCOFFObjectFile::getAdvancedSymbolEntryAddress(
- getEntryAddress(), NumberOfAuxEntries + 1);
- XCOFFSymbolRef NextSym = getObject()->toSymbolRef(Ref);
- if (!NextSym.isCsectSymbol())
+ xcoff_symbol_iterator NextIt(this);
+ // If this is the last main symbol table entry, there won't be an XTY_LD
+ // type symbol below.
+ if (++NextIt == getObject()->symbol_end())
return true;
- if (cantFail(getAddress()) != cantFail(NextSym.getAddress()))
+ if (cantFail(getAddress()) != cantFail(NextIt->getAddress()))
return true;
// Check next symbol is XTY_LD. If so, this symbol is not a function.
- Expected<XCOFFCsectAuxRef> NextCsectAuxEnt = NextSym.getXCOFFCsectAuxRef();
+ Expected<XCOFFCsectAuxRef> NextCsectAuxEnt = NextIt->getXCOFFCsectAuxRef();
if (!NextCsectAuxEnt) {
// If the next symbol has no aux entries, won't be a XTY_LD symbol.
consumeError(NextCsectAuxEnt.takeError());
@@ -1300,12 +1291,7 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_LD)
return true;
- const int16_t SectNum = getSectionNumber();
- Expected<DataRefImpl> SI = getObject()->getSectionByNum(SectNum);
- if (!SI)
- return SI.takeError();
-
- return (getObject()->getSectionFlags(SI.get()) & XCOFF::STYP_TEXT);
+ return false;
}
bool XCOFFSymbolRef::isCsectSymbol() const {
>From f0be2471cd787e4f4d099ea9bb28b5f9d64cf951 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Tue, 14 Nov 2023 03:21:26 -0500
Subject: [PATCH 5/9] address comments
---
llvm/lib/Object/XCOFFObjectFile.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index 5e28a21205bcc9f..864337f10c34456 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1252,16 +1252,16 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
CsectAuxRef.getSymbolType() == XCOFF::XTY_ER)
return false;
- // If the next symbol is an XTY_LD type symbol with same address, this XTY_SD
- // symbol is not a function. Otherwise this is a function symbol for
+ // If the next symbol is an XTY_LD type symbol with the same address, this
+ // XTY_SD symbol is not a function. Otherwise this is a function symbol for
// -ffunction-sections.
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_SD) {
// If this is a csect with size 0, it won't be a function definition.
- // This is used to hack situation that llvm always generates below symbol
- // for -ffunction-sections:
- // FIXME: remove or replace this meaningless symbol.
+ // This is used to work around the fact that LLVM always generates below
+ // symbol for -ffunction-sections:
// m 0x00000000 .text 1 unamex **No Symbol**
// a4 0x00000000 0 0 SD PR 0 0
+ // FIXME: remove or replace this meaningless symbol.
if (getSize() == 0)
return false;
>From ad3ceda85235f70168a4ef28043a81b5723e6fec Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Tue, 14 Nov 2023 22:09:02 -0500
Subject: [PATCH 6/9] rebase
---
llvm/lib/Object/XCOFFObjectFile.cpp | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index 864337f10c34456..f984f4cacf20bb8 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1276,11 +1276,8 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
// Check next symbol is XTY_LD. If so, this symbol is not a function.
Expected<XCOFFCsectAuxRef> NextCsectAuxEnt = NextIt->getXCOFFCsectAuxRef();
- if (!NextCsectAuxEnt) {
- // If the next symbol has no aux entries, won't be a XTY_LD symbol.
- consumeError(NextCsectAuxEnt.takeError());
- return true;
- }
+ if (!NextCsectAuxEnt)
+ return NextCsectAuxEnt.takeError();
if (NextCsectAuxEnt.get().getSymbolType() == XCOFF::XTY_LD)
return false;
>From 89a4f1a481591b38427ccab0c7f8d21de0a23ddf Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Wed, 15 Nov 2023 20:59:41 -0500
Subject: [PATCH 7/9] address comments
---
llvm/lib/Object/XCOFFObjectFile.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index f984f4cacf20bb8..fc198e61cf668e6 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1246,7 +1246,7 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_GL)
return false;
- // A function definition should not be a common type symbol or a external
+ // A function definition should not be a common type symbol or an external
// symbol.
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_CM ||
CsectAuxRef.getSymbolType() == XCOFF::XTY_ER)
>From 44cbb15ecce56a2f535a88cb3b30c11b8804d3ad Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Sun, 19 Nov 2023 20:36:35 -0500
Subject: [PATCH 8/9] address comments
---
llvm/lib/Object/XCOFFObjectFile.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index fc198e61cf668e6..cddd8994859f112 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1288,7 +1288,7 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_LD)
return true;
- return false;
+ return createError("csect symbol has no valid symbol type.");
}
bool XCOFFSymbolRef::isCsectSymbol() const {
>From 3744f29db0a5aa3bb7495ff64bdeaf24aaea8fba Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 20 Nov 2023 04:52:56 -0500
Subject: [PATCH 9/9] address comments
---
llvm/lib/Object/XCOFFObjectFile.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index cddd8994859f112..fcc2b8cac2fe4ba 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -1288,7 +1288,13 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_LD)
return true;
- return createError("csect symbol has no valid symbol type.");
+ Expected<StringRef> NameOrErr = getName();
+ if (!NameOrErr)
+ return NameOrErr.takeError();
+
+ return createError("csect symbol " + *NameOrErr +
+ " has invalid symbol type " +
+ Twine::utohexstr(CsectAuxRef.getSymbolType()));
}
bool XCOFFSymbolRef::isCsectSymbol() const {
More information about the llvm-commits
mailing list