forked from OSchip/llvm-project
CodeGen: Add a target option for emitting .addrsig directives for all address-significant symbols.
Differential Revision: https://reviews.llvm.org/D48143 llvm-svn: 337331
This commit is contained in:
parent
7027ffa85f
commit
bd9d313d5c
|
@ -261,6 +261,10 @@ static cl::opt<bool> EnableStackSizeSection(
|
|||
"stack-size-section",
|
||||
cl::desc("Emit a section containing stack size metadata"), cl::init(false));
|
||||
|
||||
static cl::opt<bool>
|
||||
EnableAddrsig("addrsig", cl::desc("Emit an address-significance table"),
|
||||
cl::init(false));
|
||||
|
||||
// Common utility function tightly tied to the options listed here. Initializes
|
||||
// a TargetOptions object with CodeGen flags and returns it.
|
||||
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
|
||||
|
@ -289,6 +293,7 @@ static TargetOptions InitTargetOptionsFromCodeGenFlags() {
|
|||
Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
|
||||
Options.ExceptionModel = ExceptionModel;
|
||||
Options.EmitStackSizeSection = EnableStackSizeSection;
|
||||
Options.EmitAddrsig = EnableAddrsig;
|
||||
|
||||
Options.MCOptions = InitMCTargetOptionsFromFlags();
|
||||
|
||||
|
|
|
@ -108,10 +108,10 @@ namespace llvm {
|
|||
DisableIntegratedAS(false), RelaxELFRelocations(false),
|
||||
FunctionSections(false), DataSections(false),
|
||||
UniqueSectionNames(true), TrapUnreachable(false),
|
||||
NoTrapAfterNoreturn(false),
|
||||
EmulatedTLS(false), ExplicitEmulatedTLS(false),
|
||||
EnableIPRA(false), EmitStackSizeSection(false),
|
||||
EnableMachineOutliner(false), SupportsDefaultOutlining(false) {}
|
||||
NoTrapAfterNoreturn(false), EmulatedTLS(false),
|
||||
ExplicitEmulatedTLS(false), EnableIPRA(false),
|
||||
EmitStackSizeSection(false), EnableMachineOutliner(false),
|
||||
SupportsDefaultOutlining(false), EmitAddrsig(false) {}
|
||||
|
||||
/// PrintMachineCode - This flag is enabled when the -print-machineinstrs
|
||||
/// option is specified on the command line, and should enable debugging
|
||||
|
@ -238,6 +238,9 @@ namespace llvm {
|
|||
/// Set if the target supports default outlining behaviour.
|
||||
unsigned SupportsDefaultOutlining : 1;
|
||||
|
||||
/// Emit address-significance table.
|
||||
unsigned EmitAddrsig : 1;
|
||||
|
||||
/// FloatABIType - This setting is set by -float-abi=xxx option is specfied
|
||||
/// on the command line. This setting may either be Default, Soft, or Hard.
|
||||
/// Default selects the target's default behavior. Soft selects the ABI for
|
||||
|
|
|
@ -1529,6 +1529,14 @@ bool AsmPrinter::doFinalization(Module &M) {
|
|||
}
|
||||
}
|
||||
|
||||
if (TM.Options.EmitAddrsig) {
|
||||
// Emit address-significance attributes for all globals.
|
||||
OutStreamer->EmitAddrsig();
|
||||
for (const GlobalValue &GV : M.global_values())
|
||||
if (!GV.getName().startswith("llvm.") && !GV.hasAtLeastLocalUnnamedAddr())
|
||||
OutStreamer->EmitAddrsigSym(getSymbol(&GV));
|
||||
}
|
||||
|
||||
// Allow the target to emit any magic that it wants at the end of the file,
|
||||
// after everything else has gone out.
|
||||
EmitEndOfAsmFile(M);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
; RUN: llc < %s -mtriple=x86_64-unknown-linux | FileCheck --check-prefix=NO-ADDRSIG %s
|
||||
; RUN: llc < %s -mtriple=x86_64-unknown-linux -addrsig | FileCheck %s
|
||||
|
||||
; NO-ADDRSIG-NOT: .addrsig
|
||||
|
||||
; CHECK: .addrsig
|
||||
|
||||
; CHECK: .addrsig_sym f1
|
||||
define void @f1() {
|
||||
unreachable
|
||||
}
|
||||
|
||||
; CHECK-NOT: .addrsig_sym f2
|
||||
define internal void @f2() local_unnamed_addr {
|
||||
unreachable
|
||||
}
|
||||
|
||||
; CHECK-NOT: .addrsig_sym f3
|
||||
declare void @f3() unnamed_addr
|
||||
|
||||
; CHECK: .addrsig_sym g1
|
||||
@g1 = global i32 0
|
||||
; CHECK-NOT: .addrsig_sym g2
|
||||
@g2 = internal local_unnamed_addr global i32 0
|
||||
; CHECK-NOT: .addrsig_sym g3
|
||||
@g3 = external unnamed_addr global i32
|
||||
|
||||
; CHECK: .addrsig_sym a1
|
||||
@a1 = alias i32, i32* @g1
|
||||
; CHECK-NOT: .addrsig_sym a2
|
||||
@a2 = internal local_unnamed_addr alias i32, i32* @g2
|
||||
|
||||
; CHECK: .addrsig_sym i1
|
||||
@i1 = ifunc void(), void()* @f1
|
||||
; CHECK-NOT: .addrsig_sym i2
|
||||
@i2 = internal local_unnamed_addr ifunc void(), void()* @f2
|
Loading…
Reference in New Issue