This is an archive of the discontinued LLVM Phabricator instance.

Stop resetting SanitizeAddress in TargetMachine::resetTargetOptions
ClosedPublic

Authored by ahatanak on May 7 2015, 12:26 PM.

Details

Summary

This is part of the work to remove TargetMachine::resetTargetOptions (the FIXME added to TargetMachine.cpp in r236009 explains why this function has to be removed).

In this patch, a temporary copy of MCTargetOptions is created and its SanitizeAddress field is reset based on the function's attribute every time an InlineAsm instruction is emitted in AsmPrinter::EmitInlineAsm. This is an NFC fix. Also, fixes the changes made to asm_attr.ll in r212455 which seems to have unintentionally dropped the "8" in the function name (I believe this test is supposed to fail if the line resetting SanitizeAddress in resetTargetOptions is removed, but it doesn't).

Diff Detail

Repository
rL LLVM

Event Timeline

ahatanak updated this revision to Diff 25202.May 7 2015, 12:26 PM
ahatanak retitled this revision from to Stop resetting SanitizeAddress in TargetMachine::resetTargetOptions.
ahatanak updated this object.
ahatanak edited the test plan for this revision. (Show Details)
ahatanak added reviewers: echristo, dexonsmith.
ahatanak added a subscriber: Unknown Object (MLST).
echristo edited edge metadata.May 8 2015, 3:54 PM

Hi Akira,

This is just moving the resetting to a different place. How about we get
rid of the resetting completely?

Thanks!

-eric

Hi Akira,

This is just moving the resetting to a different place. How about we get
rid of the resetting completely?

Hi Eric,

Wouldn't getting rid of the resetting completely make it impossible to turn instrumentation on and off on a per-function basis? I don't know how important it is to have that capability, but it looks like r206971 was committed to enable it.

That's not quite what I meant. I meant just have the places that need to
know whether or not we're sanitizing look at the function attribute rather
than resetting a value on MCOptions.

Thanks!

-eric

MCTargetOptions::SanitizeAddress is used in CreateX86AsmInstrumentation, which is called by X86AsmParser's constructor. Those functions don't have access to Function and therefore cannot look at the function attribute (they can be called when llvm-mc is used with -asm-instrumentation=address).

Ah, this is terrible. I think this needs to be rewritten as an MI level
pass at which point it'll have access to the MachineFunction etc.

Kostya?

-eric

kcc added a reviewer: eugenis.May 14 2015, 1:43 PM
kcc added a subscriber: kcc.

+eugenis

Yeah, this is all terrible. I see why we can't get around this right now
without rewriting all of this and that's pretty bad.

I think Akira's solution is probably the best for the moment, but we might
want to think about rewriting this work as a late MI level pass... or
something in the future.

(Yes, consider this as an LGTM Akira). :)

-eric

Thanks, I'll commit this patch shortly.

This revision was automatically updated to reflect the committed changes.