Skip to content

Commit

Permalink
[CHERI] Ensure we always emit the $local symbol for exception handling
Browse files Browse the repository at this point in the history
Without it, we would crash if GV.canBenefitFromLocalAlias() returns
false (e.g. when the function is not dso_local).
  • Loading branch information
arichardson committed Sep 17, 2024
1 parent 6205600 commit 6951ec7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,13 @@ MCSymbol *AsmPrinter::getSymbolPreferLocal(const GlobalValue &GV,
// assembler would otherwise be conservative and assume a global default
// visibility symbol can be interposable, even if the code generator already
// assumed it.
if (TM.getTargetTriple().isOSBinFormatELF() && GV.canBenefitFromLocalAlias()) {
if (Force)
return getSymbolWithGlobalValueBase(&GV, "$local");
if (TM.getTargetTriple().isOSBinFormatELF() &&
GV.canBenefitFromLocalAlias()) {
const Module &M = *GV.getParent();
if (Force || (TM.getRelocationModel() != Reloc::Static &&
M.getPIELevel() == PIELevel::Default && GV.isDSOLocal()))
if (TM.getRelocationModel() != Reloc::Static &&
M.getPIELevel() == PIELevel::Default && GV.isDSOLocal())
return getSymbolWithGlobalValueBase(&GV, "$local");
}
return TM.getSymbol(&GV);
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/RISCV/cheri/function-start-directives.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

target triple = "riscv64-unknown-freebsd13"

define dso_local noundef signext i32 @_Z4testv() local_unnamed_addr addrspace(200) uwtable personality ptr addrspace(200) @__gxx_personality_v0 {
define noundef signext i32 @_Z4testv() local_unnamed_addr addrspace(200) uwtable personality ptr addrspace(200) @__gxx_personality_v0 {
entry:
%call = invoke noundef signext i32 @_Z3foov(ptr addrspace(200) @_Z4testv)
to label %return unwind label %lpad
Expand Down

0 comments on commit 6951ec7

Please sign in to comment.